diff --git a/Control.Draggable.csproj b/Control.Draggable.csproj new file mode 100644 index 0000000..9f307c8 --- /dev/null +++ b/Control.Draggable.csproj @@ -0,0 +1,46 @@ + + + + {C63803BA-7F7A-4BBC-AC46-948637802408} + Debug + x86 + Library + Control.Draggable + Control.Draggable + v3.5 + Client + Properties + + + x86 + + + bin\Debug\ + True + Full + False + True + DEBUG;TRACE + + + bin\Release\ + False + None + True + False + TRACE + + + + + 3.5 + + + + + + + + + + \ No newline at end of file diff --git a/Control.Draggable.sln b/Control.Draggable.sln new file mode 100644 index 0000000..ad4eb76 --- /dev/null +++ b/Control.Draggable.sln @@ -0,0 +1,18 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# SharpDevelop 4.2.0.8649-Beta 2 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Control.Draggable", "Control.Draggable.csproj", "{C63803BA-7F7A-4BBC-AC46-948637802408}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C63803BA-7F7A-4BBC-AC46-948637802408}.Debug|x86.Build.0 = Debug|x86 + {C63803BA-7F7A-4BBC-AC46-948637802408}.Debug|x86.ActiveCfg = Debug|x86 + {C63803BA-7F7A-4BBC-AC46-948637802408}.Release|x86.Build.0 = Release|x86 + {C63803BA-7F7A-4BBC-AC46-948637802408}.Release|x86.ActiveCfg = Release|x86 + EndGlobalSection +EndGlobal diff --git a/Draggable.cs b/ControlExtension.cs similarity index 86% rename from Draggable.cs rename to ControlExtension.cs index 3eb484c..e0e7f16 100644 --- a/Draggable.cs +++ b/ControlExtension.cs @@ -1,22 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace DraggableControls +namespace System.Windows.Forms { + using System; + using System.Collections.Generic; + using System.Windows.Forms; + using System.Drawing; + public static class ControlExtension { // TKey is control to drag, TValue is a flag used while dragging private static Dictionary draggables = new Dictionary(); - private static System.Drawing.Size mouseOffset; + private static Size mouseOffset; /// /// Enabling/disabling dragging for control /// - public static void Draggable(this Control control, bool Enable) + public static void Draggable(this Control control, bool enable) { - if (Enable) + if (enable) { // enable drag feature if (draggables.ContainsKey(control)) @@ -48,7 +49,7 @@ namespace DraggableControls static void control_MouseDown(object sender, MouseEventArgs e) { - mouseOffset = new System.Drawing.Size(e.Location); + mouseOffset = new Size(e.Location); // turning on dragging draggables[(Control)sender] = true; } @@ -65,10 +66,10 @@ namespace DraggableControls if (draggables[(Control)sender] == true) { // calculations of control's new position - System.Drawing.Point newLocationOffset = e.Location - mouseOffset; + Point newLocationOffset = e.Location - mouseOffset; ((Control)sender).Left += newLocationOffset.X; ((Control)sender).Top += newLocationOffset.Y; } } } -} +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f02556b --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Control.Draggable")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Control.Draggable")] +[assembly: AssemblyCopyright("Copyright 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")]