project file added
This commit is contained in:
parent
6c310aa320
commit
eb1d079383
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{C63803BA-7F7A-4BBC-AC46-948637802408}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Control.Draggable</RootNamespace>
|
||||
<AssemblyName>Control.Draggable</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<DebugType>None</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ControlExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
</Project>
|
|
@ -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
|
|
@ -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<Control, bool> draggables =
|
||||
new Dictionary<Control, bool>();
|
||||
private static System.Drawing.Size mouseOffset;
|
||||
private static Size mouseOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Enabling/disabling dragging for control
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.*")]
|
Loading…
Reference in New Issue