DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
internal static class ColorHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgbHex">Hexadecimal color representation.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(string rgbHex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(rgbHex))
|
||||
return Color.Empty;
|
||||
if (rgbHex.Length == 8)
|
||||
return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(4, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(6, 2), 16));
|
||||
|
||||
return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(4, 2), 16));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgb">Color representation as 32-bit RGB value.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int rgb)
|
||||
{
|
||||
if (rgb == -1) return Color.Empty;
|
||||
return Color.FromArgb((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgb">Color representation as 32-bit RGB value.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int alpha, int rgb)
|
||||
{
|
||||
if (rgb == -1) return Color.Empty;
|
||||
return Color.FromArgb(alpha, (rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{56C369D3-61C2-4608-9C47-C7494A7875E3}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DevComponents.DotNetBar.Layout.Design</RootNamespace>
|
||||
<AssemblyName>DevComponents.DotNetBar.Layout.Design</AssemblyName>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>dotnetbar.snk</AssemblyOriginatorKeyFile>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;LAYOUT</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseTrialLayoutDesign|AnyCPU' ">
|
||||
<OutputPath>bin\ReleaseTrialLayoutDesign\</OutputPath>
|
||||
<DefineConstants>TRACE;LAYOUT;TRIAL</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Accessibility" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ColorHelpers.cs" />
|
||||
<Compile Include="Helpers.cs" />
|
||||
<Compile Include="LayoutControlDesigner.cs" />
|
||||
<Compile Include="LayoutControlItemDesigner.cs" />
|
||||
<Compile Include="LayoutGroupDesigner.cs" />
|
||||
<Compile Include="LayoutItemBaseDesigner.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SymbolTypeEditor.cs" />
|
||||
<Compile Include="TextMarkupEditor.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TextMarkupUIEditor.cs" />
|
||||
<Compile Include="WinApi.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DevComponents.DotNetBar.Layout\DevComponents.DotNetBar.Layout.csproj">
|
||||
<Project>{1641B2CE-259C-4A52-A460-48C936B13951}</Project>
|
||||
<Name>DevComponents.DotNetBar.Layout</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DotNetBar.csproj">
|
||||
<Project>{36546CE3-335C-4AB6-A2F3-40F8C818BC66}</Project>
|
||||
<Name>DotNetBar</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="dotnetbar.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TextMarkupEditor.resx">
|
||||
<DependentUpon>TextMarkupEditor.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ColorPickerButtonImage.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
internal static class Helpers
|
||||
{
|
||||
internal static Bitmap LoadBitmap(string imageName)
|
||||
{
|
||||
DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
|
||||
if (att != null && att.NamespacePrefix != "")
|
||||
{
|
||||
return new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(att.NamespacePrefix + "." + imageName));
|
||||
}
|
||||
else
|
||||
return new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager), imageName);
|
||||
}
|
||||
|
||||
internal static Icon LoadIcon(string imageName)
|
||||
{
|
||||
DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
|
||||
if (att != null && att.NamespacePrefix != "")
|
||||
{
|
||||
return new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(att.NamespacePrefix + "." + imageName));
|
||||
}
|
||||
else
|
||||
return new Icon(typeof(DevComponents.DotNetBar.DotNetBarManager), imageName);
|
||||
}
|
||||
|
||||
public static void DrawDesignTimeSelection(Graphics g, Rectangle r, Color backColor, Color border, int penWidth)
|
||||
{
|
||||
if (r.Width <= 0 || r.Height <= 0)
|
||||
return;
|
||||
if (!backColor.IsEmpty && backColor != Color.Transparent)
|
||||
{
|
||||
if ((double)backColor.GetBrightness() < 0.5)
|
||||
border = System.Windows.Forms.ControlPaint.Light(backColor);
|
||||
else
|
||||
border = System.Windows.Forms.ControlPaint.Dark(backColor);
|
||||
}
|
||||
using (Pen pen = new Pen(border, penWidth))
|
||||
{
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsOffice2007Style(eDotNetBarStyle style)
|
||||
{
|
||||
if (style == eDotNetBarStyle.StyleManagerControlled)
|
||||
style = StyleManager.GetEffectiveStyle();
|
||||
return (style == eDotNetBarStyle.Office2007 || style == eDotNetBarStyle.Office2010 || style == eDotNetBarStyle.Windows7 || StyleManager.IsMetro(style));
|
||||
}
|
||||
|
||||
internal static string GetItemErrorInfo(System.Xml.XmlElement xmlItem)
|
||||
{
|
||||
string s = "";
|
||||
if (xmlItem.HasAttribute("assembly"))
|
||||
s = s + xmlItem.GetAttribute("assembly");
|
||||
if (xmlItem.HasAttribute("class"))
|
||||
s = s + xmlItem.GetAttribute("class");
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,767 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar.Layout;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
public class LayoutControlDesigner : ParentControlDesigner
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
public override void Initialize(System.ComponentModel.IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (changeService != null)
|
||||
{
|
||||
changeService.ComponentAdded += new ComponentEventHandler(ComponentAdded);
|
||||
changeService.ComponentAdding += new ComponentEventHandler(ComponentAdding);
|
||||
changeService.ComponentChanged += new ComponentChangedEventHandler(ComponentChanged);
|
||||
changeService.ComponentRemoved += OnComponentRemoved;
|
||||
changeService.ComponentRemoving += OnComponentRemoving;
|
||||
}
|
||||
//ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
//if (selectionService != null)
|
||||
// selectionService.SelectionChanged += SelectionChanged;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
IComponentChangeService ss = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (ss != null)
|
||||
{
|
||||
ss.ComponentAdded -= ComponentAdded;
|
||||
ss.ComponentAdding -= ComponentAdding;
|
||||
ss.ComponentChanged -= ComponentChanged;
|
||||
ss.ComponentRemoved -= OnComponentRemoved;
|
||||
}
|
||||
|
||||
//ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
//if (selectionService != null)
|
||||
// selectionService.SelectionChanged -= SelectionChanged;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private bool _ControlDeleting = false;
|
||||
private void DestroyChildItems(LayoutItemBase parent, IDesignerHost dh)
|
||||
{
|
||||
LayoutGroup group = parent as LayoutGroup;
|
||||
if (group == null) return;
|
||||
|
||||
foreach (LayoutItemBase item in group.Items)
|
||||
{
|
||||
DestroyChildItems(item, dh);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
}
|
||||
private void OnComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component != this.Component)
|
||||
return;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return;
|
||||
|
||||
_ControlDeleting = true;
|
||||
|
||||
LayoutControl lc = (LayoutControl)e.Component;
|
||||
if (lc.RootGroup.Items.Count == 0) return;
|
||||
|
||||
LayoutItemBase[] items = new LayoutItemBase[lc.RootGroup.Items.Count];
|
||||
lc.RootGroup.Items.CopyTo(items);
|
||||
foreach (LayoutItemBase item in items)
|
||||
{
|
||||
DestroyChildItems(item, dh);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
|
||||
_ControlDeleting = false;
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (_ControlDeleting) return;
|
||||
if (e.Component is LayoutItemBase && ((LayoutItemBase)e.Component).GetLayoutControl() == this.Control && !_DestroyingItem)
|
||||
{
|
||||
CleanupRemovedControls(false);
|
||||
CleanupRemovedItems((LayoutItemBase)e.Component, true, false);
|
||||
}
|
||||
else if (e.Component is Control && IsContained((Control)e.Component))
|
||||
{
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc != null)
|
||||
{
|
||||
LayoutItemBase item = lc.FindControlItem((Control)e.Component);
|
||||
if (item != null)
|
||||
CleanupRemovedItems(item, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private bool IsContained(Control c)
|
||||
{
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc == null || c == null || lc == c) return false;
|
||||
Control stopParent = lc.Parent;
|
||||
Control test = c;
|
||||
do
|
||||
{
|
||||
if (test == lc) return true;
|
||||
test = test.Parent;
|
||||
} while (test != null && test != stopParent);
|
||||
return false;
|
||||
}
|
||||
private bool _DestroyingItem = false;
|
||||
private void CleanupRemovedItems(LayoutItemBase item, bool removeControl, bool destroyItem)
|
||||
{
|
||||
if (item == null || item.Parent == null) return;
|
||||
LayoutControl lc = this.Control as LayoutControl;
|
||||
if (lc == null) return;
|
||||
|
||||
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
DesignerTransaction dt = host.CreateTransaction("Removing Layout Item");
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
ICollection selectedComponents = ss.GetSelectedComponents();
|
||||
if (IsSelected(selectedComponents, item))
|
||||
{
|
||||
ss.SetSelectedComponents(new IComponent[] { item }, SelectionTypes.Remove);
|
||||
}
|
||||
|
||||
if (item.Parent is LayoutGroup)
|
||||
{
|
||||
LayoutGroup parentGroup = null;
|
||||
if (item.Parent != lc.RootGroup && item.Parent is LayoutGroup)
|
||||
{
|
||||
parentGroup = (LayoutGroup)item.Parent;
|
||||
cc.OnComponentChanging(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"]);
|
||||
}
|
||||
((LayoutGroup)item.Parent).Items.Remove(item);
|
||||
if (parentGroup != null)
|
||||
cc.OnComponentChanged(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"], null, null);
|
||||
if (destroyItem)
|
||||
{
|
||||
_DestroyingItem = true;
|
||||
try
|
||||
{
|
||||
host.DestroyComponent(item);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_DestroyingItem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removeControl && item is LayoutControlItem)
|
||||
{
|
||||
LayoutControlItem lci = (LayoutControlItem)item;
|
||||
if (lci.Control != null && lci.Control.Parent == lc)
|
||||
{
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["Controls"]);
|
||||
lc.Controls.Remove(lci.Control);
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["Controls"], null, null);
|
||||
host.DestroyComponent(lci.Control);
|
||||
}
|
||||
}
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
dt.Commit();
|
||||
lc.PerformLayout();
|
||||
ss.SetSelectedComponents(new IComponent[] { lc }, SelectionTypes.Replace);
|
||||
|
||||
}
|
||||
private void CleanupRemovedControls(bool destroyComponents)
|
||||
{
|
||||
LayoutControl lc = this.Control as LayoutControl;
|
||||
if (lc == null) return;
|
||||
List<LayoutItemBase> removed = lc.FindOrphanedControlItems();
|
||||
if (removed != null && removed.Count > 0)
|
||||
{
|
||||
|
||||
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
DesignerTransaction dt = host.CreateTransaction("Removing Layout Control Item");
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
ICollection selectedComponents = ss.GetSelectedComponents();
|
||||
foreach (LayoutItemBase item in removed)
|
||||
{
|
||||
LayoutControlItem lci = item as LayoutControlItem;
|
||||
if (IsSelected(selectedComponents, item))
|
||||
{
|
||||
ss.SetSelectedComponents(new IComponent[] { item }, SelectionTypes.Remove);
|
||||
}
|
||||
if (lci != null && IsSelected(selectedComponents, lci.Control))
|
||||
{
|
||||
ss.SetSelectedComponents(new IComponent[] { lci.Control }, SelectionTypes.Remove);
|
||||
}
|
||||
lci.Control = null;
|
||||
|
||||
if (lci.Parent is LayoutGroup)
|
||||
{
|
||||
LayoutGroup parentGroup = null;
|
||||
if (item.Parent != lc.RootGroup && item.Parent is LayoutGroup)
|
||||
{
|
||||
parentGroup = (LayoutGroup)item.Parent;
|
||||
cc.OnComponentChanging(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"]);
|
||||
}
|
||||
((LayoutGroup)lci.Parent).Items.Remove(item);
|
||||
if (parentGroup != null)
|
||||
cc.OnComponentChanged(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"], null, null);
|
||||
}
|
||||
if (destroyComponents)
|
||||
host.DestroyComponent(item);
|
||||
}
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
dt.Commit();
|
||||
lc.PerformLayout();
|
||||
ss.SetSelectedComponents(new IComponent[] { lc }, SelectionTypes.Replace);
|
||||
}
|
||||
}
|
||||
private bool IsControlSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (ss == null) return false;
|
||||
ICollection selected = ss.GetSelectedComponents();
|
||||
if (IsSelected(selected, this.Control))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private bool IsSelected(ICollection selectedComponents, object item)
|
||||
{
|
||||
foreach (object o in selectedComponents)
|
||||
{
|
||||
if (o == item) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void ComponentChanged(object sender, ComponentChangedEventArgs e)
|
||||
{
|
||||
if (e.Component == this.Control)
|
||||
{
|
||||
if (e.Member != null && e.Member.Name == "Controls")
|
||||
{
|
||||
// Find out what changed...
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc == null) return;
|
||||
foreach (Control c in lc.Controls)
|
||||
{
|
||||
if (lc.IsSystemControl(c)) continue;
|
||||
LayoutItemBase item = lc.FindControlItem(c);
|
||||
if (item == null)
|
||||
{
|
||||
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
DesignerTransaction dt = host.CreateTransaction("Creating Layout Control Item");
|
||||
LayoutControlItem lci = (LayoutControlItem)host.CreateComponent(typeof(LayoutControlItem));
|
||||
TypeDescriptor.GetProperties(lci)["Control"].SetValue(lci, c);
|
||||
lc.SetupControlItem(lci);
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
cc.OnComponentChanging(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
|
||||
lc.RootGroup.Items.Add(lci);
|
||||
|
||||
cc.OnComponentChanged(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
|
||||
dt.Commit();
|
||||
lc.PerformLayout();
|
||||
}
|
||||
}
|
||||
|
||||
// Check removed
|
||||
CleanupRemovedControls(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override bool AllowSetChildIndexOnDrop
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDragBegin(int x, int y)
|
||||
{
|
||||
//base.OnMouseDragBegin(x, y);
|
||||
}
|
||||
protected override void OnDragEnter(DragEventArgs de)
|
||||
{
|
||||
if (de.Data is LayoutItemDataObject)
|
||||
{
|
||||
de.Effect = DragDropEffects.Move;
|
||||
//LayoutControl lc = (LayoutControl)this.Control;
|
||||
//lc.Text = string.Format("{0} DragEnter", DateTime.Now.TimeOfDay);
|
||||
//lc.Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
base.OnDragEnter(de);
|
||||
}
|
||||
protected override void OnDragOver(DragEventArgs de)
|
||||
{
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc == null) return;
|
||||
//lc.Text = de.Data.GetType().ToString();
|
||||
//lc.Invalidate();
|
||||
//lc.Text = "DragOver";
|
||||
//lc.Invalidate();
|
||||
ISelectionService selectionService = (ISelectionService)this.GetService(typeof(ISelectionService));
|
||||
//lc.Text = string.Format("GetSelectedComponents().Count={0}", selectionService.GetSelectedComponents().Count);
|
||||
if (selectionService != null && (selectionService.PrimarySelection is Control || de.Data is LayoutItemDataObject) && selectionService.GetSelectedComponents().Count == 1)
|
||||
{
|
||||
LayoutItemBase item = null;
|
||||
if (de.Data is LayoutItemDataObject)
|
||||
{
|
||||
LayoutItemDataObject d = (LayoutItemDataObject)de.Data;
|
||||
item = d.DragComponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
Control c = (Control)selectionService.PrimarySelection;
|
||||
item = lc.FindControlItem(c);
|
||||
}
|
||||
if (item != null)
|
||||
{
|
||||
HitTestInsertInfo info = lc.GetHitTestInsertInfo(item, lc.PointToClient(new Point(de.X, de.Y)));
|
||||
if (!info.InsertMarkerBounds.IsEmpty)
|
||||
lc.ShowInsertMarker(info.InsertMarkerBounds);
|
||||
else
|
||||
lc.HideInsertMarker();
|
||||
de.Effect = DragDropEffects.Move;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnDragOver(de);
|
||||
}
|
||||
|
||||
protected override void OnDragLeave(EventArgs e)
|
||||
{
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc == null) return;
|
||||
lc.HideInsertMarker();
|
||||
base.OnDragLeave(e);
|
||||
}
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs de)
|
||||
{
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc == null) return;
|
||||
lc.HideInsertMarker();
|
||||
|
||||
ISelectionService selectionService = (ISelectionService)this.GetService(typeof(ISelectionService));
|
||||
if (selectionService != null && (selectionService.PrimarySelection is Control || de.Data is LayoutItemDataObject) && selectionService.GetSelectedComponents().Count == 1)
|
||||
{
|
||||
LayoutItemBase item = null;
|
||||
if (de.Data is LayoutItemDataObject)
|
||||
{
|
||||
item = ((LayoutItemDataObject)de.Data).DragComponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
Control c = (Control)selectionService.PrimarySelection;
|
||||
item = lc.FindControlItem(c);
|
||||
}
|
||||
if (item != null)
|
||||
{
|
||||
HitTestInsertInfo info = lc.GetHitTestInsertInfo(item, lc.PointToClient(new Point(de.X, de.Y)));
|
||||
if (info.Parent != null)
|
||||
{
|
||||
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
DesignerTransaction dt = host.CreateTransaction("Moving Layout Control Item");
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
//lc.Text = string.Format("Moving at: {0}", info.InsertIndex);
|
||||
//lc.Invalidate();
|
||||
if (info.Parent != item.Parent)
|
||||
{
|
||||
LayoutGroup parentGroup = (LayoutGroup)item.Parent;
|
||||
if (parentGroup != lc.RootGroup)
|
||||
cc.OnComponentChanging(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"]);
|
||||
parentGroup.Items.Remove(item);
|
||||
if (parentGroup != lc.RootGroup)
|
||||
cc.OnComponentChanged(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"], null, null);
|
||||
if (info.Parent != lc.RootGroup)
|
||||
cc.OnComponentChanging(info.Parent, TypeDescriptor.GetProperties(parentGroup)["Items"]);
|
||||
if (info.InsertIndex >= 0)
|
||||
info.Parent.Items.Insert(info.InsertIndex, item);
|
||||
else
|
||||
info.Parent.Items.Add(item);
|
||||
if (info.Parent != lc.RootGroup)
|
||||
cc.OnComponentChanged(info.Parent, TypeDescriptor.GetProperties(parentGroup)["Items"], null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
LayoutGroup parentGroup = (LayoutGroup)item.Parent;
|
||||
if (parentGroup != lc.RootGroup)
|
||||
cc.OnComponentChanging(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"]);
|
||||
info.Parent.Items.Move(item, info.InsertIndex);
|
||||
if (parentGroup != lc.RootGroup)
|
||||
cc.OnComponentChanged(parentGroup, TypeDescriptor.GetProperties(parentGroup)["Items"], null, null);
|
||||
}
|
||||
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
dt.Commit();
|
||||
lc.PerformLayout();
|
||||
|
||||
SelectionRefresh();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
base.OnDragDrop(de);
|
||||
}
|
||||
|
||||
void ComponentAdding(object sender, ComponentEventArgs e)
|
||||
{
|
||||
//Control c = e.Component as Control;
|
||||
//if (c != null)
|
||||
//{
|
||||
// if (c != null && c.Parent == this.Control)
|
||||
// {
|
||||
// MessageBox.Show("Component ADDING");
|
||||
// }
|
||||
// else
|
||||
// MessageBox.Show(string.Format("Component ADDING UNRECOGNIZED Parent: {0} Site:{1}", c.Parent, e.Component.Site));
|
||||
//}
|
||||
}
|
||||
|
||||
void ComponentAdded(object sender, ComponentEventArgs e)
|
||||
{
|
||||
//Control c = e.Component as Control;
|
||||
|
||||
//if (c != null)
|
||||
//{
|
||||
// if (c != null && c.Parent == this.Control)
|
||||
// {
|
||||
// MessageBox.Show("Component ADDED");
|
||||
// }
|
||||
// else
|
||||
// MessageBox.Show(string.Format("Component ADDED UNRECOGNIZED Parent: {0}", c.Parent));
|
||||
//}
|
||||
}
|
||||
protected override bool GetHitTest(System.Drawing.Point point)
|
||||
{
|
||||
if (base.GetHitTest(point))
|
||||
return true;
|
||||
|
||||
LayoutControl c = this.Control as LayoutControl;
|
||||
if (c == null) return false;
|
||||
|
||||
Point pc = c.PointToClient(point);
|
||||
if (c.VScrollBar.Visible && c.VScrollBar.Bounds.Contains(pc))
|
||||
return true;
|
||||
if (c.HScrollBar.Visible && c.HScrollBar.Bounds.Contains(pc))
|
||||
return true;
|
||||
|
||||
return base.GetHitTest(point);
|
||||
}
|
||||
|
||||
public void SelectionRefresh()
|
||||
{
|
||||
Message m = new Message();
|
||||
m.Msg = 0x115;
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
private System.Windows.Forms.Control _DesignerHost = null;
|
||||
/// <summary>
|
||||
/// Selection support for items on container.
|
||||
/// </summary>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (_DesignerHost == null)
|
||||
_DesignerHost = System.Windows.Forms.Control.FromHandle(m.HWnd);
|
||||
switch (m.Msg)
|
||||
{
|
||||
case WinApi.WM_LBUTTONDOWN:
|
||||
case WinApi.WM_RBUTTONDOWN:
|
||||
{
|
||||
if (OnMouseDown(ref m, m.Msg == WinApi.WM_LBUTTONDOWN ? MouseButtons.Left : MouseButtons.Right))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case WinApi.WM_RBUTTONUP:
|
||||
case WinApi.WM_LBUTTONUP:
|
||||
{
|
||||
if (OnMouseUp(ref m, m.Msg == WinApi.WM_LBUTTONDOWN ? MouseButtons.Left : MouseButtons.Right))
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
protected virtual bool OnMouseUp(ref Message m, MouseButtons param1)
|
||||
{
|
||||
if (_MouseDownSelectionPerformed)
|
||||
{
|
||||
_MouseDownSelectionPerformed = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private bool _MouseDownSelectionPerformed = false;
|
||||
protected virtual bool OnMouseDown(ref Message m, MouseButtons button)
|
||||
{
|
||||
LayoutControl lc = this.Control as LayoutControl;
|
||||
if (lc == null) return false;
|
||||
Point p = new Point(WinApi.LOWORD(m.LParam), WinApi.HIWORD(m.LParam));
|
||||
LayoutItemBase item = lc.HitTest(p);
|
||||
if (item != null)
|
||||
{
|
||||
SelectComponent(item, (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift) ? SelectionTypes.Add : SelectionTypes.Primary);
|
||||
_MouseDownSelectionPerformed = true;
|
||||
return true;
|
||||
}
|
||||
else if (!IsControlSelected)
|
||||
{
|
||||
SelectComponent(this.Control, SelectionTypes.Replace);
|
||||
//return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void SelectComponent(IComponent comp, SelectionTypes selectionType)
|
||||
{
|
||||
ISelectionService selection = (ISelectionService)this.GetService(typeof(ISelectionService));
|
||||
if (selection != null && comp != null)
|
||||
{
|
||||
ArrayList arr = new ArrayList(1);
|
||||
arr.Add(comp);
|
||||
selection.SetSelectedComponents(arr, selectionType);
|
||||
}
|
||||
}
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList list = base.AssociatedComponents as ArrayList;
|
||||
if (list == null) list = new ArrayList();
|
||||
|
||||
LayoutControl lc = (LayoutControl)this.Control;
|
||||
if (lc == null) return list;
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
foreach (LayoutItemBase item in lc.RootGroup.Items)
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaintAdornments(PaintEventArgs pe)
|
||||
{
|
||||
LayoutControl lc = (LayoutControl)base.Component;
|
||||
if (lc != null && lc.Visible)
|
||||
{
|
||||
using (Pen borderPen = this.BorderPen)
|
||||
{
|
||||
Rectangle clientRectangle = this.Control.ClientRectangle;
|
||||
clientRectangle.Width--;
|
||||
clientRectangle.Height--;
|
||||
pe.Graphics.DrawRectangle(borderPen, clientRectangle);
|
||||
}
|
||||
}
|
||||
base.OnPaintAdornments(pe);
|
||||
}
|
||||
protected Pen BorderPen
|
||||
{
|
||||
get
|
||||
{
|
||||
Color color = (this.Control.BackColor.GetBrightness() < 0.5) ? ControlPaint.Light(this.Control.BackColor) : ControlPaint.Dark(this.Control.BackColor);
|
||||
Pen pen = new Pen(color);
|
||||
pen.DashStyle = DashStyle.Dash;
|
||||
return pen;
|
||||
}
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Spacer", new EventHandler(AddSpacerItem)),
|
||||
new DesignerVerb("Add Group", new EventHandler(AddGroupItem))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
//private void AddLabelItem(object sender, EventArgs e)
|
||||
//{
|
||||
// AddLabelItem();
|
||||
//}
|
||||
|
||||
//private void AddLabelItem()
|
||||
//{
|
||||
// IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
// LayoutControl lc = this.Control as LayoutControl;
|
||||
// if (lc == null || dh == null)
|
||||
// return;
|
||||
|
||||
// DesignerTransaction dt = dh.CreateTransaction("Creating Label Item");
|
||||
// try
|
||||
// {
|
||||
// IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
// if (cc != null)
|
||||
// {
|
||||
// cc.OnComponentChanging(this.Component, null);
|
||||
// cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
// cc.OnComponentChanging(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
// }
|
||||
|
||||
// LayoutLabelItem item = null;
|
||||
// item = dh.CreateComponent(typeof(LayoutLabelItem)) as LayoutLabelItem;
|
||||
// item.Width = 100;
|
||||
// item.WidthType = eLayoutSizeType.Percent;
|
||||
// item.Height = 22;
|
||||
// item.Text = "Layout Label";
|
||||
// lc.RootGroup.Items.Add(item);
|
||||
// lc.PerformLayout();
|
||||
// if (cc != null)
|
||||
// {
|
||||
// cc.OnComponentChanged(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
// cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
// cc.OnComponentChanged(this.Component, null, null, null);
|
||||
// }
|
||||
|
||||
// SelectComponent(item, SelectionTypes.Replace);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// dt.Cancel();
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// if (!dt.Canceled) dt.Commit();
|
||||
// }
|
||||
//}
|
||||
private void AddSpacerItem(object sender, EventArgs e)
|
||||
{
|
||||
AddSpacerItem();
|
||||
}
|
||||
|
||||
private void AddSpacerItem()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
LayoutControl lc = this.Control as LayoutControl;
|
||||
if (lc == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Creating Spacer Item");
|
||||
try
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanging(this.Component, null);
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
cc.OnComponentChanging(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
}
|
||||
|
||||
LayoutSpacerItem item = null;
|
||||
item = dh.CreateComponent(typeof(LayoutSpacerItem)) as LayoutSpacerItem;
|
||||
item.Width = 32;
|
||||
item.Height = 32;
|
||||
lc.RootGroup.Items.Add(item);
|
||||
lc.PerformLayout();
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanged(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
cc.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
SelectComponent(item, SelectionTypes.Replace);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddGroupItem(object sender, EventArgs e)
|
||||
{
|
||||
AddGroupItem();
|
||||
}
|
||||
|
||||
private void AddGroupItem()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
LayoutControl lc = this.Control as LayoutControl;
|
||||
if (lc == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Creating Group Item");
|
||||
try
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanging(this.Component, null);
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
cc.OnComponentChanging(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
}
|
||||
|
||||
LayoutGroup item = null;
|
||||
item = dh.CreateComponent(typeof(LayoutGroup)) as LayoutGroup;
|
||||
item.Width = 200;
|
||||
item.Height = 100;
|
||||
item.TextPosition = eLayoutPosition.Top;
|
||||
item.MinSize = new Size(120, 32);
|
||||
lc.RootGroup.Items.Add(item);
|
||||
lc.PerformLayout();
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanged(lc.RootGroup, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
cc.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
SelectComponent(item, SelectionTypes.Replace);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Layout;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
public class LayoutControlItemDesigner : LayoutItemBaseDesigner
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
LayoutControlItem item = (LayoutControlItem)this.Component;
|
||||
|
||||
if (item.Control != null && item.Control.Site != null)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
list.Add(item.Control);
|
||||
return list;
|
||||
}
|
||||
|
||||
return base.AssociatedComponents;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
public class LayoutGroupDesigner : LayoutItemBaseDesigner
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
LayoutGroup group = (LayoutGroup)this.Component;
|
||||
|
||||
if (group.Items.Count>0)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
foreach (LayoutItemBase child in group.Items)
|
||||
{
|
||||
if (child.Site != null)
|
||||
list.Add(child);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
return base.AssociatedComponents;
|
||||
}
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Spacer", new EventHandler(AddSpacerItem)),
|
||||
new DesignerVerb("Add Group", new EventHandler(AddGroupItem)),
|
||||
new DesignerVerb("Apply Panel Style", new EventHandler(PanelStyle)),
|
||||
new DesignerVerb("Apply Group Panel Style", new EventHandler(GroupPanelStyle)),
|
||||
new DesignerVerb("Remove Panel Style", new EventHandler(RemovePanelStyle))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
private void AddSpacerItem(object sender, EventArgs e)
|
||||
{
|
||||
AddSpacerItem();
|
||||
}
|
||||
|
||||
private void AddSpacerItem()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
LayoutGroup lc = this.Component as LayoutGroup;
|
||||
if (lc == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Creating Spacer Item");
|
||||
try
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanging(this.Component, null);
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
}
|
||||
|
||||
LayoutSpacerItem item = null;
|
||||
item = dh.CreateComponent(typeof(LayoutSpacerItem)) as LayoutSpacerItem;
|
||||
item.Width = 32;
|
||||
item.Height = 32;
|
||||
lc.Items.Add(item);
|
||||
lc.InvalidateLayout();
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
cc.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
SelectComponent(item, SelectionTypes.Replace);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddGroupItem(object sender, EventArgs e)
|
||||
{
|
||||
AddGroupItem();
|
||||
}
|
||||
|
||||
private void AddGroupItem()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
LayoutGroup lc = this.Component as LayoutGroup;
|
||||
if (lc == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Creating Group Item");
|
||||
try
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanging(this.Component, null);
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
}
|
||||
|
||||
LayoutGroup item = null;
|
||||
item = dh.CreateComponent(typeof(LayoutGroup)) as LayoutGroup;
|
||||
item.Width = 200;
|
||||
item.Height = 100;
|
||||
item.TextPosition = eLayoutPosition.Top;
|
||||
item.MinSize = new Size(120, 32);
|
||||
lc.Items.Add(item);
|
||||
lc.InvalidateLayout();
|
||||
if (cc != null)
|
||||
{
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
cc.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
SelectComponent(item, SelectionTypes.Replace);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void PanelStyle(object sender, EventArgs e)
|
||||
{
|
||||
LayoutGroup group = (LayoutGroup)this.Component;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (group == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Apply Panel Style");
|
||||
|
||||
TypeDescriptor.GetProperties(group)["Appearance"].SetValue(group, eGroupAppearance.Panel); // group.Appearance = eGroupAppearance.Panel;
|
||||
TypeDescriptor.GetProperties(group)["CaptionHeight"].SetValue(group, 22); // group.CaptionHeight = 22;
|
||||
TypeDescriptor.GetProperties(group)["TextLineAlignment"].SetValue(group, DevComponents.DotNetBar.Layout.eTextLineAlignment.Middle); // group.TextLineAlignment = DevComponents.DotNetBar.Layout.eTextLineAlignment.Middle;
|
||||
TypeDescriptor.GetProperties(group)["TextPosition"].SetValue(group, DevComponents.DotNetBar.Layout.eLayoutPosition.Top); // group.TextPosition = DevComponents.DotNetBar.Layout.eLayoutPosition.Top;
|
||||
TypeDescriptor.GetProperties(group)["TextAlignment"].SetValue(group, eTextAlignment.Default); // group.TextAlignment = eTextAlignment.Default;
|
||||
if (string.IsNullOrEmpty(group.Text))
|
||||
TypeDescriptor.GetProperties(group)["Text"].SetValue(group, "Caption"); // group.Text = "Caption";
|
||||
|
||||
dt.Commit();
|
||||
|
||||
}
|
||||
|
||||
private void GroupPanelStyle(object sender, EventArgs e)
|
||||
{
|
||||
LayoutGroup group = (LayoutGroup)this.Component;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (group == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Apply Group Panel Style");
|
||||
|
||||
TypeDescriptor.GetProperties(group)["Appearance"].SetValue(group, eGroupAppearance.GroupPanel); // group.Appearance = eGroupAppearance.GroupPanel;
|
||||
TypeDescriptor.GetProperties(group)["CaptionHeight"].SetValue(group, 18); // group.CaptionHeight = 18;
|
||||
TypeDescriptor.GetProperties(group)["TextLineAlignment"].SetValue(group, DevComponents.DotNetBar.Layout.eTextLineAlignment.Middle); // group.TextLineAlignment = DevComponents.DotNetBar.Layout.eTextLineAlignment.Middle;
|
||||
TypeDescriptor.GetProperties(group)["TextPosition"].SetValue(group, DevComponents.DotNetBar.Layout.eLayoutPosition.Top); // group.TextPosition = DevComponents.DotNetBar.Layout.eLayoutPosition.Top;
|
||||
TypeDescriptor.GetProperties(group)["TextAlignment"].SetValue(group, eTextAlignment.Center); // group.TextAlignment = eTextAlignment.Center;
|
||||
if (string.IsNullOrEmpty(group.Text))
|
||||
TypeDescriptor.GetProperties(group)["Text"].SetValue(group, "Caption"); // group.Text = "Caption";
|
||||
|
||||
dt.Commit();
|
||||
}
|
||||
|
||||
private void RemovePanelStyle(object sender, EventArgs e)
|
||||
{
|
||||
LayoutGroup group = (LayoutGroup)this.Component;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (group == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Remove Panel Style");
|
||||
|
||||
TypeDescriptor.GetProperties(group)["Appearance"].SetValue(group, eGroupAppearance.None); // group.Appearance = eGroupAppearance.None;
|
||||
TypeDescriptor.GetProperties(group)["TextLineAlignment"].SetValue(group, DevComponents.DotNetBar.Layout.eTextLineAlignment.Default); // group.TextLineAlignment = DevComponents.DotNetBar.Layout.eTextLineAlignment.Default;
|
||||
TypeDescriptor.GetProperties(group)["CaptionHeight"].SetValue(group, 0); // group.CaptionHeight = 0;
|
||||
TypeDescriptor.GetProperties(group)["TextPosition"].SetValue(group, DevComponents.DotNetBar.Layout.eLayoutPosition.Default); // group.TextPosition = DevComponents.DotNetBar.Layout.eLayoutPosition.Default;
|
||||
TypeDescriptor.GetProperties(group)["TextAlignment"].SetValue(group, eTextAlignment.Default); // group.TextAlignment = eTextAlignment.Default;
|
||||
TypeDescriptor.GetProperties(group)["Text"].SetValue(group, ""); // group.Text = "Caption";
|
||||
dt.Commit();
|
||||
|
||||
}
|
||||
|
||||
protected virtual void SelectComponent(IComponent comp, SelectionTypes selectionType)
|
||||
{
|
||||
ISelectionService selection = (ISelectionService)this.GetService(typeof(ISelectionService));
|
||||
if (selection != null && comp != null)
|
||||
{
|
||||
ArrayList arr = new ArrayList(1);
|
||||
arr.Add(comp);
|
||||
selection.SetSelectedComponents(arr, selectionType);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,543 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms.Design.Behavior;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
public class LayoutItemBaseDesigner : ComponentDesigner
|
||||
{
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the LayoutItemBaseDesigner class.
|
||||
/// </summary>
|
||||
public LayoutItemBaseDesigner()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
public override void Initialize(System.ComponentModel.IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (selectionService != null)
|
||||
selectionService.SelectionChanged += SelectionChanged;
|
||||
|
||||
BehaviorService behaviorService = (BehaviorService)GetService(typeof(BehaviorService));
|
||||
Adorner designerActionAdorner = new Adorner();
|
||||
behaviorService.Adorners.Add(designerActionAdorner);
|
||||
LayoutItemGlyph glyph = new LayoutItemGlyph(behaviorService, (LayoutItemBase)component);
|
||||
designerActionAdorner.Glyphs.Add(glyph);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (selectionService != null)
|
||||
selectionService.SelectionChanged -= SelectionChanged;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void OnComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component == this.Component)
|
||||
{
|
||||
LayoutItemBase item = e.Component as LayoutItemBase;
|
||||
LayoutGroup parent = item.Parent as LayoutGroup;
|
||||
LayoutControl lc = null;
|
||||
if (parent != null) lc = parent.GetLayoutControl();
|
||||
if (item != null && parent != null && parent.Items.Contains(item))
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["Items"]);
|
||||
parent.Items.Remove(item);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["Items"], null, null);
|
||||
if (lc != null)
|
||||
{
|
||||
lc.Invalidate();
|
||||
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (host != null)
|
||||
{
|
||||
IDesigner designer = host.GetDesigner(lc);
|
||||
if (designer is LayoutControlDesigner)
|
||||
{
|
||||
((LayoutControlDesigner)designer).SelectionRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool selected = false;
|
||||
ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (selectionService.PrimarySelection == this.Component)
|
||||
selected = true;
|
||||
else
|
||||
{
|
||||
ICollection selectedComponents = selectionService.GetSelectedComponents();
|
||||
foreach (object o in selectedComponents)
|
||||
{
|
||||
if (o == this.Component)
|
||||
{
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LayoutItemBase item = (LayoutItemBase)this.Component;
|
||||
item.IsSelected = selected;
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
LayoutGroup group = this.Component as LayoutGroup;
|
||||
if (group == null)
|
||||
return base.AssociatedComponents;
|
||||
List<LayoutItemBase> items = new List<LayoutItemBase>();
|
||||
group.Items.CopyTo(items);
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Visible"] = TypeDescriptor.CreateProperty(typeof(LayoutItemBaseDesigner), (PropertyDescriptor)properties["Visible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Appearance")});
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets whether item is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Browsable(true), Category("Appearance"), Description("Indicates visiblity of the item.")]
|
||||
public bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)ShadowProperties["Visible"];
|
||||
}
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control
|
||||
this.ShadowProperties["Visible"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
class LayoutItemGlyph : Glyph
|
||||
{
|
||||
LayoutItemBase _Item;
|
||||
BehaviorService _BehaviorSvc;
|
||||
|
||||
public LayoutItemGlyph(BehaviorService behaviorSvc, LayoutItemBase item)
|
||||
:
|
||||
base(new LayoutItemBehavior())
|
||||
{
|
||||
_BehaviorSvc = behaviorSvc;
|
||||
_Item = item;
|
||||
}
|
||||
|
||||
public LayoutItemBase Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Item;
|
||||
}
|
||||
}
|
||||
|
||||
public override Rectangle Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
// Glyph coordinates are in adorner window coordinates, so we must map using the behavior service.
|
||||
Rectangle bounds = Rectangle.Empty;
|
||||
if (_Item != null && _Item.GetLayoutControl() != null)
|
||||
{
|
||||
Point edge = _BehaviorSvc.ControlToAdornerWindow(_Item.GetLayoutControl());
|
||||
|
||||
if (_Item is LayoutControlItem)
|
||||
bounds = _Item.ActualTextBounds;
|
||||
else
|
||||
bounds = _Item.Bounds;
|
||||
bounds.Offset(edge);
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle CompleteBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
Rectangle bounds = Rectangle.Empty;
|
||||
if (_Item != null && _Item.GetLayoutControl() != null)
|
||||
{
|
||||
Point edge = _BehaviorSvc.ControlToAdornerWindow(_Item.GetLayoutControl());
|
||||
bounds = _Item.Bounds;
|
||||
bounds.Offset(edge);
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
public override Cursor GetHitTest(Point p)
|
||||
{
|
||||
if (_Item != null && !_Item.IsSelected)
|
||||
return null;
|
||||
// GetHitTest is called to see if the point is
|
||||
// within this glyph. This gives us a chance to decide
|
||||
// what cursor to show. Returning null from here means
|
||||
// the mouse pointer is not currently inside of the glyph.
|
||||
// Returning a valid cursor here indicates the pointer is
|
||||
// inside the glyph, and also enables our Behavior property
|
||||
// as the active behavior.
|
||||
if (Bounds.Contains(p))
|
||||
{
|
||||
return Cursors.SizeAll;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool GetIsItemVisible()
|
||||
{
|
||||
if (_Item == null)
|
||||
return false;
|
||||
LayoutControl lc = _Item.GetLayoutControl();
|
||||
if (lc != null)
|
||||
{
|
||||
if (!lc.Visible) return false;
|
||||
if (lc.Parent != null && !lc.Parent.Visible) return false;
|
||||
if(lc.Parent is TabControlPanel && ((TabControlPanel)lc.Parent).TabItem!=null && !((TabControlPanel)lc.Parent).TabItem.IsSelected)
|
||||
return false;
|
||||
if (lc.Parent is SuperTabControlPanel && ((SuperTabControlPanel)lc.Parent).TabItem != null && !((SuperTabControlPanel)lc.Parent).TabItem.IsSelected)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Paint(PaintEventArgs pe)
|
||||
{
|
||||
// Draw our glyph
|
||||
if (_Item != null)
|
||||
{
|
||||
if (_Item.IsSelected)
|
||||
{
|
||||
Rectangle r = CompleteBounds;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
Graphics g = pe.Graphics;
|
||||
using (Pen pen = new Pen(SelectionColor))
|
||||
{
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
else if ((!_Item.TextVisible || string.IsNullOrEmpty(_Item.Text)) && GetIsItemVisible())
|
||||
{
|
||||
Rectangle r = CompleteBounds;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
Graphics g = pe.Graphics;
|
||||
using (Pen pen = new Pen(SelectableColor))
|
||||
{
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static readonly Color SelectableColor = ColorHelpers.GetColor(0x8C8C91);
|
||||
private static readonly Color SelectionColor = ColorHelpers.GetColor(0x696969);
|
||||
|
||||
// By providing our own behavior we can do something interesting
|
||||
// when the user clicks or manipulates our glyph.
|
||||
class LayoutItemBehavior : Behavior
|
||||
{
|
||||
//public override bool OnMouseUp(Glyph g, MouseButtons button)
|
||||
//{
|
||||
// //MessageBox.Show("Hey, you clicked the mouse here");
|
||||
// //return true; // indicating we processed this event.
|
||||
// return base.OnMouseUp(g, button);
|
||||
//}
|
||||
|
||||
private Point _MouseDownLocation = Point.Empty;
|
||||
public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc)
|
||||
{
|
||||
LayoutItemGlyph itemGlyph = (LayoutItemGlyph)g;
|
||||
if (itemGlyph._Item != null && itemGlyph._Item.Site != null && (!itemGlyph._Item.IsSelected || itemGlyph._Item is LayoutGroup))
|
||||
{
|
||||
LayoutItemBase item = itemGlyph._Item;
|
||||
IComponent selectItem = item;
|
||||
if (item is LayoutGroup)
|
||||
{
|
||||
LayoutControl lc = item.GetLayoutControl();
|
||||
if (lc == null) return base.OnMouseDown(g, button, mouseLoc);
|
||||
Point loc = lc.PointToClient(Control.MousePosition);
|
||||
LayoutItemBase itemAt = lc.HitTest(loc);
|
||||
if (itemAt != null && itemAt != item && itemAt.Site != null)
|
||||
{
|
||||
// Selection is selecting something inside of group
|
||||
selectItem = itemAt;
|
||||
if (itemAt is LayoutControlItem)
|
||||
{
|
||||
LayoutControlItem lci = (LayoutControlItem)itemAt;
|
||||
if (lci.Control != null && lci.Control.ClientRectangle.Contains(lci.Control.PointToClient(Control.MousePosition)) && lci.Control.Site != null)
|
||||
selectItem = lci.Control;
|
||||
}
|
||||
}
|
||||
// No need to re-select
|
||||
if (selectItem == itemGlyph._Item && itemGlyph.Item.IsSelected)
|
||||
return base.OnMouseDown(g, button, mouseLoc);
|
||||
}
|
||||
ISelectionService selectionService = (ISelectionService)selectItem.Site.GetService(typeof(ISelectionService));
|
||||
if (selectionService != null && selectItem != null)
|
||||
{
|
||||
selectionService.SetSelectedComponents(new IComponent[] { selectItem });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return base.OnMouseDown(g, button, mouseLoc);
|
||||
}
|
||||
public override bool OnMouseUp(Glyph g, MouseButtons button)
|
||||
{
|
||||
_MouseDownLocation = Point.Empty;
|
||||
return base.OnMouseUp(g, button);
|
||||
}
|
||||
public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc)
|
||||
{
|
||||
if (button == MouseButtons.Left && _MouseDownLocation.IsEmpty)
|
||||
_MouseDownLocation = mouseLoc;
|
||||
if (button == MouseButtons.Left && !_MouseDownLocation.IsEmpty &&
|
||||
(Math.Abs(mouseLoc.X - _MouseDownLocation.X) > 1 || Math.Abs(mouseLoc.Y - _MouseDownLocation.Y) > 1))
|
||||
{
|
||||
LayoutItemGlyph glyph = g as LayoutItemGlyph;
|
||||
if (glyph != null && glyph.Item != null)
|
||||
{
|
||||
ISelectionService selectionService = GetSelectionService(glyph.Item);
|
||||
if (selectionService != null && selectionService.PrimarySelection == glyph.Item && selectionService.GetSelectedComponents().Count == 1)
|
||||
{
|
||||
_MouseDownLocation = Point.Empty;
|
||||
this.DropSource.QueryContinueDrag += new QueryContinueDragEventHandler(this.QueryContinueDrag);
|
||||
this.DropSource.DoDragDrop(new LayoutItemDataObject(glyph.Item), DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;// base.OnMouseMove(g, button, mouseLoc);
|
||||
}
|
||||
|
||||
public override void OnDragDrop(Glyph g, DragEventArgs e)
|
||||
{
|
||||
if (e.Data is LayoutItemDataObject)
|
||||
{
|
||||
LayoutItemDataObject d = (LayoutItemDataObject)e.Data;
|
||||
LayoutControl lc = d.DragComponent.GetLayoutControl();
|
||||
if (lc != null)
|
||||
{
|
||||
lc.HideInsertMarker();
|
||||
LayoutItemBase item = d.DragComponent;
|
||||
ISelectionService selectionService = GetSelectionService(item);
|
||||
IDesignerHost host = GetDesignerHostService(item);
|
||||
IComponentChangeService cc = GetComponentChangeService(item);
|
||||
if (selectionService != null && host != null && cc != null)
|
||||
{
|
||||
HitTestInsertInfo info = lc.GetHitTestInsertInfo(item, lc.PointToClient(new Point(e.X, e.Y)));
|
||||
if (info.Parent != null)
|
||||
{
|
||||
DesignerTransaction dt = host.CreateTransaction("Moving Layout Control Item");
|
||||
cc.OnComponentChanging(lc, TypeDescriptor.GetProperties(lc)["RootGroup"]);
|
||||
//lc.Text = string.Format("Moving at B: {0}", info.InsertIndex);
|
||||
//lc.Invalidate();
|
||||
if (info.Parent != item.Parent)
|
||||
{
|
||||
LayoutGroup group = (LayoutGroup)item.Parent;
|
||||
if (group != lc.RootGroup)
|
||||
cc.OnComponentChanging(group, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
group.Items.Remove(item);
|
||||
if (group != lc.RootGroup)
|
||||
cc.OnComponentChanged(group, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
if (info.Parent != lc.RootGroup)
|
||||
cc.OnComponentChanging(info.Parent, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
if (info.InsertIndex >= 0)
|
||||
info.Parent.Items.Insert(info.InsertIndex, item);
|
||||
else
|
||||
info.Parent.Items.Add(item);
|
||||
if (info.Parent != lc.RootGroup)
|
||||
cc.OnComponentChanged(info.Parent, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.Parent != lc.RootGroup)
|
||||
cc.OnComponentChanging(info.Parent, TypeDescriptor.GetProperties(lc)["Items"]);
|
||||
info.Parent.Items.Move(item, info.InsertIndex);
|
||||
if (info.Parent != lc.RootGroup)
|
||||
cc.OnComponentChanged(info.Parent, TypeDescriptor.GetProperties(lc)["Items"], null, null);
|
||||
}
|
||||
|
||||
cc.OnComponentChanged(lc, TypeDescriptor.GetProperties(lc)["RootGroup"], null, null);
|
||||
dt.Commit();
|
||||
lc.PerformLayout();
|
||||
lc.Invalidate(true);
|
||||
|
||||
IDesigner designer = host.GetDesigner(lc);
|
||||
if (designer is LayoutControlDesigner)
|
||||
((LayoutControlDesigner)designer).SelectionRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
base.OnDragDrop(g, e);
|
||||
}
|
||||
public override void OnDragLeave(Glyph g, EventArgs e)
|
||||
{
|
||||
LayoutItemGlyph glyph = g as LayoutItemGlyph;
|
||||
if (glyph != null && glyph.Item != null)
|
||||
{
|
||||
LayoutControl lc = glyph.Item.GetLayoutControl();
|
||||
if (lc != null)
|
||||
lc.HideInsertMarker();
|
||||
}
|
||||
base.OnDragLeave(g, e);
|
||||
}
|
||||
|
||||
public override void OnDragOver(Glyph g, DragEventArgs e)
|
||||
{
|
||||
if (e.Data is LayoutItemDataObject)
|
||||
{
|
||||
e.Effect = DragDropEffects.Move;
|
||||
LayoutItemDataObject d = (LayoutItemDataObject)e.Data;
|
||||
LayoutControl lc = d.DragComponent.GetLayoutControl();
|
||||
if (lc != null)
|
||||
{
|
||||
HitTestInsertInfo info = lc.GetHitTestInsertInfo(d.DragComponent, lc.PointToClient(new Point(e.X, e.Y)));
|
||||
if (!info.InsertMarkerBounds.IsEmpty)
|
||||
lc.ShowInsertMarker(info.InsertMarkerBounds);
|
||||
else
|
||||
lc.HideInsertMarker();
|
||||
e.Effect = DragDropEffects.Move;
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.Effect = DragDropEffects.None;
|
||||
return;
|
||||
base.OnDragOver(g, e);
|
||||
}
|
||||
|
||||
public override void OnDragEnter(Glyph g, DragEventArgs e)
|
||||
{
|
||||
if (e.Data is LayoutItemDataObject)
|
||||
{
|
||||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
else
|
||||
e.Effect = DragDropEffects.None;
|
||||
return;
|
||||
base.OnDragEnter(g, e);
|
||||
}
|
||||
|
||||
private void QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
|
||||
{
|
||||
if ((e.Action != DragAction.Continue) && e.EscapePressed)
|
||||
{
|
||||
e.Action = DragAction.Cancel;
|
||||
//ToolStripItem glyphItem = sender as ToolStripItem;
|
||||
//this.SetParentDesignerValuesForDragDrop(glyphItem, false, Point.Empty);
|
||||
//ISelectionService selectionService = this.GetSelectionService(glyphItem);
|
||||
//if (selectionService != null)
|
||||
//{
|
||||
// selectionService.SetSelectedComponents(new IComponent[] { glyphItem }, SelectionTypes.Auto);
|
||||
//}
|
||||
//ToolStripDesigner.dragItem = null;
|
||||
}
|
||||
}
|
||||
private ISelectionService GetSelectionService(LayoutItemBase item)
|
||||
{
|
||||
if (item.Site != null)
|
||||
{
|
||||
return (ISelectionService)item.Site.GetService(typeof(ISelectionService));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private IDesignerHost GetDesignerHostService(LayoutItemBase item)
|
||||
{
|
||||
if (item.Site != null)
|
||||
{
|
||||
return (IDesignerHost)item.Site.GetService(typeof(IDesignerHost));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private IComponentChangeService GetComponentChangeService(LayoutItemBase item)
|
||||
{
|
||||
if (item.Site != null)
|
||||
{
|
||||
return (IComponentChangeService)item.Site.GetService(typeof(IComponentChangeService));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Control _DropSource = null;
|
||||
private Control DropSource
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DropSource == null)
|
||||
{
|
||||
_DropSource = new Control();
|
||||
}
|
||||
return _DropSource;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region LayoutItemDataObject
|
||||
internal class LayoutItemDataObject : DataObject
|
||||
{
|
||||
private LayoutItemBase _DragComponent;
|
||||
|
||||
// Methods
|
||||
internal LayoutItemDataObject(LayoutItemBase dragComponents)
|
||||
{
|
||||
_DragComponent = dragComponents;
|
||||
}
|
||||
|
||||
// Properties
|
||||
internal LayoutItemBase DragComponent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _DragComponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Design;
|
||||
using System.Reflection;
|
||||
using DevComponents.DotNetBar;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
public class SymbolTypeEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
#region Implementation
|
||||
private IWindowsFormsEditorService edSvc = null;
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
string stringValue = null;
|
||||
if (value != null) stringValue = value.ToString();
|
||||
|
||||
if (edSvc != null)
|
||||
{
|
||||
ItemPanel itemPanel = new ItemPanel();
|
||||
itemPanel.Font = Symbols.FontAwesome;
|
||||
itemPanel.MultiLine = true;
|
||||
itemPanel.AutoScroll = true;
|
||||
itemPanel.LayoutOrientation = eOrientation.Horizontal;
|
||||
itemPanel.SelectedIndexChanged += new EventHandler(ItemPanelSelectedIndexChanged);
|
||||
#if !TRIAL
|
||||
itemPanel.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
|
||||
#endif
|
||||
SetColors(itemPanel);
|
||||
|
||||
Dictionary<int, bool> supportedChars = GetFontSupportedChars(itemPanel.Font);
|
||||
for (int i = 0xf000; i <= 0xf200; i++)
|
||||
{
|
||||
if (!supportedChars.ContainsKey(i)) continue;
|
||||
ButtonItem button = new ButtonItem();
|
||||
button.AutoCheckOnClick = true;
|
||||
button.OptionGroup = "sym";
|
||||
button.Text = char.ConvertFromUtf32(i);
|
||||
button.Tooltip = string.Format("{0:x}", i);
|
||||
if (button.Text == stringValue) button.Checked = true;
|
||||
itemPanel.Items.Add(button);
|
||||
}
|
||||
edSvc.DropDownControl(itemPanel);
|
||||
itemPanel.SelectedIndexChanged -= new EventHandler(ItemPanelSelectedIndexChanged);
|
||||
if (itemPanel.SelectedItem != null)
|
||||
return itemPanel.SelectedItem.Text;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SetColors(ItemPanel itemPanel)
|
||||
{
|
||||
Office2007ColorTable table = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
|
||||
ElementStyle style = (ElementStyle)table.StyleClasses[ElementStyleClassKeys.ItemPanelKey];
|
||||
itemPanel.BackgroundStyle.BackColor = style.BackColor;
|
||||
itemPanel.BackgroundStyle.BackColor2 = style.BackColor2;
|
||||
}
|
||||
|
||||
void ItemPanelSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (edSvc != null)
|
||||
edSvc.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
|
||||
// This method indicates to the design environment that
|
||||
// the type editor will paint additional content in the
|
||||
// LightShape entry in the PropertyGrid.
|
||||
public override bool GetPaintValueSupported(
|
||||
ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PaintValue(PaintValueEventArgs e)
|
||||
{
|
||||
string symbol = (string)e.Value;
|
||||
Font font = Symbols.GetFontAwesome(10);
|
||||
e.Graphics.DrawString(symbol, font, Brushes.Brown, e.Bounds.X, e.Bounds.Y + 2, StringFormat.GenericDefault);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetFontSupportedChars
|
||||
private static readonly IntPtr HGDI_ERROR = new IntPtr(-1);
|
||||
private const int UIntSize = 4;
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern uint GetFontUnicodeRanges(IntPtr hdc, IntPtr lpgs);
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
|
||||
private Dictionary<int, bool> GetFontSupportedChars(Font font)
|
||||
{
|
||||
Dictionary<int, bool> table = new Dictionary<int, bool>();
|
||||
|
||||
IntPtr glyphSetData = IntPtr.Zero;
|
||||
IntPtr savedFont = HGDI_ERROR;
|
||||
IntPtr hdc = IntPtr.Zero;
|
||||
Graphics g = null;
|
||||
|
||||
try
|
||||
{
|
||||
g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
hdc = g.GetHdc();
|
||||
IntPtr hFont = font.ToHfont();
|
||||
savedFont = SelectObject(hdc, hFont);
|
||||
if (savedFont == HGDI_ERROR)
|
||||
throw new Exception(
|
||||
"Unexpected failure of SelectObject.");
|
||||
uint size = GetFontUnicodeRanges(hdc, IntPtr.Zero);
|
||||
if (size == 0)
|
||||
throw new Exception(
|
||||
"Unexpected failure of GetFontUnicodeRanges.");
|
||||
glyphSetData = Marshal.AllocHGlobal((int)size);
|
||||
if (GetFontUnicodeRanges(hdc, glyphSetData) == 0)
|
||||
throw new Exception(
|
||||
"Unexpected failure of GetFontUnicodeRanges.");
|
||||
int offset = UIntSize;
|
||||
uint flags = (uint)Marshal.ReadInt32(
|
||||
glyphSetData, offset);
|
||||
offset += UIntSize;
|
||||
uint codePointCount = (uint)Marshal.ReadInt32(
|
||||
glyphSetData, offset);
|
||||
offset += UIntSize;
|
||||
uint rangeCount = (uint)Marshal.ReadInt32(
|
||||
glyphSetData, offset);
|
||||
offset += UIntSize;
|
||||
for (uint index = 0; index < rangeCount; index++)
|
||||
{
|
||||
ushort first = (ushort)Marshal.ReadInt16(
|
||||
glyphSetData, offset);
|
||||
offset += Marshal.SizeOf(typeof(ushort));
|
||||
ushort count = (ushort)Marshal.ReadInt16(
|
||||
glyphSetData, offset);
|
||||
offset += Marshal.SizeOf(typeof(ushort));
|
||||
for (int i = first; i < first + count; i++)
|
||||
{
|
||||
table.Add(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (glyphSetData != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal(glyphSetData);
|
||||
if (savedFont != HGDI_ERROR)
|
||||
SelectObject(hdc, savedFont);
|
||||
if (g != null)
|
||||
{
|
||||
if (hdc != IntPtr.Zero)
|
||||
g.ReleaseHdc(hdc);
|
||||
g.Dispose();
|
||||
}
|
||||
}
|
||||
return table;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 222 B |
@@ -0,0 +1,324 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for TextMarkupEditor.
|
||||
/// </summary>
|
||||
[ToolboxItem(false)]
|
||||
public class TextMarkupEditor : PanelEx
|
||||
{
|
||||
public System.Windows.Forms.Button buttonCancel;
|
||||
public System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private DevComponents.DotNetBar.PanelEx previewPanel;
|
||||
public System.Windows.Forms.TextBox inputText;
|
||||
private Label label2;
|
||||
private System.ComponentModel.IContainer components;
|
||||
private Bar bar1;
|
||||
private ButtonItem buttonBold;
|
||||
private ButtonItem buttonItalic;
|
||||
private ButtonItem buttonUnderline;
|
||||
private ColorPickerDropDown buttonColor;
|
||||
private SuperTooltipControl m_Tooltip = null;
|
||||
|
||||
public TextMarkupEditor()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
this.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
|
||||
this.ApplyLabelStyle();
|
||||
this.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
|
||||
this.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
|
||||
this.TabStop = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.inputText = new System.Windows.Forms.TextBox();
|
||||
this.previewPanel = new DevComponents.DotNetBar.PanelEx();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.bar1 = new DevComponents.DotNetBar.Bar();
|
||||
this.buttonBold = new DevComponents.DotNetBar.ButtonItem();
|
||||
this.buttonItalic = new DevComponents.DotNetBar.ButtonItem();
|
||||
this.buttonUnderline = new DevComponents.DotNetBar.ButtonItem();
|
||||
this.buttonColor = new DevComponents.DotNetBar.ColorPickerDropDown();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bar1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// inputText
|
||||
//
|
||||
this.inputText.AcceptsReturn = true;
|
||||
this.inputText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.inputText.Location = new System.Drawing.Point(8, 8);
|
||||
this.inputText.Multiline = true;
|
||||
this.inputText.Name = "inputText";
|
||||
this.inputText.Size = new System.Drawing.Size(332, 110);
|
||||
this.inputText.TabIndex = 0;
|
||||
this.inputText.TextChanged += new System.EventHandler(this.inputText_TextChanged);
|
||||
//
|
||||
// previewPanel
|
||||
//
|
||||
this.previewPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.previewPanel.AutoScroll = true;
|
||||
this.previewPanel.CanvasColor = System.Drawing.SystemColors.Control;
|
||||
this.previewPanel.Location = new System.Drawing.Point(8, 152);
|
||||
this.previewPanel.Name = "previewPanel";
|
||||
this.previewPanel.Size = new System.Drawing.Size(332, 75);
|
||||
this.previewPanel.Style.BackColor1.Color = System.Drawing.Color.White;
|
||||
this.previewPanel.Style.BackgroundImagePosition = DevComponents.DotNetBar.eBackgroundImagePosition.Tile;
|
||||
this.previewPanel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
|
||||
this.previewPanel.Style.BorderColor.Color = System.Drawing.Color.DarkGray;
|
||||
this.previewPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText;
|
||||
this.previewPanel.Style.GradientAngle = 90;
|
||||
this.previewPanel.Style.LineAlignment = System.Drawing.StringAlignment.Near;
|
||||
this.previewPanel.TabIndex = 1;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(269, 233);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(71, 24);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.buttonOK.Location = new System.Drawing.Point(194, 233);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(71, 24);
|
||||
this.buttonOK.TabIndex = 3;
|
||||
this.buttonOK.Text = "OK";
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Interval = 1000;
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label2.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.Location = new System.Drawing.Point(316, 133);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(24, 16);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "?";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.label2.MouseLeave += new System.EventHandler(this.label2_MouseLeave);
|
||||
this.label2.MouseEnter += new System.EventHandler(this.label2_MouseEnter);
|
||||
//
|
||||
// bar1
|
||||
//
|
||||
this.bar1.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
|
||||
this.buttonBold,
|
||||
this.buttonItalic,
|
||||
this.buttonUnderline,
|
||||
this.buttonColor});
|
||||
this.bar1.Location = new System.Drawing.Point(8, 124);
|
||||
this.bar1.Name = "bar1";
|
||||
this.bar1.Size = new System.Drawing.Size(174, 25);
|
||||
this.bar1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
|
||||
this.bar1.TabIndex = 6;
|
||||
this.bar1.TabStop = false;
|
||||
this.bar1.Text = "bar1";
|
||||
//
|
||||
// buttonBold
|
||||
//
|
||||
this.buttonBold.Name = "buttonBold";
|
||||
this.buttonBold.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlB);
|
||||
this.buttonBold.Text = "Bold";
|
||||
this.buttonBold.Click += new System.EventHandler(this.buttonBold_Click);
|
||||
//
|
||||
// buttonItalic
|
||||
//
|
||||
this.buttonItalic.Name = "buttonItalic";
|
||||
this.buttonItalic.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlI);
|
||||
this.buttonItalic.Text = "Italic";
|
||||
this.buttonItalic.Click += new System.EventHandler(this.buttonItalic_Click);
|
||||
//
|
||||
// buttonUnderline
|
||||
//
|
||||
this.buttonUnderline.Name = "buttonUnderline";
|
||||
this.buttonUnderline.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlU);
|
||||
this.buttonUnderline.Text = "Underline";
|
||||
this.buttonUnderline.Click += new System.EventHandler(this.buttonUnderline_Click);
|
||||
//
|
||||
// buttonColor
|
||||
//
|
||||
this.buttonColor.Name = "buttonColor";
|
||||
this.buttonColor.Tooltip = "Sets the text color";
|
||||
this.buttonColor.Image = Helpers.LoadBitmap("SystemImages.ColorPickerButtonImage.png");
|
||||
this.buttonColor.SelectedColorImageRectangle = new System.Drawing.Rectangle(2, 2, 12, 12);
|
||||
this.buttonColor.Click += new System.EventHandler(this.buttonColor_SelectedColorChanged);
|
||||
//
|
||||
// TextMarkupEditor
|
||||
//
|
||||
this.Controls.Add(this.bar1);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.previewPanel);
|
||||
this.Controls.Add(this.inputText);
|
||||
this.Name = "TextMarkupEditor";
|
||||
this.Size = new System.Drawing.Size(348, 263);
|
||||
((System.ComponentModel.ISupportInitialize)(this.bar1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DestroyTooltip();
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
DestroyTooltip();
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void inputText_TextChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
timer1.Stop();
|
||||
timer1.Start();
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, System.EventArgs e)
|
||||
{
|
||||
timer1.Stop();
|
||||
UpdatePreview();
|
||||
}
|
||||
|
||||
private void UpdatePreview()
|
||||
{
|
||||
previewPanel.Text = inputText.Text;
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
inputText.Focus();
|
||||
}
|
||||
|
||||
private void label2_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
DestroyTooltip();
|
||||
|
||||
m_Tooltip = new SuperTooltipControl();
|
||||
m_Tooltip.AntiAlias = false;
|
||||
SuperTooltipInfo info = new SuperTooltipInfo();
|
||||
info.HeaderText = "Markup tags available";
|
||||
info.BodyText = "<b>b</b> - Bold <br/>" +
|
||||
"<b>i</b> - Italic <br/>" +
|
||||
"<b>u</b> - Underline <br/>" +
|
||||
"<b>p</b> - Paragraph container, <b>width</b> attribute indicates width of block element <br/>" +
|
||||
"<b>div</b> - Block-level container, <b>width</b> attribute indicates width of block element<br/>" +
|
||||
"<b>span</b> - Inline container, <b>width</b> attribute indicates width of block element. Can be used to create tables<br/>" +
|
||||
"<b>br</b> - Line break<br/>" +
|
||||
"<b>font</b> - Changes font, color, size. <b>size</b> attribute indicates absolute or relative font size. <b>color</b> attribute to change the color" +
|
||||
"You can use relative sizing for example +1 to increase font size by one point or -1 to decrease by one point. <b>face</b> attribute can be employed to set the specific font name to use.<br/>" +
|
||||
"<b>h1</b> - Header markup. You can use h1, h2, h3, h4, h5, h6 to represent header sizes<br/>" +
|
||||
"<b>a</b> - Denotes hypertext link. <b>href</b> and <b>name</b> attributes are supported<br/>" +
|
||||
"<b>expand</b> - Displays the expand part of the button" +
|
||||
"<br/>All tags must be lower case and they must be well formed i.e. each tag must be closed with end tag or be an empty tag.";
|
||||
info.Color = eTooltipColor.Default;
|
||||
Point p = label2.PointToScreen(new Point(0, label2.Height + 1));
|
||||
m_Tooltip.ShowTooltip(info, p.X, p.Y, true);
|
||||
}
|
||||
|
||||
private void DestroyTooltip()
|
||||
{
|
||||
if (m_Tooltip == null)
|
||||
return;
|
||||
m_Tooltip.Hide();
|
||||
m_Tooltip.Dispose();
|
||||
m_Tooltip = null;
|
||||
}
|
||||
|
||||
private void label2_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
DestroyTooltip();
|
||||
}
|
||||
|
||||
private void buttonBold_Click(object sender, EventArgs e)
|
||||
{
|
||||
ApplyTag("<b>", "</b>");
|
||||
}
|
||||
|
||||
private void buttonItalic_Click(object sender, EventArgs e)
|
||||
{
|
||||
ApplyTag("<i>", "</i>");
|
||||
}
|
||||
|
||||
private void buttonUnderline_Click(object sender, EventArgs e)
|
||||
{
|
||||
ApplyTag("<u>", "</u>");
|
||||
}
|
||||
|
||||
private void buttonColor_SelectedColorChanged(object sender, EventArgs e)
|
||||
{
|
||||
ApplyTag("<font color=\"" + GetHexColor(buttonColor.SelectedColor) +"\">", "</font>");
|
||||
}
|
||||
|
||||
private void ApplyTag(string startTag, string endTag)
|
||||
{
|
||||
if (inputText.SelectionLength == 0)
|
||||
inputText.SelectedText = startTag + endTag;
|
||||
else
|
||||
inputText.SelectedText = startTag + inputText.SelectedText + endTag;
|
||||
|
||||
UpdatePreview();
|
||||
}
|
||||
|
||||
private string GetHexColor(Color color)
|
||||
{
|
||||
return "#" + color.R.ToString("X02") + color.G.ToString("X02") + color.B.ToString("X02");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
public class TextMarkupUIEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
#region Private Variables
|
||||
private IWindowsFormsEditorService m_EditorService = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if (m_EditorService != null)
|
||||
{
|
||||
TextMarkupEditor editor = new TextMarkupEditor();
|
||||
editor.buttonOK.Click += new EventHandler(MarkupEditorButtonClick);
|
||||
editor.buttonCancel.Click += new EventHandler(MarkupEditorButtonClick);
|
||||
|
||||
if(value!=null)
|
||||
editor.inputText.Text = value.ToString();
|
||||
|
||||
m_EditorService.DropDownControl(editor);
|
||||
|
||||
if (editor.DialogResult == DialogResult.OK)
|
||||
{
|
||||
string text = editor.inputText.Text;
|
||||
editor.Dispose();
|
||||
return text;
|
||||
}
|
||||
editor.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void MarkupEditorButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
if (m_EditorService != null)
|
||||
m_EditorService.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Layout.Design
|
||||
{
|
||||
internal static class WinApi
|
||||
{
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
|
||||
[DllImport("gdi32")]
|
||||
public static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern bool GetTextMetrics(HandleRef hdc, TEXTMETRIC tm);
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public class TEXTMETRIC
|
||||
{
|
||||
public int tmHeight;
|
||||
public int tmAscent;
|
||||
public int tmDescent;
|
||||
public int tmInternalLeading;
|
||||
public int tmExternalLeading;
|
||||
public int tmAveCharWidth;
|
||||
public int tmMaxCharWidth;
|
||||
public int tmWeight;
|
||||
public int tmOverhang;
|
||||
public int tmDigitizedAspectX;
|
||||
public int tmDigitizedAspectY;
|
||||
public char tmFirstChar;
|
||||
public char tmLastChar;
|
||||
public char tmDefaultChar;
|
||||
public char tmBreakChar;
|
||||
public byte tmItalic;
|
||||
public byte tmUnderlined;
|
||||
public byte tmStruckOut;
|
||||
public byte tmPitchAndFamily;
|
||||
public byte tmCharSet;
|
||||
}
|
||||
|
||||
[DllImport("user32")]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
[DllImport("user32")]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
public const int WM_SETREDRAW = 0x000B;
|
||||
|
||||
public const int WM_LBUTTONDOWN = 0x0201;
|
||||
public const int WM_LBUTTONUP = 0x0202;
|
||||
public const int WM_RBUTTONDOWN = 0x0204;
|
||||
public const int WM_RBUTTONUP = 0x0205;
|
||||
public const int WM_MOUSEMOVE = 0x0200;
|
||||
public const int WM_MOUSELEAVE = 0x02A3;
|
||||
public const int WM_HSCROLL = 0x0114;
|
||||
public const int WM_VSCROLL = 0x0115;
|
||||
public const int WM_LBUTTONDBLCLK = 0x0203;
|
||||
|
||||
public static int LOWORD(int n)
|
||||
{
|
||||
return (short)(n & 0xffff);
|
||||
}
|
||||
public static int HIWORD(int n)
|
||||
{
|
||||
return (int)((n >> 0x10) & 0xffff);
|
||||
}
|
||||
public static int LOWORD(IntPtr n)
|
||||
{
|
||||
return LOWORD((int)((long)n));
|
||||
}
|
||||
public static int HIWORD(IntPtr n)
|
||||
{
|
||||
return unchecked((short)((uint)n >> 16));
|
||||
}
|
||||
|
||||
//[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
//public static extern int ScrollWindowEx(HandleRef hWnd, int nXAmount, int nYAmount, ref RECT rectScrollRegion, ref RECT rectClip, IntPtr hrgnUpdate, ref RECT prcUpdate, int flags);
|
||||
//[StructLayout(LayoutKind.Sequential)]
|
||||
//public struct RECT
|
||||
//{
|
||||
// public int left;
|
||||
// public int top;
|
||||
// public int right;
|
||||
// public int bottom;
|
||||
// public RECT(int left, int top, int right, int bottom)
|
||||
// {
|
||||
// this.left = left;
|
||||
// this.top = top;
|
||||
// this.right = right;
|
||||
// this.bottom = bottom;
|
||||
// }
|
||||
|
||||
// public RECT(Rectangle r)
|
||||
// {
|
||||
// this.left = r.Left;
|
||||
// this.top = r.Top;
|
||||
// this.right = r.Right;
|
||||
// this.bottom = r.Bottom;
|
||||
// }
|
||||
|
||||
// public static RECT FromXYWH(int x, int y, int width, int height)
|
||||
// {
|
||||
// return new RECT(x, y, x + width, y + height);
|
||||
// }
|
||||
|
||||
// public Size Size
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return new Size(this.right - this.left, this.bottom - this.top);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user