From 111d44e11f7f4a887f249a0ca57dd1f1ce97111a Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 5 Jul 2014 21:28:30 +0300 Subject: [PATCH] Few drop form changes --- HelpersLib/Helpers/ImageHelpers.cs | 5 ++++- ShareX/Forms/DropForm.cs | 13 ++++++++----- ShareX/TaskHelpers.cs | 3 +-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/HelpersLib/Helpers/ImageHelpers.cs b/HelpersLib/Helpers/ImageHelpers.cs index 20cbd5df8..931d99ec9 100644 --- a/HelpersLib/Helpers/ImageHelpers.cs +++ b/HelpersLib/Helpers/ImageHelpers.cs @@ -504,7 +504,10 @@ public static void DrawTextWithOutline(Graphics g, string text, PointF position, using (GraphicsPath gp = new GraphicsPath()) { - gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, position, new StringFormat()); + using (StringFormat sf = new StringFormat()) + { + gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, position, sf); + } using (Pen borderPen = new Pen(borderColor, 2) { LineJoin = LineJoin.Round }) { diff --git a/ShareX/Forms/DropForm.cs b/ShareX/Forms/DropForm.cs index 995bde24e..e736b3a43 100644 --- a/ShareX/Forms/DropForm.cs +++ b/ShareX/Forms/DropForm.cs @@ -57,16 +57,16 @@ public static DropForm GetInstance(int size, int offset, ContentAlignment alignm private DropForm(int size, int offset, ContentAlignment alignment, int opacity, int hoverOpacity) { InitializeComponent(); + DropSize = size.Between(10, 300); DropOffset = offset; DropAlignment = alignment; DropOpacity = opacity.Between(1, 255); DropHoverOpacity = hoverOpacity.Between(1, 255); - backgroundImage = DrawDropImage(size); + backgroundImage = DrawDropImage(DropSize); - Point position = Helpers.GetPosition(DropAlignment, new Point(DropOffset, DropOffset), Screen.PrimaryScreen.WorkingArea.Size, backgroundImage.Size); - Location = position; + Location = Helpers.GetPosition(DropAlignment, new Point(DropOffset, DropOffset), Screen.PrimaryScreen.WorkingArea.Size, backgroundImage.Size); SelectBitmap(backgroundImage, DropOpacity); } @@ -87,10 +87,10 @@ private Bitmap DrawDropImage(int size) g.DrawRectangleProper(pen, rect.RectangleOffset(-1)); } - string text = "Drag\n&\nDrop"; - StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; + string text = "Drop\nhere"; using (Font font = new Font("Arial", 20, FontStyle.Bold)) + using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }) { g.DrawString(text, font, Brushes.Black, rect.LocationOffset(1), sf); g.DrawString(text, font, Brushes.White, rect, sf); @@ -174,7 +174,9 @@ protected override void Dispose(bool disposing) { components.Dispose(); } + if (backgroundImage != null) backgroundImage.Dispose(); + base.Dispose(disposing); } @@ -186,6 +188,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Cursor = Cursors.SizeAll; this.Text = "DropForm"; this.AllowDrop = true; diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index 1d92dc3dd..bc2fee343 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -438,8 +438,7 @@ public static string CheckFilePath(string folder, string filename, TaskSettings public static void OpenDropWindow() { - DropForm.GetInstance(Program.Settings.DropSize, Program.Settings.DropOffset, Program.Settings.DropAlignment, Program.Settings.DropOpacity, - Program.Settings.DropHoverOpacity).ShowActivate(); + DropForm.GetInstance(Program.Settings.DropSize, Program.Settings.DropOffset, Program.Settings.DropAlignment, Program.Settings.DropOpacity, Program.Settings.DropHoverOpacity).ShowActivate(); } public static void DoScreenRecorder(TaskSettings taskSettings = null)