From 2db7a1d22759ece2e86888756bcfed37a335c1ae Mon Sep 17 00:00:00 2001 From: tylearymf Date: Wed, 6 Jan 2021 18:47:58 +0800 Subject: [PATCH] =?UTF-8?q?Update=20#19=20=E5=9C=A8=E6=89=98=E7=9B=98?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E4=B8=AD=E5=8A=A0=E5=85=A5=E2=80=9C=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E2=80=9D=E6=8C=89=E9=92=AE=20Update=20#27=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E4=B8=80=E9=94=AE=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=8F=82=E8=80=83=E5=9B=BE=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SETUNA/Main/ScrapBook.cs | 3 +- SETUNA/Main/Style/CDustScrapStyle.cs | 28 ++++++++++++++ SETUNA/Main/Style/CPasteStyle.cs | 56 ++++++++++++++++++++++++++++ SETUNA/Main/Style/CPreStyles.cs | 4 +- SETUNA/Mainform.cs | 2 + SETUNA/Properties/AssemblyInfo.cs | 2 +- SETUNA/SETUNA.csproj | 2 + 7 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 SETUNA/Main/Style/CDustScrapStyle.cs create mode 100644 SETUNA/Main/Style/CPasteStyle.cs diff --git a/SETUNA/Main/ScrapBook.cs b/SETUNA/Main/ScrapBook.cs index d2b64dc..ea92b4f 100644 --- a/SETUNA/Main/ScrapBook.cs +++ b/SETUNA/Main/ScrapBook.cs @@ -242,7 +242,8 @@ public void HideAllScrap() // Token: 0x060001C8 RID: 456 RVA: 0x00009E5C File Offset: 0x0000805C public void CloseAllScrap() { - foreach (var obj in _scraps) + var list = _scraps.ToArray(); + foreach (var obj in list) { var scrapBase = (ScrapBase)obj; scrapBase.Close(); diff --git a/SETUNA/Main/Style/CDustScrapStyle.cs b/SETUNA/Main/Style/CDustScrapStyle.cs new file mode 100644 index 0000000..2ed0245 --- /dev/null +++ b/SETUNA/Main/Style/CDustScrapStyle.cs @@ -0,0 +1,28 @@ +using System.Windows.Forms; + +namespace SETUNA.Main.Style +{ + // Token: 0x02000049 RID: 73 + public class CDustScrapStyle : CPreStyle + { + // Token: 0x060002BE RID: 702 RVA: 0x0000F520 File Offset: 0x0000D720 + public CDustScrapStyle() + { + _styleid = -12; + _stylename = "关闭所有截图"; + } + + // Token: 0x060002BF RID: 703 RVA: 0x0000F53B File Offset: 0x0000D73B + public override void Apply(ref ScrapBase scrap) + { + Layer.LayerManager.Instance.SuspendRefresh(); + var result = MessageBox.Show(Mainform.Instance, "是否关闭所有截图", "提示", MessageBoxButtons.YesNo); + Layer.LayerManager.Instance.ResumeRefresh(); + + if (result == DialogResult.Yes) + { + scrap.Manager.CloseAllScrap(); + } + } + } +} diff --git a/SETUNA/Main/Style/CPasteStyle.cs b/SETUNA/Main/Style/CPasteStyle.cs new file mode 100644 index 0000000..b5eb5a7 --- /dev/null +++ b/SETUNA/Main/Style/CPasteStyle.cs @@ -0,0 +1,56 @@ +using System.Drawing; +using System.IO; +using System.Windows.Forms; + +namespace SETUNA.Main.Style +{ + // Token: 0x02000049 RID: 73 + public class CPasteStyle : CPreStyle + { + // Token: 0x060002BE RID: 702 RVA: 0x0000F520 File Offset: 0x0000D720 + public CPasteStyle() + { + _styleid = -13; + _stylename = "从剪贴板中粘贴截图"; + } + + // Token: 0x060002BF RID: 703 RVA: 0x0000F53B File Offset: 0x0000D73B + public override void Apply(ref ScrapBase scrap) + { + Image image = null; + if (Clipboard.ContainsImage()) + { + image = Clipboard.GetImage(); + } + else if (Clipboard.ContainsText()) + { + var text = Clipboard.GetText(); + if (File.Exists(text)) + { + FileStream fileStream = null; + try + { + fileStream = new FileStream(text, FileMode.Open, FileAccess.Read); + image = (Bitmap)Image.FromStream(fileStream); + fileStream.Close(); + fileStream = null; + } + catch + { + } + finally + { + if (fileStream != null) + { + fileStream.Close(); + } + } + } + } + if (image != null) + { + scrap.Manager.AddScrap(image, scrap.Left, scrap.Top, image.Width, image.Height); + } + } + } +} diff --git a/SETUNA/Main/Style/CPreStyles.cs b/SETUNA/Main/Style/CPreStyles.cs index 32e8dbc..d5a16b7 100644 --- a/SETUNA/Main/Style/CPreStyles.cs +++ b/SETUNA/Main/Style/CPreStyles.cs @@ -16,9 +16,11 @@ public static List GetPreStyleList() new CScrapListStyle(), new CDustBoxStyle(), new CDustEraseStyle(), + new CDustScrapStyle(), new CCaptureStyle(), + new CPasteStyle(), new COptionStyle(), - new CShutDownStyle() + new CShutDownStyle(), }; } diff --git a/SETUNA/Mainform.cs b/SETUNA/Mainform.cs index 3cc9783..66e2ac1 100644 --- a/SETUNA/Mainform.cs +++ b/SETUNA/Mainform.cs @@ -99,8 +99,10 @@ private void SetSubMenu() setunaIconMenu.Items.Add(new CScrapListStyle().GetToolStrip(scrapBook)); setunaIconMenu.Items.Add(new CDustBoxStyle().GetToolStrip(scrapBook)); setunaIconMenu.Items.Add(new CDustEraseStyle().GetToolStrip()); + setunaIconMenu.Items.Add(new CDustScrapStyle().GetToolStrip()); setunaIconMenu.Items.Add(new ToolStripSeparator()); setunaIconMenu.Items.Add(new CCaptureStyle().GetToolStrip()); + setunaIconMenu.Items.Add(new CPasteStyle().GetToolStrip()); setunaIconMenu.Items.Add(new ToolStripSeparator()); setunaIconMenu.Items.Add(new CShowVersionStyle().GetToolStrip()); setunaIconMenu.Items.Add(new COptionStyle().GetToolStrip()); diff --git a/SETUNA/Properties/AssemblyInfo.cs b/SETUNA/Properties/AssemblyInfo.cs index eac55f2..679a29e 100644 --- a/SETUNA/Properties/AssemblyInfo.cs +++ b/SETUNA/Properties/AssemblyInfo.cs @@ -12,4 +12,4 @@ [assembly: AssemblyInformationalVersion("3.0")] [assembly: AssemblyDescription("")] [assembly: NeutralResourcesLanguage("zh-CN")] -[assembly: AssemblyVersion("3.0.0.1")] +[assembly: AssemblyVersion("3.0.0.2")] diff --git a/SETUNA/SETUNA.csproj b/SETUNA/SETUNA.csproj index 9811765..a414008 100644 --- a/SETUNA/SETUNA.csproj +++ b/SETUNA/SETUNA.csproj @@ -163,6 +163,8 @@ + +