Drag-and-drop window changes color

Drag-and-drop window changes color when the user drags a file to the
region.
This commit is contained in:
mcored 2014-04-06 22:30:08 +08:00
parent 9f3980fa39
commit 984a993b49
6 changed files with 46 additions and 13 deletions

View file

@ -387,6 +387,9 @@
<ItemGroup>
<None Include="Resources\ShareX_Logo.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ShareX_Logo_Idle.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34003
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -100,6 +100,16 @@ internal static System.Drawing.Bitmap ShareX_Logo {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ShareX_Logo_Idle {
get {
object obj = ResourceManager.GetObject("ShareX_Logo_Idle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -133,4 +133,7 @@
<data name="ShareX_Logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ShareX_Logo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
<data name="ShareX_Logo_Idle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ShareX_Logo_Idle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -45,5 +45,13 @@ public static Image Logo
return Resources.ShareX_Logo;
}
}
public static Image LogoIdle
{
get
{
return Resources.ShareX_Logo_Idle;
}
}
}
}

View file

@ -38,6 +38,8 @@ namespace ShareX
public partial class DropForm : LayeredForm
{
private static DropForm instance;
private Image logoIdle = null;
private Image logoActive = null;
public static DropForm Instance
{
@ -56,26 +58,24 @@ private DropForm()
{
InitializeComponent();
Image logo = null;
try
{
logo = ShareXResources.Logo;
logo = ImageHelpers.ResizeImage(logo, 150, 150);
logoIdle = ShareXResources.LogoIdle;
logoIdle = ImageHelpers.ResizeImage(logoIdle, 150, 150);
logoActive = ShareXResources.Logo;
logoActive = ImageHelpers.ResizeImage(logoActive, 150, 150);
int windowOffset = 5;
ContentAlignment placement = ContentAlignment.BottomRight;
Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, logo.Size);
Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, logoIdle.Size);
Location = position;
SelectBitmap((Bitmap)logo, 150);
SelectBitmap((Bitmap)logoIdle, 150);
}
finally
catch (Exception ex)
{
if (logo != null)
{
logo.Dispose();
}
DebugHelper.WriteException(ex, " while loading drag-and-drop window.");
}
}
@ -100,6 +100,7 @@ private void DropForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
SelectBitmap((Bitmap)logoActive, 150);
e.Effect = DragDropEffects.All;
}
else
@ -115,6 +116,11 @@ private void DropForm_DragDrop(object sender, DragEventArgs e)
UploadManager.UploadFile(files);
}
private void DropForm_DragLeave(object sender, EventArgs e)
{
SelectBitmap((Bitmap)logoIdle, 150);
}
#region Windows Form Designer generated code
/// <summary>
@ -130,6 +136,8 @@ protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
if (logoIdle != null) logoIdle.Dispose();
if (logoActive != null) logoActive.Dispose();
components.Dispose();
}
base.Dispose(disposing);
@ -150,6 +158,7 @@ private void InitializeComponent()
MouseUp += DropForm_MouseUp;
DragEnter += DropForm_DragEnter;
DragDrop += DropForm_DragDrop;
DragLeave += DropForm_DragLeave;
}
#endregion Windows Form Designer generated code