diff --git a/Winforms.sln b/Winforms.sln index f057e2c9260..cfbcb7f6020 100644 --- a/Winforms.sln +++ b/Winforms.sln @@ -144,6 +144,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiRichTextBoxTests", "src EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "interop", "interop", "{A31B1F6F-4880-45DE-9845-EE3EF67C2FCC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DesignSurface", "DesignSurface", "{43E46506-7DF8-4E7A-A579-996CA43041EB}" + ProjectSection(SolutionItems) = preProject + src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\.editorconfig = src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\.editorconfig + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoConsole", "src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DemoConsole\DemoConsole.csproj", "{93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesignSurfaceExt", "src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DesignSurfaceExt\DesignSurfaceExt.csproj", "{E96C74BA-9F74-4289-BF72-45CAD472D3D2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -812,6 +821,38 @@ Global {4DC0426D-E4B6-4D83-BB96-38A017A92E47}.Release|x64.Build.0 = Release|Any CPU {4DC0426D-E4B6-4D83-BB96-38A017A92E47}.Release|x86.ActiveCfg = Release|Any CPU {4DC0426D-E4B6-4D83-BB96-38A017A92E47}.Release|x86.Build.0 = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|arm64.ActiveCfg = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|arm64.Build.0 = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|x64.ActiveCfg = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|x64.Build.0 = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|x86.ActiveCfg = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Debug|x86.Build.0 = Debug|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|Any CPU.Build.0 = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|arm64.ActiveCfg = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|arm64.Build.0 = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|x64.ActiveCfg = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|x64.Build.0 = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|x86.ActiveCfg = Release|Any CPU + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4}.Release|x86.Build.0 = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|arm64.ActiveCfg = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|arm64.Build.0 = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|x64.ActiveCfg = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|x64.Build.0 = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|x86.ActiveCfg = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Debug|x86.Build.0 = Debug|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|Any CPU.Build.0 = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|arm64.ActiveCfg = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|arm64.Build.0 = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|x64.ActiveCfg = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|x64.Build.0 = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|x86.ActiveCfg = Release|Any CPU + {E96C74BA-9F74-4289-BF72-45CAD472D3D2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -865,6 +906,9 @@ Global {B8FD66E7-BD6F-4E6F-8199-7CE6149FBE48} = {8F20A905-BD37-4D80-B8DF-FA45276FC23F} {4DC0426D-E4B6-4D83-BB96-38A017A92E47} = {8F20A905-BD37-4D80-B8DF-FA45276FC23F} {A31B1F6F-4880-45DE-9845-EE3EF67C2FCC} = {DF68A171-D27B-4E6A-8A7E-63A651622355} + {43E46506-7DF8-4E7A-A579-996CA43041EB} = {680FB14C-7B0C-4D63-9F1A-18ACCDB0F52A} + {93310A19-DDCA-4BCD-AEDE-5C5D788DAFB4} = {43E46506-7DF8-4E7A-A579-996CA43041EB} + {E96C74BA-9F74-4289-BF72-45CAD472D3D2} = {43E46506-7DF8-4E7A-A579-996CA43041EB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7B1B0433-F612-4E5A-BE7E-FCF5B9F6E136} diff --git a/src/System.Design/src/System.Design.Forwards.cs b/src/System.Design/src/System.Design.Forwards.cs index df1ca0343f3..869b0513c0e 100644 --- a/src/System.Design/src/System.Design.Forwards.cs +++ b/src/System.Design/src/System.Design.Forwards.cs @@ -33,10 +33,27 @@ [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripMenuItemCodeDomSerializer))] // internal designers +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ButtonBaseDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ComboBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FormDocumentDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.GroupBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.LabelDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListViewDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MaskedTextBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PanelDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PictureBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RadioButtonDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RichTextBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TextBoxBaseDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TextBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripDropDownDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripDropDownItemDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripItemDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripMenuItemDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TreeViewDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.UpDownBaseDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.UserControlDocumentDesigner))] + +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabOrder))] diff --git a/src/System.Windows.Forms.Design/src/AssemblyRef.cs b/src/System.Windows.Forms.Design/src/AssemblyRef.cs new file mode 100644 index 00000000000..102c181a2b5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/AssemblyRef.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static class AssemblyRef +{ + internal const string MicrosoftPublicKey = "b03f5f7f11d50a3a"; + internal const string EnvDTE = "EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=" + MicrosoftPublicKey; +} diff --git a/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt index c00fd2f41f0..08b4a72aa8a 100644 --- a/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt @@ -1,186 +1,187 @@ +#nullable enable System.ComponentModel.Design.ComponentDesigner -System.ComponentModel.Design.ComponentDesigner.Component.get -> System.ComponentModel.IComponent +~System.ComponentModel.Design.ComponentDesigner.Component.get -> System.ComponentModel.IComponent System.ComponentModel.Design.ComponentDesigner.ComponentDesigner() -> void System.ComponentModel.Design.ComponentDesigner.Dispose() -> void System.ComponentModel.Design.ComponentDesigner.Inherited.get -> bool -System.ComponentModel.Design.ComponentDesigner.InvokeGetInheritanceAttribute(System.ComponentModel.Design.ComponentDesigner toInvoke) -> System.ComponentModel.InheritanceAttribute -System.ComponentModel.Design.ComponentDesigner.RaiseComponentChanged(System.ComponentModel.MemberDescriptor member, object oldValue, object newValue) -> void -System.ComponentModel.Design.ComponentDesigner.RaiseComponentChanging(System.ComponentModel.MemberDescriptor member) -> void -System.ComponentModel.Design.ComponentDesigner.ShadowProperties.get -> System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection +~System.ComponentModel.Design.ComponentDesigner.InvokeGetInheritanceAttribute(System.ComponentModel.Design.ComponentDesigner toInvoke) -> System.ComponentModel.InheritanceAttribute +~System.ComponentModel.Design.ComponentDesigner.RaiseComponentChanged(System.ComponentModel.MemberDescriptor member, object oldValue, object newValue) -> void +~System.ComponentModel.Design.ComponentDesigner.RaiseComponentChanging(System.ComponentModel.MemberDescriptor member) -> void +~System.ComponentModel.Design.ComponentDesigner.ShadowProperties.get -> System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection -System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection.Contains(string propertyName) -> bool -System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection.this[string propertyName].get -> object -System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection.this[string propertyName].set -> void +~System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection.Contains(string propertyName) -> bool +~System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection.this[string propertyName].get -> object +~System.ComponentModel.Design.ComponentDesigner.ShadowPropertyCollection.this[string propertyName].set -> void System.ComponentModel.Design.DesignSurface -System.ComponentModel.Design.DesignSurface.BeginLoad(System.ComponentModel.Design.Serialization.DesignerLoader loader) -> void -System.ComponentModel.Design.DesignSurface.BeginLoad(System.Type rootComponentType) -> void -System.ComponentModel.Design.DesignSurface.ComponentContainer.get -> System.ComponentModel.IContainer -System.ComponentModel.Design.DesignSurface.CreateNestedContainer(System.ComponentModel.IComponent owningComponent) -> System.ComponentModel.INestedContainer -System.ComponentModel.Design.DesignSurface.CreateNestedContainer(System.ComponentModel.IComponent owningComponent, string containerName) -> System.ComponentModel.INestedContainer +~System.ComponentModel.Design.DesignSurface.BeginLoad(System.ComponentModel.Design.Serialization.DesignerLoader loader) -> void +~System.ComponentModel.Design.DesignSurface.BeginLoad(System.Type rootComponentType) -> void +~System.ComponentModel.Design.DesignSurface.ComponentContainer.get -> System.ComponentModel.IContainer +~System.ComponentModel.Design.DesignSurface.CreateNestedContainer(System.ComponentModel.IComponent owningComponent) -> System.ComponentModel.INestedContainer +~System.ComponentModel.Design.DesignSurface.CreateNestedContainer(System.ComponentModel.IComponent owningComponent, string containerName) -> System.ComponentModel.INestedContainer System.ComponentModel.Design.DesignSurface.DesignSurface() -> void -System.ComponentModel.Design.DesignSurface.DesignSurface(System.IServiceProvider parentProvider) -> void -System.ComponentModel.Design.DesignSurface.DesignSurface(System.IServiceProvider parentProvider, System.Type rootComponentType) -> void -System.ComponentModel.Design.DesignSurface.DesignSurface(System.Type rootComponentType) -> void +~System.ComponentModel.Design.DesignSurface.DesignSurface(System.IServiceProvider parentProvider) -> void +~System.ComponentModel.Design.DesignSurface.DesignSurface(System.IServiceProvider parentProvider, System.Type rootComponentType) -> void +~System.ComponentModel.Design.DesignSurface.DesignSurface(System.Type rootComponentType) -> void System.ComponentModel.Design.DesignSurface.Dispose() -> void System.ComponentModel.Design.DesignSurface.Disposed -> System.EventHandler System.ComponentModel.Design.DesignSurface.DtelLoading.get -> bool System.ComponentModel.Design.DesignSurface.DtelLoading.set -> void System.ComponentModel.Design.DesignSurface.Flush() -> void System.ComponentModel.Design.DesignSurface.Flushed -> System.EventHandler -System.ComponentModel.Design.DesignSurface.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.DesignSurface.GetService(System.Type serviceType) -> object System.ComponentModel.Design.DesignSurface.IsLoaded.get -> bool -System.ComponentModel.Design.DesignSurface.LoadErrors.get -> System.Collections.ICollection +~System.ComponentModel.Design.DesignSurface.LoadErrors.get -> System.Collections.ICollection System.ComponentModel.Design.DesignSurface.Loaded -> System.ComponentModel.Design.LoadedEventHandler System.ComponentModel.Design.DesignSurface.Loading -> System.EventHandler -System.ComponentModel.Design.DesignSurface.ServiceContainer.get -> System.ComponentModel.Design.ServiceContainer +~System.ComponentModel.Design.DesignSurface.ServiceContainer.get -> System.ComponentModel.Design.ServiceContainer System.ComponentModel.Design.DesignSurface.Unloaded -> System.EventHandler System.ComponentModel.Design.DesignSurface.Unloading -> System.EventHandler -System.ComponentModel.Design.DesignSurface.View.get -> object +~System.ComponentModel.Design.DesignSurface.View.get -> object System.ComponentModel.Design.DesignSurface.ViewActivated -> System.EventHandler System.ComponentModel.Design.DesignerActionHeaderItem -System.ComponentModel.Design.DesignerActionHeaderItem.DesignerActionHeaderItem(string displayName) -> void -System.ComponentModel.Design.DesignerActionHeaderItem.DesignerActionHeaderItem(string displayName, string category) -> void +~System.ComponentModel.Design.DesignerActionHeaderItem.DesignerActionHeaderItem(string displayName) -> void +~System.ComponentModel.Design.DesignerActionHeaderItem.DesignerActionHeaderItem(string displayName, string category) -> void System.ComponentModel.Design.DesignerActionItem System.ComponentModel.Design.DesignerActionItem.AllowAssociate.get -> bool System.ComponentModel.Design.DesignerActionItem.AllowAssociate.set -> void -System.ComponentModel.Design.DesignerActionItem.DesignerActionItem(string displayName, string category, string description) -> void -System.ComponentModel.Design.DesignerActionItem.Properties.get -> System.Collections.IDictionary +~System.ComponentModel.Design.DesignerActionItem.DesignerActionItem(string displayName, string category, string description) -> void +~System.ComponentModel.Design.DesignerActionItem.Properties.get -> System.Collections.IDictionary System.ComponentModel.Design.DesignerActionItem.ShowInSourceView.get -> bool System.ComponentModel.Design.DesignerActionItem.ShowInSourceView.set -> void System.ComponentModel.Design.DesignerActionItemCollection -System.ComponentModel.Design.DesignerActionItemCollection.Add(System.ComponentModel.Design.DesignerActionItem value) -> int -System.ComponentModel.Design.DesignerActionItemCollection.Contains(System.ComponentModel.Design.DesignerActionItem value) -> bool -System.ComponentModel.Design.DesignerActionItemCollection.CopyTo(System.ComponentModel.Design.DesignerActionItem[] array, int index) -> void +~System.ComponentModel.Design.DesignerActionItemCollection.Add(System.ComponentModel.Design.DesignerActionItem value) -> int +~System.ComponentModel.Design.DesignerActionItemCollection.Contains(System.ComponentModel.Design.DesignerActionItem value) -> bool +~System.ComponentModel.Design.DesignerActionItemCollection.CopyTo(System.ComponentModel.Design.DesignerActionItem[] array, int index) -> void System.ComponentModel.Design.DesignerActionItemCollection.DesignerActionItemCollection() -> void -System.ComponentModel.Design.DesignerActionItemCollection.IndexOf(System.ComponentModel.Design.DesignerActionItem value) -> int -System.ComponentModel.Design.DesignerActionItemCollection.Insert(int index, System.ComponentModel.Design.DesignerActionItem value) -> void -System.ComponentModel.Design.DesignerActionItemCollection.Remove(System.ComponentModel.Design.DesignerActionItem value) -> void -System.ComponentModel.Design.DesignerActionItemCollection.this[int index].get -> System.ComponentModel.Design.DesignerActionItem -System.ComponentModel.Design.DesignerActionItemCollection.this[int index].set -> void +~System.ComponentModel.Design.DesignerActionItemCollection.IndexOf(System.ComponentModel.Design.DesignerActionItem value) -> int +~System.ComponentModel.Design.DesignerActionItemCollection.Insert(int index, System.ComponentModel.Design.DesignerActionItem value) -> void +~System.ComponentModel.Design.DesignerActionItemCollection.Remove(System.ComponentModel.Design.DesignerActionItem value) -> void +~System.ComponentModel.Design.DesignerActionItemCollection.this[int index].get -> System.ComponentModel.Design.DesignerActionItem +~System.ComponentModel.Design.DesignerActionItemCollection.this[int index].set -> void System.ComponentModel.Design.DesignerActionList -System.ComponentModel.Design.DesignerActionList.Component.get -> System.ComponentModel.IComponent -System.ComponentModel.Design.DesignerActionList.DesignerActionList(System.ComponentModel.IComponent component) -> void -System.ComponentModel.Design.DesignerActionList.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.DesignerActionList.Component.get -> System.ComponentModel.IComponent +~System.ComponentModel.Design.DesignerActionList.DesignerActionList(System.ComponentModel.IComponent component) -> void +~System.ComponentModel.Design.DesignerActionList.GetService(System.Type serviceType) -> object System.ComponentModel.Design.DesignerActionListCollection -System.ComponentModel.Design.DesignerActionListCollection.Add(System.ComponentModel.Design.DesignerActionList value) -> int -System.ComponentModel.Design.DesignerActionListCollection.AddRange(System.ComponentModel.Design.DesignerActionListCollection value) -> void -System.ComponentModel.Design.DesignerActionListCollection.AddRange(System.ComponentModel.Design.DesignerActionList[] value) -> void -System.ComponentModel.Design.DesignerActionListCollection.Contains(System.ComponentModel.Design.DesignerActionList value) -> bool -System.ComponentModel.Design.DesignerActionListCollection.CopyTo(System.ComponentModel.Design.DesignerActionList[] array, int index) -> void +~System.ComponentModel.Design.DesignerActionListCollection.Add(System.ComponentModel.Design.DesignerActionList value) -> int +~System.ComponentModel.Design.DesignerActionListCollection.AddRange(System.ComponentModel.Design.DesignerActionListCollection value) -> void +~System.ComponentModel.Design.DesignerActionListCollection.AddRange(System.ComponentModel.Design.DesignerActionList[] value) -> void +~System.ComponentModel.Design.DesignerActionListCollection.Contains(System.ComponentModel.Design.DesignerActionList value) -> bool +~System.ComponentModel.Design.DesignerActionListCollection.CopyTo(System.ComponentModel.Design.DesignerActionList[] array, int index) -> void System.ComponentModel.Design.DesignerActionListCollection.DesignerActionListCollection() -> void -System.ComponentModel.Design.DesignerActionListCollection.DesignerActionListCollection(System.ComponentModel.Design.DesignerActionList[] value) -> void -System.ComponentModel.Design.DesignerActionListCollection.IndexOf(System.ComponentModel.Design.DesignerActionList value) -> int -System.ComponentModel.Design.DesignerActionListCollection.Insert(int index, System.ComponentModel.Design.DesignerActionList value) -> void -System.ComponentModel.Design.DesignerActionListCollection.Remove(System.ComponentModel.Design.DesignerActionList value) -> void -System.ComponentModel.Design.DesignerActionListCollection.this[int index].get -> System.ComponentModel.Design.DesignerActionList -System.ComponentModel.Design.DesignerActionListCollection.this[int index].set -> void +~System.ComponentModel.Design.DesignerActionListCollection.DesignerActionListCollection(System.ComponentModel.Design.DesignerActionList[] value) -> void +~System.ComponentModel.Design.DesignerActionListCollection.IndexOf(System.ComponentModel.Design.DesignerActionList value) -> int +~System.ComponentModel.Design.DesignerActionListCollection.Insert(int index, System.ComponentModel.Design.DesignerActionList value) -> void +~System.ComponentModel.Design.DesignerActionListCollection.Remove(System.ComponentModel.Design.DesignerActionList value) -> void +~System.ComponentModel.Design.DesignerActionListCollection.this[int index].get -> System.ComponentModel.Design.DesignerActionList +~System.ComponentModel.Design.DesignerActionListCollection.this[int index].set -> void System.ComponentModel.Design.DesignerActionListsChangedEventArgs -System.ComponentModel.Design.DesignerActionListsChangedEventArgs.ActionLists.get -> System.ComponentModel.Design.DesignerActionListCollection +~System.ComponentModel.Design.DesignerActionListsChangedEventArgs.ActionLists.get -> System.ComponentModel.Design.DesignerActionListCollection System.ComponentModel.Design.DesignerActionListsChangedEventArgs.ChangeType.get -> System.ComponentModel.Design.DesignerActionListsChangedType -System.ComponentModel.Design.DesignerActionListsChangedEventArgs.DesignerActionListsChangedEventArgs(object relatedObject, System.ComponentModel.Design.DesignerActionListsChangedType changeType, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void -System.ComponentModel.Design.DesignerActionListsChangedEventArgs.RelatedObject.get -> object +~System.ComponentModel.Design.DesignerActionListsChangedEventArgs.DesignerActionListsChangedEventArgs(object relatedObject, System.ComponentModel.Design.DesignerActionListsChangedType changeType, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void +~System.ComponentModel.Design.DesignerActionListsChangedEventArgs.RelatedObject.get -> object System.ComponentModel.Design.DesignerActionListsChangedEventHandler System.ComponentModel.Design.DesignerActionListsChangedType System.ComponentModel.Design.DesignerActionListsChangedType.ActionListsAdded = 0 -> System.ComponentModel.Design.DesignerActionListsChangedType System.ComponentModel.Design.DesignerActionListsChangedType.ActionListsRemoved = 1 -> System.ComponentModel.Design.DesignerActionListsChangedType System.ComponentModel.Design.DesignerActionMethodItem -System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName) -> void -System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, bool includeAsDesignerVerb) -> void -System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category) -> void -System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb) -> void -System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description) -> void -System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description, bool includeAsDesignerVerb) -> void -System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.get -> System.ComponentModel.IComponent -System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.set -> void +~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName) -> void +~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, bool includeAsDesignerVerb) -> void +~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category) -> void +~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb) -> void +~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description) -> void +~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description, bool includeAsDesignerVerb) -> void +~System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.get -> System.ComponentModel.IComponent +~System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.set -> void System.ComponentModel.Design.DesignerActionPropertyItem -System.ComponentModel.Design.DesignerActionPropertyItem.DesignerActionPropertyItem(string memberName, string displayName) -> void -System.ComponentModel.Design.DesignerActionPropertyItem.DesignerActionPropertyItem(string memberName, string displayName, string category) -> void -System.ComponentModel.Design.DesignerActionPropertyItem.DesignerActionPropertyItem(string memberName, string displayName, string category, string description) -> void -System.ComponentModel.Design.DesignerActionPropertyItem.MemberName.get -> string -System.ComponentModel.Design.DesignerActionPropertyItem.RelatedComponent.get -> System.ComponentModel.IComponent -System.ComponentModel.Design.DesignerActionPropertyItem.RelatedComponent.set -> void +~System.ComponentModel.Design.DesignerActionPropertyItem.DesignerActionPropertyItem(string memberName, string displayName) -> void +~System.ComponentModel.Design.DesignerActionPropertyItem.DesignerActionPropertyItem(string memberName, string displayName, string category) -> void +~System.ComponentModel.Design.DesignerActionPropertyItem.DesignerActionPropertyItem(string memberName, string displayName, string category, string description) -> void +~System.ComponentModel.Design.DesignerActionPropertyItem.MemberName.get -> string +~System.ComponentModel.Design.DesignerActionPropertyItem.RelatedComponent.get -> System.ComponentModel.IComponent +~System.ComponentModel.Design.DesignerActionPropertyItem.RelatedComponent.set -> void System.ComponentModel.Design.DesignerActionService -System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionList actionList) -> void -System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionListCollection designerActionListCollection) -> void +~System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionList actionList) -> void +~System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionListCollection designerActionListCollection) -> void System.ComponentModel.Design.DesignerActionService.Clear() -> void -System.ComponentModel.Design.DesignerActionService.Contains(System.ComponentModel.IComponent comp) -> bool +~System.ComponentModel.Design.DesignerActionService.Contains(System.ComponentModel.IComponent comp) -> bool System.ComponentModel.Design.DesignerActionService.DesignerActionListsChanged -> System.ComponentModel.Design.DesignerActionListsChangedEventHandler -System.ComponentModel.Design.DesignerActionService.DesignerActionService(System.IServiceProvider serviceProvider) -> void +~System.ComponentModel.Design.DesignerActionService.DesignerActionService(System.IServiceProvider serviceProvider) -> void System.ComponentModel.Design.DesignerActionService.Dispose() -> void -System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent component) -> System.ComponentModel.Design.DesignerActionListCollection -System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.Design.DesignerActionList actionList) -> void -System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent comp) -> void -System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionList actionList) -> void +~System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent component) -> System.ComponentModel.Design.DesignerActionListCollection +~System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.Design.DesignerActionList actionList) -> void +~System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent comp) -> void +~System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionList actionList) -> void System.ComponentModel.Design.DesignerActionTextItem -System.ComponentModel.Design.DesignerActionTextItem.DesignerActionTextItem(string displayName, string category) -> void +~System.ComponentModel.Design.DesignerActionTextItem.DesignerActionTextItem(string displayName, string category) -> void System.ComponentModel.Design.DesignerActionUIService System.ComponentModel.Design.DesignerActionUIService.DesignerActionUIStateChange -> System.ComponentModel.Design.DesignerActionUIStateChangeEventHandler System.ComponentModel.Design.DesignerActionUIService.Dispose() -> void -System.ComponentModel.Design.DesignerActionUIService.HideUI(System.ComponentModel.IComponent component) -> void -System.ComponentModel.Design.DesignerActionUIService.Refresh(System.ComponentModel.IComponent component) -> void -System.ComponentModel.Design.DesignerActionUIService.ShouldAutoShow(System.ComponentModel.IComponent component) -> bool -System.ComponentModel.Design.DesignerActionUIService.ShowUI(System.ComponentModel.IComponent component) -> void +~System.ComponentModel.Design.DesignerActionUIService.HideUI(System.ComponentModel.IComponent component) -> void +~System.ComponentModel.Design.DesignerActionUIService.Refresh(System.ComponentModel.IComponent component) -> void +~System.ComponentModel.Design.DesignerActionUIService.ShouldAutoShow(System.ComponentModel.IComponent component) -> bool +~System.ComponentModel.Design.DesignerActionUIService.ShowUI(System.ComponentModel.IComponent component) -> void System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.ChangeType.get -> System.ComponentModel.Design.DesignerActionUIStateChangeType -System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.DesignerActionUIStateChangeEventArgs(object relatedObject, System.ComponentModel.Design.DesignerActionUIStateChangeType changeType) -> void -System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.RelatedObject.get -> object +~System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.DesignerActionUIStateChangeEventArgs(object relatedObject, System.ComponentModel.Design.DesignerActionUIStateChangeType changeType) -> void +~System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.RelatedObject.get -> object System.ComponentModel.Design.DesignerActionUIStateChangeEventHandler System.ComponentModel.Design.DesignerActionUIStateChangeType System.ComponentModel.Design.DesignerActionUIStateChangeType.Hide = 1 -> System.ComponentModel.Design.DesignerActionUIStateChangeType System.ComponentModel.Design.DesignerActionUIStateChangeType.Refresh = 2 -> System.ComponentModel.Design.DesignerActionUIStateChangeType System.ComponentModel.Design.DesignerActionUIStateChangeType.Show = 0 -> System.ComponentModel.Design.DesignerActionUIStateChangeType System.ComponentModel.Design.DesignerCommandSet -System.ComponentModel.Design.DesignerCommandSet.ActionLists.get -> System.ComponentModel.Design.DesignerActionListCollection +~System.ComponentModel.Design.DesignerCommandSet.ActionLists.get -> System.ComponentModel.Design.DesignerActionListCollection System.ComponentModel.Design.DesignerCommandSet.DesignerCommandSet() -> void -System.ComponentModel.Design.DesignerCommandSet.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection +~System.ComponentModel.Design.DesignerCommandSet.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection System.ComponentModel.Design.ExceptionCollection -System.ComponentModel.Design.ExceptionCollection.ExceptionCollection(System.Collections.ArrayList exceptions) -> void -System.ComponentModel.Design.ExceptionCollection.Exceptions.get -> System.Collections.ArrayList +~System.ComponentModel.Design.ExceptionCollection.ExceptionCollection(System.Collections.ArrayList exceptions) -> void +~System.ComponentModel.Design.ExceptionCollection.Exceptions.get -> System.Collections.ArrayList System.ComponentModel.Design.IMultitargetHelperService -System.ComponentModel.Design.IMultitargetHelperService.GetAssemblyQualifiedName(System.Type type) -> string +~System.ComponentModel.Design.IMultitargetHelperService.GetAssemblyQualifiedName(System.Type type) -> string System.ComponentModel.Design.InheritanceService -System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.ComponentModel.IComponent component, System.ComponentModel.IContainer container) -> void +~System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.ComponentModel.IComponent component, System.ComponentModel.IContainer container) -> void System.ComponentModel.Design.InheritanceService.Dispose() -> void -System.ComponentModel.Design.InheritanceService.GetInheritanceAttribute(System.ComponentModel.IComponent component) -> System.ComponentModel.InheritanceAttribute +~System.ComponentModel.Design.InheritanceService.GetInheritanceAttribute(System.ComponentModel.IComponent component) -> System.ComponentModel.InheritanceAttribute System.ComponentModel.Design.InheritanceService.InheritanceService() -> void System.ComponentModel.Design.LoadedEventArgs -System.ComponentModel.Design.LoadedEventArgs.Errors.get -> System.Collections.ICollection +~System.ComponentModel.Design.LoadedEventArgs.Errors.get -> System.Collections.ICollection System.ComponentModel.Design.LoadedEventArgs.HasSucceeded.get -> bool -System.ComponentModel.Design.LoadedEventArgs.LoadedEventArgs(bool succeeded, System.Collections.ICollection errors) -> void +~System.ComponentModel.Design.LoadedEventArgs.LoadedEventArgs(bool succeeded, System.Collections.ICollection errors) -> void System.ComponentModel.Design.LoadedEventHandler System.ComponentModel.Design.ProjectTargetFrameworkAttribute -System.ComponentModel.Design.ProjectTargetFrameworkAttribute.ProjectTargetFrameworkAttribute(string targetFrameworkMoniker) -> void -System.ComponentModel.Design.ProjectTargetFrameworkAttribute.TargetFrameworkMoniker.get -> string +~System.ComponentModel.Design.ProjectTargetFrameworkAttribute.ProjectTargetFrameworkAttribute(string targetFrameworkMoniker) -> void +~System.ComponentModel.Design.ProjectTargetFrameworkAttribute.TargetFrameworkMoniker.get -> string System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CodeDomComponentSerializationService() -> void -System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CodeDomComponentSerializationService(System.IServiceProvider provider) -> void +~System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CodeDomComponentSerializationService(System.IServiceProvider provider) -> void System.ComponentModel.Design.Serialization.CodeDomSerializer System.ComponentModel.Design.Serialization.CodeDomSerializer.CodeDomSerializer() -> void -System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeStatement statement) -> object -System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeToReferenceExpression(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> System.CodeDom.CodeExpression +~System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeStatement statement) -> object +~System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeToReferenceExpression(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> System.CodeDom.CodeExpression System.ComponentModel.Design.Serialization.CodeDomSerializerBase System.ComponentModel.Design.Serialization.CodeDomSerializerException -System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception ex, System.CodeDom.CodeLinePragma linePragma) -> void -System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception ex, System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string message, System.CodeDom.CodeLinePragma linePragma) -> void -System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string message, System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -System.ComponentModel.Design.Serialization.CodeDomSerializerException.LinePragma.get -> System.CodeDom.CodeLinePragma +~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception ex, System.CodeDom.CodeLinePragma linePragma) -> void +~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception ex, System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void +~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string message, System.CodeDom.CodeLinePragma linePragma) -> void +~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string message, System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void +~System.ComponentModel.Design.Serialization.CodeDomSerializerException.LinePragma.get -> System.CodeDom.CodeLinePragma System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.CollectionCodeDomSerializer() -> void -System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.MethodSupportsSerialization(System.Reflection.MethodInfo method) -> bool +~System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.MethodSupportsSerialization(System.Reflection.MethodInfo method) -> bool System.ComponentModel.Design.Serialization.DesignerSerializationManager -System.ComponentModel.Design.Serialization.DesignerSerializationManager.Container.get -> System.ComponentModel.IContainer -System.ComponentModel.Design.Serialization.DesignerSerializationManager.Container.set -> void -System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateSession() -> System.IDisposable +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.Container.get -> System.ComponentModel.IContainer +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.Container.set -> void +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateSession() -> System.IDisposable System.ComponentModel.Design.Serialization.DesignerSerializationManager.DesignerSerializationManager() -> void -System.ComponentModel.Design.Serialization.DesignerSerializationManager.DesignerSerializationManager(System.IServiceProvider provider) -> void -System.ComponentModel.Design.Serialization.DesignerSerializationManager.Errors.get -> System.Collections.IList -System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetRuntimeType(string typeName) -> System.Type -System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetSerializer(System.Type objectType, System.Type serializerType) -> object +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.DesignerSerializationManager(System.IServiceProvider provider) -> void +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.Errors.get -> System.Collections.IList +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetRuntimeType(string typeName) -> System.Type +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetSerializer(System.Type objectType, System.Type serializerType) -> object System.ComponentModel.Design.Serialization.DesignerSerializationManager.PreserveNames.get -> bool System.ComponentModel.Design.Serialization.DesignerSerializationManager.PreserveNames.set -> void -System.ComponentModel.Design.Serialization.DesignerSerializationManager.PropertyProvider.get -> object -System.ComponentModel.Design.Serialization.DesignerSerializationManager.PropertyProvider.set -> void +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.PropertyProvider.get -> object +~System.ComponentModel.Design.Serialization.DesignerSerializationManager.PropertyProvider.set -> void System.ComponentModel.Design.Serialization.DesignerSerializationManager.RecycleInstances.get -> bool System.ComponentModel.Design.Serialization.DesignerSerializationManager.RecycleInstances.set -> void System.ComponentModel.Design.Serialization.DesignerSerializationManager.SessionCreated -> System.EventHandler @@ -188,31 +189,31 @@ System.ComponentModel.Design.Serialization.DesignerSerializationManager.SessionD System.ComponentModel.Design.Serialization.DesignerSerializationManager.ValidateRecycledTypes.get -> bool System.ComponentModel.Design.Serialization.DesignerSerializationManager.ValidateRecycledTypes.set -> void System.ComponentModel.Design.Serialization.ExpressionContext -System.ComponentModel.Design.Serialization.ExpressionContext.Expression.get -> System.CodeDom.CodeExpression -System.ComponentModel.Design.Serialization.ExpressionContext.ExpressionContext(System.CodeDom.CodeExpression expression, System.Type expressionType, object owner) -> void -System.ComponentModel.Design.Serialization.ExpressionContext.ExpressionContext(System.CodeDom.CodeExpression expression, System.Type expressionType, object owner, object presetValue) -> void -System.ComponentModel.Design.Serialization.ExpressionContext.ExpressionType.get -> System.Type -System.ComponentModel.Design.Serialization.ExpressionContext.Owner.get -> object -System.ComponentModel.Design.Serialization.ExpressionContext.PresetValue.get -> object +~System.ComponentModel.Design.Serialization.ExpressionContext.Expression.get -> System.CodeDom.CodeExpression +~System.ComponentModel.Design.Serialization.ExpressionContext.ExpressionContext(System.CodeDom.CodeExpression expression, System.Type expressionType, object owner) -> void +~System.ComponentModel.Design.Serialization.ExpressionContext.ExpressionContext(System.CodeDom.CodeExpression expression, System.Type expressionType, object owner, object presetValue) -> void +~System.ComponentModel.Design.Serialization.ExpressionContext.ExpressionType.get -> System.Type +~System.ComponentModel.Design.Serialization.ExpressionContext.Owner.get -> object +~System.ComponentModel.Design.Serialization.ExpressionContext.PresetValue.get -> object System.ComponentModel.Design.Serialization.MemberCodeDomSerializer System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.MemberCodeDomSerializer() -> void System.ComponentModel.Design.Serialization.ObjectStatementCollection -System.ComponentModel.Design.Serialization.ObjectStatementCollection.ContainsKey(object statementOwner) -> bool -System.ComponentModel.Design.Serialization.ObjectStatementCollection.GetEnumerator() -> System.Collections.IDictionaryEnumerator -System.ComponentModel.Design.Serialization.ObjectStatementCollection.Populate(System.Collections.ICollection statementOwners) -> void -System.ComponentModel.Design.Serialization.ObjectStatementCollection.Populate(object owner) -> void -System.ComponentModel.Design.Serialization.ObjectStatementCollection.this[object statementOwner].get -> System.CodeDom.CodeStatementCollection +~System.ComponentModel.Design.Serialization.ObjectStatementCollection.ContainsKey(object statementOwner) -> bool +~System.ComponentModel.Design.Serialization.ObjectStatementCollection.GetEnumerator() -> System.Collections.IDictionaryEnumerator +~System.ComponentModel.Design.Serialization.ObjectStatementCollection.Populate(System.Collections.ICollection statementOwners) -> void +~System.ComponentModel.Design.Serialization.ObjectStatementCollection.Populate(object owner) -> void +~System.ComponentModel.Design.Serialization.ObjectStatementCollection.this[object statementOwner].get -> System.CodeDom.CodeStatementCollection System.ComponentModel.Design.Serialization.RootContext -System.ComponentModel.Design.Serialization.RootContext.Expression.get -> System.CodeDom.CodeExpression -System.ComponentModel.Design.Serialization.RootContext.RootContext(System.CodeDom.CodeExpression expression, object value) -> void -System.ComponentModel.Design.Serialization.RootContext.Value.get -> object +~System.ComponentModel.Design.Serialization.RootContext.Expression.get -> System.CodeDom.CodeExpression +~System.ComponentModel.Design.Serialization.RootContext.RootContext(System.CodeDom.CodeExpression expression, object value) -> void +~System.ComponentModel.Design.Serialization.RootContext.Value.get -> object System.ComponentModel.Design.Serialization.SerializeAbsoluteContext -System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.Member.get -> System.ComponentModel.MemberDescriptor +~System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.Member.get -> System.ComponentModel.MemberDescriptor System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.SerializeAbsoluteContext() -> void -System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.SerializeAbsoluteContext(System.ComponentModel.MemberDescriptor member) -> void -System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.ShouldSerialize(System.ComponentModel.MemberDescriptor member) -> bool +~System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.SerializeAbsoluteContext(System.ComponentModel.MemberDescriptor member) -> void +~System.ComponentModel.Design.Serialization.SerializeAbsoluteContext.ShouldSerialize(System.ComponentModel.MemberDescriptor member) -> bool System.ComponentModel.Design.Serialization.StatementContext -System.ComponentModel.Design.Serialization.StatementContext.StatementCollection.get -> System.ComponentModel.Design.Serialization.ObjectStatementCollection +~System.ComponentModel.Design.Serialization.StatementContext.StatementCollection.get -> System.ComponentModel.Design.Serialization.ObjectStatementCollection System.ComponentModel.Design.Serialization.StatementContext.StatementContext() -> void System.ComponentModel.Design.Serialization.TypeCodeDomSerializer System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.TypeCodeDomSerializer() -> void @@ -220,231 +221,231 @@ System.ComponentModel.Design.UndoEngine System.ComponentModel.Design.UndoEngine.Dispose() -> void System.ComponentModel.Design.UndoEngine.Enabled.get -> bool System.ComponentModel.Design.UndoEngine.Enabled.set -> void -System.ComponentModel.Design.UndoEngine.GetRequiredService(System.Type serviceType) -> object -System.ComponentModel.Design.UndoEngine.GetService(System.Type serviceType) -> object -System.ComponentModel.Design.UndoEngine.UndoEngine(System.IServiceProvider provider) -> void +~System.ComponentModel.Design.UndoEngine.GetRequiredService(System.Type serviceType) -> object +~System.ComponentModel.Design.UndoEngine.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.UndoEngine.UndoEngine(System.IServiceProvider provider) -> void System.ComponentModel.Design.UndoEngine.UndoInProgress.get -> bool System.ComponentModel.Design.UndoEngine.UndoUnit -System.ComponentModel.Design.UndoEngine.UndoUnit.GetService(System.Type serviceType) -> object -System.ComponentModel.Design.UndoEngine.UndoUnit.Name.get -> string +~System.ComponentModel.Design.UndoEngine.UndoUnit.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.UndoEngine.UndoUnit.Name.get -> string System.ComponentModel.Design.UndoEngine.UndoUnit.Undo() -> void -System.ComponentModel.Design.UndoEngine.UndoUnit.UndoEngine.get -> System.ComponentModel.Design.UndoEngine -System.ComponentModel.Design.UndoEngine.UndoUnit.UndoUnit(System.ComponentModel.Design.UndoEngine engine, string name) -> void +~System.ComponentModel.Design.UndoEngine.UndoUnit.UndoEngine.get -> System.ComponentModel.Design.UndoEngine +~System.ComponentModel.Design.UndoEngine.UndoUnit.UndoUnit(System.ComponentModel.Design.UndoEngine engine, string name) -> void System.ComponentModel.Design.UndoEngine.Undoing -> System.EventHandler System.ComponentModel.Design.UndoEngine.Undone -> System.EventHandler System.Drawing.Design.IToolboxItemProvider -System.Drawing.Design.IToolboxItemProvider.Items.get -> System.Drawing.Design.ToolboxItemCollection +~System.Drawing.Design.IToolboxItemProvider.Items.get -> System.Drawing.Design.ToolboxItemCollection System.Drawing.Design.IToolboxService -System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format) -> void -System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) -> void -System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, System.ComponentModel.Design.IDesignerHost host) -> void -System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host) -> void -System.Drawing.Design.IToolboxService.AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> void -System.Drawing.Design.IToolboxService.AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category) -> void -System.Drawing.Design.IToolboxService.CategoryNames.get -> System.Drawing.Design.CategoryNameCollection -System.Drawing.Design.IToolboxService.DeserializeToolboxItem(object serializedObject) -> System.Drawing.Design.ToolboxItem -System.Drawing.Design.IToolboxService.DeserializeToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItem -System.Drawing.Design.IToolboxService.GetSelectedToolboxItem() -> System.Drawing.Design.ToolboxItem -System.Drawing.Design.IToolboxService.GetSelectedToolboxItem(System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItem -System.Drawing.Design.IToolboxService.GetToolboxItems() -> System.Drawing.Design.ToolboxItemCollection -System.Drawing.Design.IToolboxService.GetToolboxItems(System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItemCollection -System.Drawing.Design.IToolboxService.GetToolboxItems(string category) -> System.Drawing.Design.ToolboxItemCollection -System.Drawing.Design.IToolboxService.GetToolboxItems(string category, System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItemCollection -System.Drawing.Design.IToolboxService.IsSupported(object serializedObject, System.Collections.ICollection filterAttributes) -> bool -System.Drawing.Design.IToolboxService.IsSupported(object serializedObject, System.ComponentModel.Design.IDesignerHost host) -> bool -System.Drawing.Design.IToolboxService.IsToolboxItem(object serializedObject) -> bool -System.Drawing.Design.IToolboxService.IsToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host) -> bool +~System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format) -> void +~System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) -> void +~System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, System.ComponentModel.Design.IDesignerHost host) -> void +~System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host) -> void +~System.Drawing.Design.IToolboxService.AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> void +~System.Drawing.Design.IToolboxService.AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category) -> void +~System.Drawing.Design.IToolboxService.CategoryNames.get -> System.Drawing.Design.CategoryNameCollection +~System.Drawing.Design.IToolboxService.DeserializeToolboxItem(object serializedObject) -> System.Drawing.Design.ToolboxItem +~System.Drawing.Design.IToolboxService.DeserializeToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItem +~System.Drawing.Design.IToolboxService.GetSelectedToolboxItem() -> System.Drawing.Design.ToolboxItem +~System.Drawing.Design.IToolboxService.GetSelectedToolboxItem(System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItem +~System.Drawing.Design.IToolboxService.GetToolboxItems() -> System.Drawing.Design.ToolboxItemCollection +~System.Drawing.Design.IToolboxService.GetToolboxItems(System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItemCollection +~System.Drawing.Design.IToolboxService.GetToolboxItems(string category) -> System.Drawing.Design.ToolboxItemCollection +~System.Drawing.Design.IToolboxService.GetToolboxItems(string category, System.ComponentModel.Design.IDesignerHost host) -> System.Drawing.Design.ToolboxItemCollection +~System.Drawing.Design.IToolboxService.IsSupported(object serializedObject, System.Collections.ICollection filterAttributes) -> bool +~System.Drawing.Design.IToolboxService.IsSupported(object serializedObject, System.ComponentModel.Design.IDesignerHost host) -> bool +~System.Drawing.Design.IToolboxService.IsToolboxItem(object serializedObject) -> bool +~System.Drawing.Design.IToolboxService.IsToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host) -> bool System.Drawing.Design.IToolboxService.Refresh() -> void -System.Drawing.Design.IToolboxService.RemoveCreator(string format) -> void -System.Drawing.Design.IToolboxService.RemoveCreator(string format, System.ComponentModel.Design.IDesignerHost host) -> void -System.Drawing.Design.IToolboxService.RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> void -System.Drawing.Design.IToolboxService.RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category) -> void -System.Drawing.Design.IToolboxService.SelectedCategory.get -> string -System.Drawing.Design.IToolboxService.SelectedCategory.set -> void +~System.Drawing.Design.IToolboxService.RemoveCreator(string format) -> void +~System.Drawing.Design.IToolboxService.RemoveCreator(string format, System.ComponentModel.Design.IDesignerHost host) -> void +~System.Drawing.Design.IToolboxService.RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> void +~System.Drawing.Design.IToolboxService.RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category) -> void +~System.Drawing.Design.IToolboxService.SelectedCategory.get -> string +~System.Drawing.Design.IToolboxService.SelectedCategory.set -> void System.Drawing.Design.IToolboxService.SelectedToolboxItemUsed() -> void -System.Drawing.Design.IToolboxService.SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> object +~System.Drawing.Design.IToolboxService.SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> object System.Drawing.Design.IToolboxService.SetCursor() -> bool -System.Drawing.Design.IToolboxService.SetSelectedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> void +~System.Drawing.Design.IToolboxService.SetSelectedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem) -> void System.Drawing.Design.IToolboxUser -System.Drawing.Design.IToolboxUser.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool -System.Drawing.Design.IToolboxUser.ToolPicked(System.Drawing.Design.ToolboxItem tool) -> void +~System.Drawing.Design.IToolboxUser.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool +~System.Drawing.Design.IToolboxUser.ToolPicked(System.Drawing.Design.ToolboxItem tool) -> void System.Drawing.Design.ToolboxComponentsCreatedEventArgs -System.Drawing.Design.ToolboxComponentsCreatedEventArgs.Components.get -> System.ComponentModel.IComponent[] -System.Drawing.Design.ToolboxComponentsCreatedEventArgs.ToolboxComponentsCreatedEventArgs(System.ComponentModel.IComponent[] components) -> void +~System.Drawing.Design.ToolboxComponentsCreatedEventArgs.Components.get -> System.ComponentModel.IComponent[] +~System.Drawing.Design.ToolboxComponentsCreatedEventArgs.ToolboxComponentsCreatedEventArgs(System.ComponentModel.IComponent[] components) -> void System.Drawing.Design.ToolboxComponentsCreatedEventHandler System.Drawing.Design.ToolboxComponentsCreatingEventArgs -System.Drawing.Design.ToolboxComponentsCreatingEventArgs.DesignerHost.get -> System.ComponentModel.Design.IDesignerHost -System.Drawing.Design.ToolboxComponentsCreatingEventArgs.ToolboxComponentsCreatingEventArgs(System.ComponentModel.Design.IDesignerHost host) -> void +~System.Drawing.Design.ToolboxComponentsCreatingEventArgs.DesignerHost.get -> System.ComponentModel.Design.IDesignerHost +~System.Drawing.Design.ToolboxComponentsCreatingEventArgs.ToolboxComponentsCreatingEventArgs(System.ComponentModel.Design.IDesignerHost host) -> void System.Drawing.Design.ToolboxComponentsCreatingEventHandler System.Drawing.Design.ToolboxItem -System.Drawing.Design.ToolboxItem.AssemblyName.get -> System.Reflection.AssemblyName -System.Drawing.Design.ToolboxItem.AssemblyName.set -> void -System.Drawing.Design.ToolboxItem.Bitmap.get -> System.Drawing.Bitmap -System.Drawing.Design.ToolboxItem.Bitmap.set -> void +~System.Drawing.Design.ToolboxItem.AssemblyName.get -> System.Reflection.AssemblyName +~System.Drawing.Design.ToolboxItem.AssemblyName.set -> void +~System.Drawing.Design.ToolboxItem.Bitmap.get -> System.Drawing.Bitmap +~System.Drawing.Design.ToolboxItem.Bitmap.set -> void System.Drawing.Design.ToolboxItem.CheckUnlocked() -> void -System.Drawing.Design.ToolboxItem.Company.get -> string -System.Drawing.Design.ToolboxItem.Company.set -> void +~System.Drawing.Design.ToolboxItem.Company.get -> string +~System.Drawing.Design.ToolboxItem.Company.set -> void System.Drawing.Design.ToolboxItem.ComponentsCreated -> System.Drawing.Design.ToolboxComponentsCreatedEventHandler System.Drawing.Design.ToolboxItem.ComponentsCreating -> System.Drawing.Design.ToolboxComponentsCreatingEventHandler -System.Drawing.Design.ToolboxItem.CreateComponents() -> System.ComponentModel.IComponent[] -System.Drawing.Design.ToolboxItem.CreateComponents(System.ComponentModel.Design.IDesignerHost host) -> System.ComponentModel.IComponent[] -System.Drawing.Design.ToolboxItem.CreateComponents(System.ComponentModel.Design.IDesignerHost host, System.Collections.IDictionary defaultValues) -> System.ComponentModel.IComponent[] -System.Drawing.Design.ToolboxItem.DependentAssemblies.get -> System.Reflection.AssemblyName[] -System.Drawing.Design.ToolboxItem.DependentAssemblies.set -> void -System.Drawing.Design.ToolboxItem.Description.get -> string -System.Drawing.Design.ToolboxItem.Description.set -> void -System.Drawing.Design.ToolboxItem.DisplayName.get -> string -System.Drawing.Design.ToolboxItem.DisplayName.set -> void -System.Drawing.Design.ToolboxItem.Filter.get -> System.Collections.ICollection -System.Drawing.Design.ToolboxItem.Filter.set -> void -System.Drawing.Design.ToolboxItem.GetType(System.ComponentModel.Design.IDesignerHost host) -> System.Type +~System.Drawing.Design.ToolboxItem.CreateComponents() -> System.ComponentModel.IComponent[] +~System.Drawing.Design.ToolboxItem.CreateComponents(System.ComponentModel.Design.IDesignerHost host) -> System.ComponentModel.IComponent[] +~System.Drawing.Design.ToolboxItem.CreateComponents(System.ComponentModel.Design.IDesignerHost host, System.Collections.IDictionary defaultValues) -> System.ComponentModel.IComponent[] +~System.Drawing.Design.ToolboxItem.DependentAssemblies.get -> System.Reflection.AssemblyName[] +~System.Drawing.Design.ToolboxItem.DependentAssemblies.set -> void +~System.Drawing.Design.ToolboxItem.Description.get -> string +~System.Drawing.Design.ToolboxItem.Description.set -> void +~System.Drawing.Design.ToolboxItem.DisplayName.get -> string +~System.Drawing.Design.ToolboxItem.DisplayName.set -> void +~System.Drawing.Design.ToolboxItem.Filter.get -> System.Collections.ICollection +~System.Drawing.Design.ToolboxItem.Filter.set -> void +~System.Drawing.Design.ToolboxItem.GetType(System.ComponentModel.Design.IDesignerHost host) -> System.Type System.Drawing.Design.ToolboxItem.IsTransient.get -> bool System.Drawing.Design.ToolboxItem.IsTransient.set -> void -System.Drawing.Design.ToolboxItem.OriginalBitmap.get -> System.Drawing.Bitmap -System.Drawing.Design.ToolboxItem.OriginalBitmap.set -> void -System.Drawing.Design.ToolboxItem.Properties.get -> System.Collections.IDictionary +~System.Drawing.Design.ToolboxItem.OriginalBitmap.get -> System.Drawing.Bitmap +~System.Drawing.Design.ToolboxItem.OriginalBitmap.set -> void +~System.Drawing.Design.ToolboxItem.Properties.get -> System.Collections.IDictionary System.Drawing.Design.ToolboxItem.ToolboxItem() -> void -System.Drawing.Design.ToolboxItem.ToolboxItem(System.Type toolType) -> void -System.Drawing.Design.ToolboxItem.TypeName.get -> string -System.Drawing.Design.ToolboxItem.TypeName.set -> void -System.Drawing.Design.ToolboxItem.ValidatePropertyType(string propertyName, object value, System.Type expectedType, bool allowNull) -> void +~System.Drawing.Design.ToolboxItem.ToolboxItem(System.Type toolType) -> void +~System.Drawing.Design.ToolboxItem.TypeName.get -> string +~System.Drawing.Design.ToolboxItem.TypeName.set -> void +~System.Drawing.Design.ToolboxItem.ValidatePropertyType(string propertyName, object value, System.Type expectedType, bool allowNull) -> void System.Drawing.Design.ToolboxItemCollection -System.Drawing.Design.ToolboxItemCollection.Contains(System.Drawing.Design.ToolboxItem value) -> bool -System.Drawing.Design.ToolboxItemCollection.CopyTo(System.Drawing.Design.ToolboxItem[] array, int index) -> void -System.Drawing.Design.ToolboxItemCollection.IndexOf(System.Drawing.Design.ToolboxItem value) -> int -System.Drawing.Design.ToolboxItemCollection.ToolboxItemCollection(System.Drawing.Design.ToolboxItemCollection value) -> void -System.Drawing.Design.ToolboxItemCollection.ToolboxItemCollection(System.Drawing.Design.ToolboxItem[] value) -> void -System.Drawing.Design.ToolboxItemCollection.this[int index].get -> System.Drawing.Design.ToolboxItem +~System.Drawing.Design.ToolboxItemCollection.Contains(System.Drawing.Design.ToolboxItem value) -> bool +~System.Drawing.Design.ToolboxItemCollection.CopyTo(System.Drawing.Design.ToolboxItem[] array, int index) -> void +~System.Drawing.Design.ToolboxItemCollection.IndexOf(System.Drawing.Design.ToolboxItem value) -> int +~System.Drawing.Design.ToolboxItemCollection.ToolboxItemCollection(System.Drawing.Design.ToolboxItemCollection value) -> void +~System.Drawing.Design.ToolboxItemCollection.ToolboxItemCollection(System.Drawing.Design.ToolboxItem[] value) -> void +~System.Drawing.Design.ToolboxItemCollection.this[int index].get -> System.Drawing.Design.ToolboxItem System.Drawing.Design.ToolboxItemCreatorCallback System.Runtime.InteropServices.UCOMITypeLib -System.Runtime.InteropServices.UCOMITypeLib.GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile) -> void +~System.Runtime.InteropServices.UCOMITypeLib.GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile) -> void System.Runtime.InteropServices.UCOMITypeLib.GetLibAttr(out System.IntPtr ppTLibAttr) -> void System.Runtime.InteropServices.UCOMITypeLib.GetTypeInfoCount() -> int System.Runtime.InteropServices.UCOMITypeLib.GetTypeInfoType(int index, out System.Runtime.InteropServices.ComTypes.TYPEKIND pTKind) -> void -System.Runtime.InteropServices.UCOMITypeLib.IsName(string szNameBuf, int lHashVal) -> bool +~System.Runtime.InteropServices.UCOMITypeLib.IsName(string szNameBuf, int lHashVal) -> bool System.Runtime.InteropServices.UCOMITypeLib.ReleaseTLibAttr(System.IntPtr pTLibAttr) -> void System.Windows.Forms.Design.AxImporter -System.Windows.Forms.Design.AxImporter.AxImporter(System.Windows.Forms.Design.AxImporter.Options options) -> void +~System.Windows.Forms.Design.AxImporter.AxImporter(System.Windows.Forms.Design.AxImporter.Options options) -> void System.Windows.Forms.Design.AxImporter.IReferenceResolver -System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveActiveXReference(System.Runtime.InteropServices.UCOMITypeLib typeLib) -> string -System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Reflection.AssemblyName name) -> string -System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Runtime.InteropServices.UCOMITypeLib typeLib) -> string -System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveManagedReference(string assemName) -> string +~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveActiveXReference(System.Runtime.InteropServices.UCOMITypeLib typeLib) -> string +~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Reflection.AssemblyName name) -> string +~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Runtime.InteropServices.UCOMITypeLib typeLib) -> string +~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveManagedReference(string assemName) -> string System.Windows.Forms.Design.AxImporter.Options System.Windows.Forms.Design.AxImporter.Options.Options() -> void System.Windows.Forms.Design.AxImporter.Options.delaySign -> bool System.Windows.Forms.Design.AxImporter.Options.genSources -> bool System.Windows.Forms.Design.AxImporter.Options.ignoreRegisteredOcx -> bool -System.Windows.Forms.Design.AxImporter.Options.keyContainer -> string -System.Windows.Forms.Design.AxImporter.Options.keyFile -> string -System.Windows.Forms.Design.AxImporter.Options.keyPair -> System.Reflection.StrongNameKeyPair +~System.Windows.Forms.Design.AxImporter.Options.keyContainer -> string +~System.Windows.Forms.Design.AxImporter.Options.keyFile -> string +~System.Windows.Forms.Design.AxImporter.Options.keyPair -> System.Reflection.StrongNameKeyPair System.Windows.Forms.Design.AxImporter.Options.msBuildErrors -> bool System.Windows.Forms.Design.AxImporter.Options.noLogo -> bool -System.Windows.Forms.Design.AxImporter.Options.outputDirectory -> string -System.Windows.Forms.Design.AxImporter.Options.outputName -> string +~System.Windows.Forms.Design.AxImporter.Options.outputDirectory -> string +~System.Windows.Forms.Design.AxImporter.Options.outputName -> string System.Windows.Forms.Design.AxImporter.Options.overwriteRCW -> bool -System.Windows.Forms.Design.AxImporter.Options.publicKey -> byte[] -System.Windows.Forms.Design.AxImporter.Options.references -> System.Windows.Forms.Design.AxImporter.IReferenceResolver +~System.Windows.Forms.Design.AxImporter.Options.publicKey -> byte[] +~System.Windows.Forms.Design.AxImporter.Options.references -> System.Windows.Forms.Design.AxImporter.IReferenceResolver System.Windows.Forms.Design.AxImporter.Options.silentMode -> bool System.Windows.Forms.Design.AxImporter.Options.verboseMode -> bool System.Windows.Forms.Design.Behavior.Adorner System.Windows.Forms.Design.Behavior.Adorner.Adorner() -> void -System.Windows.Forms.Design.Behavior.Adorner.BehaviorService.get -> System.Windows.Forms.Design.Behavior.BehaviorService -System.Windows.Forms.Design.Behavior.Adorner.BehaviorService.set -> void +~System.Windows.Forms.Design.Behavior.Adorner.BehaviorService.get -> System.Windows.Forms.Design.Behavior.BehaviorService +~System.Windows.Forms.Design.Behavior.Adorner.BehaviorService.set -> void System.Windows.Forms.Design.Behavior.Adorner.Enabled.get -> bool System.Windows.Forms.Design.Behavior.Adorner.Enabled.set -> void -System.Windows.Forms.Design.Behavior.Adorner.Glyphs.get -> System.Windows.Forms.Design.Behavior.GlyphCollection +~System.Windows.Forms.Design.Behavior.Adorner.Glyphs.get -> System.Windows.Forms.Design.Behavior.GlyphCollection System.Windows.Forms.Design.Behavior.Adorner.Invalidate() -> void System.Windows.Forms.Design.Behavior.Adorner.Invalidate(System.Drawing.Rectangle rectangle) -> void -System.Windows.Forms.Design.Behavior.Adorner.Invalidate(System.Drawing.Region region) -> void +~System.Windows.Forms.Design.Behavior.Adorner.Invalidate(System.Drawing.Region region) -> void System.Windows.Forms.Design.Behavior.Behavior System.Windows.Forms.Design.Behavior.Behavior.Behavior() -> void -System.Windows.Forms.Design.Behavior.Behavior.Behavior(bool callParentBehavior, System.Windows.Forms.Design.Behavior.BehaviorService behaviorService) -> void +System.Windows.Forms.Design.Behavior.Behavior.Behavior(bool callParentBehavior, System.Windows.Forms.Design.Behavior.BehaviorService? behaviorService) -> void System.Windows.Forms.Design.Behavior.BehaviorDragDropEventArgs -System.Windows.Forms.Design.Behavior.BehaviorDragDropEventArgs.BehaviorDragDropEventArgs(System.Collections.ICollection dragComponents) -> void -System.Windows.Forms.Design.Behavior.BehaviorDragDropEventArgs.DragComponents.get -> System.Collections.ICollection +~System.Windows.Forms.Design.Behavior.BehaviorDragDropEventArgs.BehaviorDragDropEventArgs(System.Collections.ICollection dragComponents) -> void +~System.Windows.Forms.Design.Behavior.BehaviorDragDropEventArgs.DragComponents.get -> System.Collections.ICollection System.Windows.Forms.Design.Behavior.BehaviorDragDropEventHandler System.Windows.Forms.Design.Behavior.BehaviorService -System.Windows.Forms.Design.Behavior.BehaviorService.AdornerWindowGraphics.get -> System.Drawing.Graphics +~System.Windows.Forms.Design.Behavior.BehaviorService.AdornerWindowGraphics.get -> System.Drawing.Graphics System.Windows.Forms.Design.Behavior.BehaviorService.AdornerWindowPointToScreen(System.Drawing.Point p) -> System.Drawing.Point System.Windows.Forms.Design.Behavior.BehaviorService.AdornerWindowToScreen() -> System.Drawing.Point -System.Windows.Forms.Design.Behavior.BehaviorService.Adorners.get -> System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection +~System.Windows.Forms.Design.Behavior.BehaviorService.Adorners.get -> System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection System.Windows.Forms.Design.Behavior.BehaviorService.BeginDrag -> System.Windows.Forms.Design.Behavior.BehaviorDragDropEventHandler -System.Windows.Forms.Design.Behavior.BehaviorService.ControlRectInAdornerWindow(System.Windows.Forms.Control c) -> System.Drawing.Rectangle -System.Windows.Forms.Design.Behavior.BehaviorService.ControlToAdornerWindow(System.Windows.Forms.Control c) -> System.Drawing.Point -System.Windows.Forms.Design.Behavior.BehaviorService.CurrentBehavior.get -> System.Windows.Forms.Design.Behavior.Behavior +~System.Windows.Forms.Design.Behavior.BehaviorService.ControlRectInAdornerWindow(System.Windows.Forms.Control c) -> System.Drawing.Rectangle +~System.Windows.Forms.Design.Behavior.BehaviorService.ControlToAdornerWindow(System.Windows.Forms.Control c) -> System.Drawing.Point +~System.Windows.Forms.Design.Behavior.BehaviorService.CurrentBehavior.get -> System.Windows.Forms.Design.Behavior.Behavior System.Windows.Forms.Design.Behavior.BehaviorService.Dispose() -> void System.Windows.Forms.Design.Behavior.BehaviorService.EndDrag -> System.Windows.Forms.Design.Behavior.BehaviorDragDropEventHandler -System.Windows.Forms.Design.Behavior.BehaviorService.GetNextBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> System.Windows.Forms.Design.Behavior.Behavior +~System.Windows.Forms.Design.Behavior.BehaviorService.GetNextBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> System.Windows.Forms.Design.Behavior.Behavior System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate() -> void System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate(System.Drawing.Rectangle rect) -> void -System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate(System.Drawing.Region r) -> void +~System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate(System.Drawing.Region r) -> void System.Windows.Forms.Design.Behavior.BehaviorService.MapAdornerWindowPoint(System.IntPtr handle, System.Drawing.Point pt) -> System.Drawing.Point -System.Windows.Forms.Design.Behavior.BehaviorService.PopBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> System.Windows.Forms.Design.Behavior.Behavior -System.Windows.Forms.Design.Behavior.BehaviorService.PushBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void -System.Windows.Forms.Design.Behavior.BehaviorService.PushCaptureBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void +~System.Windows.Forms.Design.Behavior.BehaviorService.PopBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> System.Windows.Forms.Design.Behavior.Behavior +~System.Windows.Forms.Design.Behavior.BehaviorService.PushBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void +~System.Windows.Forms.Design.Behavior.BehaviorService.PushCaptureBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void System.Windows.Forms.Design.Behavior.BehaviorService.ScreenToAdornerWindow(System.Drawing.Point p) -> System.Drawing.Point System.Windows.Forms.Design.Behavior.BehaviorService.SyncSelection() -> void System.Windows.Forms.Design.Behavior.BehaviorService.Synchronize -> System.EventHandler System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Add(System.Windows.Forms.Design.Behavior.Adorner value) -> int -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.Adorner[] value) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection value) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.BehaviorServiceAdornerCollection(System.Windows.Forms.Design.Behavior.Adorner[] value) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.BehaviorServiceAdornerCollection(System.Windows.Forms.Design.Behavior.BehaviorService behaviorService) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.BehaviorServiceAdornerCollection(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection value) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Contains(System.Windows.Forms.Design.Behavior.Adorner value) -> bool -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.CopyTo(System.Windows.Forms.Design.Behavior.Adorner[] array, int index) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.GetEnumerator() -> System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.IndexOf(System.Windows.Forms.Design.Behavior.Adorner value) -> int -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Insert(int index, System.Windows.Forms.Design.Behavior.Adorner value) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Remove(System.Windows.Forms.Design.Behavior.Adorner value) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.this[int index].get -> System.Windows.Forms.Design.Behavior.Adorner -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.this[int index].set -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Add(System.Windows.Forms.Design.Behavior.Adorner value) -> int +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.Adorner[] value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.BehaviorServiceAdornerCollection(System.Windows.Forms.Design.Behavior.Adorner[] value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.BehaviorServiceAdornerCollection(System.Windows.Forms.Design.Behavior.BehaviorService behaviorService) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.BehaviorServiceAdornerCollection(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Contains(System.Windows.Forms.Design.Behavior.Adorner value) -> bool +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.CopyTo(System.Windows.Forms.Design.Behavior.Adorner[] array, int index) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.GetEnumerator() -> System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.IndexOf(System.Windows.Forms.Design.Behavior.Adorner value) -> int +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Insert(int index, System.Windows.Forms.Design.Behavior.Adorner value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Remove(System.Windows.Forms.Design.Behavior.Adorner value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.this[int index].get -> System.Windows.Forms.Design.Behavior.Adorner +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.this[int index].set -> void System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator.BehaviorServiceAdornerCollectionEnumerator(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection mappings) -> void -System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator.Current.get -> System.Windows.Forms.Design.Behavior.Adorner +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator.BehaviorServiceAdornerCollectionEnumerator(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection mappings) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator.Current.get -> System.Windows.Forms.Design.Behavior.Adorner System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator.MoveNext() -> bool System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollectionEnumerator.Reset() -> void System.Windows.Forms.Design.Behavior.ComponentGlyph -System.Windows.Forms.Design.Behavior.ComponentGlyph.ComponentGlyph(System.ComponentModel.IComponent relatedComponent) -> void -System.Windows.Forms.Design.Behavior.ComponentGlyph.ComponentGlyph(System.ComponentModel.IComponent relatedComponent, System.Windows.Forms.Design.Behavior.Behavior behavior) -> void -System.Windows.Forms.Design.Behavior.ComponentGlyph.RelatedComponent.get -> System.ComponentModel.IComponent +System.Windows.Forms.Design.Behavior.ComponentGlyph.ComponentGlyph(System.ComponentModel.IComponent? relatedComponent) -> void +System.Windows.Forms.Design.Behavior.ComponentGlyph.ComponentGlyph(System.ComponentModel.IComponent? relatedComponent, System.Windows.Forms.Design.Behavior.Behavior? behavior) -> void +System.Windows.Forms.Design.Behavior.ComponentGlyph.RelatedComponent.get -> System.ComponentModel.IComponent? System.Windows.Forms.Design.Behavior.ControlBodyGlyph -System.Windows.Forms.Design.Behavior.ControlBodyGlyph.ControlBodyGlyph(System.Drawing.Rectangle bounds, System.Windows.Forms.Cursor cursor, System.ComponentModel.IComponent relatedComponent, System.Windows.Forms.Design.Behavior.Behavior behavior) -> void -System.Windows.Forms.Design.Behavior.ControlBodyGlyph.ControlBodyGlyph(System.Drawing.Rectangle bounds, System.Windows.Forms.Cursor cursor, System.ComponentModel.IComponent relatedComponent, System.Windows.Forms.Design.ControlDesigner designer) -> void +System.Windows.Forms.Design.Behavior.ControlBodyGlyph.ControlBodyGlyph(System.Drawing.Rectangle bounds, System.Windows.Forms.Cursor? cursor, System.ComponentModel.IComponent? relatedComponent, System.Windows.Forms.Design.Behavior.Behavior? behavior) -> void +System.Windows.Forms.Design.Behavior.ControlBodyGlyph.ControlBodyGlyph(System.Drawing.Rectangle bounds, System.Windows.Forms.Cursor? cursor, System.ComponentModel.IComponent? relatedComponent, System.Windows.Forms.Design.ControlDesigner? designer) -> void System.Windows.Forms.Design.Behavior.Glyph -System.Windows.Forms.Design.Behavior.Glyph.Glyph(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void -System.Windows.Forms.Design.Behavior.Glyph.SetBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void +~System.Windows.Forms.Design.Behavior.Glyph.Glyph(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void +~System.Windows.Forms.Design.Behavior.Glyph.SetBehavior(System.Windows.Forms.Design.Behavior.Behavior behavior) -> void System.Windows.Forms.Design.Behavior.GlyphCollection -System.Windows.Forms.Design.Behavior.GlyphCollection.Add(System.Windows.Forms.Design.Behavior.Glyph value) -> int -System.Windows.Forms.Design.Behavior.GlyphCollection.AddRange(System.Windows.Forms.Design.Behavior.GlyphCollection value) -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.AddRange(System.Windows.Forms.Design.Behavior.Glyph[] value) -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.Contains(System.Windows.Forms.Design.Behavior.Glyph value) -> bool -System.Windows.Forms.Design.Behavior.GlyphCollection.CopyTo(System.Windows.Forms.Design.Behavior.Glyph[] array, int index) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.Add(System.Windows.Forms.Design.Behavior.Glyph value) -> int +~System.Windows.Forms.Design.Behavior.GlyphCollection.AddRange(System.Windows.Forms.Design.Behavior.GlyphCollection value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.AddRange(System.Windows.Forms.Design.Behavior.Glyph[] value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.Contains(System.Windows.Forms.Design.Behavior.Glyph value) -> bool +~System.Windows.Forms.Design.Behavior.GlyphCollection.CopyTo(System.Windows.Forms.Design.Behavior.Glyph[] array, int index) -> void System.Windows.Forms.Design.Behavior.GlyphCollection.GlyphCollection() -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.GlyphCollection(System.Windows.Forms.Design.Behavior.GlyphCollection value) -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.GlyphCollection(System.Windows.Forms.Design.Behavior.Glyph[] value) -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.IndexOf(System.Windows.Forms.Design.Behavior.Glyph value) -> int -System.Windows.Forms.Design.Behavior.GlyphCollection.Insert(int index, System.Windows.Forms.Design.Behavior.Glyph value) -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.Remove(System.Windows.Forms.Design.Behavior.Glyph value) -> void -System.Windows.Forms.Design.Behavior.GlyphCollection.this[int index].get -> System.Windows.Forms.Design.Behavior.Glyph -System.Windows.Forms.Design.Behavior.GlyphCollection.this[int index].set -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.GlyphCollection(System.Windows.Forms.Design.Behavior.GlyphCollection value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.GlyphCollection(System.Windows.Forms.Design.Behavior.Glyph[] value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.IndexOf(System.Windows.Forms.Design.Behavior.Glyph value) -> int +~System.Windows.Forms.Design.Behavior.GlyphCollection.Insert(int index, System.Windows.Forms.Design.Behavior.Glyph value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.Remove(System.Windows.Forms.Design.Behavior.Glyph value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.this[int index].get -> System.Windows.Forms.Design.Behavior.Glyph +~System.Windows.Forms.Design.Behavior.GlyphCollection.this[int index].set -> void System.Windows.Forms.Design.Behavior.GlyphSelectionType System.Windows.Forms.Design.Behavior.GlyphSelectionType.NotSelected = 0 -> System.Windows.Forms.Design.Behavior.GlyphSelectionType System.Windows.Forms.Design.Behavior.GlyphSelectionType.Selected = 1 -> System.Windows.Forms.Design.Behavior.GlyphSelectionType System.Windows.Forms.Design.Behavior.GlyphSelectionType.SelectedPrimary = 2 -> System.Windows.Forms.Design.Behavior.GlyphSelectionType System.Windows.Forms.Design.Behavior.SnapLine System.Windows.Forms.Design.Behavior.SnapLine.AdjustOffset(int adjustment) -> void -System.Windows.Forms.Design.Behavior.SnapLine.Filter.get -> string +~System.Windows.Forms.Design.Behavior.SnapLine.Filter.get -> string System.Windows.Forms.Design.Behavior.SnapLine.IsHorizontal.get -> bool System.Windows.Forms.Design.Behavior.SnapLine.IsVertical.get -> bool System.Windows.Forms.Design.Behavior.SnapLine.Offset.get -> int System.Windows.Forms.Design.Behavior.SnapLine.Priority.get -> System.Windows.Forms.Design.Behavior.SnapLinePriority System.Windows.Forms.Design.Behavior.SnapLine.SnapLine(System.Windows.Forms.Design.Behavior.SnapLineType type, int offset) -> void System.Windows.Forms.Design.Behavior.SnapLine.SnapLine(System.Windows.Forms.Design.Behavior.SnapLineType type, int offset, System.Windows.Forms.Design.Behavior.SnapLinePriority priority) -> void -System.Windows.Forms.Design.Behavior.SnapLine.SnapLine(System.Windows.Forms.Design.Behavior.SnapLineType type, int offset, string filter) -> void -System.Windows.Forms.Design.Behavior.SnapLine.SnapLine(System.Windows.Forms.Design.Behavior.SnapLineType type, int offset, string filter, System.Windows.Forms.Design.Behavior.SnapLinePriority priority) -> void +~System.Windows.Forms.Design.Behavior.SnapLine.SnapLine(System.Windows.Forms.Design.Behavior.SnapLineType type, int offset, string filter) -> void +~System.Windows.Forms.Design.Behavior.SnapLine.SnapLine(System.Windows.Forms.Design.Behavior.SnapLineType type, int offset, string filter, System.Windows.Forms.Design.Behavior.SnapLinePriority priority) -> void System.Windows.Forms.Design.Behavior.SnapLine.SnapLineType.get -> System.Windows.Forms.Design.Behavior.SnapLineType System.Windows.Forms.Design.Behavior.SnapLinePriority System.Windows.Forms.Design.Behavior.SnapLinePriority.Always = 4 -> System.Windows.Forms.Design.Behavior.SnapLinePriority @@ -465,7 +466,7 @@ System.Windows.Forms.Design.ComponentActionsType.Component = 1 -> System.Windows System.Windows.Forms.Design.ComponentActionsType.Service = 2 -> System.Windows.Forms.Design.ComponentActionsType System.Windows.Forms.Design.ComponentDocumentDesigner System.Windows.Forms.Design.ComponentDocumentDesigner.ComponentDocumentDesigner() -> void -System.Windows.Forms.Design.ComponentDocumentDesigner.Control.get -> System.Windows.Forms.Control +~System.Windows.Forms.Design.ComponentDocumentDesigner.Control.get -> System.Windows.Forms.Control System.Windows.Forms.Design.ComponentDocumentDesigner.TrayAutoArrange.get -> bool System.Windows.Forms.Design.ComponentDocumentDesigner.TrayAutoArrange.set -> void System.Windows.Forms.Design.ComponentDocumentDesigner.TrayLargeIcon.get -> bool @@ -474,59 +475,59 @@ System.Windows.Forms.Design.ComponentTray System.Windows.Forms.Design.ComponentTray.AutoArrange.get -> bool System.Windows.Forms.Design.ComponentTray.AutoArrange.set -> void System.Windows.Forms.Design.ComponentTray.ComponentCount.get -> int -System.Windows.Forms.Design.ComponentTray.ComponentTray(System.ComponentModel.Design.IDesigner mainDesigner, System.IServiceProvider serviceProvider) -> void -System.Windows.Forms.Design.ComponentTray.CreateComponentFromTool(System.Drawing.Design.ToolboxItem tool) -> void -System.Windows.Forms.Design.ComponentTray.DisplayError(System.Exception e) -> void -System.Windows.Forms.Design.ComponentTray.GetLocation(System.ComponentModel.IComponent receiver) -> System.Drawing.Point -System.Windows.Forms.Design.ComponentTray.GetNextComponent(System.ComponentModel.IComponent component, bool forward) -> System.ComponentModel.IComponent -System.Windows.Forms.Design.ComponentTray.GetTrayLocation(System.ComponentModel.IComponent receiver) -> System.Drawing.Point -System.Windows.Forms.Design.ComponentTray.IsTrayComponent(System.ComponentModel.IComponent comp) -> bool -System.Windows.Forms.Design.ComponentTray.SetLocation(System.ComponentModel.IComponent receiver, System.Drawing.Point location) -> void -System.Windows.Forms.Design.ComponentTray.SetTrayLocation(System.ComponentModel.IComponent receiver, System.Drawing.Point location) -> void +~System.Windows.Forms.Design.ComponentTray.ComponentTray(System.ComponentModel.Design.IDesigner mainDesigner, System.IServiceProvider serviceProvider) -> void +~System.Windows.Forms.Design.ComponentTray.CreateComponentFromTool(System.Drawing.Design.ToolboxItem tool) -> void +~System.Windows.Forms.Design.ComponentTray.DisplayError(System.Exception e) -> void +~System.Windows.Forms.Design.ComponentTray.GetLocation(System.ComponentModel.IComponent receiver) -> System.Drawing.Point +~System.Windows.Forms.Design.ComponentTray.GetNextComponent(System.ComponentModel.IComponent component, bool forward) -> System.ComponentModel.IComponent +~System.Windows.Forms.Design.ComponentTray.GetTrayLocation(System.ComponentModel.IComponent receiver) -> System.Drawing.Point +~System.Windows.Forms.Design.ComponentTray.IsTrayComponent(System.ComponentModel.IComponent comp) -> bool +~System.Windows.Forms.Design.ComponentTray.SetLocation(System.ComponentModel.IComponent receiver, System.Drawing.Point location) -> void +~System.Windows.Forms.Design.ComponentTray.SetTrayLocation(System.ComponentModel.IComponent receiver, System.Drawing.Point location) -> void System.Windows.Forms.Design.ComponentTray.ShowLargeIcons.get -> bool System.Windows.Forms.Design.ComponentTray.ShowLargeIcons.set -> void System.Windows.Forms.Design.ControlDesigner System.Windows.Forms.Design.ControlDesigner.AutoResizeHandles.get -> bool System.Windows.Forms.Design.ControlDesigner.AutoResizeHandles.set -> void System.Windows.Forms.Design.ControlDesigner.BaseWndProc(ref System.Windows.Forms.Message m) -> void -System.Windows.Forms.Design.ControlDesigner.BehaviorService.get -> System.Windows.Forms.Design.Behavior.BehaviorService +~System.Windows.Forms.Design.ControlDesigner.BehaviorService.get -> System.Windows.Forms.Design.Behavior.BehaviorService System.Windows.Forms.Design.ControlDesigner.ControlDesigner() -> void System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject -System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.ControlDesignerAccessibleObject(System.Windows.Forms.Design.ControlDesigner designer, System.Windows.Forms.Control control) -> void +~System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.ControlDesignerAccessibleObject(System.Windows.Forms.Design.ControlDesigner designer, System.Windows.Forms.Control control) -> void System.Windows.Forms.Design.ControlDesigner.DefWndProc(ref System.Windows.Forms.Message m) -> void -System.Windows.Forms.Design.ControlDesigner.DisplayError(System.Exception e) -> void -System.Windows.Forms.Design.ControlDesigner.EnableDesignMode(System.Windows.Forms.Control child, string name) -> bool +~System.Windows.Forms.Design.ControlDesigner.DisplayError(System.Exception e) -> void +~System.Windows.Forms.Design.ControlDesigner.EnableDesignMode(System.Windows.Forms.Control child, string name) -> bool System.Windows.Forms.Design.ControlDesigner.EnableDragDrop(bool value) -> void -System.Windows.Forms.Design.ControlDesigner.HookChildControls(System.Windows.Forms.Control firstChild) -> void -System.Windows.Forms.Design.ControlDesigner.UnhookChildControls(System.Windows.Forms.Control firstChild) -> void -System.Windows.Forms.Design.ControlDesigner.accessibilityObj -> System.Windows.Forms.AccessibleObject +~System.Windows.Forms.Design.ControlDesigner.HookChildControls(System.Windows.Forms.Control firstChild) -> void +~System.Windows.Forms.Design.ControlDesigner.UnhookChildControls(System.Windows.Forms.Control firstChild) -> void +~System.Windows.Forms.Design.ControlDesigner.accessibilityObj -> System.Windows.Forms.AccessibleObject System.Windows.Forms.Design.DesignerOptions System.Windows.Forms.Design.DesignerOptions.DesignerOptions() -> void System.Windows.Forms.Design.DocumentDesigner System.Windows.Forms.Design.DocumentDesigner.DocumentDesigner() -> void System.Windows.Forms.Design.EventHandlerService System.Windows.Forms.Design.EventHandlerService.EventHandlerChanged -> System.EventHandler -System.Windows.Forms.Design.EventHandlerService.EventHandlerService(System.Windows.Forms.Control focusWnd) -> void -System.Windows.Forms.Design.EventHandlerService.FocusWindow.get -> System.Windows.Forms.Control -System.Windows.Forms.Design.EventHandlerService.GetHandler(System.Type handlerType) -> object -System.Windows.Forms.Design.EventHandlerService.PopHandler(object handler) -> void -System.Windows.Forms.Design.EventHandlerService.PushHandler(object handler) -> void +~System.Windows.Forms.Design.EventHandlerService.EventHandlerService(System.Windows.Forms.Control focusWnd) -> void +~System.Windows.Forms.Design.EventHandlerService.FocusWindow.get -> System.Windows.Forms.Control +~System.Windows.Forms.Design.EventHandlerService.GetHandler(System.Type handlerType) -> object +~System.Windows.Forms.Design.EventHandlerService.PopHandler(object handler) -> void +~System.Windows.Forms.Design.EventHandlerService.PushHandler(object handler) -> void System.Windows.Forms.Design.IContainsThemedScrollbarWindows -System.Windows.Forms.Design.IContainsThemedScrollbarWindows.ThemedScrollbarWindows() -> System.Collections.IEnumerable +~System.Windows.Forms.Design.IContainsThemedScrollbarWindows.ThemedScrollbarWindows() -> System.Collections.IEnumerable System.Windows.Forms.Design.ImageListCodeDomSerializer System.Windows.Forms.Design.ImageListCodeDomSerializer.ImageListCodeDomSerializer() -> void System.Windows.Forms.Design.MenuCommands System.Windows.Forms.Design.MenuCommands.MenuCommands() -> void System.Windows.Forms.Design.ParentControlDesigner -System.Windows.Forms.Design.ParentControlDesigner.AddPaddingSnapLines(ref System.Collections.ArrayList snapLines) -> void -System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool) -> void -System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool, System.Drawing.Point location) -> void -System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool, System.Drawing.Rectangle bounds) -> void -System.Windows.Forms.Design.ParentControlDesigner.GetControl(object component) -> System.Windows.Forms.Control +~System.Windows.Forms.Design.ParentControlDesigner.AddPaddingSnapLines(ref System.Collections.ArrayList snapLines) -> void +~System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool) -> void +~System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool, System.Drawing.Point location) -> void +~System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool, System.Drawing.Rectangle bounds) -> void +~System.Windows.Forms.Design.ParentControlDesigner.GetControl(object component) -> System.Windows.Forms.Control System.Windows.Forms.Design.ParentControlDesigner.GetUpdatedRect(System.Drawing.Rectangle originalRect, System.Drawing.Rectangle dragRect, bool updateSize) -> System.Drawing.Rectangle System.Windows.Forms.Design.ParentControlDesigner.GridSize.get -> System.Drawing.Size System.Windows.Forms.Design.ParentControlDesigner.GridSize.set -> void -System.Windows.Forms.Design.ParentControlDesigner.MouseDragTool.get -> System.Drawing.Design.ToolboxItem +~System.Windows.Forms.Design.ParentControlDesigner.MouseDragTool.get -> System.Drawing.Design.ToolboxItem System.Windows.Forms.Design.ParentControlDesigner.ParentControlDesigner() -> void System.Windows.Forms.Design.ScrollableControlDesigner System.Windows.Forms.Design.ScrollableControlDesigner.ScrollableControlDesigner() -> void @@ -550,286 +551,286 @@ System.Windows.Forms.Design.ThemedScrollbarWindow.Mode -> System.Windows.Forms.D System.Windows.Forms.Design.ThemedScrollbarWindow.ThemedScrollbarWindow() -> void System.Windows.Forms.Design.WindowsFormsDesignerOptionService System.Windows.Forms.Design.WindowsFormsDesignerOptionService.WindowsFormsDesignerOptionService() -> void -abstract System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor, System.CodeDom.CodeStatementCollection statements) -> void -abstract System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.ShouldSerialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor) -> bool -abstract System.ComponentModel.Design.UndoEngine.AddUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit unit) -> void -abstract System.Windows.Forms.Design.Behavior.Glyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor -abstract System.Windows.Forms.Design.Behavior.Glyph.Paint(System.Windows.Forms.PaintEventArgs pe) -> void -override System.ComponentModel.Design.DesignerActionListCollection.OnValidate(object value) -> void -override System.ComponentModel.Design.ExceptionCollection.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore() -> System.ComponentModel.Design.Serialization.SerializationStore -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Deserialize(System.ComponentModel.Design.Serialization.SerializationStore store) -> System.Collections.ICollection -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Deserialize(System.ComponentModel.Design.Serialization.SerializationStore store, System.ComponentModel.IContainer container) -> System.Collections.ICollection -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.DeserializeTo(System.ComponentModel.Design.Serialization.SerializationStore store, System.ComponentModel.IContainer container, bool validateRecycledTypes, bool applyDefaults) -> void -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.LoadStore(System.IO.Stream stream) -> System.ComponentModel.Design.Serialization.SerializationStore -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Serialize(System.ComponentModel.Design.Serialization.SerializationStore store, object value) -> void -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeAbsolute(System.ComponentModel.Design.Serialization.SerializationStore store, object value) -> void -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeMember(System.ComponentModel.Design.Serialization.SerializationStore store, object owningObject, System.ComponentModel.MemberDescriptor member) -> void -override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.SerializationStore store, object owningObject, System.ComponentModel.MemberDescriptor member) -> void -override System.ComponentModel.Design.Serialization.CodeDomSerializerException.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void -override System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -override System.ComponentModel.Design.UndoEngine.UndoUnit.ToString() -> string -override System.Drawing.Design.ToolboxItem.Equals(object obj) -> bool +~abstract System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor, System.CodeDom.CodeStatementCollection statements) -> void +~abstract System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.ShouldSerialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor) -> bool +~abstract System.ComponentModel.Design.UndoEngine.AddUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit unit) -> void +~abstract System.Windows.Forms.Design.Behavior.Glyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor +~abstract System.Windows.Forms.Design.Behavior.Glyph.Paint(System.Windows.Forms.PaintEventArgs pe) -> void +~override System.ComponentModel.Design.DesignerActionListCollection.OnValidate(object value) -> void +~override System.ComponentModel.Design.ExceptionCollection.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore() -> System.ComponentModel.Design.Serialization.SerializationStore +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Deserialize(System.ComponentModel.Design.Serialization.SerializationStore store) -> System.Collections.ICollection +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Deserialize(System.ComponentModel.Design.Serialization.SerializationStore store, System.ComponentModel.IContainer container) -> System.Collections.ICollection +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.DeserializeTo(System.ComponentModel.Design.Serialization.SerializationStore store, System.ComponentModel.IContainer container, bool validateRecycledTypes, bool applyDefaults) -> void +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.LoadStore(System.IO.Stream stream) -> System.ComponentModel.Design.Serialization.SerializationStore +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Serialize(System.ComponentModel.Design.Serialization.SerializationStore store, object value) -> void +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeAbsolute(System.ComponentModel.Design.Serialization.SerializationStore store, object value) -> void +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeMember(System.ComponentModel.Design.Serialization.SerializationStore store, object owningObject, System.ComponentModel.MemberDescriptor member) -> void +~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.SerializationStore store, object owningObject, System.ComponentModel.MemberDescriptor member) -> void +~override System.ComponentModel.Design.Serialization.CodeDomSerializerException.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void +~override System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object +~override System.ComponentModel.Design.UndoEngine.UndoUnit.ToString() -> string +~override System.Drawing.Design.ToolboxItem.Equals(object obj) -> bool override System.Drawing.Design.ToolboxItem.GetHashCode() -> int -override System.Drawing.Design.ToolboxItem.ToString() -> string -override System.Windows.Forms.Design.Behavior.ComponentGlyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor -override System.Windows.Forms.Design.Behavior.ComponentGlyph.Paint(System.Windows.Forms.PaintEventArgs pe) -> void +~override System.Drawing.Design.ToolboxItem.ToString() -> string +override System.Windows.Forms.Design.Behavior.ComponentGlyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor? +override System.Windows.Forms.Design.Behavior.ComponentGlyph.Paint(System.Windows.Forms.PaintEventArgs! pe) -> void override System.Windows.Forms.Design.Behavior.ControlBodyGlyph.Bounds.get -> System.Drawing.Rectangle -override System.Windows.Forms.Design.Behavior.ControlBodyGlyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor -override System.Windows.Forms.Design.Behavior.SnapLine.ToString() -> string +override System.Windows.Forms.Design.Behavior.ControlBodyGlyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor? +~override System.Windows.Forms.Design.Behavior.SnapLine.ToString() -> string override System.Windows.Forms.Design.ComponentDocumentDesigner.Dispose(bool disposing) -> void -override System.Windows.Forms.Design.ComponentDocumentDesigner.Initialize(System.ComponentModel.IComponent component) -> void -override System.Windows.Forms.Design.ComponentDocumentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void +~override System.Windows.Forms.Design.ComponentDocumentDesigner.Initialize(System.ComponentModel.IComponent component) -> void +~override System.Windows.Forms.Design.ComponentDocumentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void override System.Windows.Forms.Design.ComponentTray.Dispose(bool disposing) -> void -override System.Windows.Forms.Design.ComponentTray.GetService(System.Type serviceType) -> object -override System.Windows.Forms.Design.ComponentTray.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void -override System.Windows.Forms.Design.ComponentTray.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void -override System.Windows.Forms.Design.ComponentTray.OnDragLeave(System.EventArgs e) -> void -override System.Windows.Forms.Design.ComponentTray.OnDragOver(System.Windows.Forms.DragEventArgs de) -> void -override System.Windows.Forms.Design.ComponentTray.OnGiveFeedback(System.Windows.Forms.GiveFeedbackEventArgs gfevent) -> void -override System.Windows.Forms.Design.ComponentTray.OnLayout(System.Windows.Forms.LayoutEventArgs levent) -> void -override System.Windows.Forms.Design.ComponentTray.OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e) -> void -override System.Windows.Forms.Design.ComponentTray.OnMouseDown(System.Windows.Forms.MouseEventArgs e) -> void -override System.Windows.Forms.Design.ComponentTray.OnMouseMove(System.Windows.Forms.MouseEventArgs e) -> void -override System.Windows.Forms.Design.ComponentTray.OnMouseUp(System.Windows.Forms.MouseEventArgs e) -> void -override System.Windows.Forms.Design.ComponentTray.OnPaint(System.Windows.Forms.PaintEventArgs pe) -> void +~override System.Windows.Forms.Design.ComponentTray.GetService(System.Type serviceType) -> object +~override System.Windows.Forms.Design.ComponentTray.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ComponentTray.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ComponentTray.OnDragLeave(System.EventArgs e) -> void +~override System.Windows.Forms.Design.ComponentTray.OnDragOver(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ComponentTray.OnGiveFeedback(System.Windows.Forms.GiveFeedbackEventArgs gfevent) -> void +~override System.Windows.Forms.Design.ComponentTray.OnLayout(System.Windows.Forms.LayoutEventArgs levent) -> void +~override System.Windows.Forms.Design.ComponentTray.OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e) -> void +~override System.Windows.Forms.Design.ComponentTray.OnMouseDown(System.Windows.Forms.MouseEventArgs e) -> void +~override System.Windows.Forms.Design.ComponentTray.OnMouseMove(System.Windows.Forms.MouseEventArgs e) -> void +~override System.Windows.Forms.Design.ComponentTray.OnMouseUp(System.Windows.Forms.MouseEventArgs e) -> void +~override System.Windows.Forms.Design.ComponentTray.OnPaint(System.Windows.Forms.PaintEventArgs pe) -> void override System.Windows.Forms.Design.ComponentTray.WndProc(ref System.Windows.Forms.Message m) -> void -override System.Windows.Forms.Design.ControlDesigner.AssociatedComponents.get -> System.Collections.ICollection +~override System.Windows.Forms.Design.ControlDesigner.AssociatedComponents.get -> System.Collections.ICollection override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Bounds.get -> System.Drawing.Rectangle -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.DefaultAction.get -> string -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Description.get -> string -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetChild(int index) -> System.Windows.Forms.AccessibleObject +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.DefaultAction.get -> string +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Description.get -> string +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetChild(int index) -> System.Windows.Forms.AccessibleObject override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetChildCount() -> int -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetFocused() -> System.Windows.Forms.AccessibleObject -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetSelected() -> System.Windows.Forms.AccessibleObject -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.HitTest(int x, int y) -> System.Windows.Forms.AccessibleObject -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Name.get -> string -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Parent.get -> System.Windows.Forms.AccessibleObject +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetFocused() -> System.Windows.Forms.AccessibleObject +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.GetSelected() -> System.Windows.Forms.AccessibleObject +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.HitTest(int x, int y) -> System.Windows.Forms.AccessibleObject +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Name.get -> string +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Parent.get -> System.Windows.Forms.AccessibleObject override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Role.get -> System.Windows.Forms.AccessibleRole override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.State.get -> System.Windows.Forms.AccessibleStates -override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Value.get -> string +~override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Value.get -> string override System.Windows.Forms.Design.ControlDesigner.Dispose(bool disposing) -> void -override System.Windows.Forms.Design.ControlDesigner.InheritanceAttribute.get -> System.ComponentModel.InheritanceAttribute -override System.Windows.Forms.Design.ControlDesigner.Initialize(System.ComponentModel.IComponent component) -> void -override System.Windows.Forms.Design.ControlDesigner.InitializeExistingComponent(System.Collections.IDictionary defaultValues) -> void -override System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void +~override System.Windows.Forms.Design.ControlDesigner.InheritanceAttribute.get -> System.ComponentModel.InheritanceAttribute +~override System.Windows.Forms.Design.ControlDesigner.Initialize(System.ComponentModel.IComponent component) -> void +~override System.Windows.Forms.Design.ControlDesigner.InitializeExistingComponent(System.Collections.IDictionary defaultValues) -> void +~override System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void override System.Windows.Forms.Design.ControlDesigner.OnSetComponentDefaults() -> void -override System.Windows.Forms.Design.ControlDesigner.ParentComponent.get -> System.ComponentModel.IComponent -override System.Windows.Forms.Design.ControlDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void +~override System.Windows.Forms.Design.ControlDesigner.ParentComponent.get -> System.ComponentModel.IComponent +~override System.Windows.Forms.Design.ControlDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void override System.Windows.Forms.Design.DocumentDesigner.Dispose(bool disposing) -> void -override System.Windows.Forms.Design.DocumentDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection -override System.Windows.Forms.Design.DocumentDesigner.Initialize(System.ComponentModel.IComponent component) -> void +~override System.Windows.Forms.Design.DocumentDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection +~override System.Windows.Forms.Design.DocumentDesigner.Initialize(System.ComponentModel.IComponent component) -> void override System.Windows.Forms.Design.DocumentDesigner.OnContextMenu(int x, int y) -> void override System.Windows.Forms.Design.DocumentDesigner.OnCreateHandle() -> void -override System.Windows.Forms.Design.DocumentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void +~override System.Windows.Forms.Design.DocumentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void override System.Windows.Forms.Design.DocumentDesigner.SelectionRules.get -> System.Windows.Forms.Design.SelectionRules override System.Windows.Forms.Design.DocumentDesigner.WndProc(ref System.Windows.Forms.Message m) -> void -override System.Windows.Forms.Design.ImageListCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object codeObject) -> object -override System.Windows.Forms.Design.ImageListCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object +~override System.Windows.Forms.Design.ImageListCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object codeObject) -> object +~override System.Windows.Forms.Design.ImageListCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object override System.Windows.Forms.Design.ParentControlDesigner.Dispose(bool disposing) -> void override System.Windows.Forms.Design.ParentControlDesigner.EnableDragRect.get -> bool -override System.Windows.Forms.Design.ParentControlDesigner.GetControlGlyph(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.ControlBodyGlyph -override System.Windows.Forms.Design.ParentControlDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection -override System.Windows.Forms.Design.ParentControlDesigner.Initialize(System.ComponentModel.IComponent component) -> void -override System.Windows.Forms.Design.ParentControlDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void -override System.Windows.Forms.Design.ParentControlDesigner.OnDragComplete(System.Windows.Forms.DragEventArgs de) -> void -override System.Windows.Forms.Design.ParentControlDesigner.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void -override System.Windows.Forms.Design.ParentControlDesigner.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void -override System.Windows.Forms.Design.ParentControlDesigner.OnDragLeave(System.EventArgs e) -> void -override System.Windows.Forms.Design.ParentControlDesigner.OnDragOver(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.GetControlGlyph(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.ControlBodyGlyph +~override System.Windows.Forms.Design.ParentControlDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection +~override System.Windows.Forms.Design.ParentControlDesigner.Initialize(System.ComponentModel.IComponent component) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.OnDragComplete(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.OnDragLeave(System.EventArgs e) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.OnDragOver(System.Windows.Forms.DragEventArgs de) -> void override System.Windows.Forms.Design.ParentControlDesigner.OnMouseDragBegin(int x, int y) -> void override System.Windows.Forms.Design.ParentControlDesigner.OnMouseDragEnd(bool cancel) -> void override System.Windows.Forms.Design.ParentControlDesigner.OnMouseDragMove(int x, int y) -> void -override System.Windows.Forms.Design.ParentControlDesigner.OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe) -> void override System.Windows.Forms.Design.ParentControlDesigner.OnSetCursor() -> void -override System.Windows.Forms.Design.ParentControlDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void -override System.Windows.Forms.Design.ParentControlDesigner.SnapLines.get -> System.Collections.IList +~override System.Windows.Forms.Design.ParentControlDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void +~override System.Windows.Forms.Design.ParentControlDesigner.SnapLines.get -> System.Collections.IList override System.Windows.Forms.Design.ScrollableControlDesigner.GetHitTest(System.Drawing.Point pt) -> bool override System.Windows.Forms.Design.ScrollableControlDesigner.WndProc(ref System.Windows.Forms.Message m) -> void -override System.Windows.Forms.Design.WindowsFormsDesignerOptionService.PopulateOptionCollection(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection options) -> void -static System.Windows.Forms.Design.Behavior.SnapLine.ShouldSnap(System.Windows.Forms.Design.Behavior.SnapLine line1, System.Windows.Forms.Design.Behavior.SnapLine line2) -> bool -static System.Windows.Forms.Design.ParentControlDesigner.InvokeCreateTool(System.Windows.Forms.Design.ParentControlDesigner toInvoke, System.Drawing.Design.ToolboxItem tool) -> void +~override System.Windows.Forms.Design.WindowsFormsDesignerOptionService.PopulateOptionCollection(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection options) -> void +~static System.Windows.Forms.Design.Behavior.SnapLine.ShouldSnap(System.Windows.Forms.Design.Behavior.SnapLine line1, System.Windows.Forms.Design.Behavior.SnapLine line2) -> bool +~static System.Windows.Forms.Design.ParentControlDesigner.InvokeCreateTool(System.Windows.Forms.Design.ParentControlDesigner toInvoke, System.Drawing.Design.ToolboxItem tool) -> void static readonly System.Windows.Forms.Design.ControlDesigner.InvalidPoint -> System.Drawing.Point -static readonly System.Windows.Forms.Design.MenuCommands.ComponentTrayMenu -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.ContainerMenu -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.DesignerProperties -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.EditLabel -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyCancel -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyDefaultAction -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyEnd -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyHome -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyInvokeSmartTag -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveDown -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveLeft -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveRight -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveUp -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeDown -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeHeightDecrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeHeightIncrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeLeft -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeRight -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeUp -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeWidthDecrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeWidthIncrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyReverseCancel -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeySelectNext -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeySelectPrevious -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyShiftEnd -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyShiftHome -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeySizeHeightDecrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeySizeHeightIncrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeySizeWidthDecrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeySizeWidthIncrease -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.KeyTabOrderSelect -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.SelectionMenu -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.SetStatusRectangle -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.SetStatusText -> System.ComponentModel.Design.CommandID -static readonly System.Windows.Forms.Design.MenuCommands.TraySelectionMenu -> System.ComponentModel.Design.CommandID -virtual System.ComponentModel.Design.ComponentDesigner.ActionLists.get -> System.ComponentModel.Design.DesignerActionListCollection -virtual System.ComponentModel.Design.ComponentDesigner.AssociatedComponents.get -> System.Collections.ICollection +~static readonly System.Windows.Forms.Design.MenuCommands.ComponentTrayMenu -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.ContainerMenu -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.DesignerProperties -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.EditLabel -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyCancel -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyDefaultAction -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyEnd -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyHome -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyInvokeSmartTag -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveDown -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveLeft -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveRight -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyMoveUp -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeDown -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeHeightDecrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeHeightIncrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeLeft -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeRight -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeUp -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeWidthDecrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyNudgeWidthIncrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyReverseCancel -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeySelectNext -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeySelectPrevious -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyShiftEnd -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyShiftHome -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeySizeHeightDecrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeySizeHeightIncrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeySizeWidthDecrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeySizeWidthIncrease -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.KeyTabOrderSelect -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.SelectionMenu -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.SetStatusRectangle -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.SetStatusText -> System.ComponentModel.Design.CommandID +~static readonly System.Windows.Forms.Design.MenuCommands.TraySelectionMenu -> System.ComponentModel.Design.CommandID +~virtual System.ComponentModel.Design.ComponentDesigner.ActionLists.get -> System.ComponentModel.Design.DesignerActionListCollection +~virtual System.ComponentModel.Design.ComponentDesigner.AssociatedComponents.get -> System.Collections.ICollection virtual System.ComponentModel.Design.ComponentDesigner.Dispose(bool disposing) -> void virtual System.ComponentModel.Design.ComponentDesigner.DoDefaultAction() -> void -virtual System.ComponentModel.Design.ComponentDesigner.GetService(System.Type serviceType) -> object -virtual System.ComponentModel.Design.ComponentDesigner.InheritanceAttribute.get -> System.ComponentModel.InheritanceAttribute -virtual System.ComponentModel.Design.ComponentDesigner.Initialize(System.ComponentModel.IComponent component) -> void -virtual System.ComponentModel.Design.ComponentDesigner.InitializeExistingComponent(System.Collections.IDictionary defaultValues) -> void -virtual System.ComponentModel.Design.ComponentDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.GetService(System.Type serviceType) -> object +~virtual System.ComponentModel.Design.ComponentDesigner.InheritanceAttribute.get -> System.ComponentModel.InheritanceAttribute +~virtual System.ComponentModel.Design.ComponentDesigner.Initialize(System.ComponentModel.IComponent component) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.InitializeExistingComponent(System.Collections.IDictionary defaultValues) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void virtual System.ComponentModel.Design.ComponentDesigner.InitializeNonDefault() -> void virtual System.ComponentModel.Design.ComponentDesigner.OnSetComponentDefaults() -> void -virtual System.ComponentModel.Design.ComponentDesigner.ParentComponent.get -> System.ComponentModel.IComponent -virtual System.ComponentModel.Design.ComponentDesigner.PostFilterAttributes(System.Collections.IDictionary attributes) -> void -virtual System.ComponentModel.Design.ComponentDesigner.PostFilterEvents(System.Collections.IDictionary events) -> void -virtual System.ComponentModel.Design.ComponentDesigner.PostFilterProperties(System.Collections.IDictionary properties) -> void -virtual System.ComponentModel.Design.ComponentDesigner.PreFilterAttributes(System.Collections.IDictionary attributes) -> void -virtual System.ComponentModel.Design.ComponentDesigner.PreFilterEvents(System.Collections.IDictionary events) -> void -virtual System.ComponentModel.Design.ComponentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void -virtual System.ComponentModel.Design.ComponentDesigner.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection -virtual System.ComponentModel.Design.DesignSurface.CreateComponent(System.Type componentType) -> System.ComponentModel.IComponent -virtual System.ComponentModel.Design.DesignSurface.CreateDesigner(System.ComponentModel.IComponent component, bool rootDesigner) -> System.ComponentModel.Design.IDesigner -virtual System.ComponentModel.Design.DesignSurface.CreateInstance(System.Type type) -> object +~virtual System.ComponentModel.Design.ComponentDesigner.ParentComponent.get -> System.ComponentModel.IComponent +~virtual System.ComponentModel.Design.ComponentDesigner.PostFilterAttributes(System.Collections.IDictionary attributes) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.PostFilterEvents(System.Collections.IDictionary events) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.PostFilterProperties(System.Collections.IDictionary properties) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.PreFilterAttributes(System.Collections.IDictionary attributes) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.PreFilterEvents(System.Collections.IDictionary events) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void +~virtual System.ComponentModel.Design.ComponentDesigner.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection +~virtual System.ComponentModel.Design.DesignSurface.CreateComponent(System.Type componentType) -> System.ComponentModel.IComponent +~virtual System.ComponentModel.Design.DesignSurface.CreateDesigner(System.ComponentModel.IComponent component, bool rootDesigner) -> System.ComponentModel.Design.IDesigner +~virtual System.ComponentModel.Design.DesignSurface.CreateInstance(System.Type type) -> object virtual System.ComponentModel.Design.DesignSurface.Dispose(bool disposing) -> void -virtual System.ComponentModel.Design.DesignSurface.OnLoaded(System.ComponentModel.Design.LoadedEventArgs e) -> void -virtual System.ComponentModel.Design.DesignSurface.OnLoading(System.EventArgs e) -> void -virtual System.ComponentModel.Design.DesignSurface.OnUnloaded(System.EventArgs e) -> void -virtual System.ComponentModel.Design.DesignSurface.OnUnloading(System.EventArgs e) -> void -virtual System.ComponentModel.Design.DesignSurface.OnViewActivate(System.EventArgs e) -> void -virtual System.ComponentModel.Design.DesignerActionItem.Category.get -> string -virtual System.ComponentModel.Design.DesignerActionItem.Description.get -> string -virtual System.ComponentModel.Design.DesignerActionItem.DisplayName.get -> string +~virtual System.ComponentModel.Design.DesignSurface.OnLoaded(System.ComponentModel.Design.LoadedEventArgs e) -> void +~virtual System.ComponentModel.Design.DesignSurface.OnLoading(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.DesignSurface.OnUnloaded(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.DesignSurface.OnUnloading(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.DesignSurface.OnViewActivate(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.DesignerActionItem.Category.get -> string +~virtual System.ComponentModel.Design.DesignerActionItem.Description.get -> string +~virtual System.ComponentModel.Design.DesignerActionItem.DisplayName.get -> string virtual System.ComponentModel.Design.DesignerActionList.AutoShow.get -> bool virtual System.ComponentModel.Design.DesignerActionList.AutoShow.set -> void -virtual System.ComponentModel.Design.DesignerActionList.GetSortedActionItems() -> System.ComponentModel.Design.DesignerActionItemCollection +~virtual System.ComponentModel.Design.DesignerActionList.GetSortedActionItems() -> System.ComponentModel.Design.DesignerActionItemCollection virtual System.ComponentModel.Design.DesignerActionMethodItem.IncludeAsDesignerVerb.get -> bool virtual System.ComponentModel.Design.DesignerActionMethodItem.Invoke() -> void -virtual System.ComponentModel.Design.DesignerActionMethodItem.MemberName.get -> string +~virtual System.ComponentModel.Design.DesignerActionMethodItem.MemberName.get -> string virtual System.ComponentModel.Design.DesignerActionService.Dispose(bool disposing) -> void -virtual System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent component, System.Windows.Forms.Design.ComponentActionsType type) -> System.ComponentModel.Design.DesignerActionListCollection -virtual System.ComponentModel.Design.DesignerActionService.GetComponentDesignerActions(System.ComponentModel.IComponent component, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void -virtual System.ComponentModel.Design.DesignerActionService.GetComponentServiceActions(System.ComponentModel.IComponent component, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void -virtual System.ComponentModel.Design.DesignerCommandSet.GetCommands(string name) -> System.Collections.ICollection -virtual System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.Type type, System.ComponentModel.IComponent component, System.ComponentModel.IContainer container) -> void +~virtual System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent component, System.Windows.Forms.Design.ComponentActionsType type) -> System.ComponentModel.Design.DesignerActionListCollection +~virtual System.ComponentModel.Design.DesignerActionService.GetComponentDesignerActions(System.ComponentModel.IComponent component, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void +~virtual System.ComponentModel.Design.DesignerActionService.GetComponentServiceActions(System.ComponentModel.IComponent component, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void +~virtual System.ComponentModel.Design.DesignerCommandSet.GetCommands(string name) -> System.Collections.ICollection +~virtual System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.Type type, System.ComponentModel.IComponent component, System.ComponentModel.IContainer container) -> void virtual System.ComponentModel.Design.InheritanceService.Dispose(bool disposing) -> void -virtual System.ComponentModel.Design.InheritanceService.IgnoreInheritedMember(System.Reflection.MemberInfo member, System.ComponentModel.IComponent component) -> bool -virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object codeObject) -> object -virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.GetTargetComponentName(System.CodeDom.CodeStatement statement, System.CodeDom.CodeExpression expression, System.Type targetType) -> string -virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMember(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object owningObject, System.ComponentModel.MemberDescriptor member) -> System.CodeDom.CodeStatementCollection -virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object owningObject, System.ComponentModel.MemberDescriptor member) -> System.CodeDom.CodeStatementCollection -virtual System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.SerializeCollection(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeExpression targetExpression, System.Type targetType, System.Collections.ICollection originalCollection, System.Collections.ICollection valuesToSerialize) -> object -virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(System.Type type, System.Collections.ICollection arguments, string name, bool addToContainer) -> object -virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetService(System.Type serviceType) -> object -virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(string typeName) -> System.Type -virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnResolveName(System.ComponentModel.Design.Serialization.ResolveNameEventArgs e) -> void -virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnSessionCreated(System.EventArgs e) -> void -virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnSessionDisposed(System.EventArgs e) -> void -virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) -> object -virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.GetInitializeMethod(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration, object value) -> System.CodeDom.CodeMemberMethod -virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.GetInitializeMethods(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) -> System.CodeDom.CodeMemberMethod[] -virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object root, System.Collections.ICollection members) -> System.CodeDom.CodeTypeDeclaration -virtual System.ComponentModel.Design.UndoEngine.CreateUndoUnit(string name, bool primary) -> System.ComponentModel.Design.UndoEngine.UndoUnit -virtual System.ComponentModel.Design.UndoEngine.DiscardUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit unit) -> void +~virtual System.ComponentModel.Design.InheritanceService.IgnoreInheritedMember(System.Reflection.MemberInfo member, System.ComponentModel.IComponent component) -> bool +~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object codeObject) -> object +~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.GetTargetComponentName(System.CodeDom.CodeStatement statement, System.CodeDom.CodeExpression expression, System.Type targetType) -> string +~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object +~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object +~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMember(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object owningObject, System.ComponentModel.MemberDescriptor member) -> System.CodeDom.CodeStatementCollection +~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object owningObject, System.ComponentModel.MemberDescriptor member) -> System.CodeDom.CodeStatementCollection +~virtual System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.SerializeCollection(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeExpression targetExpression, System.Type targetType, System.Collections.ICollection originalCollection, System.Collections.ICollection valuesToSerialize) -> object +~virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(System.Type type, System.Collections.ICollection arguments, string name, bool addToContainer) -> object +~virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetService(System.Type serviceType) -> object +~virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(string typeName) -> System.Type +~virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnResolveName(System.ComponentModel.Design.Serialization.ResolveNameEventArgs e) -> void +~virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnSessionCreated(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnSessionDisposed(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) -> object +~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.GetInitializeMethod(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration, object value) -> System.CodeDom.CodeMemberMethod +~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.GetInitializeMethods(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) -> System.CodeDom.CodeMemberMethod[] +~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object root, System.Collections.ICollection members) -> System.CodeDom.CodeTypeDeclaration +~virtual System.ComponentModel.Design.UndoEngine.CreateUndoUnit(string name, bool primary) -> System.ComponentModel.Design.UndoEngine.UndoUnit +~virtual System.ComponentModel.Design.UndoEngine.DiscardUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit unit) -> void virtual System.ComponentModel.Design.UndoEngine.Dispose(bool disposing) -> void -virtual System.ComponentModel.Design.UndoEngine.OnUndoing(System.EventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.OnUndone(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.OnUndoing(System.EventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.OnUndone(System.EventArgs e) -> void virtual System.ComponentModel.Design.UndoEngine.UndoUnit.Close() -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdded(System.ComponentModel.Design.ComponentEventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdding(System.ComponentModel.Design.ComponentEventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanged(System.ComponentModel.Design.ComponentChangedEventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanging(System.ComponentModel.Design.ComponentChangingEventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoved(System.ComponentModel.Design.ComponentEventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoving(System.ComponentModel.Design.ComponentEventArgs e) -> void -virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRename(System.ComponentModel.Design.ComponentRenameEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdded(System.ComponentModel.Design.ComponentEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdding(System.ComponentModel.Design.ComponentEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanged(System.ComponentModel.Design.ComponentChangedEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanging(System.ComponentModel.Design.ComponentChangingEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoved(System.ComponentModel.Design.ComponentEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoving(System.ComponentModel.Design.ComponentEventArgs e) -> void +~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRename(System.ComponentModel.Design.ComponentRenameEventArgs e) -> void virtual System.ComponentModel.Design.UndoEngine.UndoUnit.IsEmpty.get -> bool virtual System.ComponentModel.Design.UndoEngine.UndoUnit.UndoCore() -> void -virtual System.Drawing.Design.ToolboxItem.ComponentType.get -> string -virtual System.Drawing.Design.ToolboxItem.CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host) -> System.ComponentModel.IComponent[] -virtual System.Drawing.Design.ToolboxItem.CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host, System.Collections.IDictionary defaultValues) -> System.ComponentModel.IComponent[] -virtual System.Drawing.Design.ToolboxItem.Deserialize(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void -virtual System.Drawing.Design.ToolboxItem.FilterPropertyValue(string propertyName, object value) -> object -virtual System.Drawing.Design.ToolboxItem.GetType(System.ComponentModel.Design.IDesignerHost host, System.Reflection.AssemblyName assemblyName, string typeName, bool reference) -> System.Type -virtual System.Drawing.Design.ToolboxItem.Initialize(System.Type type) -> void +~virtual System.Drawing.Design.ToolboxItem.ComponentType.get -> string +~virtual System.Drawing.Design.ToolboxItem.CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host) -> System.ComponentModel.IComponent[] +~virtual System.Drawing.Design.ToolboxItem.CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host, System.Collections.IDictionary defaultValues) -> System.ComponentModel.IComponent[] +~virtual System.Drawing.Design.ToolboxItem.Deserialize(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void +~virtual System.Drawing.Design.ToolboxItem.FilterPropertyValue(string propertyName, object value) -> object +~virtual System.Drawing.Design.ToolboxItem.GetType(System.ComponentModel.Design.IDesignerHost host, System.Reflection.AssemblyName assemblyName, string typeName, bool reference) -> System.Type +~virtual System.Drawing.Design.ToolboxItem.Initialize(System.Type type) -> void virtual System.Drawing.Design.ToolboxItem.Lock() -> void virtual System.Drawing.Design.ToolboxItem.Locked.get -> bool -virtual System.Drawing.Design.ToolboxItem.OnComponentsCreated(System.Drawing.Design.ToolboxComponentsCreatedEventArgs args) -> void -virtual System.Drawing.Design.ToolboxItem.OnComponentsCreating(System.Drawing.Design.ToolboxComponentsCreatingEventArgs args) -> void -virtual System.Drawing.Design.ToolboxItem.Serialize(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void -virtual System.Drawing.Design.ToolboxItem.ValidatePropertyValue(string propertyName, object value) -> object -virtual System.Drawing.Design.ToolboxItem.Version.get -> string -virtual System.Windows.Forms.Design.Behavior.Behavior.Cursor.get -> System.Windows.Forms.Cursor +~virtual System.Drawing.Design.ToolboxItem.OnComponentsCreated(System.Drawing.Design.ToolboxComponentsCreatedEventArgs args) -> void +~virtual System.Drawing.Design.ToolboxItem.OnComponentsCreating(System.Drawing.Design.ToolboxComponentsCreatingEventArgs args) -> void +~virtual System.Drawing.Design.ToolboxItem.Serialize(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void +~virtual System.Drawing.Design.ToolboxItem.ValidatePropertyValue(string propertyName, object value) -> object +~virtual System.Drawing.Design.ToolboxItem.Version.get -> string +virtual System.Windows.Forms.Design.Behavior.Behavior.Cursor.get -> System.Windows.Forms.Cursor! virtual System.Windows.Forms.Design.Behavior.Behavior.DisableAllCommands.get -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.FindCommand(System.ComponentModel.Design.CommandID commandId) -> System.ComponentModel.Design.MenuCommand -virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragDrop(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.DragEventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragEnter(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.DragEventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragLeave(System.Windows.Forms.Design.Behavior.Glyph g, System.EventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragOver(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.DragEventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Behavior.OnGiveFeedback(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.GiveFeedbackEventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Behavior.OnLoseCapture(System.Windows.Forms.Design.Behavior.Glyph g, System.EventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseDoubleClick(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseDown(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseEnter(System.Windows.Forms.Design.Behavior.Glyph g) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseHover(System.Windows.Forms.Design.Behavior.Glyph g, System.Drawing.Point mouseLoc) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseLeave(System.Windows.Forms.Design.Behavior.Glyph g) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseMove(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseUp(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.MouseButtons button) -> bool -virtual System.Windows.Forms.Design.Behavior.Behavior.OnQueryContinueDrag(System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.QueryContinueDragEventArgs e) -> void -virtual System.Windows.Forms.Design.Behavior.Glyph.Behavior.get -> System.Windows.Forms.Design.Behavior.Behavior +virtual System.Windows.Forms.Design.Behavior.Behavior.FindCommand(System.ComponentModel.Design.CommandID! commandId) -> System.ComponentModel.Design.MenuCommand? +virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragDrop(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.DragEventArgs! e) -> void +virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragEnter(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.DragEventArgs! e) -> void +virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragLeave(System.Windows.Forms.Design.Behavior.Glyph? g, System.EventArgs! e) -> void +virtual System.Windows.Forms.Design.Behavior.Behavior.OnDragOver(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.DragEventArgs! e) -> void +virtual System.Windows.Forms.Design.Behavior.Behavior.OnGiveFeedback(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.GiveFeedbackEventArgs! e) -> void +virtual System.Windows.Forms.Design.Behavior.Behavior.OnLoseCapture(System.Windows.Forms.Design.Behavior.Glyph? g, System.EventArgs! e) -> void +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseDoubleClick(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseDown(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseEnter(System.Windows.Forms.Design.Behavior.Glyph? g) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseHover(System.Windows.Forms.Design.Behavior.Glyph? g, System.Drawing.Point mouseLoc) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseLeave(System.Windows.Forms.Design.Behavior.Glyph? g) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseMove(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnMouseUp(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.MouseButtons button) -> bool +virtual System.Windows.Forms.Design.Behavior.Behavior.OnQueryContinueDrag(System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.QueryContinueDragEventArgs! e) -> void +~virtual System.Windows.Forms.Design.Behavior.Glyph.Behavior.get -> System.Windows.Forms.Design.Behavior.Behavior virtual System.Windows.Forms.Design.Behavior.Glyph.Bounds.get -> System.Drawing.Rectangle -virtual System.Windows.Forms.Design.ComponentDocumentDesigner.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool -virtual System.Windows.Forms.Design.ComponentTray.AddComponent(System.ComponentModel.IComponent component) -> void -virtual System.Windows.Forms.Design.ComponentTray.CanCreateComponentFromTool(System.Drawing.Design.ToolboxItem tool) -> bool -virtual System.Windows.Forms.Design.ComponentTray.CanDisplayComponent(System.ComponentModel.IComponent component) -> bool +~virtual System.Windows.Forms.Design.ComponentDocumentDesigner.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool +~virtual System.Windows.Forms.Design.ComponentTray.AddComponent(System.ComponentModel.IComponent component) -> void +~virtual System.Windows.Forms.Design.ComponentTray.CanCreateComponentFromTool(System.Drawing.Design.ToolboxItem tool) -> bool +~virtual System.Windows.Forms.Design.ComponentTray.CanDisplayComponent(System.ComponentModel.IComponent component) -> bool virtual System.Windows.Forms.Design.ComponentTray.OnLostCapture() -> void virtual System.Windows.Forms.Design.ComponentTray.OnSetCursor() -> void -virtual System.Windows.Forms.Design.ComponentTray.RemoveComponent(System.ComponentModel.IComponent component) -> void -virtual System.Windows.Forms.Design.ControlDesigner.AccessibilityObject.get -> System.Windows.Forms.AccessibleObject -virtual System.Windows.Forms.Design.ControlDesigner.CanBeParentedTo(System.ComponentModel.Design.IDesigner parentDesigner) -> bool -virtual System.Windows.Forms.Design.ControlDesigner.Control.get -> System.Windows.Forms.Control +~virtual System.Windows.Forms.Design.ComponentTray.RemoveComponent(System.ComponentModel.IComponent component) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.AccessibilityObject.get -> System.Windows.Forms.AccessibleObject +~virtual System.Windows.Forms.Design.ControlDesigner.CanBeParentedTo(System.ComponentModel.Design.IDesigner parentDesigner) -> bool +~virtual System.Windows.Forms.Design.ControlDesigner.Control.get -> System.Windows.Forms.Control virtual System.Windows.Forms.Design.ControlDesigner.EnableDragRect.get -> bool -virtual System.Windows.Forms.Design.ControlDesigner.GetControlGlyph(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.ControlBodyGlyph -virtual System.Windows.Forms.Design.ControlDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection +~virtual System.Windows.Forms.Design.ControlDesigner.GetControlGlyph(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.ControlBodyGlyph +~virtual System.Windows.Forms.Design.ControlDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection virtual System.Windows.Forms.Design.ControlDesigner.GetHitTest(System.Drawing.Point point) -> bool -virtual System.Windows.Forms.Design.ControlDesigner.InternalControlDesigner(int internalControlIndex) -> System.Windows.Forms.Design.ControlDesigner +~virtual System.Windows.Forms.Design.ControlDesigner.InternalControlDesigner(int internalControlIndex) -> System.Windows.Forms.Design.ControlDesigner virtual System.Windows.Forms.Design.ControlDesigner.NumberOfInternalControlDesigners() -> int virtual System.Windows.Forms.Design.ControlDesigner.OnContextMenu(int x, int y) -> void virtual System.Windows.Forms.Design.ControlDesigner.OnCreateHandle() -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnDragComplete(System.Windows.Forms.DragEventArgs de) -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnDragLeave(System.EventArgs e) -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnDragOver(System.Windows.Forms.DragEventArgs de) -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnGiveFeedback(System.Windows.Forms.GiveFeedbackEventArgs e) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnDragComplete(System.Windows.Forms.DragEventArgs de) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnDragLeave(System.EventArgs e) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnDragOver(System.Windows.Forms.DragEventArgs de) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnGiveFeedback(System.Windows.Forms.GiveFeedbackEventArgs e) -> void virtual System.Windows.Forms.Design.ControlDesigner.OnMouseDragBegin(int x, int y) -> void virtual System.Windows.Forms.Design.ControlDesigner.OnMouseDragEnd(bool cancel) -> void virtual System.Windows.Forms.Design.ControlDesigner.OnMouseDragMove(int x, int y) -> void virtual System.Windows.Forms.Design.ControlDesigner.OnMouseEnter() -> void virtual System.Windows.Forms.Design.ControlDesigner.OnMouseHover() -> void virtual System.Windows.Forms.Design.ControlDesigner.OnMouseLeave() -> void -virtual System.Windows.Forms.Design.ControlDesigner.OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe) -> void +~virtual System.Windows.Forms.Design.ControlDesigner.OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe) -> void virtual System.Windows.Forms.Design.ControlDesigner.OnSetCursor() -> void virtual System.Windows.Forms.Design.ControlDesigner.ParticipatesWithSnapLines.get -> bool virtual System.Windows.Forms.Design.ControlDesigner.SelectionRules.get -> System.Windows.Forms.Design.SelectionRules -virtual System.Windows.Forms.Design.ControlDesigner.SnapLines.get -> System.Collections.IList +~virtual System.Windows.Forms.Design.ControlDesigner.SnapLines.get -> System.Collections.IList virtual System.Windows.Forms.Design.ControlDesigner.WndProc(ref System.Windows.Forms.Message m) -> void virtual System.Windows.Forms.Design.DesignerOptions.EnableInSituEditing.get -> bool virtual System.Windows.Forms.Design.DesignerOptions.EnableInSituEditing.set -> void @@ -848,65 +849,65 @@ virtual System.Windows.Forms.Design.DesignerOptions.UseSmartTags.set -> void virtual System.Windows.Forms.Design.DesignerOptions.UseSnapLines.get -> bool virtual System.Windows.Forms.Design.DesignerOptions.UseSnapLines.set -> void virtual System.Windows.Forms.Design.DocumentDesigner.EnsureMenuEditorService(System.ComponentModel.IComponent c) -> void -virtual System.Windows.Forms.Design.DocumentDesigner.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool -virtual System.Windows.Forms.Design.DocumentDesigner.ToolPicked(System.Drawing.Design.ToolboxItem tool) -> void +~virtual System.Windows.Forms.Design.DocumentDesigner.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool +~virtual System.Windows.Forms.Design.DocumentDesigner.ToolPicked(System.Drawing.Design.ToolboxItem tool) -> void virtual System.Windows.Forms.Design.ParentControlDesigner.AllowControlLasso.get -> bool virtual System.Windows.Forms.Design.ParentControlDesigner.AllowGenericDragBox.get -> bool virtual System.Windows.Forms.Design.ParentControlDesigner.AllowSetChildIndexOnDrop.get -> bool -virtual System.Windows.Forms.Design.ParentControlDesigner.CanAddComponent(System.ComponentModel.IComponent component) -> bool -virtual System.Windows.Forms.Design.ParentControlDesigner.CanParent(System.Windows.Forms.Control control) -> bool -virtual System.Windows.Forms.Design.ParentControlDesigner.CanParent(System.Windows.Forms.Design.ControlDesigner controlDesigner) -> bool -virtual System.Windows.Forms.Design.ParentControlDesigner.CreateToolCore(System.Drawing.Design.ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) -> System.ComponentModel.IComponent[] +~virtual System.Windows.Forms.Design.ParentControlDesigner.CanAddComponent(System.ComponentModel.IComponent component) -> bool +~virtual System.Windows.Forms.Design.ParentControlDesigner.CanParent(System.Windows.Forms.Control control) -> bool +~virtual System.Windows.Forms.Design.ParentControlDesigner.CanParent(System.Windows.Forms.Design.ControlDesigner controlDesigner) -> bool +~virtual System.Windows.Forms.Design.ParentControlDesigner.CreateToolCore(System.Drawing.Design.ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) -> System.ComponentModel.IComponent[] virtual System.Windows.Forms.Design.ParentControlDesigner.DefaultControlLocation.get -> System.Drawing.Point virtual System.Windows.Forms.Design.ParentControlDesigner.DrawGrid.get -> bool virtual System.Windows.Forms.Design.ParentControlDesigner.DrawGrid.set -> void -virtual System.Windows.Forms.Design.ParentControlDesigner.GetParentForComponent(System.ComponentModel.IComponent component) -> System.Windows.Forms.Control -virtual System.Windows.Forms.Design.WindowsFormsDesignerOptionService.CompatibilityOptions.get -> System.Windows.Forms.Design.DesignerOptions +~virtual System.Windows.Forms.Design.ParentControlDesigner.GetParentForComponent(System.ComponentModel.IComponent component) -> System.Windows.Forms.Control +~virtual System.Windows.Forms.Design.WindowsFormsDesignerOptionService.CompatibilityOptions.get -> System.Windows.Forms.Design.DesignerOptions System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs -System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs.ActiveDesignSurfaceChangedEventArgs(System.ComponentModel.Design.DesignSurface oldSurface, System.ComponentModel.Design.DesignSurface newSurface) -> void -System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs.NewSurface.get -> System.ComponentModel.Design.DesignSurface -System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs.OldSurface.get -> System.ComponentModel.Design.DesignSurface +~System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs.ActiveDesignSurfaceChangedEventArgs(System.ComponentModel.Design.DesignSurface oldSurface, System.ComponentModel.Design.DesignSurface newSurface) -> void +~System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs.NewSurface.get -> System.ComponentModel.Design.DesignSurface +~System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs.OldSurface.get -> System.ComponentModel.Design.DesignSurface System.ComponentModel.Design.ActiveDesignSurfaceChangedEventHandler System.ComponentModel.Design.BinaryEditor System.ComponentModel.Design.BinaryEditor.BinaryEditor() -> void System.ComponentModel.Design.ByteViewer System.ComponentModel.Design.ByteViewer.ByteViewer() -> void System.ComponentModel.Design.DesignSurfaceCollection -System.ComponentModel.Design.DesignSurfaceCollection.CopyTo(System.ComponentModel.Design.DesignSurface[] array, int index) -> void +~System.ComponentModel.Design.DesignSurfaceCollection.CopyTo(System.ComponentModel.Design.DesignSurface[] array, int index) -> void System.ComponentModel.Design.DesignSurfaceCollection.Count.get -> int -System.ComponentModel.Design.DesignSurfaceCollection.GetEnumerator() -> System.Collections.IEnumerator -System.ComponentModel.Design.DesignSurfaceCollection.this[int index].get -> System.ComponentModel.Design.DesignSurface +~System.ComponentModel.Design.DesignSurfaceCollection.GetEnumerator() -> System.Collections.IEnumerator +~System.ComponentModel.Design.DesignSurfaceCollection.this[int index].get -> System.ComponentModel.Design.DesignSurface System.ComponentModel.Design.DesignSurfaceEventArgs -System.ComponentModel.Design.DesignSurfaceEventArgs.DesignSurfaceEventArgs(System.ComponentModel.Design.DesignSurface surface) -> void -System.ComponentModel.Design.DesignSurfaceEventArgs.Surface.get -> System.ComponentModel.Design.DesignSurface +~System.ComponentModel.Design.DesignSurfaceEventArgs.DesignSurfaceEventArgs(System.ComponentModel.Design.DesignSurface surface) -> void +~System.ComponentModel.Design.DesignSurfaceEventArgs.Surface.get -> System.ComponentModel.Design.DesignSurface System.ComponentModel.Design.DesignSurfaceEventHandler System.ComponentModel.Design.DesignSurfaceManager System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurfaceChanged -> System.ComponentModel.Design.ActiveDesignSurfaceChangedEventHandler -System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurface() -> System.ComponentModel.Design.DesignSurface -System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurface(System.IServiceProvider parentProvider) -> System.ComponentModel.Design.DesignSurface +~System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurface() -> System.ComponentModel.Design.DesignSurface +~System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurface(System.IServiceProvider parentProvider) -> System.ComponentModel.Design.DesignSurface System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaceCreated -> System.ComponentModel.Design.DesignSurfaceEventHandler System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaceDisposed -> System.ComponentModel.Design.DesignSurfaceEventHandler System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaceManager() -> void -System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaceManager(System.IServiceProvider parentProvider) -> void -System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaces.get -> System.ComponentModel.Design.DesignSurfaceCollection +~System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaceManager(System.IServiceProvider parentProvider) -> void +~System.ComponentModel.Design.DesignSurfaceManager.DesignSurfaces.get -> System.ComponentModel.Design.DesignSurfaceCollection System.ComponentModel.Design.DesignSurfaceManager.Dispose() -> void -System.ComponentModel.Design.DesignSurfaceManager.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.DesignSurfaceManager.GetService(System.Type serviceType) -> object System.ComponentModel.Design.DesignSurfaceManager.SelectionChanged -> System.EventHandler -System.ComponentModel.Design.DesignSurfaceManager.ServiceContainer.get -> System.ComponentModel.Design.ServiceContainer +~System.ComponentModel.Design.DesignSurfaceManager.ServiceContainer.get -> System.ComponentModel.Design.ServiceContainer System.ComponentModel.Design.DisplayMode System.ComponentModel.Design.DisplayMode.Ansi = 2 -> System.ComponentModel.Design.DisplayMode System.ComponentModel.Design.DisplayMode.Auto = 4 -> System.ComponentModel.Design.DisplayMode System.ComponentModel.Design.DisplayMode.Hexdump = 1 -> System.ComponentModel.Design.DisplayMode System.ComponentModel.Design.DisplayMode.Unicode = 3 -> System.ComponentModel.Design.DisplayMode System.ComponentModel.Design.EventBindingService -System.ComponentModel.Design.EventBindingService.EventBindingService(System.IServiceProvider provider) -> void -System.ComponentModel.Design.EventBindingService.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.EventBindingService.EventBindingService(System.IServiceProvider provider) -> void +~System.ComponentModel.Design.EventBindingService.GetService(System.Type serviceType) -> object System.ComponentModel.Design.Serialization.BasicDesignerLoader System.ComponentModel.Design.Serialization.BasicDesignerLoader.BasicDesignerLoader() -> void -System.ComponentModel.Design.Serialization.BasicDesignerLoader.GetService(System.Type serviceType) -> object -System.ComponentModel.Design.Serialization.BasicDesignerLoader.LoaderHost.get -> System.ComponentModel.Design.Serialization.IDesignerLoaderHost -System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.get -> object -System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.set -> void +~System.ComponentModel.Design.Serialization.BasicDesignerLoader.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.Serialization.BasicDesignerLoader.LoaderHost.get -> System.ComponentModel.Design.Serialization.IDesignerLoaderHost +~System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.get -> object +~System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.set -> void System.ComponentModel.Design.Serialization.BasicDesignerLoader.Reload(System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions flags) -> void System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions.Default = 0 -> System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions @@ -914,7 +915,7 @@ System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions.For System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions.ModifyOnError = 1 -> System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions.NoFlush = 4 -> System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadOptions System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReloadPending.get -> bool -System.ComponentModel.Design.Serialization.BasicDesignerLoader.SetBaseComponentClassName(string name) -> void +~System.ComponentModel.Design.Serialization.BasicDesignerLoader.SetBaseComponentClassName(string name) -> void System.ComponentModel.Design.Serialization.CodeDomDesignerLoader System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.CodeDomDesignerLoader() -> void System.ComponentModel.Design.Serialization.CodeDomLocalizationModel @@ -922,34 +923,34 @@ System.ComponentModel.Design.Serialization.CodeDomLocalizationModel.None = 0 -> System.ComponentModel.Design.Serialization.CodeDomLocalizationModel.PropertyAssignment = 1 -> System.ComponentModel.Design.Serialization.CodeDomLocalizationModel System.ComponentModel.Design.Serialization.CodeDomLocalizationModel.PropertyReflection = 2 -> System.ComponentModel.Design.Serialization.CodeDomLocalizationModel System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider -System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.CodeDomLocalizationProvider(System.IServiceProvider provider, System.ComponentModel.Design.Serialization.CodeDomLocalizationModel model) -> void -System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.CodeDomLocalizationProvider(System.IServiceProvider provider, System.ComponentModel.Design.Serialization.CodeDomLocalizationModel model, System.Globalization.CultureInfo[] supportedCultures) -> void +~System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.CodeDomLocalizationProvider(System.IServiceProvider provider, System.ComponentModel.Design.Serialization.CodeDomLocalizationModel model) -> void +~System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.CodeDomLocalizationProvider(System.IServiceProvider provider, System.ComponentModel.Design.Serialization.CodeDomLocalizationModel model, System.Globalization.CultureInfo[] supportedCultures) -> void System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.Dispose() -> void System.ComponentModel.Design.Serialization.ICodeDomDesignerReload -System.ComponentModel.Design.Serialization.ICodeDomDesignerReload.ShouldReloadDesigner(System.CodeDom.CodeCompileUnit newTree) -> bool +~System.ComponentModel.Design.Serialization.ICodeDomDesignerReload.ShouldReloadDesigner(System.CodeDom.CodeCompileUnit newTree) -> bool System.Windows.Forms.Design.MaskDescriptor System.Windows.Forms.Design.MaskDescriptor.MaskDescriptor() -> void -abstract System.ComponentModel.Design.EventBindingService.CreateUniqueMethodName(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e) -> string -abstract System.ComponentModel.Design.EventBindingService.GetCompatibleMethods(System.ComponentModel.EventDescriptor e) -> System.Collections.ICollection +~abstract System.ComponentModel.Design.EventBindingService.CreateUniqueMethodName(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e) -> string +~abstract System.ComponentModel.Design.EventBindingService.GetCompatibleMethods(System.ComponentModel.EventDescriptor e) -> System.Collections.ICollection abstract System.ComponentModel.Design.EventBindingService.ShowCode() -> bool -abstract System.ComponentModel.Design.EventBindingService.ShowCode(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> bool +~abstract System.ComponentModel.Design.EventBindingService.ShowCode(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> bool abstract System.ComponentModel.Design.EventBindingService.ShowCode(int lineNumber) -> bool -abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager) -> void -abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager) -> void -abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.CodeDomProvider.get -> System.CodeDom.Compiler.CodeDomProvider -abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Parse() -> System.CodeDom.CodeCompileUnit -abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.TypeResolutionService.get -> System.ComponentModel.Design.ITypeResolutionService -abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Write(System.CodeDom.CodeCompileUnit unit) -> void -abstract System.Windows.Forms.Design.MaskDescriptor.Mask.get -> string -abstract System.Windows.Forms.Design.MaskDescriptor.Name.get -> string -abstract System.Windows.Forms.Design.MaskDescriptor.Sample.get -> string -abstract System.Windows.Forms.Design.MaskDescriptor.ValidatingType.get -> System.Type -override System.ComponentModel.Design.BinaryEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.ComponentModel.Design.BinaryEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.ComponentModel.Design.ByteViewer.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void -override System.ComponentModel.Design.ByteViewer.OnLayout(System.Windows.Forms.LayoutEventArgs e) -> void -override System.ComponentModel.Design.ByteViewer.OnPaint(System.Windows.Forms.PaintEventArgs e) -> void -override System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(System.ComponentModel.Design.Serialization.IDesignerLoaderHost host) -> void +~abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager) -> void +~abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager) -> void +~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.CodeDomProvider.get -> System.CodeDom.Compiler.CodeDomProvider +~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Parse() -> System.CodeDom.CodeCompileUnit +~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.TypeResolutionService.get -> System.ComponentModel.Design.ITypeResolutionService +~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Write(System.CodeDom.CodeCompileUnit unit) -> void +~abstract System.Windows.Forms.Design.MaskDescriptor.Mask.get -> string +~abstract System.Windows.Forms.Design.MaskDescriptor.Name.get -> string +~abstract System.Windows.Forms.Design.MaskDescriptor.Sample.get -> string +~abstract System.Windows.Forms.Design.MaskDescriptor.ValidatingType.get -> System.Type +~override System.ComponentModel.Design.BinaryEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.ComponentModel.Design.BinaryEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.ComponentModel.Design.ByteViewer.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void +~override System.ComponentModel.Design.ByteViewer.OnLayout(System.Windows.Forms.LayoutEventArgs e) -> void +~override System.ComponentModel.Design.ByteViewer.OnPaint(System.Windows.Forms.PaintEventArgs e) -> void +~override System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(System.ComponentModel.Design.Serialization.IDesignerLoaderHost host) -> void override System.ComponentModel.Design.Serialization.BasicDesignerLoader.Dispose() -> void override System.ComponentModel.Design.Serialization.BasicDesignerLoader.Flush() -> void override System.ComponentModel.Design.Serialization.BasicDesignerLoader.Loading.get -> bool @@ -958,29 +959,29 @@ override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Initia override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.IsReloadNeeded() -> bool override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnBeginLoad() -> void override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnBeginUnload() -> void -override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection errors) -> void -override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -override System.Windows.Forms.Design.MaskDescriptor.Equals(object maskDescriptor) -> bool +~override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection errors) -> void +~override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void +~override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void +~override System.Windows.Forms.Design.MaskDescriptor.Equals(object maskDescriptor) -> bool override System.Windows.Forms.Design.MaskDescriptor.GetHashCode() -> int -override System.Windows.Forms.Design.MaskDescriptor.ToString() -> string -static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor maskDescriptor) -> bool -static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor maskDescriptor, out string validationErrorDescription) -> bool -virtual System.ComponentModel.Design.ByteViewer.GetBytes() -> byte[] +~override System.Windows.Forms.Design.MaskDescriptor.ToString() -> string +~static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor maskDescriptor) -> bool +~static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor maskDescriptor, out string validationErrorDescription) -> bool +~virtual System.ComponentModel.Design.ByteViewer.GetBytes() -> byte[] virtual System.ComponentModel.Design.ByteViewer.GetDisplayMode() -> System.ComponentModel.Design.DisplayMode -virtual System.ComponentModel.Design.ByteViewer.SaveToFile(string path) -> void -virtual System.ComponentModel.Design.ByteViewer.ScrollChanged(object source, System.EventArgs e) -> void -virtual System.ComponentModel.Design.ByteViewer.SetBytes(byte[] bytes) -> void +~virtual System.ComponentModel.Design.ByteViewer.SaveToFile(string path) -> void +~virtual System.ComponentModel.Design.ByteViewer.ScrollChanged(object source, System.EventArgs e) -> void +~virtual System.ComponentModel.Design.ByteViewer.SetBytes(byte[] bytes) -> void virtual System.ComponentModel.Design.ByteViewer.SetDisplayMode(System.ComponentModel.Design.DisplayMode mode) -> void -virtual System.ComponentModel.Design.ByteViewer.SetFile(string path) -> void +~virtual System.ComponentModel.Design.ByteViewer.SetFile(string path) -> void virtual System.ComponentModel.Design.ByteViewer.SetStartLine(int line) -> void -virtual System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurface.get -> System.ComponentModel.Design.DesignSurface -virtual System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurface.set -> void -virtual System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurfaceCore(System.IServiceProvider parentProvider) -> System.ComponentModel.Design.DesignSurface +~virtual System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurface.get -> System.ComponentModel.Design.DesignSurface +~virtual System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurface.set -> void +~virtual System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurfaceCore(System.IServiceProvider parentProvider) -> System.ComponentModel.Design.DesignSurface virtual System.ComponentModel.Design.DesignSurfaceManager.Dispose(bool disposing) -> void -virtual System.ComponentModel.Design.EventBindingService.FreeMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> void -virtual System.ComponentModel.Design.EventBindingService.UseMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> void -virtual System.ComponentModel.Design.EventBindingService.ValidateMethodName(string methodName) -> void +~virtual System.ComponentModel.Design.EventBindingService.FreeMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> void +~virtual System.ComponentModel.Design.EventBindingService.UseMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> void +~virtual System.ComponentModel.Design.EventBindingService.ValidateMethodName(string methodName) -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.EnableComponentNotification(bool enable) -> bool virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.Initialize() -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.IsReloadNeeded() -> bool @@ -988,54 +989,54 @@ virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.Modified. virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.Modified.set -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnBeginLoad() -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnBeginUnload() -> void -virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection errors) -> void +~virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection errors) -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnModifying() -> void -virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReportFlushErrors(System.Collections.ICollection errors) -> void -virtual System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnComponentRename(object component, string oldName, string newName) -> void -virtual System.Windows.Forms.Design.MaskDescriptor.Culture.get -> System.Globalization.CultureInfo +~virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReportFlushErrors(System.Collections.ICollection errors) -> void +~virtual System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnComponentRename(object component, string oldName, string newName) -> void +~virtual System.Windows.Forms.Design.MaskDescriptor.Culture.get -> System.Globalization.CultureInfo System.ComponentModel.Design.ArrayEditor -System.ComponentModel.Design.ArrayEditor.ArrayEditor(System.Type type) -> void +~System.ComponentModel.Design.ArrayEditor.ArrayEditor(System.Type type) -> void System.ComponentModel.Design.CollectionEditor -System.ComponentModel.Design.CollectionEditor.CollectionEditor(System.Type type) -> void +~System.ComponentModel.Design.CollectionEditor.CollectionEditor(System.Type type) -> void System.ComponentModel.Design.CollectionEditor.CollectionForm -System.ComponentModel.Design.CollectionEditor.CollectionForm.CanRemoveInstance(object value) -> bool -System.ComponentModel.Design.CollectionEditor.CollectionForm.CollectionForm(System.ComponentModel.Design.CollectionEditor editor) -> void -System.ComponentModel.Design.CollectionEditor.CollectionForm.CollectionItemType.get -> System.Type -System.ComponentModel.Design.CollectionEditor.CollectionForm.CollectionType.get -> System.Type -System.ComponentModel.Design.CollectionEditor.CollectionForm.Context.get -> System.ComponentModel.ITypeDescriptorContext -System.ComponentModel.Design.CollectionEditor.CollectionForm.CreateInstance(System.Type itemType) -> object -System.ComponentModel.Design.CollectionEditor.CollectionForm.DestroyInstance(object instance) -> void -System.ComponentModel.Design.CollectionEditor.CollectionForm.EditValue.get -> object -System.ComponentModel.Design.CollectionEditor.CollectionForm.EditValue.set -> void -System.ComponentModel.Design.CollectionEditor.CollectionForm.Items.get -> object[] -System.ComponentModel.Design.CollectionEditor.CollectionForm.Items.set -> void -System.ComponentModel.Design.CollectionEditor.CollectionForm.NewItemTypes.get -> System.Type[] -System.ComponentModel.Design.CollectionEditor.CollectionItemType.get -> System.Type -System.ComponentModel.Design.CollectionEditor.CollectionType.get -> System.Type -System.ComponentModel.Design.CollectionEditor.Context.get -> System.ComponentModel.ITypeDescriptorContext -System.ComponentModel.Design.CollectionEditor.GetService(System.Type serviceType) -> object -System.ComponentModel.Design.CollectionEditor.NewItemTypes.get -> System.Type[] +~System.ComponentModel.Design.CollectionEditor.CollectionForm.CanRemoveInstance(object value) -> bool +~System.ComponentModel.Design.CollectionEditor.CollectionForm.CollectionForm(System.ComponentModel.Design.CollectionEditor editor) -> void +~System.ComponentModel.Design.CollectionEditor.CollectionForm.CollectionItemType.get -> System.Type +~System.ComponentModel.Design.CollectionEditor.CollectionForm.CollectionType.get -> System.Type +~System.ComponentModel.Design.CollectionEditor.CollectionForm.Context.get -> System.ComponentModel.ITypeDescriptorContext +~System.ComponentModel.Design.CollectionEditor.CollectionForm.CreateInstance(System.Type itemType) -> object +~System.ComponentModel.Design.CollectionEditor.CollectionForm.DestroyInstance(object instance) -> void +~System.ComponentModel.Design.CollectionEditor.CollectionForm.EditValue.get -> object +~System.ComponentModel.Design.CollectionEditor.CollectionForm.EditValue.set -> void +~System.ComponentModel.Design.CollectionEditor.CollectionForm.Items.get -> object[] +~System.ComponentModel.Design.CollectionEditor.CollectionForm.Items.set -> void +~System.ComponentModel.Design.CollectionEditor.CollectionForm.NewItemTypes.get -> System.Type[] +~System.ComponentModel.Design.CollectionEditor.CollectionItemType.get -> System.Type +~System.ComponentModel.Design.CollectionEditor.CollectionType.get -> System.Type +~System.ComponentModel.Design.CollectionEditor.Context.get -> System.ComponentModel.ITypeDescriptorContext +~System.ComponentModel.Design.CollectionEditor.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.CollectionEditor.NewItemTypes.get -> System.Type[] System.ComponentModel.Design.MultilineStringEditor System.ComponentModel.Design.MultilineStringEditor.MultilineStringEditor() -> void System.ComponentModel.Design.ObjectSelectorEditor -System.ComponentModel.Design.ObjectSelectorEditor.EqualsToValue(object value) -> bool +~System.ComponentModel.Design.ObjectSelectorEditor.EqualsToValue(object value) -> bool System.ComponentModel.Design.ObjectSelectorEditor.ObjectSelectorEditor() -> void System.ComponentModel.Design.ObjectSelectorEditor.ObjectSelectorEditor(bool subObjectSelector) -> void System.ComponentModel.Design.ObjectSelectorEditor.Selector -System.ComponentModel.Design.ObjectSelectorEditor.Selector.AddNode(string label, object value, System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode parent) -> System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode +~System.ComponentModel.Design.ObjectSelectorEditor.Selector.AddNode(string label, object value, System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode parent) -> System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode System.ComponentModel.Design.ObjectSelectorEditor.Selector.Clear() -> void -System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnAfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) -> void -System.ComponentModel.Design.ObjectSelectorEditor.Selector.Selector(System.ComponentModel.Design.ObjectSelectorEditor editor) -> void -System.ComponentModel.Design.ObjectSelectorEditor.Selector.SetSelection(object value, System.Windows.Forms.TreeNodeCollection nodes) -> bool -System.ComponentModel.Design.ObjectSelectorEditor.Selector.Start(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc, object value) -> void +~System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnAfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) -> void +~System.ComponentModel.Design.ObjectSelectorEditor.Selector.Selector(System.ComponentModel.Design.ObjectSelectorEditor editor) -> void +~System.ComponentModel.Design.ObjectSelectorEditor.Selector.SetSelection(object value, System.Windows.Forms.TreeNodeCollection nodes) -> bool +~System.ComponentModel.Design.ObjectSelectorEditor.Selector.Start(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc, object value) -> void System.ComponentModel.Design.ObjectSelectorEditor.Selector.Stop() -> void System.ComponentModel.Design.ObjectSelectorEditor.Selector.clickSeen -> bool System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode -System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.SelectorNode(string label, object value) -> void -System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.value -> object +~System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.SelectorNode(string label, object value) -> void +~System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.value -> object System.ComponentModel.Design.ObjectSelectorEditor.SubObjectSelector -> bool -System.ComponentModel.Design.ObjectSelectorEditor.currValue -> object -System.ComponentModel.Design.ObjectSelectorEditor.prevValue -> object +~System.ComponentModel.Design.ObjectSelectorEditor.currValue -> object +~System.ComponentModel.Design.ObjectSelectorEditor.prevValue -> object System.Drawing.Design.BitmapEditor System.Drawing.Design.BitmapEditor.BitmapEditor() -> void System.Drawing.Design.ColorEditor @@ -1060,12 +1061,12 @@ System.Windows.Forms.Design.FileNameEditor System.Windows.Forms.Design.FileNameEditor.FileNameEditor() -> void System.Windows.Forms.Design.FolderNameEditor System.Windows.Forms.Design.FolderNameEditor.FolderBrowser -System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.get -> string -System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.set -> void -System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.DirectoryPath.get -> string +~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.get -> string +~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.set -> void +~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.DirectoryPath.get -> string System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.FolderBrowser() -> void System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.ShowDialog() -> System.Windows.Forms.DialogResult -System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.ShowDialog(System.Windows.Forms.IWin32Window owner) -> System.Windows.Forms.DialogResult +~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.ShowDialog(System.Windows.Forms.IWin32Window owner) -> System.Windows.Forms.DialogResult System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.StartLocation.get -> System.Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.StartLocation.set -> void System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Style.get -> System.Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles @@ -1097,132 +1098,132 @@ System.Windows.Forms.Design.ImageListImageEditor.ImageListImageEditor() -> void System.Windows.Forms.Design.ShortcutKeysEditor System.Windows.Forms.Design.ShortcutKeysEditor.ShortcutKeysEditor() -> void abstract System.ComponentModel.Design.CollectionEditor.CollectionForm.OnEditValueChanged() -> void -override System.ComponentModel.Design.ArrayEditor.CreateCollectionItemType() -> System.Type -override System.ComponentModel.Design.ArrayEditor.GetItems(object editValue) -> object[] -override System.ComponentModel.Design.ArrayEditor.SetItems(object editValue, object[] value) -> object -override System.ComponentModel.Design.CollectionEditor.CollectionForm.GetService(System.Type serviceType) -> object -override System.ComponentModel.Design.CollectionEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.ComponentModel.Design.CollectionEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.ComponentModel.Design.MultilineStringEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.ComponentModel.Design.MultilineStringEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.ComponentModel.Design.MultilineStringEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -override System.ComponentModel.Design.ObjectSelectorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.ComponentModel.Design.ObjectSelectorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void -override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) -> void -override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnNodeMouseClick(System.Windows.Forms.TreeNodeMouseClickEventArgs e) -> void +~override System.ComponentModel.Design.ArrayEditor.CreateCollectionItemType() -> System.Type +~override System.ComponentModel.Design.ArrayEditor.GetItems(object editValue) -> object[] +~override System.ComponentModel.Design.ArrayEditor.SetItems(object editValue, object[] value) -> object +~override System.ComponentModel.Design.CollectionEditor.CollectionForm.GetService(System.Type serviceType) -> object +~override System.ComponentModel.Design.CollectionEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.ComponentModel.Design.CollectionEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.ComponentModel.Design.MultilineStringEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.ComponentModel.Design.MultilineStringEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.ComponentModel.Design.MultilineStringEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool +~override System.ComponentModel.Design.ObjectSelectorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.ComponentModel.Design.ObjectSelectorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void +~override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) -> void +~override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnNodeMouseClick(System.Windows.Forms.TreeNodeMouseClickEventArgs e) -> void override System.ComponentModel.Design.ObjectSelectorEditor.Selector.WndProc(ref System.Windows.Forms.Message m) -> void -override System.Drawing.Design.BitmapEditor.GetExtensions() -> string[] -override System.Drawing.Design.BitmapEditor.GetFileDialogDescription() -> string -override System.Drawing.Design.BitmapEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Image -override System.Drawing.Design.ColorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Drawing.Design.ColorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Drawing.Design.ColorEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -override System.Drawing.Design.ColorEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void -override System.Drawing.Design.CursorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Drawing.Design.CursorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.BitmapEditor.GetExtensions() -> string[] +~override System.Drawing.Design.BitmapEditor.GetFileDialogDescription() -> string +~override System.Drawing.Design.BitmapEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Image +~override System.Drawing.Design.ColorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Drawing.Design.ColorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.ColorEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool +~override System.Drawing.Design.ColorEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void +~override System.Drawing.Design.CursorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Drawing.Design.CursorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle override System.Drawing.Design.CursorEditor.IsDropDownResizable.get -> bool -override System.Drawing.Design.FontEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Drawing.Design.FontEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Drawing.Design.FontNameEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -override System.Drawing.Design.FontNameEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void -override System.Drawing.Design.ImageEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Drawing.Design.ImageEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Drawing.Design.ImageEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -override System.Drawing.Design.ImageEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void -override System.Drawing.Design.MetafileEditor.GetExtensions() -> string[] -override System.Drawing.Design.MetafileEditor.GetFileDialogDescription() -> string -override System.Drawing.Design.MetafileEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Image -override System.Windows.Forms.Design.AnchorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.AnchorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Windows.Forms.Design.BorderSidesEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.BorderSidesEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Windows.Forms.Design.DockEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.DockEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Windows.Forms.Design.FileNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.FileNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Windows.Forms.Design.FolderNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.FolderNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Windows.Forms.Design.ImageListImageEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.ImageListImageEditor.GetFileDialogDescription() -> string -override System.Windows.Forms.Design.ImageListImageEditor.GetImageExtenders() -> System.Type[] -override System.Windows.Forms.Design.ImageListImageEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -override System.Windows.Forms.Design.ImageListImageEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void -override System.Windows.Forms.Design.ShortcutKeysEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Windows.Forms.Design.ShortcutKeysEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -static System.ComponentModel.Design.ObjectSelectorEditor.ApplyTreeViewThemeStyles(System.Windows.Forms.TreeView treeView) -> void -static System.Drawing.Design.BitmapEditor.BitmapExtensions -> System.Collections.Generic.List -static System.Drawing.Design.ImageEditor.CreateExtensionsString(string[] extensions, string sep) -> string -static System.Drawing.Design.ImageEditor.CreateFilterEntry(System.Drawing.Design.ImageEditor e) -> string -virtual System.ComponentModel.Design.CollectionEditor.CanRemoveInstance(object value) -> bool +~override System.Drawing.Design.FontEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Drawing.Design.FontEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.FontNameEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool +~override System.Drawing.Design.FontNameEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void +~override System.Drawing.Design.ImageEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Drawing.Design.ImageEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.ImageEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool +~override System.Drawing.Design.ImageEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void +~override System.Drawing.Design.MetafileEditor.GetExtensions() -> string[] +~override System.Drawing.Design.MetafileEditor.GetFileDialogDescription() -> string +~override System.Drawing.Design.MetafileEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Image +~override System.Windows.Forms.Design.AnchorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.AnchorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Windows.Forms.Design.BorderSidesEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.BorderSidesEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Windows.Forms.Design.DockEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.DockEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Windows.Forms.Design.FileNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.FileNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Windows.Forms.Design.FolderNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.FolderNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Windows.Forms.Design.ImageListImageEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.ImageListImageEditor.GetFileDialogDescription() -> string +~override System.Windows.Forms.Design.ImageListImageEditor.GetImageExtenders() -> System.Type[] +~override System.Windows.Forms.Design.ImageListImageEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool +~override System.Windows.Forms.Design.ImageListImageEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void +~override System.Windows.Forms.Design.ShortcutKeysEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Windows.Forms.Design.ShortcutKeysEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~static System.ComponentModel.Design.ObjectSelectorEditor.ApplyTreeViewThemeStyles(System.Windows.Forms.TreeView treeView) -> void +~static System.Drawing.Design.BitmapEditor.BitmapExtensions -> System.Collections.Generic.List +~static System.Drawing.Design.ImageEditor.CreateExtensionsString(string[] extensions, string sep) -> string +~static System.Drawing.Design.ImageEditor.CreateFilterEntry(System.Drawing.Design.ImageEditor e) -> string +~virtual System.ComponentModel.Design.CollectionEditor.CanRemoveInstance(object value) -> bool virtual System.ComponentModel.Design.CollectionEditor.CanSelectMultipleInstances() -> bool virtual System.ComponentModel.Design.CollectionEditor.CancelChanges() -> void virtual System.ComponentModel.Design.CollectionEditor.CollectionForm.CanSelectMultipleInstances() -> bool -virtual System.ComponentModel.Design.CollectionEditor.CollectionForm.DisplayError(System.Exception e) -> void -virtual System.ComponentModel.Design.CollectionEditor.CollectionForm.ShowEditorDialog(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc) -> System.Windows.Forms.DialogResult -virtual System.ComponentModel.Design.CollectionEditor.CreateCollectionForm() -> System.ComponentModel.Design.CollectionEditor.CollectionForm -virtual System.ComponentModel.Design.CollectionEditor.CreateCollectionItemType() -> System.Type -virtual System.ComponentModel.Design.CollectionEditor.CreateInstance(System.Type itemType) -> object -virtual System.ComponentModel.Design.CollectionEditor.CreateNewItemTypes() -> System.Type[] -virtual System.ComponentModel.Design.CollectionEditor.DestroyInstance(object instance) -> void -virtual System.ComponentModel.Design.CollectionEditor.GetDisplayText(object value) -> string -virtual System.ComponentModel.Design.CollectionEditor.GetItems(object editValue) -> object[] -virtual System.ComponentModel.Design.CollectionEditor.GetObjectsFromInstance(object instance) -> System.Collections.IList -virtual System.ComponentModel.Design.CollectionEditor.HelpTopic.get -> string -virtual System.ComponentModel.Design.CollectionEditor.SetItems(object editValue, object[] value) -> object +~virtual System.ComponentModel.Design.CollectionEditor.CollectionForm.DisplayError(System.Exception e) -> void +~virtual System.ComponentModel.Design.CollectionEditor.CollectionForm.ShowEditorDialog(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc) -> System.Windows.Forms.DialogResult +~virtual System.ComponentModel.Design.CollectionEditor.CreateCollectionForm() -> System.ComponentModel.Design.CollectionEditor.CollectionForm +~virtual System.ComponentModel.Design.CollectionEditor.CreateCollectionItemType() -> System.Type +~virtual System.ComponentModel.Design.CollectionEditor.CreateInstance(System.Type itemType) -> object +~virtual System.ComponentModel.Design.CollectionEditor.CreateNewItemTypes() -> System.Type[] +~virtual System.ComponentModel.Design.CollectionEditor.DestroyInstance(object instance) -> void +~virtual System.ComponentModel.Design.CollectionEditor.GetDisplayText(object value) -> string +~virtual System.ComponentModel.Design.CollectionEditor.GetItems(object editValue) -> object[] +~virtual System.ComponentModel.Design.CollectionEditor.GetObjectsFromInstance(object instance) -> System.Collections.IList +~virtual System.ComponentModel.Design.CollectionEditor.HelpTopic.get -> string +~virtual System.ComponentModel.Design.CollectionEditor.SetItems(object editValue, object[] value) -> object virtual System.ComponentModel.Design.CollectionEditor.ShowHelp() -> void -virtual System.ComponentModel.Design.ObjectSelectorEditor.FillTreeWithData(System.ComponentModel.Design.ObjectSelectorEditor.Selector selector, System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider) -> void -virtual System.ComponentModel.Design.ObjectSelectorEditor.SetValue(object value) -> void -virtual System.Drawing.Design.ImageEditor.GetExtensions() -> string[] -virtual System.Drawing.Design.ImageEditor.GetFileDialogDescription() -> string -virtual System.Drawing.Design.ImageEditor.GetImageExtenders() -> System.Type[] -virtual System.Drawing.Design.ImageEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Image -virtual System.Windows.Forms.Design.FileNameEditor.InitializeDialog(System.Windows.Forms.OpenFileDialog openFileDialog) -> void -virtual System.Windows.Forms.Design.FolderNameEditor.InitializeDialog(System.Windows.Forms.Design.FolderNameEditor.FolderBrowser folderBrowser) -> void +~virtual System.ComponentModel.Design.ObjectSelectorEditor.FillTreeWithData(System.ComponentModel.Design.ObjectSelectorEditor.Selector selector, System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider) -> void +~virtual System.ComponentModel.Design.ObjectSelectorEditor.SetValue(object value) -> void +~virtual System.Drawing.Design.ImageEditor.GetExtensions() -> string[] +~virtual System.Drawing.Design.ImageEditor.GetFileDialogDescription() -> string +~virtual System.Drawing.Design.ImageEditor.GetImageExtenders() -> System.Type[] +~virtual System.Drawing.Design.ImageEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Image +~virtual System.Windows.Forms.Design.FileNameEditor.InitializeDialog(System.Windows.Forms.OpenFileDialog openFileDialog) -> void +~virtual System.Windows.Forms.Design.FolderNameEditor.InitializeDialog(System.Windows.Forms.Design.FolderNameEditor.FolderBrowser folderBrowser) -> void System.ComponentModel.Design.DateTimeEditor System.ComponentModel.Design.DateTimeEditor.DateTimeEditor() -> void System.Drawing.Design.ContentAlignmentEditor System.Drawing.Design.ContentAlignmentEditor.ContentAlignmentEditor() -> void System.Drawing.Design.IconEditor System.Drawing.Design.IconEditor.IconEditor() -> void -override System.ComponentModel.Design.DateTimeEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.ComponentModel.Design.DateTimeEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Drawing.Design.ContentAlignmentEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Drawing.Design.ContentAlignmentEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Drawing.Design.IconEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -override System.Drawing.Design.IconEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -override System.Drawing.Design.IconEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -override System.Drawing.Design.IconEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void -static System.Drawing.Design.IconEditor.CreateExtensionsString(string[] extensions, string sep) -> string -static System.Drawing.Design.IconEditor.CreateFilterEntry(System.Drawing.Design.IconEditor editor) -> string -virtual System.Drawing.Design.IconEditor.GetExtensions() -> string[] -virtual System.Drawing.Design.IconEditor.GetFileDialogDescription() -> string -virtual System.Drawing.Design.IconEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Icon +~override System.ComponentModel.Design.DateTimeEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.ComponentModel.Design.DateTimeEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.ContentAlignmentEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Drawing.Design.ContentAlignmentEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.IconEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object +~override System.Drawing.Design.IconEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +~override System.Drawing.Design.IconEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool +~override System.Drawing.Design.IconEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void +~static System.Drawing.Design.IconEditor.CreateExtensionsString(string[] extensions, string sep) -> string +~static System.Drawing.Design.IconEditor.CreateFilterEntry(System.Drawing.Design.IconEditor editor) -> string +~virtual System.Drawing.Design.IconEditor.GetExtensions() -> string[] +~virtual System.Drawing.Design.IconEditor.GetFileDialogDescription() -> string +~virtual System.Drawing.Design.IconEditor.LoadFromStream(System.IO.Stream stream) -> System.Drawing.Icon System.ComponentModel.Design.MenuCommandService System.ComponentModel.Design.MenuCommandService.Dispose() -> void System.ComponentModel.Design.MenuCommandService.EnsureVerbs() -> void -System.ComponentModel.Design.MenuCommandService.FindCommand(System.ComponentModel.Design.CommandID commandID) -> System.ComponentModel.Design.MenuCommand -System.ComponentModel.Design.MenuCommandService.FindCommand(System.Guid guid, int id) -> System.ComponentModel.Design.MenuCommand -System.ComponentModel.Design.MenuCommandService.GetCommandList(System.Guid guid) -> System.Collections.ICollection -System.ComponentModel.Design.MenuCommandService.GetService(System.Type serviceType) -> object -System.ComponentModel.Design.MenuCommandService.MenuCommandService(System.IServiceProvider serviceProvider) -> void +~System.ComponentModel.Design.MenuCommandService.FindCommand(System.ComponentModel.Design.CommandID commandID) -> System.ComponentModel.Design.MenuCommand +~System.ComponentModel.Design.MenuCommandService.FindCommand(System.Guid guid, int id) -> System.ComponentModel.Design.MenuCommand +~System.ComponentModel.Design.MenuCommandService.GetCommandList(System.Guid guid) -> System.Collections.ICollection +~System.ComponentModel.Design.MenuCommandService.GetService(System.Type serviceType) -> object +~System.ComponentModel.Design.MenuCommandService.MenuCommandService(System.IServiceProvider serviceProvider) -> void System.ComponentModel.Design.MenuCommandService.MenuCommandsChanged -> System.ComponentModel.Design.MenuCommandsChangedEventHandler System.ComponentModel.Design.MenuCommandsChangedEventArgs System.ComponentModel.Design.MenuCommandsChangedEventArgs.ChangeType.get -> System.ComponentModel.Design.MenuCommandsChangedType -System.ComponentModel.Design.MenuCommandsChangedEventArgs.Command.get -> System.ComponentModel.Design.MenuCommand -System.ComponentModel.Design.MenuCommandsChangedEventArgs.MenuCommandsChangedEventArgs(System.ComponentModel.Design.MenuCommandsChangedType changeType, System.ComponentModel.Design.MenuCommand command) -> void +~System.ComponentModel.Design.MenuCommandsChangedEventArgs.Command.get -> System.ComponentModel.Design.MenuCommand +~System.ComponentModel.Design.MenuCommandsChangedEventArgs.MenuCommandsChangedEventArgs(System.ComponentModel.Design.MenuCommandsChangedType changeType, System.ComponentModel.Design.MenuCommand command) -> void System.ComponentModel.Design.MenuCommandsChangedEventHandler System.ComponentModel.Design.MenuCommandsChangedType System.ComponentModel.Design.MenuCommandsChangedType.CommandAdded = 0 -> System.ComponentModel.Design.MenuCommandsChangedType System.ComponentModel.Design.MenuCommandsChangedType.CommandChanged = 2 -> System.ComponentModel.Design.MenuCommandsChangedType System.ComponentModel.Design.MenuCommandsChangedType.CommandRemoved = 1 -> System.ComponentModel.Design.MenuCommandsChangedType -virtual System.ComponentModel.Design.MenuCommandService.AddCommand(System.ComponentModel.Design.MenuCommand command) -> void -virtual System.ComponentModel.Design.MenuCommandService.AddVerb(System.ComponentModel.Design.DesignerVerb verb) -> void +~virtual System.ComponentModel.Design.MenuCommandService.AddCommand(System.ComponentModel.Design.MenuCommand command) -> void +~virtual System.ComponentModel.Design.MenuCommandService.AddVerb(System.ComponentModel.Design.DesignerVerb verb) -> void virtual System.ComponentModel.Design.MenuCommandService.Dispose(bool disposing) -> void -virtual System.ComponentModel.Design.MenuCommandService.GlobalInvoke(System.ComponentModel.Design.CommandID commandID) -> bool -virtual System.ComponentModel.Design.MenuCommandService.GlobalInvoke(System.ComponentModel.Design.CommandID commandId, object arg) -> bool -virtual System.ComponentModel.Design.MenuCommandService.OnCommandsChanged(System.ComponentModel.Design.MenuCommandsChangedEventArgs e) -> void -virtual System.ComponentModel.Design.MenuCommandService.RemoveCommand(System.ComponentModel.Design.MenuCommand command) -> void -virtual System.ComponentModel.Design.MenuCommandService.RemoveVerb(System.ComponentModel.Design.DesignerVerb verb) -> void -virtual System.ComponentModel.Design.MenuCommandService.ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y) -> void -virtual System.ComponentModel.Design.MenuCommandService.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection +~virtual System.ComponentModel.Design.MenuCommandService.GlobalInvoke(System.ComponentModel.Design.CommandID commandID) -> bool +~virtual System.ComponentModel.Design.MenuCommandService.GlobalInvoke(System.ComponentModel.Design.CommandID commandId, object arg) -> bool +~virtual System.ComponentModel.Design.MenuCommandService.OnCommandsChanged(System.ComponentModel.Design.MenuCommandsChangedEventArgs e) -> void +~virtual System.ComponentModel.Design.MenuCommandService.RemoveCommand(System.ComponentModel.Design.MenuCommand command) -> void +~virtual System.ComponentModel.Design.MenuCommandService.RemoveVerb(System.ComponentModel.Design.DesignerVerb verb) -> void +~virtual System.ComponentModel.Design.MenuCommandService.ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y) -> void +~virtual System.ComponentModel.Design.MenuCommandService.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection diff --git a/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt b/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt index e69de29bb2d..d3a90e7a693 100644 --- a/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt +++ b/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +*REMOVED*virtual System.Windows.Forms.Design.DocumentDesigner.EnsureMenuEditorService(System.ComponentModel.IComponent c) -> void +*REMOVED*override System.Windows.Forms.Design.DocumentDesigner.WndProc(ref System.Windows.Forms.Message m) -> void diff --git a/src/System.Windows.Forms.Design/src/Resources/MaskDesignerDialog.Designer.cs b/src/System.Windows.Forms.Design/src/Resources/MaskDesignerDialog.Designer.cs index 69a1c55a47c..8af38da7041 100644 --- a/src/System.Windows.Forms.Design/src/Resources/MaskDesignerDialog.Designer.cs +++ b/src/System.Windows.Forms.Design/src/Resources/MaskDesignerDialog.Designer.cs @@ -13,7 +13,7 @@ namespace System.Windows.Forms.Design.Resources { /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. @@ -33,7 +33,7 @@ internal class MaskDesignerDialog { } /// - /// Returns the cached ResourceManager instance used by this class. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal class MaskDesignerDialog { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. /// internal static System.Windows.Forms.AnchorStyles btnCancel_Anchor { get { @@ -71,7 +71,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool btnCancel_AutoSize { get { @@ -81,7 +81,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=81,Y=0}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=81,Y=0}. /// internal static System.Drawing.Point btnCancel_Location { get { @@ -91,7 +91,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=75, Height=23}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=75, Height=23}. /// internal static System.Drawing.Size btnCancel_Size { get { @@ -101,7 +101,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 1. + /// Looks up a localized resource of type System.Int32 similar to 1. /// internal static int btnCancel_TabIndex { get { @@ -111,7 +111,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to Cancel. + /// Looks up a localized string similar to Cancel. /// internal static string btnCancel_Text { get { @@ -120,7 +120,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. /// internal static System.Windows.Forms.AnchorStyles btnOK_Anchor { get { @@ -130,7 +130,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool btnOK_AutoSize { get { @@ -140,7 +140,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=0}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=0}. /// internal static System.Drawing.Point btnOK_Location { get { @@ -150,7 +150,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=75, Height=23}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=75, Height=23}. /// internal static System.Drawing.Size btnOK_Size { get { @@ -160,7 +160,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 0. + /// Looks up a localized resource of type System.Int32 similar to 0. /// internal static int btnOK_TabIndex { get { @@ -170,7 +170,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to OK. + /// Looks up a localized string similar to OK. /// internal static string btnOK_Text { get { @@ -179,7 +179,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. /// internal static System.Windows.Forms.AnchorStyles checkBoxUseValidatingType_Anchor { get { @@ -189,7 +189,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool checkBoxUseValidatingType_AutoSize { get { @@ -199,7 +199,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=364,Y=1}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=364,Y=1}. /// internal static System.Drawing.Point checkBoxUseValidatingType_Location { get { @@ -209,7 +209,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=114, Height=17}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=114, Height=17}. /// internal static System.Drawing.Size checkBoxUseValidatingType_Size { get { @@ -219,7 +219,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 2. + /// Looks up a localized resource of type System.Int32 similar to 2. /// internal static int checkBoxUseValidatingType_TabIndex { get { @@ -229,7 +229,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to &Use ValidatingType. + /// Looks up a localized string similar to &Use ValidatingType. /// internal static string checkBoxUseValidatingType_Text { get { @@ -238,7 +238,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 160. + /// Looks up a localized resource of type System.Int32 similar to 160. /// internal static int dataFormatHeader_Width { get { @@ -248,7 +248,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. /// internal static System.Windows.Forms.AnchorStyles lblHeader_Anchor { get { @@ -258,7 +258,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool lblHeader_AutoSize { get { @@ -268,7 +268,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=0}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=0}. /// internal static System.Drawing.Point lblHeader_Location { get { @@ -278,7 +278,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=469, Height=13}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=469, Height=13}. /// internal static System.Drawing.Size lblHeader_Size { get { @@ -288,7 +288,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 0. + /// Looks up a localized resource of type System.Int32 similar to 0. /// internal static int lblHeader_TabIndex { get { @@ -298,7 +298,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to &Select a predefined mask description from the list below or select Custom to define a custom mask.. + /// Looks up a localized string similar to &Select a predefined mask description from the list below or select Custom to define a custom mask.. /// internal static string lblHeader_Text { get { @@ -307,7 +307,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. /// internal static System.Windows.Forms.AnchorStyles lblMask_Anchor { get { @@ -317,7 +317,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool lblMask_AutoSize { get { @@ -327,7 +327,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=3}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=3}. /// internal static System.Drawing.Point lblMask_Location { get { @@ -337,7 +337,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=35, Height=13}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=35, Height=13}. /// internal static System.Drawing.Size lblMask_Size { get { @@ -347,7 +347,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 0. + /// Looks up a localized resource of type System.Int32 similar to 0. /// internal static int lblMask_TabIndex { get { @@ -357,7 +357,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to &Mask:. + /// Looks up a localized string similar to &Mask:. /// internal static string lblMask_Text { get { @@ -366,7 +366,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left. /// internal static System.Windows.Forms.AnchorStyles lblTryIt_Anchor { get { @@ -376,7 +376,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool lblTryIt_AutoSize { get { @@ -386,7 +386,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=29}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=29}. /// internal static System.Drawing.Point lblTryIt_Location { get { @@ -396,7 +396,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=47, Height=13}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=47, Height=13}. /// internal static System.Drawing.Size lblTryIt_Size { get { @@ -406,7 +406,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 3. + /// Looks up a localized resource of type System.Int32 similar to 3. /// internal static int lblTryIt_TabIndex { get { @@ -416,7 +416,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to &Preview:. + /// Looks up a localized string similar to &Preview:. /// internal static string lblTryIt_Text { get { @@ -425,7 +425,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Top, Bottom, Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Top, Bottom, Left, Right. /// internal static System.Windows.Forms.AnchorStyles listViewCannedMasks_Anchor { get { @@ -435,7 +435,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to . + /// Looks up a localized string similar to . /// internal static string listViewCannedMasks_Columns { get { @@ -444,7 +444,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to . + /// Looks up a localized string similar to . /// internal static string listViewCannedMasks_Columns1 { get { @@ -453,7 +453,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to . + /// Looks up a localized string similar to . /// internal static string listViewCannedMasks_Columns2 { get { @@ -462,7 +462,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to False. + /// Looks up a localized resource of type System.Boolean similar to False. /// internal static bool listViewCannedMasks_LabelWrap { get { @@ -472,7 +472,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=19}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=19}. /// internal static System.Drawing.Point listViewCannedMasks_Location { get { @@ -482,7 +482,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=478, Height=198}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=478, Height=198}. /// internal static System.Drawing.Size listViewCannedMasks_Size { get { @@ -492,7 +492,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 1. + /// Looks up a localized resource of type System.Int32 similar to 1. /// internal static int listViewCannedMasks_TabIndex { get { @@ -502,7 +502,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 160. + /// Looks up a localized resource of type System.Int32 similar to 160. /// internal static int maskDescriptionHeader_Width { get { @@ -512,7 +512,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. /// internal static System.Windows.Forms.AnchorStyles maskedTextBox_Anchor { get { @@ -522,7 +522,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=53,Y=26}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=53,Y=26}. /// internal static System.Drawing.Point maskedTextBox_Location { get { @@ -532,7 +532,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=293, Height=20}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=293, Height=20}. /// internal static System.Drawing.Size maskedTextBox_Size { get { @@ -542,7 +542,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 4. + /// Looks up a localized resource of type System.Int32 similar to 4. /// internal static int maskedTextBox_TabIndex { get { @@ -552,7 +552,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. /// internal static System.Windows.Forms.AnchorStyles maskTryItTable_Anchor { get { @@ -562,7 +562,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool maskTryItTable_AutoSize { get { @@ -572,7 +572,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 3. + /// Looks up a localized resource of type System.Int32 similar to 3. /// internal static int maskTryItTable_ColumnCount { get { @@ -582,7 +582,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="checkBoxUseValidatingType" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lblMask" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="txtBoxMask" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lblTryIt" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="maskedTextBox" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,Aut [rest of string was truncated]";. + /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="checkBoxUseValidatingType" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lblMask" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="txtBoxMask" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lblTryIt" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="maskedTextBox" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,Aut [rest of string was truncated]";. /// internal static string maskTryItTable_LayoutSettings { get { @@ -591,7 +591,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=223}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=0,Y=223}. /// internal static System.Drawing.Point maskTryItTable_Location { get { @@ -601,7 +601,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 2. + /// Looks up a localized resource of type System.Int32 similar to 2. /// internal static int maskTryItTable_RowCount { get { @@ -611,7 +611,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=478, Height=46}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=478, Height=46}. /// internal static System.Drawing.Size maskTryItTable_Size { get { @@ -621,7 +621,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 2. + /// Looks up a localized resource of type System.Int32 similar to 2. /// internal static int maskTryItTable_TabIndex { get { @@ -631,7 +631,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Right. /// internal static System.Windows.Forms.AnchorStyles okCancelTableLayoutPanel_Anchor { get { @@ -641,7 +641,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Boolean similar to True. + /// Looks up a localized resource of type System.Boolean similar to True. /// internal static bool okCancelTableLayoutPanel_AutoSize { get { @@ -651,7 +651,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 2. + /// Looks up a localized resource of type System.Int32 similar to 2. /// internal static int okCancelTableLayoutPanel_ColumnCount { get { @@ -661,7 +661,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="btnCancel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="btnOK" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="AutoSize,0" /></TableLayoutSettings>. + /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="btnCancel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="btnOK" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="AutoSize,0" /></TableLayoutSettings>. /// internal static string okCancelTableLayoutPanel_LayoutSettings { get { @@ -670,7 +670,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=322,Y=278}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=322,Y=278}. /// internal static System.Drawing.Point okCancelTableLayoutPanel_Location { get { @@ -680,7 +680,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 1. + /// Looks up a localized resource of type System.Int32 similar to 1. /// internal static int okCancelTableLayoutPanel_RowCount { get { @@ -690,7 +690,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=156, Height=23}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=156, Height=23}. /// internal static System.Drawing.Size okCancelTableLayoutPanel_Size { get { @@ -700,7 +700,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 3. + /// Looks up a localized resource of type System.Int32 similar to 3. /// internal static int okCancelTableLayoutPanel_TabIndex { get { @@ -710,7 +710,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Top, Bottom, Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Top, Bottom, Left, Right. /// internal static System.Windows.Forms.AnchorStyles overarchingTableLayoutPanel_Anchor { get { @@ -720,7 +720,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 1. + /// Looks up a localized resource of type System.Int32 similar to 1. /// internal static int overarchingTableLayoutPanel_ColumnCount { get { @@ -730,7 +730,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="maskTryItTable" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="okCancelTableLayoutPanel" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lblHeader" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="listViewCannedMasks" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50" /><Rows Styles="AutoSize,0,AutoSize,0,Percent,50,AutoSize,0,AutoSize,0" /></ [rest of string was truncated]";. + /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="maskTryItTable" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="okCancelTableLayoutPanel" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lblHeader" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="listViewCannedMasks" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50" /><Rows Styles="AutoSize,0,AutoSize,0,Percent,50,AutoSize,0,AutoSize,0" /></ [rest of string was truncated]";. /// internal static string overarchingTableLayoutPanel_LayoutSettings { get { @@ -739,7 +739,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=13,Y=13}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=13,Y=13}. /// internal static System.Drawing.Point overarchingTableLayoutPanel_Location { get { @@ -749,7 +749,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 5. + /// Looks up a localized resource of type System.Int32 similar to 5. /// internal static int overarchingTableLayoutPanel_RowCount { get { @@ -759,7 +759,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=478, Height=301}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=478, Height=301}. /// internal static System.Drawing.Size overarchingTableLayoutPanel_Size { get { @@ -769,7 +769,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 0. + /// Looks up a localized resource of type System.Int32 similar to 0. /// internal static int overarchingTableLayoutPanel_TabIndex { get { @@ -779,7 +779,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. + /// Looks up a localized resource of type System.Windows.Forms.AnchorStyles similar to Left, Right. /// internal static System.Windows.Forms.AnchorStyles txtBoxMask_Anchor { get { @@ -789,7 +789,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Point similar to {X=53,Y=0}. + /// Looks up a localized resource of type System.Drawing.Point similar to {X=53,Y=0}. /// internal static System.Drawing.Point txtBoxMask_Location { get { @@ -799,7 +799,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Drawing.Size similar to {Width=293, Height=20}. + /// Looks up a localized resource of type System.Drawing.Size similar to {Width=293, Height=20}. /// internal static System.Drawing.Size txtBoxMask_Size { get { @@ -809,7 +809,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 1. + /// Looks up a localized resource of type System.Int32 similar to 1. /// internal static int txtBoxMask_TabIndex { get { @@ -819,7 +819,7 @@ internal class MaskDesignerDialog { } /// - /// Looks up a localized resource of type System.Int32 similar to 150. + /// Looks up a localized resource of type System.Int32 similar to 150. /// internal static int validatingTypeHeader_Width { get { diff --git a/src/System.Windows.Forms.Design/src/Resources/SR.resx b/src/System.Windows.Forms.Design/src/Resources/SR.resx index 942c9ef6c0a..53a8c199278 100644 --- a/src/System.Windows.Forms.Design/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Design/src/Resources/SR.resx @@ -1,4 +1,4 @@ - + @@ -1072,4 +1072,139 @@ Press Ctrl+Enter to accept Text. Select the directory that will initially be opened in the dialog. - \ No newline at end of file + + ActiveX Control + + + Failed to import the ActiveX control. Please ensure it is properly registered. + + + Could not create ActiveX control '{0}' because it is not properly registered. + + + Select the image displayed in the PictureBox + + + Choose Image... + + + Requested Clipboard operation did not succeed. + + + Bring {0} controls to front + + + Lock {0} components + + + Send {0} controls to back + + + Creating components in tool '{0}' + + + Indicates the name used in code to identify the object. + + + Cannot add component of type '{0}' to container of type '{1}' + + + Drop components + + + Opens the Lines collection editor + + + Edit Text Lines... + + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + + ImageList: + + + Chooses an ImageList to use with this TreeView + + + Edit Nodes... + + + Opens the Nodes collection editor + + + Items + + + Links + + + Opens the Items collection editor + + + Edit Items... + + + Edit Columns... + + + Opens the Columns collection editor + + + Edit Groups... + + + Opens the Groups collection editor + + + View: + + + Changes the type of View this ListView shows + + + Small ImageList: + + + Selects an ImageList to use with SmallIcon mode + + + Large ImageList: + + + Selects an ImageList to use with LargeIcon mode + + + Edit Items... + + + Opens the Items collection editor + + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + + Puts the TextBox in a mode where it can display multiple lines of text + + + MultiLine + + + Place existing controls in new containerDetermines the size of the positioning grid. + + + Place existing controls in new container, '{0}'. + + + Properties + + + Changes the sizing mode of the Image displayed in the PictureBox + + + Size Mode: + + + - Read Only + + diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/MoverGlyph.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/MoverGlyph.bmp new file mode 100644 index 00000000000..9a4b26593ac Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/MoverGlyph.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/MoverGlyph.ico b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/MoverGlyph.ico deleted file mode 100644 index 8adfca864d4..00000000000 Binary files a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/MoverGlyph.ico and /dev/null differ diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf index f691e93efd2..62e43961848 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Editor ukotvení @@ -27,6 +32,16 @@ Nahoře + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Návrhář je již zaveden. @@ -202,6 +217,21 @@ Náhled na vybrané položky + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Úložiště serializace je zavřeno. Do zavřeného úložiště nelze přidávat nové objekty. @@ -354,6 +384,11 @@ Zarovnání součástí do mřížky (počet: {0}) + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Vyjmutí součástí (počet: {0}) @@ -376,11 +411,21 @@ Formátování (určení rozestupů) součástí (počet: {0}) + + Lock {0} components + Lock {0} components + + Paste components Vložení součástí + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Změna velikosti součástí (počet: {0}) @@ -601,11 +646,21 @@ Při nastavování hodnoty {0} vlastnosti {1} došlo k chybě. Podrobnosti: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Před voláním přetahovacích funkcí musí být úspěšně vyvolána funkce BeginDrag. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Zděděný ovládací prvek @@ -800,6 +855,11 @@ Určuje, zda mají být v návrháři použity vodicí čáry. Pokud je tato vlastnost nastavena na hodnotu True, vodicí čáry budou použity jako vodítka. Pokud je tato vlastnost nastavena na hodnotu False, budou použity čáry mřížky. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Ukotvit v nadřazeném kontejneru @@ -855,6 +915,11 @@ Počet přetažených součástí: {0} + + Drop components + Drop components + + Move {0} Přesunout: {0} @@ -880,6 +945,16 @@ Změna velikosti součástí (počet: {0}) + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. Pro událost {0} je očekáván argument typu {1}. @@ -910,6 +985,11 @@ Zprostředkovatel rozšířeného objektu {0} již byl přidán jako rozšiřující objekt. V případě přidání dalšího by došlo k duplicitě vlastností. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Dialogové okno formátovacího řetězce @@ -940,6 +1020,16 @@ Editor kolekce Images + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Jen pro čtení @@ -960,6 +1050,21 @@ Hodnota {1} není platnou hodnotou pro argument {0}. Hodnota {0} musí být v rozsahu od {2} do {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Storno @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ Služba {0} je požadována, ale nebyla nalezena. Pokud jste tuto službu odebrali, zajistěte její náhradu. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. Maska není úplná. @@ -1105,6 +1290,16 @@ Pro příkaz nabídky {0} již existuje obslužná rutina příkazu. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. Tuto metodu nebo objekt návrh neimplementuje. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Winforms Designer není na této platformě podporován. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. (Neznámý) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &O aplikaci... @@ -1667,6 +1887,11 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. Svislé zarovnání součástí na střed (počet: {0}) + + - Read Only + - Read Only + + Bitmap files Rastrové soubory diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf index 16c1069eb61..a2811cc2367 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Anker-Editor @@ -27,6 +32,16 @@ Oben + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Der Designer ist bereits geladen. @@ -202,6 +217,21 @@ Auswahlvorschau + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Der Serialisierungsspeicher ist geschlossen. Neue Objekte können nicht zu einem geschlossenen Speicher hinzugefügt werden. @@ -354,6 +384,11 @@ {0}-Komponenten am Raster ausrichten + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components {0}-Komponenten ausschneiden @@ -376,11 +411,21 @@ {0}-Komponenten formatieren (Abstände) + + Lock {0} components + Lock {0} components + + Paste components Komponenten einfügen + + Send {0} controls to back + Send {0} controls to back + + Size {0} components {0}-Komponentengröße festlegen @@ -601,11 +646,21 @@ Fehler beim Festlegen von {0}-Wert auf {1}-Eigenschaft. Details: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Der Aufruf von BeginDrag muss vor dem Aufrufen von Ziehfunktionen ausgeführt werden. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Vererbtes Steuerelement @@ -800,6 +855,11 @@ Steuert, ob Designer Ausrichtungslinien verwenden. Wenn "true", werden Ausrichtungslinien als Führungslinien verwendet. Wenn "false", werden Rasterlinien verwendet. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container In übergeordnetem Container andocken @@ -855,6 +915,11 @@ {0} Komponenten ziehen + + Drop components + Drop components + + Move {0} {0} verschieben @@ -880,6 +945,16 @@ {0}-Komponentengröße festlegen + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. Das Ereignis {0} erwartet den Argumenttyp {1}. @@ -910,6 +985,11 @@ Der Extenderanbieter {0} wurde bereits als Extender hinzugefügt. Wenn ein weiterer hinzugefügt wird, führt dies zu doppelten Eigenschaften. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Formatierungszeichenfolge @@ -940,6 +1020,16 @@ Bildsammlungs-Editor + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Schreibgeschützt @@ -960,6 +1050,21 @@ {1} ist kein gültiger Wert für {0}. {0} sollte zwischen {2} und {3} liegen. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Abbrechen @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ Der Dienst {0} ist erforderlich, wurde aber nicht gefunden. Wenn Sie den Dienst entfernt haben, stellen Sie sicher, dass ein Ersatz verfügbar ist. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. Maske ist nicht voll. @@ -1105,6 +1290,16 @@ Für den Menübefehl {0} ist bereits ein Befehlshandler vorhanden. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. Diese Methode/dieses Objekt wird entwurfsbedingt nicht implementiert. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Der Windows Forms-Designer wird auf dieser Plattform nicht unterstützt. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. (Unbekannt) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &Info... @@ -1667,6 +1887,11 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. {0} Komponenten vertikal zentrieren + + - Read Only + - Read Only + + Bitmap files Bitmapdateien diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf index eaf71aee8f3..596364320d8 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Editor de delimitadores @@ -27,6 +32,16 @@ Superior + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Ya está cargado el diseñador. @@ -202,6 +217,21 @@ Vista previa seleccionada + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. El almacén de serialización está cerrado. No se pueden agregar nuevos objetos a un almacén cerrado. @@ -354,6 +384,11 @@ Alinear {0} componentes a la cuadrícula + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Cortar {0} componentes @@ -376,11 +411,21 @@ Dar formato a {0} componentes (espaciado) + + Lock {0} components + Lock {0} components + + Paste components Pegar componentes + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Ajustar el tamaño de {0} componentes @@ -601,11 +646,21 @@ Error al establecer el valor '{0}' en la propiedad '{1}'. Detalles: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Debe ejecutarse correctamente la llamada a BeginDrag antes de llamar a las funciones de arrastre. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Control heredado @@ -800,6 +855,11 @@ Controla si los diseñadores deberían utilizar líneas de ajuste. Si es true, las líneas de ajuste se utilizarán como guías. Si es false, se utilizarán líneas de cuadrícula. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Acoplar en contenedor primario @@ -855,6 +915,11 @@ Arrastrar {0} componentes + + Drop components + Drop components + + Move {0} Mover {0} @@ -880,6 +945,16 @@ Ajustar el tamaño de {0} componentes + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. El evento {0} espera un tipo de argumento de {1}. @@ -910,6 +985,11 @@ El proveedor extensor {0} ya se ha agregado como extensor. Si agrega otro habría propiedades duplicadas. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Cuadro de diálogo de formato de cadenas @@ -940,6 +1020,16 @@ Editor de la colección Imágenes + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Solo lectura @@ -960,6 +1050,21 @@ '{1}' no es un valor válido para '{0}'. '{0}' debería estar entre {2} y {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Cancelar @@ -980,6 +1085,81 @@ Aceptar + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ El servicio {0} es obligatorio pero no se pudo encontrar. Si ha quitado este servicio, asegúrese de proporcionar un reemplazo. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. La máscara no está llena. @@ -1105,6 +1290,16 @@ Ya hay un controlador de comandos del comando de menú '{0}'. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Presione Ctrl+Entrar para aceptar el texto. Este objeto o método no se implementa por diseño. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Winforms Designer no se admite en esta plataforma. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Presione Ctrl+Entrar para aceptar el texto. (Se desconoce) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &Acerca de... @@ -1667,6 +1887,11 @@ Presione Ctrl+Entrar para aceptar el texto. Centrado vertical de {0} componentes + + - Read Only + - Read Only + + Bitmap files Archivos de mapas de bits diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf index 6cda8e0fc7d..9b4444da252 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Éditeur d'ancres @@ -27,6 +32,16 @@ Haut + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Le concepteur est déjà chargé. @@ -202,6 +217,21 @@ Aperçu sélectionné + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Le magasin de sérialisation est fermé. Impossible d'ajouter de nouveaux objets à un magasin fermé. @@ -354,6 +384,11 @@ Aligner les composants {0} sur la grille + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Couper les composants {0} @@ -376,11 +411,21 @@ Mettre en forme les composants {0} (espacement) + + Lock {0} components + Lock {0} components + + Paste components Coller les composants + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Redimensionner les composants {0} @@ -601,11 +646,21 @@ Erreur lors de l'affectation de la valeur '{0}' à la propriété '{1}'. Détails : {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. L'appel à BeginDrag doit avoir lieu avant l'appel aux fonctions de glissement. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Contrôle hérité @@ -800,6 +855,11 @@ Contrôle si les concepteurs doivent utiliser des lignes d'alignement. Si tel est le cas, les lignes d'alignement sont utilisées à titre de guides. Dans le cas contraire, un quadrillage est utilisé. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Ancrer dans le conteneur parent @@ -855,6 +915,11 @@ Faire glisser les composants {0} + + Drop components + Drop components + + Move {0} Déplacer {0} @@ -880,6 +945,16 @@ Redimensionner les composants {0} + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. L'événement {0} attend un type d'argument de {1}. @@ -910,6 +985,11 @@ Le fournisseur d'extendeurs {0} a déjà été ajouté en tant qu'extendeur. L'ajout d'un autre créerait des propriétés en double. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Boîte de dialogue Chaîne de format @@ -940,6 +1020,16 @@ Éditeur de collections Images + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only En lecture seule @@ -960,6 +1050,21 @@ '{1}' n'est pas une valeur valide pour '{0}'. '{0}' doit être compris entre {2} et {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Annuler @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ Le service {0} requis est introuvable. Si vous avez supprimé ce service, assurez-vous qu'un service de remplacement est fourni. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. Le masque n'est pas plein. @@ -1105,6 +1290,16 @@ Il existe déjà un gestionnaire de commandes pour la commande de menu '{0}'. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Appuyez sur Ctrl+Entrée pour valider le texte. Cette méthode ou cet objet n'est pas implémenté(e) dans la conception. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Le concepteur WinForms n'est pas pris en charge sur cette plateforme. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Appuyez sur Ctrl+Entrée pour valider le texte. (Inconnu) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &À propos de... @@ -1667,6 +1887,11 @@ Appuyez sur Ctrl+Entrée pour valider le texte. Centre vertical des composants {0} + + - Read Only + - Read Only + + Bitmap files Fichiers bitmap diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf index 83232d06296..d6c16f1608d 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Ancoraggio dell'editor. @@ -27,6 +32,16 @@ All'inizio + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Finestra di progettazione già caricata. @@ -202,6 +217,21 @@ Anteprima selezionata + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. L'archivio di serializzazione è chiuso. Non è possibile aggiungere nuovi oggetti a un archivio chiuso. @@ -354,6 +384,11 @@ Allinea {0} componenti alla griglia + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Taglia {0} componenti @@ -376,11 +411,21 @@ Formatta {0} componenti (spaziatura) + + Lock {0} components + Lock {0} components + + Paste components Incolla componenti + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Ridimensiona {0} componenti @@ -601,11 +646,21 @@ Errore durante l'impostazione del valore '{0}' sulla proprietà '{1}'. Dettagli: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Prima di chiamare le funzioni di trascinamento, è necessario eseguire correttamente una chiamata a BeginDrag. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Controllo ereditato @@ -800,6 +855,11 @@ Controlla se nelle finestre di progettazione devono essere utilizzate guide di allineamento. Se è true, le guide di allineamento verranno utilizzate come riferimento. In caso contrario, verranno utilizzare le linee della griglia. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Ancora nel contenitore padre @@ -855,6 +915,11 @@ Trascina componenti {0} + + Drop components + Drop components + + Move {0} Sposta {0} @@ -880,6 +945,16 @@ Ridimensiona {0} componenti + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. Per l'evento {0} è previsto un argomento di tipo {1}. @@ -910,6 +985,11 @@ Il provider di Extender {0} è già stato aggiunto come Extender. Aggiungendone un altro si creerebbero proprietà duplicate. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Finestra di dialogo Stringa di formato @@ -940,6 +1020,16 @@ Editor della raccolta Images + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Sola lettura @@ -960,6 +1050,21 @@ '{1}' non è un valore valido per '{0}'. '{0}' deve essere compreso tra {2} e {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Annulla @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ Impossibile trovare il servizio richiesto {0}. Se tale servizio è stato rimosso, sarà necessario sostituirlo. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. La maschera non è piena. @@ -1105,6 +1290,16 @@ Esiste già un gestore comando per il comando di menu '{0}'. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Per accettare testo premere CTRL+INVIO. Questo metodo/oggetto non è implementato per impostazione predefinita. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Winforms Designer non è supportato in questa piattaforma. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Per accettare testo premere CTRL+INVIO. (Sconosciuto) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &Informazioni su... @@ -1667,6 +1887,11 @@ Per accettare testo premere CTRL+INVIO. Centro verticale di {0} componente/i + + - Read Only + - Read Only + + Bitmap files File bitmap diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf index 3d0e7d79cfc..662ee2181e0 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor アンカー エディター @@ -27,6 +32,16 @@ + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. デザイナーは既に読み込まれています。 @@ -202,6 +217,21 @@ 選択されたプレビュー + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. シリアル化ストアは閉じられています。 閉じられたストアに新しいオブジェクトを追加することはできません。 @@ -354,6 +384,11 @@ {0} コンポーネントをグリッドに合わせる + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components {0} コンポーネントを切り取る @@ -376,11 +411,21 @@ {0} コンポーネントのフォーマット (スペース) + + Lock {0} components + Lock {0} components + + Paste components コンポーネントの貼り付け + + Send {0} controls to back + Send {0} controls to back + + Size {0} components {0} コンポーネントのサイズを変更 @@ -601,11 +646,21 @@ 値 '{0}' をプロパティ '{1}' に設定中にエラーが発生しました。 詳細情報:{2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. ドラッグ関数を呼び出す前に BeginDrag への呼び出しを完了しなければなりません。 + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control 継承されたコントロール @@ -800,6 +855,11 @@ デザイナーでスナップ線を使用するかどうかを制御します。 true の場合、スナップ線がガイドとして使用されます。 false の場合、グリッド線が使用されます。 + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container 親コンテナーにドッキングする @@ -855,6 +915,11 @@ {0} 個のコンポーネントをドラッグする + + Drop components + Drop components + + Move {0} {0} の移動 @@ -880,6 +945,16 @@ {0} コンポーネントのサイズを変更 + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. イベント {0} には {1} の引数型が必要です。 @@ -910,6 +985,11 @@ 拡張プロバイダー {0} はエクステンダーとして既に追加されています。 もう 1 つ追加すると、プロパティが重複します。 + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog 書式文字列のダイアログ @@ -940,6 +1020,16 @@ イメージ コレクション エディター + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only 読み取り専用 @@ -960,6 +1050,21 @@ '{1}' は '{0}' に有効な値ではありません。'{0}' は {2} と {3} の間でなければなりません。 + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel キャンセル @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ サービス {0} が必要ですが、見つかりませんでした。 このサービスを削除した場合、必ず置換したサービスを指定してください。 + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. マスクが完全ではありません。 @@ -1105,6 +1290,16 @@ メニュー コマンド '{0}' のコマンド ハンドラーが既に存在します。 + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Press Ctrl+Enter to accept Text. このメソッド/オブジェクトはデザインによって実装されていません。 + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Windows フォーム デザイナーは、このプラットフォームではサポートされていません。 + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Press Ctrl+Enter to accept Text. (不明) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... バージョン情報(&A)... @@ -1667,6 +1887,11 @@ Press Ctrl+Enter to accept Text. {0} コンポーネントの上下方向の中心 + + - Read Only + - Read Only + + Bitmap files ビットマップ ファイル diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf index 2b8ea584bd3..16a1296f5b6 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor 앵커 편집기 @@ -27,6 +32,16 @@ 위쪽 + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. 디자이너가 이미 로드되었습니다. @@ -202,6 +217,21 @@ 선택된 미리 보기 + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Serialization 저장소가 닫혀 있습니다. 닫힌 저장소에는 새 개체를 추가할 수 없습니다. @@ -354,6 +384,11 @@ {0}개 구성 요소를 모눈에 맞춤 + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components {0}개 구성 요소 잘라내기 @@ -376,11 +411,21 @@ {0} 구성 요소에 서식 지정(간격) + + Lock {0} components + Lock {0} components + + Paste components 구성 요소 붙여넣기 + + Send {0} controls to back + Send {0} controls to back + + Size {0} components {0}개 구성 요소 크기 조정 @@ -601,11 +646,21 @@ '{0}' 값을 '{1}' 속성에 설정하는 동안 오류가 발생했습니다. 자세한 정보: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. drag 함수를 호출하기 전에 먼저 BeginDrag를 호출해야 합니다. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control 상속된 컨트롤 @@ -800,6 +855,11 @@ 디자이너에서 맞춤선을 사용할지 여부를 제어합니다. true이면 맞춤선이 안내선으로 사용되고 false이면 모눈선이 사용됩니다. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container 부모 컨테이너에서 도킹 @@ -855,6 +915,11 @@ {0} 구성 요소 끌어 놓기 + + Drop components + Drop components + + Move {0} {0} 이동 @@ -880,6 +945,16 @@ {0}개 구성 요소 크기 조정 + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. {0} 이벤트에는 형식이 {1}인 인수가 필요합니다. @@ -910,6 +985,11 @@ Extender 공급자 {0}이(가) Extender로 이미 추가되었습니다. 다른 공급자를 추가하면 속성이 중복됩니다. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog 서식 문자열 대화 상자 @@ -940,6 +1020,16 @@ 이미지 컬렉션 편집기 + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only 읽기 전용 @@ -960,6 +1050,21 @@ '{1}'은(는) '{0}'에 사용할 수 없는 값입니다. '{0}'은(는) {2}에서 {3} 사이에 있어야 합니다. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel 취소 @@ -980,6 +1085,81 @@ 확인 + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ 필요한 {0} 서비스를 찾을 수 없습니다. 이 서비스를 제거한 경우에는 대체할 서비스를 제공해야 합니다. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. 마스크가 완전하지 않습니다. @@ -1105,6 +1290,16 @@ 메뉴 명령 '{0}'에 대한 명령 처리기가 이미 있습니다. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Press Ctrl+Enter to accept Text. 이 메서드/개체는 의도적으로 구현되지 않습니다. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Winforms 디자이너는 이 플랫폼에서 지원되지 않습니다. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Press Ctrl+Enter to accept Text. (알 수 없음) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... 정보(&A)... @@ -1667,6 +1887,11 @@ Press Ctrl+Enter to accept Text. {0}개 구성 요소를 세로로 가운데에 맞춥니다. + + - Read Only + - Read Only + + Bitmap files 비트맵 파일 diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf index bda1a41692a..be88e071527 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Zakotwicz edytor @@ -27,6 +32,16 @@ Do góry + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Projektant został już załadowany. @@ -202,6 +217,21 @@ Wybrany podgląd + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Magazyn serializacji jest zamknięty. Do zamkniętego magazynu nie można dodawać nowych obiektów. @@ -354,6 +384,11 @@ Wyrównaj do siatki {0} składników + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Wytnij {0} składników @@ -376,11 +411,21 @@ Formatuj {0} składników (odstępy) + + Lock {0} components + Lock {0} components + + Paste components Wklej składniki + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Zmień rozmiar {0} składników @@ -601,11 +646,21 @@ Wystąpił błąd podczas ustawiania właściwości '{1}' wartości '{0}'. Szczegóły: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Wywołanie elementu BeginDrag musi się zakończyć powodzeniem przed wywołaniem funkcji przeciągania. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Formant dziedziczony @@ -800,6 +855,11 @@ Określa, czy projektanci mają używać linii przyciągania. Jeśli tak, linie przyciągania będą używane jako prowadnice. Jeśli nie, będą używane linie siatki. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Zadokuj w kontenerze nadrzędnym @@ -855,6 +915,11 @@ Przeciągnij {0} składników + + Drop components + Drop components + + Move {0} Przenieś element {0} @@ -880,6 +945,16 @@ Zmień rozmiar {0} składników + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. Zdarzenie {0} oczekuje typu argumentu {1}. @@ -910,6 +985,11 @@ Dostawca rozszerzony {0} został już dodany jako rozszerzenie. Dodanie kolejnego dostawcy spowodowałoby zduplikowanie właściwości. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Okno dialogowe formatu ciągu @@ -940,6 +1020,16 @@ Edytor kolekcji obrazów + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Tylko do odczytu @@ -960,6 +1050,21 @@ '{1}' nie jest prawidłową wartością dla '{0}'. Wartość '{0}' powinna należeć do zakresu od {2} do {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Anuluj @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ Usługa {0} jest wymagana, ale nie można jej znaleźć. Jeśli została usunięta, pamiętaj o zapewnieniu jej zamiennika. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. Maska nie jest pełna. @@ -1105,6 +1290,16 @@ Istnieje już moduł obsługi polecenia menu '{0}'. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. Ta metoda/obiekt nie jest domyślnie implementowana. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Projektant formularzy systemu Windows nie jest obsługiwany na tej platformie. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. (Nieznany) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... Inform&acje o... @@ -1667,6 +1887,11 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. Wyśrodkowanie w pionie {0} składników + + - Read Only + - Read Only + + Bitmap files Pliki map bitowych diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf index 8f37dd5f10d..bafc366bf8a 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Editor de Âncora @@ -27,6 +32,16 @@ Superior + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. O designer já está carregado. @@ -202,6 +217,21 @@ Visualização Selecionada + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. O repositório de serialização está fechado. Não é possível adicionar novos objetos a um repositório fechado. @@ -354,6 +384,11 @@ Alinhar {0} componentes à grade + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Recortar {0} componentes @@ -376,11 +411,21 @@ Formatar {0} componentes (espaçamento) + + Lock {0} components + Lock {0} components + + Paste components Colar componentes + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Dimensionar componentes {0} @@ -601,11 +646,21 @@ Erro ao definir o valor '{0}' para a propriedade '{1}'. Detalhes: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Chamada para BeginDrag deve obter êxito para poder chamar as funções arrastadas. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Controle herdado @@ -800,6 +855,11 @@ Controla se os designers devem usar linhas de ajuste. Se verdadeiro, essas linhas serão usadas como guias. Se falso, as linhas de grade serão usadas em vez das linhas de ajuste. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Encaixar no Contêiner Pai @@ -855,6 +915,11 @@ Arrastar {0} componentes + + Drop components + Drop components + + Move {0} Mover {0} @@ -880,6 +945,16 @@ Dimensionar componentes {0} + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. O evento {0} espera um tipo de argumento {1}. @@ -910,6 +985,11 @@ O provedor do extensor {0} já foi adicionado como extensor. A inclusão de outro resultará em propriedades duplicadas. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Caixa de Diálogo Formatar Cadeia de Caracteres @@ -940,6 +1020,16 @@ Editor de Coleção de Imagens + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Somente Leitura @@ -960,6 +1050,21 @@ '{1}' não é um valor válido para '{0}'. '{0}' deve estar entre {2} e {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Cancelar @@ -980,6 +1085,81 @@ OK + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ O serviço {0} é necessário, mas não foi encontrado. Se você tiver removido esse serviço, forneça um substituto. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. A máscara não está completa. @@ -1105,6 +1290,16 @@ Já existe um manipulador de comando para o comando de menu '{0}'. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Pressione Ctrl+Enter para aceitar Texto. Este método/objeto não é implementado por design. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. O Designer de Formulários do Windows não é compatível com esta plataforma. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Pressione Ctrl+Enter para aceitar Texto. (Desconhecido) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &Sobre... @@ -1667,6 +1887,11 @@ Pressione Ctrl+Enter para aceitar Texto. Centro vertical do(s) componente(s) {0} + + - Read Only + - Read Only + + Bitmap files Arquivos de bitmap diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf index 3773fbb268a..ac11166e638 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Редактор привязки @@ -27,6 +32,16 @@ Сверху + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Конструктор уже загружен. @@ -202,6 +217,21 @@ Выборочный предварительный просмотр + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Хранилище сериализованных объектов закрыто. Добавление новых объектов в закрытое хранилище невозможно. @@ -354,6 +384,11 @@ Выровнять {0} компонентов по сетке + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components Вырезать {0} компонентов @@ -376,11 +411,21 @@ Форматировать {0} компонентов (с интервалом) + + Lock {0} components + Lock {0} components + + Paste components Вставить компоненты + + Send {0} controls to back + Send {0} controls to back + + Size {0} components Изменить размер {0} компонентов @@ -601,11 +646,21 @@ Ошибка при установке значения '{0}' для свойства '{1}'. Подробно: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Перед вызовом функций перетаскивания необходимо, чтобы успешно завершился вызов функции BeginDrag. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Унаследованный элемент управления @@ -800,6 +855,11 @@ Определяет, будут ли конструкторы использовать линии выравнивания. Если задано значение true, линии выравнивания используются в качестве направляющих. В случае false используются линии сетки. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Закрепить в родительском контейнере @@ -855,6 +915,11 @@ Перетащить {0} компонентов + + Drop components + Drop components + + Move {0} Переместить {0} @@ -880,6 +945,16 @@ Изменить размер {0} компонентов + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. Событие {0} ожидает тип аргумента {1}. @@ -910,6 +985,11 @@ Поставщик расширений {0} уже добавлен в качестве расширения. Добавление другого поставщика приведет к появлению повторяющихся свойств. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Диалог формата строки @@ -940,6 +1020,16 @@ Редактор коллекции изображений + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Только для чтения @@ -960,6 +1050,21 @@ '{1}' не является допустимым значением для '{0}'. Значение '{0}' должно лежать в диапазоне от {2} до {3}. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel Отмена @@ -980,6 +1085,81 @@ ОК + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ Требуется служба {0}, но она не найдена. Если вы перенесли эту службу, убедитесь в том, что обеспечили замену. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. Маска не полная. @@ -1105,6 +1290,16 @@ Уже существует дескриптор команд для команды меню '{0}'. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Press Ctrl+Enter to accept Text. Этот метод или объект не реализован намеренно. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Конструктор Windows Forms не поддерживается на этой платформе. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Press Ctrl+Enter to accept Text. (Неизвестный) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &О программе... @@ -1667,6 +1887,11 @@ Press Ctrl+Enter to accept Text. Центр {0} компонентов по вертикали + + - Read Only + - Read Only + + Bitmap files Файлы точечных рисунков diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf index 3839df8a4a3..2e552b50990 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor Bağlantı Düzenleyicisi @@ -27,6 +32,16 @@ Üst + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. Tasarımcı zaten yüklendi. @@ -202,6 +217,21 @@ Seçili Önizleme + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. Serileştirme deposu kapalı. Kapalı depoya yeni nesneler eklenemez. @@ -354,6 +384,11 @@ {0} bileşeni kılavuza göre hizala + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components {0} bileşeni kes @@ -376,11 +411,21 @@ {0} bileşeni biçimlendir (aralık) + + Lock {0} components + Lock {0} components + + Paste components Bileşenleri yapıştır + + Send {0} controls to back + Send {0} controls to back + + Size {0} components {0} bileşeni boyutlandır @@ -601,11 +646,21 @@ '{0}' değerini '{1}' özelliğine ayarlama hatası. Ayrıntılar: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. Sürükleme işlevleri çağrılmadan önce Call to BeginDrag başarıyla tamamlanmalıdır. + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control Devralınan denetim @@ -800,6 +855,11 @@ Tasarımcıların dayama çizgileri kullanıp kullanmayacağını denetler. True ise, dayama çizgileri kılavuz olarak kullanılır. False ise, kılavuz çizgileri kullanılır. + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container Ana Kapsayıcıda Yerleştir @@ -855,6 +915,11 @@ {0} bileşeni sürükle + + Drop components + Drop components + + Move {0} {0} öğesini taşı @@ -880,6 +945,16 @@ {0} bileşeni boyutlandır + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. {0} olayı {1} türünde bir bağımsız değişken bekliyor. @@ -910,6 +985,11 @@ {0} uzatma sağlayıcısı zaten bir uzatma olarak eklendi. Bir uzatma daha eklemek yinelenen özelliklere neden olabilir. + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog Dizeyi Biçimlendir İletişim Kutusu @@ -940,6 +1020,16 @@ Görüntüler Koleksiyonu Düzenleyicisi + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only Salt Okunur @@ -960,6 +1050,21 @@ '{1}' değeri '{0}' öğesi için geçerli değil. '{0}' değeri {2} ile {3} arasında olmalıdır. + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel İptal @@ -980,6 +1085,81 @@ Tamam + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ {0} hizmeti gerekiyordu ancak bulunamadı. Bu hizmeti kaldırdıysanız bunun yerine geçecek bir hizmet sağladığınızdan emin olun. + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. Maske dolu değil. @@ -1105,6 +1290,16 @@ '{0}' menü komutu için zaten bir komut işleyicisi var. + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. Tasarım gereği, bu metot/nesne uygulanmadı. + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. Winforms Tasarımcısı bu platformda desteklenmiyor. + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. (Bilinmiyor) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... &Hakkında... @@ -1667,6 +1887,11 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. {0} bileşenlerinin dikey ortası + + - Read Only + - Read Only + + Bitmap files Bit eşlem dosyaları diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf index 0eab965db03..4ac855bc028 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor 定位点编辑器 @@ -27,6 +32,16 @@ + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. 已加载设计器。 @@ -202,6 +217,21 @@ 所选预览 + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. 序列化存储区已关闭。新对象无法添加到已关闭的存储区中。 @@ -354,6 +384,11 @@ 将 {0} 组件与网格对齐 + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components 剪切 {0} 组件 @@ -376,11 +411,21 @@ 格式化 {0} 组件(间距) + + Lock {0} components + Lock {0} components + + Paste components 粘贴组件 + + Send {0} controls to back + Send {0} controls to back + + Size {0} components 调整 {0} 组件的大小 @@ -601,11 +646,21 @@ 将值“{0}”设置为属性“{1}”时出错。详细信息: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. 对 BeginDrag 的调用必须成功,才能调用拖动函数。 + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control 继承的控件 @@ -800,6 +855,11 @@ 控制设计器是否应使用对齐线。如果设置为 True,则使用对齐线作为参考线。如果设置为 False,则使用网格线。 + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container 在父容器中停靠 @@ -855,6 +915,11 @@ 拖动 {0} 组件 + + Drop components + Drop components + + Move {0} 移动 {0} @@ -880,6 +945,16 @@ 调整 {0} 组件的大小 + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. 事件 {0} 要求参数类型为 {1}。 @@ -910,6 +985,11 @@ 扩展程序提供程序 {0} 已添加为扩展程序。添加其他扩展程序提供程序将导致重复的属性。 + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog 格式字符串对话框 @@ -940,6 +1020,16 @@ 图像集合编辑器 + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only 只读 @@ -960,6 +1050,21 @@ “{1}”不是“{0}”的有效值。“{0}”应介于 {2} 和 {3} 之间。 + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel 取消 @@ -980,6 +1085,81 @@ 确定 + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ 未能找到所需服务 {0}。如果您移除了此服务,请确保提供替代服务。 + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. 掩码未满。 @@ -1105,6 +1290,16 @@ 菜单命令“{0}”已经有一个命令处理程序。 + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Press Ctrl+Enter to accept Text. 未按设计实现此方法/对象。 + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. 此平台上不支持 Winforms Designer。 + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Press Ctrl+Enter to accept Text. (未知) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... 关于(&A)... @@ -1667,6 +1887,11 @@ Press Ctrl+Enter to accept Text. {0} 组件的垂直中心 + + - Read Only + - Read Only + + Bitmap files 位图文件 diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf index 2e5f4db8ea0..4b8bdc2d73a 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf @@ -2,6 +2,11 @@ + + Could not create ActiveX control '{0}' because it is not properly registered. + Could not create ActiveX control '{0}' because it is not properly registered. + + Anchor Editor 錨定編輯器 @@ -27,6 +32,16 @@ + + Failed to import the ActiveX control. Please ensure it is properly registered. + Failed to import the ActiveX control. Please ensure it is properly registered. + + + + ActiveX Control + ActiveX Control + + The designer is already loaded. 已經載入設計工具。 @@ -202,6 +217,21 @@ 已選取預覽 + + Select the image displayed in the PictureBox + Select the image displayed in the PictureBox + + + + Choose Image... + Choose Image... + + + + Requested Clipboard operation did not succeed. + Requested Clipboard operation did not succeed. + + The serialization store is closed. New objects cannot be added to a closed store. 序列化存放區已關閉。新物件無法加入已關閉的存放區。 @@ -354,6 +384,11 @@ 將 {0} 元件對齊格線 + + Bring {0} controls to front + Bring {0} controls to front + + Cut {0} Components 剪下 {0} 元件 @@ -376,11 +411,21 @@ 格式化 {0} 元件 (間隔) + + Lock {0} components + Lock {0} components + + Paste components 貼上元件 + + Send {0} controls to back + Send {0} controls to back + + Size {0} components 調整 {0} 元件的大小 @@ -601,11 +646,21 @@ 將值 '{0}' 設定為屬性 '{1}' 時發生錯誤。詳細資料: {2} + + Creating components in tool '{0}' + Creating components in tool '{0}' + + Call to BeginDrag must succeed before calling drag functions. 呼叫拖曳函式之前必須先成功呼叫 BeginDrag。 + + Cannot add component of type '{0}' to container of type '{1}' + Cannot add component of type '{0}' to container of type '{1}' + + Inherited control 繼承的控制項 @@ -800,6 +855,11 @@ 控制設計工具是否應使用對齊線。如果為 true,就會使用對齊線來對齊。如果為 false,就會使用格線。 + + Indicates the name used in code to identify the object. + Indicates the name used in code to identify the object. + + Dock in Parent Container 停駐於父容器中 @@ -855,6 +915,11 @@ 拖曳 {0} 個元件 + + Drop components + Drop components + + Move {0} 移動 {0} @@ -880,6 +945,16 @@ 調整 {0} 元件的大小 + + Opens the Lines collection editor + Opens the Lines collection editor + + + + Edit Text Lines... + Edit Text Lines... + + The event {0} expects an argument type of {1}. 事件 {0} 的引數類型必須為 {1}。 @@ -910,6 +985,11 @@ 已經將擴充性提供者 {0} 加入做為擴充項。加入另一個會產生重複的屬性。 + + Failed to create component '{0}'. The error message follows:\r\n '{1}' + Failed to create component '{0}'. The error message follows:\r\n '{1}' + + Format String Dialog 格式字串對話方塊 @@ -940,6 +1020,16 @@ 影像集合編輯器 + + Chooses an ImageList to use with this TreeView + Chooses an ImageList to use with this TreeView + + + + ImageList: + ImageList: + + Read-Only 唯讀 @@ -960,6 +1050,21 @@ '{1}' 不是 '{0}' 的有效值。'{0}' 應該介於 {2} 與 {3} 之間。 + + Opens the Nodes collection editor + Opens the Nodes collection editor + + + + Edit Nodes... + Edit Nodes... + + + + Items + Items + + Cancel 取消 @@ -980,6 +1085,81 @@ 確定 + + Links + Links + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Opens the Columns collection editor + Opens the Columns collection editor + + + + Edit Columns... + Edit Columns... + + + + Opens the Groups collection editor + Opens the Groups collection editor + + + + Edit Groups... + Edit Groups... + + + + Opens the Items collection editor + Opens the Items collection editor + + + + Edit Items... + Edit Items... + + + + Selects an ImageList to use with LargeIcon mode + Selects an ImageList to use with LargeIcon mode + + + + Large ImageList: + Large ImageList: + + + + Selects an ImageList to use with SmallIcon mode + Selects an ImageList to use with SmallIcon mode + + + + Small ImageList: + Small ImageList: + + + + Changes the type of View this ListView shows + Changes the type of View this ListView shows + + + + View: + View: + + ListViewSubItem ListViewSubItem @@ -995,6 +1175,11 @@ 找不到必要的服務 {0}。如果您已移除這項服務,請務必提供替代的服務。 + + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + Components cannot be added in localization mode. Select (Default) in the Language property to return to the default form and add components. + + Mask is not full. 遮罩輸入不完整。 @@ -1105,6 +1290,16 @@ 功能表命令 '{0}' 已經有命令處理常式。 + + Puts the TextBox in a mode where it can display multiple lines of text + Puts the TextBox in a mode where it can display multiple lines of text + + + + MultiLine + MultiLine + + Press Enter to begin a new line. Press Ctrl+Enter to accept Text. @@ -1127,11 +1322,26 @@ Press Ctrl+Enter to accept Text. 此方法/物件並非由設計實作。 + + Place existing controls in new containerDetermines the size of the positioning grid. + Place existing controls in new containerDetermines the size of the positioning grid. + + + + Place existing controls in new container, '{0}'. + Place existing controls in new container, '{0}'. + + Winforms Designer is not supported on this platform. 此平台不支援 WinForms Designer。 + + Properties + Properties + + RTL_False RTL_False @@ -1267,6 +1477,16 @@ Press Ctrl+Enter to accept Text. (未知) + + Changes the sizing mode of the Image displayed in the PictureBox + Changes the sizing mode of the Image displayed in the PictureBox + + + + Size Mode: + Size Mode: + + &About... 關於(&A)... @@ -1667,6 +1887,11 @@ Press Ctrl+Enter to accept Text. {0} 元件垂直置中 + + - Read Only + - Read Only + + Bitmap files 點陣圖檔 diff --git a/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs b/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs index 6b68caacbb2..88cc95c1676 100644 --- a/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs +++ b/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs @@ -9,13 +9,11 @@ namespace System.Windows.Forms [AttributeUsage(AttributeTargets.All)] internal sealed class SRCategoryAttribute : CategoryAttribute { - public SRCategoryAttribute(string category) : base(category) + public SRCategoryAttribute(string category) + : base(category) { } - protected override string GetLocalizedString(string value) - { - return value; - } + protected override string GetLocalizedString(string value) => SR.GetResourceString(value); } } diff --git a/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs b/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs index aac388f78c0..33fa7c2112c 100644 --- a/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs +++ b/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs @@ -11,7 +11,8 @@ internal sealed class SRDescriptionAttribute : DescriptionAttribute { private bool replaced; - public SRDescriptionAttribute(string description) : base(description) + public SRDescriptionAttribute(string description) + : base(description) { } @@ -22,7 +23,7 @@ public override string Description if (!replaced) { replaced = true; - DescriptionValue = base.Description; + DescriptionValue = SR.GetResourceString(base.Description); } return base.Description; diff --git a/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs b/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs index 1e96e300004..ea6f11831da 100644 --- a/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs +++ b/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs @@ -11,7 +11,8 @@ internal sealed class SRDisplayNameAttribute : DisplayNameAttribute { private bool replaced; - public SRDisplayNameAttribute(string displayName) : base(displayName) + public SRDisplayNameAttribute(string displayName) + : base(displayName) { } @@ -22,7 +23,7 @@ public override string DisplayName if (!replaced) { replaced = true; - DisplayNameValue = base.DisplayName; + DisplayNameValue = SR.GetResourceString(base.DisplayName); } return base.DisplayName; diff --git a/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj b/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj index 34c43a4e8ab..116c6e6a71f 100644 --- a/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj +++ b/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj @@ -100,7 +100,7 @@ System.Windows.Forms.Design.InheritedGlyph - + System.Windows.Forms.Design.Behavior.MoverGlyph diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs index 13cb1f6ed5b..913e0f7df1d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs @@ -10,7 +10,7 @@ namespace System.ComponentModel.Design public class ArrayEditor : CollectionEditor { /// - /// Initializes a new instance of + /// Initializes a new instance of /// using the specified type for the array. /// public ArrayEditor(Type type) : base(type) diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs index 7058c0cb582..94261783a06 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs @@ -164,7 +164,7 @@ private void DrawAddress(Graphics g, int startLine, int line) } /// - /// Draws the client background and frames + /// Draws the client background and frames /// /// private void DrawClient(Graphics g) @@ -194,7 +194,7 @@ private void DrawClient(Graphics g) // Copied code here to preserve semantics. -- BrianGru, 10/3/2000 private static bool CharIsPrintable(char c) { - UnicodeCategory uc = Char.GetUnicodeCategory(c); + UnicodeCategory uc = char.GetUnicodeCategory(c); return (!(uc == UnicodeCategory.Control) || (uc == UnicodeCategory.Format) || (uc == UnicodeCategory.LineSeparator) || (uc == UnicodeCategory.ParagraphSeparator) || (uc == UnicodeCategory.OtherNotAssigned)); @@ -227,7 +227,7 @@ private void DrawDump(Graphics g, byte[] lineBuffer, int line) } /// - /// Draws the "HEX" part in the HEXDUMP view + /// Draws the "HEX" part in the HEXDUMP view /// /// private void DrawHex(Graphics g, byte[] lineBuffer, int line) @@ -278,9 +278,9 @@ private void DrawLines(Graphics g, int startLine, int linesCount) /// This is based on the following algorithm: /// * Count number of zeros, prinables and other characters in the half of the dataBuffer /// * Base on the following table establish the mode: - /// - 80% Characters or digits -> ANSI - /// - 80% Valid Unicode chars -> Unicode - /// - All other cases -> HEXDUMP + /// - 80% Characters or digits -> ANSI + /// - 80% Valid Unicode chars -> Unicode + /// - All other cases -> HEXDUMP /// Also for the buffer of size [0..5] it returns the HEXDUMP mode /// /// @@ -341,7 +341,7 @@ private DisplayMode GetAutoDisplayMode() for (int i = 0; i < size; i++) { char c = (char)_dataBuf[i]; //OK we do not care for Unicode now - if (Char.IsLetterOrDigit(c) || Char.IsWhiteSpace(c)) + if (char.IsLetterOrDigit(c) || char.IsWhiteSpace(c)) { printablesCount++; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs index 6d4d25b4f01..e389892b442 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs @@ -29,7 +29,7 @@ public class CollectionEditor : UITypeEditor private bool _ignoreChangingEvents; /// - /// Initializes a new instance of the class using the specified collection type. + /// Initializes a new instance of the class using the specified collection type. /// public CollectionEditor(Type type) { @@ -219,7 +219,7 @@ protected virtual void DestroyInstance(object instance) } /// - /// Edits the specified object value using the editor style provided by . + /// Edits the specified object value using the editor style provided by . /// public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { @@ -926,7 +926,7 @@ private int CalcItemWidth(Graphics g, ListItem item) int c = Math.Max(2, _listbox.Items.Count); SizeF sizeW = g.MeasureString(c.ToString(CultureInfo.CurrentCulture), _listbox.Font); - int charactersInNumber = ((int)(Math.Log((double)(c - 1)) / s_log10) + 1); + int charactersInNumber = ((int)(Math.Log(c - 1) / s_log10) + 1); int w = 4 + charactersInNumber * (Font.Height / 2); w = Math.Max(w, (int)Math.Ceiling(sizeW.Width)); @@ -1278,7 +1278,7 @@ private void Listbox_drawItem(object sender, DrawItemEventArgs e) // We add the +4 is a fudge factor... SizeF sizeW = g.MeasureString(maxC.ToString(CultureInfo.CurrentCulture), _listbox.Font); - int charactersInNumber = ((int)(Math.Log((double)maxC) / s_log10) + 1);// Luckily, this is never called if count = 0 + int charactersInNumber = ((int)(Math.Log(maxC) / s_log10) + 1);// Luckily, this is never called if count = 0 int w = 4 + charactersInNumber * (Font.Height / 2); w = Math.Max(w, (int)Math.Ceiling(sizeW.Width)); @@ -2224,7 +2224,7 @@ protected override void WndProc(ref Message m) } /// - /// The provides a modal dialog for editing the contents of a collection. + /// The provides a modal dialog for editing the contents of a collection. /// protected abstract class CollectionForm : Form { @@ -2237,7 +2237,7 @@ protected abstract class CollectionForm : Form private const short EditableNo = 2; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public CollectionForm(CollectionEditor editor) { @@ -2396,7 +2396,7 @@ protected internal virtual DialogResult ShowEditorDialog(IWindowsFormsEditorServ } /// - /// This is called when the value property in the has changed. + /// This is called when the value property in the has changed. /// protected abstract void OnEditValueChanged(); } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs index 2977eb68b38..676a4c100c3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs @@ -197,7 +197,7 @@ IDesigner ITreeDesigner.Parent } /// - /// Disposes of the resources (other than memory) used by the . + /// Disposes of the resources (other than memory) used by the . /// public void Dispose() { @@ -272,7 +272,7 @@ public virtual void DoDefaultAction() } eventChanged = true; - handler = ebs.CreateUniqueMethodName((IComponent)comp, defaultEvent); + handler = ebs.CreateUniqueMethodName(comp, defaultEvent); } else { @@ -336,7 +336,7 @@ internal bool IsRootDesigner } /// - /// Initializes a new instance of the class using the specified component. + /// Initializes a new instance of the class using the specified component. /// public virtual void Initialize(IComponent component) { @@ -384,7 +384,7 @@ private void InitializeInheritedProperties() PropertyDescriptor prop = values[i]; // Skip some properties - if (object.Equals(prop.Attributes[typeof(DesignOnlyAttribute)], DesignOnlyAttribute.Yes)) + if (Equals(prop.Attributes[typeof(DesignOnlyAttribute)], DesignOnlyAttribute.Yes)) { continue; } @@ -416,7 +416,7 @@ protected InheritanceAttribute InvokeGetInheritanceAttribute(ComponentDesigner t => toInvoke?.InheritanceAttribute; /// - /// Disposes of the resources (other than memory) used by the . + /// Disposes of the resources (other than memory) used by the . /// protected virtual void Dispose(bool disposing) { @@ -706,14 +706,14 @@ protected virtual void PreFilterProperties(IDictionary properties) } /// - /// Notifies the that this component has been changed. + /// Notifies the that this component has been changed. /// You only need to call this when you are affecting component properties directly and not through the MemberDescriptor's accessors. /// protected void RaiseComponentChanged(MemberDescriptor member, object oldValue, object newValue) => GetService()?.OnComponentChanged(Component, member, oldValue, newValue); /// - /// Notifies the that this component is + /// Notifies the that this component is /// about to be changed. You only need to call this when you are affecting component properties directly and /// not through the MemberDescriptor's accessors. /// diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs index 9050e0f2824..3212bc8c817 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs @@ -53,7 +53,7 @@ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext contex /// private class DateTimeUI : Control { - private MonthCalendar _monthCalendar = new DateTimeMonthCalendar(); + private readonly MonthCalendar _monthCalendar = new DateTimeMonthCalendar(); private object _value; private IWindowsFormsEditorService _edSvc; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs index 1b3e63bab01..3e04c7d5f83 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs @@ -449,8 +449,8 @@ private void OnSelectionChanged(object sender, EventArgs e) /// private sealed class MergedServiceProvider : IServiceProvider { - private IServiceProvider _primaryProvider; - private IServiceProvider _secondaryProvider; + private readonly IServiceProvider _primaryProvider; + private readonly IServiceProvider _secondaryProvider; internal MergedServiceProvider(IServiceProvider primaryProvider, IServiceProvider secondaryProvider) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs index 49781241aad..daaad253c46 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Runtime.InteropServices; - namespace System.ComponentModel.Design { /// diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs index 0ee53543712..9a8518c8234 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Runtime.InteropServices; - namespace System.ComponentModel.Design { /// diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs new file mode 100644 index 00000000000..f94e6cb49a1 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs @@ -0,0 +1,71 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class CheckBoxPropertyLine : PropertyLine + { + private CheckBox _checkBox; + + public CheckBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + : base(serviceProvider, actionPanel) + { + } + + protected override void AddControls(List controls) + { + _checkBox = new CheckBox + { + BackColor = Color.Transparent, + CheckAlign = ContentAlignment.MiddleLeft, + TextAlign = ContentAlignment.MiddleLeft, + UseMnemonic = false, + ForeColor = ActionPanel.LabelForeColor + }; + _checkBox.CheckedChanged += new EventHandler(OnCheckBoxCheckedChanged); + + controls.Add(_checkBox); + } + + public sealed override void Focus() => _checkBox.Focus(); + + public override Size LayoutControls(int top, int width, bool measureOnly) + { + Size checkBoxPreferredSize = _checkBox.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); + if (!measureOnly) + { + _checkBox.Location = new Point(LineLeftMargin, top + LineVerticalPadding / 2); + _checkBox.Size = checkBoxPreferredSize; + } + + return checkBoxPreferredSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); + } + + private void OnCheckBoxCheckedChanged(object sender, EventArgs e) + { + SetValue(_checkBox.Checked); + } + + protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) + { + _checkBox.Text = StripAmpersands(PropertyItem.DisplayName); + _checkBox.AccessibleDescription = PropertyItem.Description; + _checkBox.TabIndex = currentTabIndex++; + + toolTip.SetToolTip(_checkBox, PropertyItem.Description); + } + + protected override void OnValueChanged() + { + _checkBox.Checked = (bool)Value; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs new file mode 100644 index 00000000000..53e3b6778b1 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class DesignerActionPanelHeaderItem : DesignerActionItem + { + private readonly string _subtitle; + + public DesignerActionPanelHeaderItem(string title, string subtitle) : base(title, null, null) + { + _subtitle = subtitle; + } + + public string Subtitle + { + get => _subtitle; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs new file mode 100644 index 00000000000..7e65ea01769 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs @@ -0,0 +1,830 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Design; +using System.Drawing.Imaging; +using System.Globalization; +using System.Windows.Forms; +using System.Windows.Forms.Design; +using System.Windows.Forms.VisualStyles; +using static Interop; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class EditorPropertyLine : TextBoxPropertyLine, IWindowsFormsEditorService, IServiceProvider + { + private EditorButton _button; + private UITypeEditor _editor; + private bool _hasSwatch; + private Image _swatch; + private FlyoutDialog _dropDownHolder; + private bool _ignoreNextSelectChange; + private bool _ignoreDropDownValue; + + public EditorPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + : base(serviceProvider, actionPanel) + { + } + + private void ActivateDropDown() + { + if (_editor != null) + { + try + { + object newValue = _editor.EditValue(TypeDescriptorContext, this, Value); + SetValue(newValue); + } + catch (Exception ex) + { + ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorActivatingDropDown, ex.Message)); + } + } + else + { + ListBox listBox = new ListBox + { + BorderStyle = BorderStyle.None, + IntegralHeight = false, + Font = ActionPanel.Font + }; + listBox.SelectedIndexChanged += new EventHandler(OnListBoxSelectedIndexChanged); + listBox.KeyDown += new KeyEventHandler(OnListBoxKeyDown); + + TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); + if (standardValues != null) + { + foreach (object o in standardValues) + { + string newItem = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, CultureInfo.CurrentCulture, o); + listBox.Items.Add(newItem); + + if ((o != null) && o.Equals(Value)) + { + listBox.SelectedItem = newItem; + } + } + } + + // All measurement code borrowed from WinForms PropertyGridView.cs + int maxWidth = 0; + + // The listbox draws with GDI, not GDI+. So, we use a normal DC here. + using (var hdc = new User32.GetDcScope(listBox.Handle)) + { + using var hFont = new Gdi32.ObjectScope(listBox.Font.ToHFONT()); + using var fontSelection = new Gdi32.SelectObjectScope(hdc, hFont); + + var tm = new Gdi32.TEXTMETRICW(); + + if (listBox.Items.Count > 0) + { + foreach (string s in listBox.Items) + { + var textSize = new Size(); + Gdi32.GetTextExtentPoint32W(hdc, s, s.Length, ref textSize); + maxWidth = Math.Max(textSize.Width, maxWidth); + } + } + + Gdi32.GetTextMetricsW(hdc, ref tm); + + // border + padding + scrollbar + maxWidth += 2 + tm.tmMaxCharWidth + SystemInformation.VerticalScrollBarWidth; + + listBox.Height = Math.Max(tm.tmHeight + 2, Math.Min(ListBoxMaximumHeight, listBox.PreferredHeight)); + listBox.Width = Math.Max(maxWidth, EditRegionSize.Width); + _ignoreDropDownValue = false; + } + + try + { + ShowDropDown(listBox, SystemColors.ControlDark); + } + finally + { + listBox.SelectedIndexChanged -= new EventHandler(OnListBoxSelectedIndexChanged); + listBox.KeyDown -= new KeyEventHandler(OnListBoxKeyDown); + } + + if (!_ignoreDropDownValue) + { + if (listBox.SelectedItem != null) + { + SetValue(listBox.SelectedItem); + } + } + } + } + + protected override void AddControls(List controls) + { + base.AddControls(controls); + + _button = new EditorButton(); + _button.Click += new EventHandler(OnButtonClick); + _button.GotFocus += new EventHandler(OnButtonGotFocus); + + controls.Add(_button); + } + + private void CloseDropDown() + { + if (_dropDownHolder != null) + { + _dropDownHolder.Visible = false; + } + } + + protected override int GetTextBoxLeftPadding(int textBoxHeight) + { + if (_hasSwatch) + { + return base.GetTextBoxLeftPadding(textBoxHeight) + textBoxHeight + 2 * EditorLineSwatchPadding; + } + else + { + return base.GetTextBoxLeftPadding(textBoxHeight); + } + } + + protected override int GetTextBoxRightPadding(int textBoxHeight) => base.GetTextBoxRightPadding(textBoxHeight) + textBoxHeight + 2 * EditorLineButtonPadding; + + protected override bool IsReadOnly() + { + if (base.IsReadOnly()) + { + return true; + } + + // If we can't convert from string, we are readonly because we can't convert the user's input + bool converterReadOnly = !PropertyDescriptor.Converter.CanConvertFrom(TypeDescriptorContext, typeof(string)); + + // If standard values are supported and are exclusive, we are readonly + bool standardValuesExclusive = + PropertyDescriptor.Converter.GetStandardValuesSupported(TypeDescriptorContext) && + PropertyDescriptor.Converter.GetStandardValuesExclusive(TypeDescriptorContext); + + return converterReadOnly || standardValuesExclusive; + } + + public override Size LayoutControls(int top, int width, bool measureOnly) + { + Size size = base.LayoutControls(top, width, measureOnly); + + if (!measureOnly) + { + int buttonHeight = EditRegionSize.Height - EditorLineButtonPadding * 2 - 1; + _button.Location = new Point(EditRegionLocation.X + EditRegionSize.Width - buttonHeight - EditorLineButtonPadding, EditRegionLocation.Y + EditorLineButtonPadding + 1); + _button.Size = new Size(buttonHeight, buttonHeight); + } + + return size; + } + + private void OnButtonClick(object sender, EventArgs e) + { + ActivateDropDown(); + } + + private void OnButtonGotFocus(object sender, EventArgs e) + { + if (!_button.Ellipsis) + { + Focus(); + } + } + + private void OnListBoxKeyDown(object sender, KeyEventArgs e) + { + // Always respect the enter key and F4 + if (e.KeyData == Keys.Enter) + { + _ignoreNextSelectChange = false; + CloseDropDown(); + e.Handled = true; + } + else + { + // Ignore selected index change events when the user is navigating via the keyboard + _ignoreNextSelectChange = true; + } + } + + private void OnListBoxSelectedIndexChanged(object sender, EventArgs e) + { + // If we're ignoring this selected index change, do nothing + if (_ignoreNextSelectChange) + { + _ignoreNextSelectChange = false; + } + else + { + CloseDropDown(); + } + } + + protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) + { + _editor = (UITypeEditor)PropertyDescriptor.GetEditor(typeof(UITypeEditor)); + + base.OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); + + if (_editor != null) + { + _button.Ellipsis = (_editor.GetEditStyle(TypeDescriptorContext) == UITypeEditorEditStyle.Modal); + _hasSwatch = _editor.GetPaintValueSupported(TypeDescriptorContext); + } + else + { + _button.Ellipsis = false; + } + + if (_button.Ellipsis) + { + EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.StaticText : AccessibleRole.Text); + } + else + { + EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.DropList : AccessibleRole.ComboBox); + } + + _button.TabStop = _button.Ellipsis; + _button.TabIndex = currentTabIndex++; + _button.AccessibleRole = (_button.Ellipsis ? AccessibleRole.PushButton : AccessibleRole.ButtonDropDown); + + _button.AccessibleDescription = EditControl.AccessibleDescription; + _button.AccessibleName = EditControl.AccessibleName; + } + + protected override void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs e) + { + base.OnReadOnlyTextBoxLabelClick(sender, e); + + if (e.Button == MouseButtons.Left) + { + if (ActionPanel.DropDownActive) + { + _ignoreDropDownValue = true; + CloseDropDown(); + } + else + { + ActivateDropDown(); + } + } + } + + protected override void OnValueChanged() + { + base.OnValueChanged(); + + _swatch = null; + if (_hasSwatch) + { + ActionPanel.Invalidate(new Rectangle(EditRegionLocation, EditRegionSize), false); + } + } + + public override void PaintLine(Graphics g, int lineWidth, int lineHeight) + { + base.PaintLine(g, lineWidth, lineHeight); + + if (_hasSwatch) + { + if (_swatch is null) + { + int width = EditRegionSize.Height - EditorLineSwatchPadding * 2; + int height = width - 1; + _swatch = new Bitmap(width, height); + Rectangle rect = new Rectangle(1, 1, width - 2, height - 2); + using (Graphics swatchGraphics = Graphics.FromImage(_swatch)) + { + _editor.PaintValue(Value, swatchGraphics, rect); + swatchGraphics.DrawRectangle(SystemPens.ControlDark, new Rectangle(0, 0, width - 1, height - 1)); + } + } + + g.DrawImage(_swatch, new Point(EditRegionRelativeLocation.X + 2, EditorLineSwatchPadding + 5)); + } + } + + protected internal override bool ProcessDialogKey(Keys keyData) + { + // Do this here rather than in OnKeyDown because if hierarchy is properly set, + // VS is going to eat the F4 in PreProcessMessage, preventing it from ever + // getting to an OnKeyDown on this control. Doing it here also allow to not + // hook up to multiple events for each button. + if (!_button.Focused && !_button.Ellipsis) + { + if ((keyData == (Keys.Alt | Keys.Down)) || (keyData == (Keys.Alt | Keys.Up)) || (keyData == Keys.F4)) + { + if (!ActionPanel.DropDownActive) + { + ActivateDropDown(); + } + else + { + CloseDropDown(); + } + + return true; + } + + // Not passing Alt key event to base class to prevent closing 'Combobox Tasks window' + else if ((keyData & Keys.Alt) == Keys.Alt) + { + return true; + } + } + + return base.ProcessDialogKey(keyData); + } + + private void ShowDropDown(Control hostedControl, Color borderColor) + { + hostedControl.Width = Math.Max(hostedControl.Width, EditRegionSize.Width - 2); + + _dropDownHolder = new DropDownHolder(hostedControl, ActionPanel, borderColor, ActionPanel.Font, this); + + if (ActionPanel.RightToLeft != RightToLeft.Yes) + { + Rectangle editorBounds = new Rectangle(Point.Empty, EditRegionSize); + Size dropDownSize = _dropDownHolder.Size; + Point editorLocation = ActionPanel.PointToScreen(EditRegionLocation); + Rectangle rectScreen = Screen.FromRectangle(ActionPanel.RectangleToScreen(editorBounds)).WorkingArea; + dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); + + editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip + Math.Max(rectScreen.X, editorLocation.X + editorBounds.Right - dropDownSize.Width)); // max = left screen edge clip + editorLocation.Y += editorBounds.Y; + if (rectScreen.Bottom < (dropDownSize.Height + editorLocation.Y + editorBounds.Height)) + { + editorLocation.Y -= dropDownSize.Height + 1; + } + else + { + editorLocation.Y += editorBounds.Height; + } + + _dropDownHolder.Location = editorLocation; + } + else + { + _dropDownHolder.RightToLeft = ActionPanel.RightToLeft; + + Rectangle editorBounds = new Rectangle(Point.Empty, EditRegionSize); + Size dropDownSize = _dropDownHolder.Size; + Point editorLocation = ActionPanel.PointToScreen(EditRegionLocation); + Rectangle rectScreen = Screen.FromRectangle(ActionPanel.RectangleToScreen(editorBounds)).WorkingArea; + dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); + + editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip + Math.Max(rectScreen.X, editorLocation.X - editorBounds.Width)); // max = left screen edge clip + editorLocation.Y += editorBounds.Y; + if (rectScreen.Bottom < (dropDownSize.Height + editorLocation.Y + editorBounds.Height)) + { + editorLocation.Y -= dropDownSize.Height + 1; + } + else + { + editorLocation.Y += editorBounds.Height; + } + + _dropDownHolder.Location = editorLocation; + } + + ActionPanel.InMethodInvoke = true; + ActionPanel.SetDropDownActive(true); + try + { + _dropDownHolder.ShowDropDown(_button); + } + finally + { + _button.ResetMouseStates(); + ActionPanel.SetDropDownActive(false); + ActionPanel.InMethodInvoke = false; + } + } + + #region IWindowsFormsEditorService implementation + void IWindowsFormsEditorService.CloseDropDown() + { + CloseDropDown(); + } + + void IWindowsFormsEditorService.DropDownControl(Control control) + { + ShowDropDown(control, ActionPanel.BorderColor); + } + + DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) + { + IUIService uiService = (IUIService)ServiceProvider.GetService(typeof(IUIService)); + if (uiService != null) + { + return uiService.ShowDialog(dialog); + } + + return dialog.ShowDialog(); + } + #endregion + + #region IServiceProvider implementation + object IServiceProvider.GetService(Type serviceType) + { + // Inject this class as the IWindowsFormsEditroService + // so drop-down custom editors can work + if (serviceType == typeof(IWindowsFormsEditorService)) + { + return this; + } + + return ServiceProvider.GetService(serviceType); + } + #endregion + + private class DropDownHolder : FlyoutDialog + { + private readonly EditorPropertyLine _parent; + + public DropDownHolder(Control hostedControl, Control parentControl, Color borderColor, Font font, EditorPropertyLine parent) + : base(hostedControl, parentControl, borderColor, font) + { + _parent = parent; + _parent.ActionPanel.SetDropDownActive(true); + } + + protected override void OnClosed(EventArgs e) + { + base.OnClosed(e); + _parent.ActionPanel.SetDropDownActive(false); + } + + protected override bool ProcessDialogKey(Keys keyData) + { + if (keyData == Keys.Escape) + { + // Indicates that the selection was aborted so we should ignore the value + _parent._ignoreDropDownValue = true; + Visible = false; + return true; + } + + return base.ProcessDialogKey(keyData); + } + } + + internal class FlyoutDialog : Form, IHandle + { + private readonly Control _hostedControl; + private readonly Control _parentControl; + + public FlyoutDialog(Control hostedControl, Control parentControl, Color borderColor, Font font) + { + _hostedControl = hostedControl; + _parentControl = parentControl; + BackColor = SystemColors.Window; + ControlBox = false; + Font = font; + FormBorderStyle = FormBorderStyle.None; + MinimizeBox = false; + MaximizeBox = false; + ShowInTaskbar = false; + StartPosition = FormStartPosition.Manual; + Text = string.Empty; + SuspendLayout(); + try + { + Controls.Add(hostedControl); + + int width = Math.Max(_hostedControl.Width, SystemInformation.MinimumWindowSize.Width); + int height = Math.Max(_hostedControl.Height, SystemInformation.MinimizedWindowSize.Height); + if (!borderColor.IsEmpty) + { + DockPadding.All = 1; + BackColor = borderColor; + width += 2; + height += 4; + } + + _hostedControl.Dock = DockStyle.Fill; + + Width = width; + Height = height; + } + finally + { + ResumeLayout(); + } + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + cp.ExStyle |= (int)User32.WS_EX.TOOLWINDOW; + cp.Style |= unchecked((int)(User32.WS.POPUP | User32.WS.BORDER)); + cp.ClassStyle |= (int)User32.CS.SAVEBITS; + if (_parentControl != null) + { + if (!_parentControl.IsDisposed) + { + cp.Parent = _parentControl.Handle; + } + } + + return cp; + } + } + + public virtual void FocusComponent() + { + if (_hostedControl != null && Visible) + { + _hostedControl.Focus(); + } + } + + // Lifted directly from PropertyGridView.DropDownHolder. Less destructive than using ShowDialog(). + public void DoModalLoop() + { + while (Visible) + { + Application.DoEvents(); + User32.MsgWaitForMultipleObjectsEx(0, IntPtr.Zero, 250, User32.QS.ALLINPUT, User32.MWMO.INPUTAVAILABLE); + } + } + + /// + /// General purpose method, based on Control.Contains()... Determines whether a given window (specified using native window handle) is a descendant of this control. This catches both contained descendants and 'owned' windows such as modal dialogs. Using window handles rather than Control objects allows it to catch un-managed windows as well. + /// + private bool OwnsWindow(IntPtr hWnd) + { + while (hWnd != IntPtr.Zero) + { + hWnd = User32.GetWindowLong(hWnd, User32.GWL.HWNDPARENT); + if (hWnd == IntPtr.Zero) + { + return false; + } + + if (hWnd == Handle) + { + return true; + } + } + + return false; + } + + protected override bool ProcessDialogKey(Keys keyData) + { + if ((keyData == (Keys.Alt | Keys.Down)) || + (keyData == (Keys.Alt | Keys.Up)) || + (keyData == Keys.F4)) + { + // Any of these keys indicates the selection is accepted + Visible = false; + return true; + } + + return base.ProcessDialogKey(keyData); + } + + public void ShowDropDown(Control parent) + { + try + { + User32.SetWindowLong(this, User32.GWL.HWNDPARENT, parent.Handle); + + // Lifted directly from Form.ShowDialog()... + IntPtr hWndCapture = User32.GetCapture(); + if (hWndCapture != IntPtr.Zero) + { + User32.SendMessageW(hWndCapture, User32.WM.CANCELMODE, IntPtr.Zero, IntPtr.Zero); + User32.ReleaseCapture(); + } + + Visible = true; // NOTE: Do this AFTER creating handle and setting parent + FocusComponent(); + DoModalLoop(); + } + finally + { + User32.SetWindowLong(this, User32.GWL.HWNDPARENT, IntPtr.Zero); + + // sometimes activation goes to LALA land - if our parent control is still around, remind it to take focus. + if (parent != null && parent.Visible) + { + parent.Focus(); + } + } + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == (int)User32.WM.ACTIVATE) + { + if (Visible && PARAM.LOWORD(m.WParam) == (int)User32.WA.INACTIVE) + { + if (!OwnsWindow(m.LParam)) + { + Visible = false; + if (m.LParam == IntPtr.Zero) + { //we 're switching process, also dismiss the parent + Control toplevel = _parentControl.TopLevelControl; + if (toplevel is ToolStripDropDown dropDown) + { + // if it's a toolstrip dropdown let it know that we have a specific close reason. + dropDown.Close(); + } + else if (toplevel != null) + { + toplevel.Visible = false; + } + } + + return; + } + } + } + + base.WndProc(ref m); + } + } + + // Class that renders either the ellipsis or dropdown button + internal sealed class EditorButton : Button + { + private bool _mouseOver; + private bool _mouseDown; + private bool _ellipsis; + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (e.Button == MouseButtons.Left) + { + _mouseDown = true; + } + } + + protected override void OnMouseEnter(EventArgs e) + { + base.OnMouseEnter(e); + _mouseOver = true; + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + _mouseOver = false; + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + + if (e.Button == MouseButtons.Left) + { + _mouseDown = false; + } + } + + public bool Ellipsis + { + get => _ellipsis; + set => _ellipsis = value; + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + if (_ellipsis) + { + PushButtonState buttonState = PushButtonState.Normal; + if (_mouseDown) + { + buttonState = PushButtonState.Pressed; + } + else if (_mouseOver) + { + buttonState = PushButtonState.Hot; + } + + ButtonRenderer.DrawButton(g, new Rectangle(-1, -1, Width + 2, Height + 2), "…", Font, Focused, buttonState); + } + else + { + if (ComboBoxRenderer.IsSupported) + { + ComboBoxState state = ComboBoxState.Normal; + if (Enabled) + { + if (_mouseDown) + { + state = ComboBoxState.Pressed; + } + else if (_mouseOver) + { + state = ComboBoxState.Hot; + } + } + else + { + state = ComboBoxState.Disabled; + } + + ComboBoxRenderer.DrawDropDownButton(g, new Rectangle(0, 0, Width, Height), state); + } + else + { + PushButtonState buttonState = PushButtonState.Normal; + if (Enabled) + { + if (_mouseDown) + { + buttonState = PushButtonState.Pressed; + } + else if (_mouseOver) + { + buttonState = PushButtonState.Hot; + } + } + else + { + buttonState = PushButtonState.Disabled; + } + + ButtonRenderer.DrawButton(g, new Rectangle(-1, -1, Width + 2, Height + 2), string.Empty, Font, Focused, buttonState); + // Draw the arrow icon + try + { + Icon icon = new Icon(typeof(DesignerActionPanel), "Arrow.ico"); + try + { + Bitmap arrowBitmap = icon.ToBitmap(); + + // Make sure we draw properly under high contrast by re-mapping + // the arrow color to the WindowText color + ImageAttributes attrs = new ImageAttributes(); + try + { + ColorMap cm = new ColorMap + { + OldColor = Color.Black, + NewColor = SystemColors.WindowText + }; + attrs.SetRemapTable(new ColorMap[] { cm }, ColorAdjustType.Bitmap); + int imageWidth = arrowBitmap.Width; + int imageHeight = arrowBitmap.Height; + g.DrawImage(arrowBitmap, new Rectangle((Width - imageWidth + 1) / 2, (Height - imageHeight + 1) / 2, imageWidth, imageHeight), + 0, 0, imageWidth, imageWidth, GraphicsUnit.Pixel, attrs, null, IntPtr.Zero); + } + finally + { + if (attrs != null) + { + attrs.Dispose(); + } + } + } + finally + { + if (icon != null) + { + icon.Dispose(); + } + } + } + catch + { + } + } + + if (Focused) + { + ControlPaint.DrawFocusRectangle(g, new Rectangle(2, 2, Width - 5, Height - 5)); + } + } + } + + public void ResetMouseStates() + { + _mouseDown = false; + _mouseOver = false; + Invalidate(); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs new file mode 100644 index 00000000000..f08f5739e48 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class HeaderLine : TextLine + { + public HeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) + { + } + + protected override Font GetFont() => new Font(ActionPanel.Font, FontStyle.Bold); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs new file mode 100644 index 00000000000..e870e702e24 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private abstract class Line + { + private readonly DesignerActionPanel _actionPanel; + private List _addedControls; + private readonly IServiceProvider _serviceProvider; + + public Line(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + _serviceProvider = serviceProvider; + _actionPanel = actionPanel ?? throw new ArgumentNullException(nameof(actionPanel)); + } + + protected DesignerActionPanel ActionPanel + { + get => _actionPanel; + } + + public abstract string FocusId + { + get; + } + + protected IServiceProvider ServiceProvider + { + get => _serviceProvider; + } + + protected abstract void AddControls(List controls); + + internal List GetControls() + { + _addedControls = new List(); + AddControls(_addedControls); + // Tag all the controls with the Line so we know who owns it + foreach (Control c in _addedControls) + { + c.Tag = this; + } + + return _addedControls; + } + + public abstract void Focus(); + + public abstract Size LayoutControls(int top, int width, bool measureOnly); + + public virtual void PaintLine(Graphics g, int lineWidth, int lineHeight) + { + } + + protected internal virtual bool ProcessDialogKey(Keys keyData) => false; + + internal void RemoveControls(ControlCollection controls) + { + for (int i = 0; i < _addedControls.Count; i++) + { + Control c = _addedControls[i]; + c.Tag = null; + controls.Remove(c); + } + } + + internal abstract void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs new file mode 100644 index 00000000000..6fed250a2cc --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private class LineInfo + { + public Line Line; + public DesignerActionItem Item; + public DesignerActionList List; + + public LineInfo(DesignerActionList list, DesignerActionItem item, Line line) + { + Debug.Assert(line != null); + Line = line; + Item = item; + List = list; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs new file mode 100644 index 00000000000..bc0d0342951 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs @@ -0,0 +1,121 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Reflection; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class MethodLine : Line + { + private DesignerActionList _actionList; + private DesignerActionMethodItem _methodItem; + private MethodItemLinkLabel _linkLabel; + public MethodLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) + { + } + + public sealed override string FocusId + { + get => "METHOD:" + _actionList.GetType().FullName + "." + _methodItem.MemberName; + } + + protected override void AddControls(List controls) + { + _linkLabel = new MethodItemLinkLabel + { + ActiveLinkColor = ActionPanel.ActiveLinkColor, + AutoSize = false, + BackColor = Color.Transparent, + LinkBehavior = LinkBehavior.HoverUnderline, + LinkColor = ActionPanel.LinkColor, + TextAlign = ContentAlignment.MiddleLeft, + UseMnemonic = false, + VisitedLinkColor = ActionPanel.LinkColor + }; + _linkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(OnLinkLabelLinkClicked); + controls.Add(_linkLabel); + } + + public sealed override void Focus() + { + _linkLabel.Focus(); + } + + public override Size LayoutControls(int top, int width, bool measureOnly) + { + Size linkLabelSize = _linkLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); + if (!measureOnly) + { + _linkLabel.Location = new Point(LineLeftMargin, top + LineVerticalPadding / 2); + _linkLabel.Size = linkLabelSize; + } + + return linkLabelSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); + } + + private void OnLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Debug.Assert(!ActionPanel.InMethodInvoke, "Nested method invocation"); + ActionPanel.InMethodInvoke = true; + try + { + _methodItem.Invoke(); + } + catch (Exception ex) + { + if (ex is TargetInvocationException) + { + ex = ex.InnerException; + } + + //NOTE: We had code to rethrow if this was one of [NullReferenceException, StackOverflowException, OutOfMemoryException, + //ThreadAbortException]. Removing this rethrow. StackOverflow and ThreadAbort can't be meaningfully caught, and + //NullRef and OutOfMemory really shouldn't be caught. Out of these, OOM is the most correct one to call, but OOM is + //thrown by GDI+ for pretty much any problem, so isn't reliable as an actual indicator that you're out of memory. If + //you really are out of memory, it's very likely you'll get another OOM shortly. + ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorInvokingAction, _methodItem.DisplayName, Environment.NewLine + ex.Message)); + } + finally + { + ActionPanel.InMethodInvoke = false; + } + } + + internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + { + _actionList = actionList; + _methodItem = (DesignerActionMethodItem)actionItem; + toolTip.SetToolTip(_linkLabel, _methodItem.Description); + _linkLabel.Text = StripAmpersands(_methodItem.DisplayName); + _linkLabel.AccessibleDescription = actionItem.Description; + _linkLabel.TabIndex = currentTabIndex++; + } + + private sealed class MethodItemLinkLabel : LinkLabel + { + protected override bool ProcessDialogKey(Keys keyData) + { + if ((keyData & Keys.Control) == Keys.Control) + { + Keys keyCode = keyData & Keys.KeyCode; + switch (keyCode) + { + case Keys.Tab: + // We specifically ignore Ctrl+Tab because it prevents the window switcher dialog from showing up in VS. Normally the key combination is only needed when a LinkLabel contains multiple links, but that can't happen inside the DesignerActionPanel. + return false; + } + } + + return base.ProcessDialogKey(keyData); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs new file mode 100644 index 00000000000..99eb8a6e10b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs @@ -0,0 +1,142 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class PanelHeaderLine : Line + { + private DesignerActionList _actionList; + private DesignerActionPanelHeaderItem _panelHeaderItem; + private Label _titleLabel; + private Label _subtitleLabel; + private bool _formActive; + + public PanelHeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + : base(serviceProvider, actionPanel) + { + actionPanel.FontChanged += new EventHandler(OnParentControlFontChanged); + } + + public sealed override string FocusId + { + get => string.Empty; + } + + protected override void AddControls(List controls) + { + _titleLabel = new Label + { + BackColor = Color.Transparent, + ForeColor = ActionPanel.TitleBarTextColor, + TextAlign = ContentAlignment.MiddleLeft, + UseMnemonic = false + }; + + _subtitleLabel = new Label + { + BackColor = Color.Transparent, + ForeColor = ActionPanel.TitleBarTextColor, + TextAlign = ContentAlignment.MiddleLeft, + UseMnemonic = false + }; + + controls.Add(_titleLabel); + controls.Add(_subtitleLabel); + + // TODO: Need to figure out how to unhook these events. Perhaps have Initialize() and Cleanup() methods. + ActionPanel.FormActivated += new EventHandler(OnFormActivated); + ActionPanel.FormDeactivate += new EventHandler(OnFormDeactivate); + } + + public sealed override void Focus() + { + Debug.Fail("Should never try to focus a PanelHeaderLine"); + } + + public override Size LayoutControls(int top, int width, bool measureOnly) + { + Size titleSize = _titleLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); + Size subtitleSize = Size.Empty; + if (!string.IsNullOrEmpty(_panelHeaderItem.Subtitle)) + { + subtitleSize = _subtitleLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); + } + + if (!measureOnly) + { + _titleLabel.Location = new Point(LineLeftMargin, top + PanelHeaderVerticalPadding); + _titleLabel.Size = titleSize; + + _subtitleLabel.Location = new Point(LineLeftMargin, top + PanelHeaderVerticalPadding * 2 + titleSize.Height); + _subtitleLabel.Size = subtitleSize; + } + + int newWidth = Math.Max(titleSize.Width, subtitleSize.Width) + 2 * PanelHeaderHorizontalPadding; + int newHeight = (subtitleSize.IsEmpty ? (titleSize.Height + 2 * PanelHeaderVerticalPadding) : (titleSize.Height + subtitleSize.Height + 3 * PanelHeaderVerticalPadding)); + return new Size(newWidth + 2, newHeight + 1); + } + + private void OnFormActivated(object sender, EventArgs e) + { + // TODO: Figure out better rect + _formActive = true; + ActionPanel.Invalidate(); + //ActionPanel.Invalidate(new Rectangle(EditRegionLocation, EditRegionSize), false); + } + + private void OnFormDeactivate(object sender, EventArgs e) + { + // TODO: Figure out better rect + _formActive = false; + ActionPanel.Invalidate(); + } + + private void OnParentControlFontChanged(object sender, EventArgs e) + { + if (_titleLabel != null && _subtitleLabel != null) + { + _titleLabel.Font = new Font(ActionPanel.Font, FontStyle.Bold); + _subtitleLabel.Font = ActionPanel.Font; + } + } + + public override void PaintLine(Graphics g, int lineWidth, int lineHeight) + { + Color backColor = (_formActive || ActionPanel.DropDownActive) ? ActionPanel.TitleBarColor : ActionPanel.TitleBarUnselectedColor; + using (SolidBrush b = new SolidBrush(backColor)) + { + g.FillRectangle(b, 1, 1, lineWidth - 2, lineHeight - 1); + } + + // Paint a line under the title label + using (Pen p = new Pen(ActionPanel.BorderColor)) + { + g.DrawLine(p, 0, lineHeight - 1, lineWidth, lineHeight - 1); + } + } + + internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + { + _actionList = actionList; + _panelHeaderItem = (DesignerActionPanelHeaderItem)actionItem; + + _titleLabel.Text = _panelHeaderItem.DisplayName; + _titleLabel.TabIndex = currentTabIndex++; + _subtitleLabel.Text = _panelHeaderItem.Subtitle; + _subtitleLabel.TabIndex = currentTabIndex++; + _subtitleLabel.Visible = (_subtitleLabel.Text.Length != 0); + + // Force the font to update + OnParentControlFontChanged(null, EventArgs.Empty); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs new file mode 100644 index 00000000000..e0cb85fdf30 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs @@ -0,0 +1,147 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Globalization; +using System.Reflection; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private abstract class PropertyLine : Line + { + private DesignerActionList _actionList; + private DesignerActionPropertyItem _propertyItem; + private object _value; + private bool _pushingValue; + private PropertyDescriptor _propDesc; + private ITypeDescriptorContext _typeDescriptorContext; + + public PropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) + { + } + + public sealed override string FocusId + { + get => "PROPERTY:" + _actionList.GetType().FullName + "." + _propertyItem.MemberName; + } + + protected PropertyDescriptor PropertyDescriptor + { + get + { + if (_propDesc is null) + { + _propDesc = TypeDescriptor.GetProperties(_actionList)[_propertyItem.MemberName]; + } + + return _propDesc; + } + } + + protected DesignerActionPropertyItem PropertyItem + { + get => _propertyItem; + } + + protected ITypeDescriptorContext TypeDescriptorContext + { + get + { + if (_typeDescriptorContext is null) + { + _typeDescriptorContext = new TypeDescriptorContext(ServiceProvider, PropertyDescriptor, _actionList); + } + + return _typeDescriptorContext; + } + } + + protected object Value + { + get => _value; + } + + protected abstract void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex); + + protected abstract void OnValueChanged(); + + protected void SetValue(object newValue) + { + if (_pushingValue || ActionPanel.DropDownActive) + { + return; + } + + _pushingValue = true; + try + { + // Only push the change if the values are different + if (newValue != null) + { + Type valueType = newValue.GetType(); + // If it's not assignable, try to convert it + if (!PropertyDescriptor.PropertyType.IsAssignableFrom(valueType)) + { + if (PropertyDescriptor.Converter != null) + { + // If we can't convert it, show an error + if (!PropertyDescriptor.Converter.CanConvertFrom(_typeDescriptorContext, valueType)) + { + ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_CouldNotConvertValue, newValue, _propDesc.PropertyType)); + return; + } + else + { + newValue = PropertyDescriptor.Converter.ConvertFrom(_typeDescriptorContext, CultureInfo.CurrentCulture, newValue); + } + } + } + } + + if (!Equals(_value, newValue)) + { + PropertyDescriptor.SetValue(_actionList, newValue); + // Update the value we're caching + _value = PropertyDescriptor.GetValue(_actionList); + OnValueChanged(); + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + { + e = e.InnerException; + } + + ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorSettingValue, newValue, PropertyDescriptor.Name, e.Message)); + } + finally + { + _pushingValue = false; + } + } + + internal sealed override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + { + _actionList = actionList; + _propertyItem = (DesignerActionPropertyItem)actionItem; + _propDesc = null; + _typeDescriptorContext = null; + _value = PropertyDescriptor.GetValue(actionList); + OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); + _pushingValue = true; + try + { + OnValueChanged(); + } + finally + { + _pushingValue = false; + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs new file mode 100644 index 00000000000..b2160d2d32f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private sealed class SeparatorLine : Line + { + private readonly bool _isSubSeparator; + public SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : this(serviceProvider, actionPanel, false) + { + } + + public SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel, bool isSubSeparator) : base(serviceProvider, actionPanel) + { + _isSubSeparator = isSubSeparator; + } + + public sealed override string FocusId + { + get => string.Empty; + } + + public bool IsSubSeparator => _isSubSeparator; + + protected override void AddControls(List controls) + { + } + + public sealed override void Focus() => Debug.Fail("Should never try to focus a SeparatorLine"); + + public override Size LayoutControls(int top, int width, bool measureOnly) => new Size(MinimumWidth, 1); + + public override void PaintLine(Graphics g, int lineWidth, int lineHeight) + { + using (Pen p = new Pen(ActionPanel.SeparatorColor)) + { + g.DrawLine(p, SeparatorHorizontalPadding, 0, lineWidth - (SeparatorHorizontalPadding + 1), 0); + } + } + + internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + { + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs new file mode 100644 index 00000000000..7175c97ae07 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs @@ -0,0 +1,385 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private class TextBoxPropertyLine : PropertyLine + { + private TextBox _textBox; + private EditorLabel _readOnlyTextBoxLabel; + private Control _editControl; + private Label _label; + private int _editXPos; + private bool _textBoxDirty; + private Point _editRegionLocation; + private Point _editRegionRelativeLocation; + private Size _editRegionSize; + + public TextBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + : base(serviceProvider, actionPanel) + { + } + + protected Control EditControl + { + get => _editControl; + } + + protected Point EditRegionLocation + { + get => _editRegionLocation; + } + + protected Point EditRegionRelativeLocation + { + get => _editRegionRelativeLocation; + } + + protected Size EditRegionSize + { + get => _editRegionSize; + } + + protected override void AddControls(List controls) + { + _label = new Label + { + BackColor = Color.Transparent, + ForeColor = ActionPanel.LabelForeColor, + TextAlign = ContentAlignment.MiddleLeft, + UseMnemonic = false + }; + + _readOnlyTextBoxLabel = new EditorLabel + { + BackColor = Color.Transparent, + ForeColor = SystemColors.WindowText, + TabStop = true, + TextAlign = ContentAlignment.TopLeft, + UseMnemonic = false, + Visible = false + }; + _readOnlyTextBoxLabel.MouseClick += new MouseEventHandler(OnReadOnlyTextBoxLabelClick); + _readOnlyTextBoxLabel.Enter += new EventHandler(OnReadOnlyTextBoxLabelEnter); + _readOnlyTextBoxLabel.Leave += new EventHandler(OnReadOnlyTextBoxLabelLeave); + _readOnlyTextBoxLabel.KeyDown += new KeyEventHandler(OnReadOnlyTextBoxLabelKeyDown); + + _textBox = new TextBox + { + BorderStyle = BorderStyle.None, + TextAlign = HorizontalAlignment.Left, + Visible = false + }; + _textBox.TextChanged += new EventHandler(OnTextBoxTextChanged); + _textBox.KeyDown += new KeyEventHandler(OnTextBoxKeyDown); + _textBox.LostFocus += new EventHandler(OnTextBoxLostFocus); + + controls.Add(_readOnlyTextBoxLabel); + controls.Add(_textBox); + controls.Add(_label); + } + + public sealed override void Focus() + { + _editControl.Focus(); + } + + internal int GetEditRegionXPos() + { + if (string.IsNullOrEmpty(_label.Text)) + { + return LineLeftMargin; + } + + return LineLeftMargin + _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Width + TextBoxLineCenterMargin; + } + + protected virtual int GetTextBoxLeftPadding(int textBoxHeight) => TextBoxLineInnerPadding; + + protected virtual int GetTextBoxRightPadding(int textBoxHeight) => TextBoxLineInnerPadding; + + public override Size LayoutControls(int top, int width, bool measureOnly) + { + // Figure out our minimum width, Compare to proposed width, If we are smaller, widen the textbox to fit the line based on the bonus + int textBoxPreferredHeight = _textBox.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Height; + textBoxPreferredHeight += TextBoxHeightFixup; + int height = textBoxPreferredHeight + LineVerticalPadding + TextBoxLineInnerPadding * 2 + 2; // 2 == border size + + int editRegionXPos = Math.Max(_editXPos, GetEditRegionXPos()); + int minimumWidth = editRegionXPos + EditInputWidth + LineRightMargin; + width = Math.Max(width, minimumWidth); + int textBoxWidthBonus = width - minimumWidth; + + if (!measureOnly) + { + _editRegionLocation = new Point(editRegionXPos, top + TextBoxTopPadding); + _editRegionRelativeLocation = new Point(editRegionXPos, TextBoxTopPadding); + _editRegionSize = new Size(EditInputWidth + textBoxWidthBonus, textBoxPreferredHeight + TextBoxLineInnerPadding * 2); + + _label.Location = new Point(LineLeftMargin, top); + int labelPreferredWidth = _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Width; + _label.Size = new Size(labelPreferredWidth, height); + int specialPadding = 0; + if (_editControl is TextBox) + { + specialPadding = 2; + } + + _editControl.Location = new Point(_editRegionLocation.X + GetTextBoxLeftPadding(textBoxPreferredHeight) + 1 + specialPadding, _editRegionLocation.Y + TextBoxLineInnerPadding + 1); + _editControl.Width = _editRegionSize.Width - GetTextBoxRightPadding(textBoxPreferredHeight) - GetTextBoxLeftPadding(textBoxPreferredHeight) - specialPadding; + _editControl.Height = _editRegionSize.Height - TextBoxLineInnerPadding * 2 - 1; + } + + return new Size(width, height); + } + + protected virtual bool IsReadOnly() => IsReadOnlyProperty(PropertyDescriptor); + + protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) + { + _label.Text = StripAmpersands(PropertyItem.DisplayName); + _label.TabIndex = currentTabIndex++; + toolTip.SetToolTip(_label, PropertyItem.Description); + _textBoxDirty = false; + + if (IsReadOnly()) + { + _readOnlyTextBoxLabel.Visible = true; + _textBox.Visible = false; + // REVIEW: Setting Visible to false doesn't seem to work, so position far away + _textBox.Location = new Point(int.MaxValue, int.MaxValue); + _editControl = _readOnlyTextBoxLabel; + } + else + { + _readOnlyTextBoxLabel.Visible = false; + // REVIEW: Setting Visible to false doesn't seem to work, so position far away + _readOnlyTextBoxLabel.Location = new Point(int.MaxValue, int.MaxValue); + _textBox.Visible = true; + _editControl = _textBox; + } + + _editControl.AccessibleDescription = PropertyItem.Description; + _editControl.AccessibleName = StripAmpersands(PropertyItem.DisplayName); + _editControl.TabIndex = currentTabIndex++; + _editControl.BringToFront(); + } + + protected virtual void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + Focus(); + } + } + + private void OnReadOnlyTextBoxLabelEnter(object sender, EventArgs e) + { + _readOnlyTextBoxLabel.ForeColor = SystemColors.HighlightText; + _readOnlyTextBoxLabel.BackColor = SystemColors.Highlight; + } + + private void OnReadOnlyTextBoxLabelLeave(object sender, EventArgs e) + { + _readOnlyTextBoxLabel.ForeColor = SystemColors.WindowText; + _readOnlyTextBoxLabel.BackColor = SystemColors.Window; + } + + protected TypeConverter.StandardValuesCollection GetStandardValues() + { + TypeConverter converter = PropertyDescriptor.Converter; + if (converter != null && + converter.GetStandardValuesSupported(TypeDescriptorContext)) + { + return converter.GetStandardValues(TypeDescriptorContext); + } + + return null; + } + + private void OnEditControlKeyDown(KeyEventArgs e) + { + if (e.KeyCode == Keys.Down) + { + e.Handled = true; + // Try to find the existing value and then pick the one after it + TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); + if (standardValues != null) + { + for (int i = 0; i < standardValues.Count; i++) + { + if (Equals(Value, standardValues[i])) + { + if (i < standardValues.Count - 1) + { + SetValue(standardValues[i + 1]); + } + + return; + } + } + + // Previous value wasn't found, select the first one by default + if (standardValues.Count > 0) + { + SetValue(standardValues[0]); + } + } + + return; + } + + if (e.KeyCode == Keys.Up) + { + e.Handled = true; + // Try to find the existing value and then pick the one before it + TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); + if (standardValues != null) + { + for (int i = 0; i < standardValues.Count; i++) + { + if (Equals(Value, standardValues[i])) + { + if (i > 0) + { + SetValue(standardValues[i - 1]); + } + + return; + } + } + + // Previous value wasn't found, select the first one by default + if (standardValues.Count > 0) + { + SetValue(standardValues[standardValues.Count - 1]); + } + } + + return; + } + } + + private void OnReadOnlyTextBoxLabelKeyDown(object sender, KeyEventArgs e) + { + // Delegate the rest of the processing to a common helper + OnEditControlKeyDown(e); + } + + private void OnTextBoxKeyDown(object sender, KeyEventArgs e) + { + if (ActionPanel.DropDownActive) + { + return; + } + + if (e.KeyCode == Keys.Enter) + { + UpdateValue(); + e.Handled = true; + return; + } + + // Delegate the rest of the processing to a common helper + OnEditControlKeyDown(e); + } + + private void OnTextBoxLostFocus(object sender, EventArgs e) + { + if (ActionPanel.DropDownActive) + { + return; + } + + UpdateValue(); + } + + private void OnTextBoxTextChanged(object sender, EventArgs e) => _textBoxDirty = true; + + protected override void OnValueChanged() => _editControl.Text = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, Value); + + public override void PaintLine(Graphics g, int lineWidth, int lineHeight) + { + Rectangle editRect = new Rectangle(EditRegionRelativeLocation, EditRegionSize); + g.FillRectangle(SystemBrushes.Window, editRect); + g.DrawRectangle(SystemPens.ControlDark, editRect); + } + + internal void SetEditRegionXPos(int xPos) + { + // Ignore the x-position if we have no text. This allows the textbox to span the entire width of the panel. + if (!string.IsNullOrEmpty(_label.Text)) + { + _editXPos = xPos; + } + else + { + _editXPos = LineLeftMargin; + } + } + + private void UpdateValue() + { + if (_textBoxDirty) + { + SetValue(_editControl.Text); + _textBoxDirty = false; + } + } + + /// + /// Custom label that provides accurate accessibility information and focus abilities. + /// + private sealed class EditorLabel : Label + { + public EditorLabel() + { + SetStyle(ControlStyles.Selectable, true); + } + + protected override AccessibleObject CreateAccessibilityInstance() => new EditorLabelAccessibleObject(this); + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + + // Since we are not a standard focusable control, we have to raise our own accessibility events. + // objectID = OBJID_WINDOW, childID = CHILDID_SELF - 1 (the -1 is because WinForms always adds 1 to the value) + // (these consts are defined in winuser.h) + AccessibilityNotifyClients(AccessibleEvents.Focus, 0, -1); + } + + protected override bool IsInputKey(Keys keyData) + { + if (keyData == Keys.Down || + keyData == Keys.Up) + { + return true; + } + + return base.IsInputKey(keyData); + } + + private sealed class EditorLabelAccessibleObject : ControlAccessibleObject + { + public EditorLabelAccessibleObject(EditorLabel owner) + : base(owner) + { + } + + public override string Value + { + get => Owner.Text; + } + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs new file mode 100644 index 00000000000..f0c3c9021a6 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + private class TextLine : Line + { + private Label _label; + private DesignerActionTextItem _textItem; + + public TextLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + : base(serviceProvider, actionPanel) + { + actionPanel.FontChanged += new EventHandler(OnParentControlFontChanged); + } + + public sealed override string FocusId + { + get => string.Empty; + } + + protected override void AddControls(List controls) + { + _label = new Label + { + BackColor = Color.Transparent, + ForeColor = ActionPanel.LabelForeColor, + TextAlign = ContentAlignment.MiddleLeft, + UseMnemonic = false + }; + controls.Add(_label); + } + + public sealed override void Focus() + { + Debug.Fail("Should never try to focus a TextLine"); + } + + public override Size LayoutControls(int top, int width, bool measureOnly) + { + Size labelSize = _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); + if (!measureOnly) + { + _label.Location = new Point(LineLeftMargin, top + LineVerticalPadding / 2); + _label.Size = labelSize; + } + + return labelSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); + } + + private void OnParentControlFontChanged(object sender, EventArgs e) + { + if (_label != null && _label.Font != null) + { + _label.Font = GetFont(); + } + } + + protected virtual Font GetFont() + { + return ActionPanel.Font; + } + + internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + { + _textItem = (DesignerActionTextItem)actionItem; + _label.Text = StripAmpersands(_textItem.DisplayName); + _label.Font = GetFont(); + _label.TabIndex = currentTabIndex++; + toolTip.SetToolTip(_label, _textItem.Description); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs new file mode 100644 index 00000000000..4c47dac18ff --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.ComponentModel.Design +{ + internal sealed partial class DesignerActionPanel + { + internal sealed class TypeDescriptorContext : ITypeDescriptorContext + { + private readonly IServiceProvider _serviceProvider; + private readonly PropertyDescriptor _propDesc; + private readonly object _instance; + + public TypeDescriptorContext(IServiceProvider serviceProvider, PropertyDescriptor propDesc, object instance) + { + _serviceProvider = serviceProvider; + _propDesc = propDesc; + _instance = instance; + } + + private IComponentChangeService ComponentChangeService + { + get => (IComponentChangeService)_serviceProvider.GetService(typeof(IComponentChangeService)); + } + + public IContainer Container + { + get => (IContainer)_serviceProvider.GetService(typeof(IContainer)); + } + + public object Instance + { + get => _instance; + } + + public PropertyDescriptor PropertyDescriptor + { + get => _propDesc; + } + + public object GetService(Type serviceType) => _serviceProvider.GetService(serviceType); + + public bool OnComponentChanging() + { + if (ComponentChangeService != null) + { + try + { + ComponentChangeService.OnComponentChanging(_instance, _propDesc); + } + catch (CheckoutException ce) + { + if (ce == CheckoutException.Canceled) + { + return false; + } + + throw; + } + } + + return true; + } + + public void OnComponentChanged() + { + if (ComponentChangeService != null) + { + ComponentChangeService.OnComponentChanged(_instance, _propDesc, null, null); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs index 1bfdfe9aed1..3de1b36da35 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -9,18 +9,13 @@ using System.Drawing; using System.Drawing.Design; using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.Globalization; -using System.Reflection; using System.Text; using System.Windows.Forms; using System.Windows.Forms.Design; -using System.Windows.Forms.VisualStyles; -using static Interop; namespace System.ComponentModel.Design { - internal sealed class DesignerActionPanel : ContainerControl + internal sealed partial class DesignerActionPanel : ContainerControl { private static readonly object s_eventFormActivated = new object(); private static readonly object s_eventFormDeactivate = new object(); @@ -884,7 +879,7 @@ private void UpdateEditXPos() { if (_lines[i] is TextBoxPropertyLine line) { - editXPos = Math.Max(editXPos, ((TextBoxPropertyLine)line).GetEditRegionXPos()); + editXPos = Math.Max(editXPos, line.GetEditRegionXPos()); } } @@ -1020,1839 +1015,5 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction Invalidate(); } - - private class LineInfo - { - public Line Line; - public DesignerActionItem Item; - public DesignerActionList List; - - public LineInfo(DesignerActionList list, DesignerActionItem item, Line line) - { - Debug.Assert(line != null); - Line = line; - Item = item; - List = list; - } - } - - internal sealed class TypeDescriptorContext : ITypeDescriptorContext - { - private readonly IServiceProvider _serviceProvider; - private readonly PropertyDescriptor _propDesc; - private readonly object _instance; - - public TypeDescriptorContext(IServiceProvider serviceProvider, PropertyDescriptor propDesc, object instance) - { - _serviceProvider = serviceProvider; - _propDesc = propDesc; - _instance = instance; - } - - private IComponentChangeService ComponentChangeService - { - get => (IComponentChangeService)_serviceProvider.GetService(typeof(IComponentChangeService)); - } - - public IContainer Container - { - get => (IContainer)_serviceProvider.GetService(typeof(IContainer)); - } - - public object Instance - { - get => _instance; - } - - public PropertyDescriptor PropertyDescriptor - { - get => _propDesc; - } - - public object GetService(Type serviceType) => _serviceProvider.GetService(serviceType); - - public bool OnComponentChanging() - { - if (ComponentChangeService != null) - { - try - { - ComponentChangeService.OnComponentChanging(_instance, _propDesc); - } - catch (CheckoutException ce) - { - if (ce == CheckoutException.Canceled) - { - return false; - } - - throw; - } - } - - return true; - } - - public void OnComponentChanged() - { - if (ComponentChangeService != null) - { - ComponentChangeService.OnComponentChanged(_instance, _propDesc, null, null); - } - } - } - - private abstract class Line - { - private readonly DesignerActionPanel _actionPanel; - private List _addedControls; - private readonly IServiceProvider _serviceProvider; - - public Line(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) - { - _serviceProvider = serviceProvider; - _actionPanel = actionPanel ?? throw new ArgumentNullException(nameof(actionPanel)); - } - - protected DesignerActionPanel ActionPanel - { - get => _actionPanel; - } - - public abstract string FocusId - { - get; - } - - protected IServiceProvider ServiceProvider - { - get => _serviceProvider; - } - - protected abstract void AddControls(List controls); - - internal List GetControls() - { - _addedControls = new List(); - AddControls(_addedControls); - // Tag all the controls with the Line so we know who owns it - foreach (Control c in _addedControls) - { - c.Tag = this; - } - - return _addedControls; - } - - public abstract void Focus(); - - public abstract Size LayoutControls(int top, int width, bool measureOnly); - - public virtual void PaintLine(Graphics g, int lineWidth, int lineHeight) - { - } - - protected internal virtual bool ProcessDialogKey(Keys keyData) => false; - - internal void RemoveControls(Control.ControlCollection controls) - { - for (int i = 0; i < _addedControls.Count; i++) - { - Control c = _addedControls[i]; - c.Tag = null; - controls.Remove(c); - } - } - - internal abstract void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex); - } - - private sealed class DesignerActionPanelHeaderItem : DesignerActionItem - { - private readonly string _subtitle; - - public DesignerActionPanelHeaderItem(string title, string subtitle) : base(title, null, null) - { - _subtitle = subtitle; - } - - public string Subtitle - { - get => _subtitle; - } - } - - private sealed class PanelHeaderLine : Line - { - private DesignerActionList _actionList; - private DesignerActionPanelHeaderItem _panelHeaderItem; - private Label _titleLabel; - private Label _subtitleLabel; - private bool _formActive; - - public PanelHeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - public sealed override string FocusId - { - get => string.Empty; - } - - protected override void AddControls(List controls) - { - _titleLabel = new Label - { - BackColor = Color.Transparent, - ForeColor = ActionPanel.TitleBarTextColor, - TextAlign = Drawing.ContentAlignment.MiddleLeft, - UseMnemonic = false - }; - - _subtitleLabel = new Label - { - BackColor = Color.Transparent, - ForeColor = ActionPanel.TitleBarTextColor, - TextAlign = Drawing.ContentAlignment.MiddleLeft, - UseMnemonic = false - }; - - controls.Add(_titleLabel); - controls.Add(_subtitleLabel); - } - - public sealed override void Focus() - { - Debug.Fail("Should never try to focus a PanelHeaderLine"); - } - - public override Size LayoutControls(int top, int width, bool measureOnly) - { - Size titleSize = _titleLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); - Size subtitleSize = Size.Empty; - if (!string.IsNullOrEmpty(_panelHeaderItem.Subtitle)) - { - subtitleSize = _subtitleLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); - } - - if (!measureOnly) - { - _titleLabel.Location = new Point(LineLeftMargin, top + PanelHeaderVerticalPadding); - _titleLabel.Size = titleSize; - _subtitleLabel.Location = new Point(LineLeftMargin, top + PanelHeaderVerticalPadding * 2 + titleSize.Height); - _subtitleLabel.Size = subtitleSize; - } - - int newWidth = Math.Max(titleSize.Width, subtitleSize.Width) + 2 * PanelHeaderHorizontalPadding; - int newHeight = (subtitleSize.IsEmpty ? (titleSize.Height + 2 * PanelHeaderVerticalPadding) : (titleSize.Height + subtitleSize.Height + 3 * PanelHeaderVerticalPadding)); - return new Size(newWidth + 2, newHeight + 1); - } - - private void OnFormActivated(object sender, EventArgs e) - { - // TODO: Figure out better rect - _formActive = true; - ActionPanel.Invalidate(); - //ActionPanel.Invalidate(new Rectangle(EditRegionLocation, EditRegionSize), false); - } - - private void OnFormDeactivate(object sender, EventArgs e) - { - // TODO: Figure out better rect - _formActive = false; - ActionPanel.Invalidate(); - } - - private void OnParentControlFontChanged(object sender, EventArgs e) - { - if (_titleLabel != null && _subtitleLabel != null) - { - _titleLabel.Font = new Font(ActionPanel.Font, FontStyle.Bold); - _subtitleLabel.Font = ActionPanel.Font; - } - } - - public override void PaintLine(Graphics g, int lineWidth, int lineHeight) - { - Color backColor = (_formActive || ActionPanel.DropDownActive) ? ActionPanel.TitleBarColor : ActionPanel.TitleBarUnselectedColor; - using (SolidBrush b = new SolidBrush(backColor)) - { - g.FillRectangle(b, 1, 1, lineWidth - 2, lineHeight - 1); - } - - // Paint a line under the title label - using (Pen p = new Pen(ActionPanel.BorderColor)) - { - g.DrawLine(p, 0, lineHeight - 1, lineWidth, lineHeight - 1); - } - } - - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) - { - _actionList = actionList; - _panelHeaderItem = (DesignerActionPanelHeaderItem)actionItem; - _titleLabel.Text = _panelHeaderItem.DisplayName; - _titleLabel.TabIndex = currentTabIndex++; - _subtitleLabel.Text = _panelHeaderItem.Subtitle; - _subtitleLabel.TabIndex = currentTabIndex++; - _subtitleLabel.Visible = (_subtitleLabel.Text.Length != 0); - // Force the font to update - OnParentControlFontChanged(null, EventArgs.Empty); - } - } - - private sealed class MethodLine : Line - { - private DesignerActionList _actionList; - private DesignerActionMethodItem _methodItem; - private MethodItemLinkLabel _linkLabel; - public MethodLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - public sealed override string FocusId - { - get => "METHOD:" + _actionList.GetType().FullName + "." + _methodItem.MemberName; - } - - protected override void AddControls(List controls) - { - _linkLabel = new MethodItemLinkLabel - { - ActiveLinkColor = ActionPanel.ActiveLinkColor, - AutoSize = false, - BackColor = Color.Transparent, - LinkBehavior = LinkBehavior.HoverUnderline, - LinkColor = ActionPanel.LinkColor, - TextAlign = Drawing.ContentAlignment.MiddleLeft, - UseMnemonic = false, - VisitedLinkColor = ActionPanel.LinkColor - }; - _linkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(OnLinkLabelLinkClicked); - controls.Add(_linkLabel); - } - - public sealed override void Focus() - { - _linkLabel.Focus(); - } - - public override Size LayoutControls(int top, int width, bool measureOnly) - { - Size linkLabelSize = _linkLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); - if (!measureOnly) - { - _linkLabel.Location = new Point(LineLeftMargin, top + LineVerticalPadding / 2); - _linkLabel.Size = linkLabelSize; - } - - return linkLabelSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); - } - - private void OnLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Debug.Assert(!ActionPanel.InMethodInvoke, "Nested method invocation"); - ActionPanel.InMethodInvoke = true; - try - { - _methodItem.Invoke(); - } - catch (Exception ex) - { - if (ex is TargetInvocationException) - { - ex = ex.InnerException; - } - - //NOTE: We had code to rethrow if this was one of [NullReferenceException, StackOverflowException, OutOfMemoryException, - //ThreadAbortException]. Removing this rethrow. StackOverflow and ThreadAbort can't be meaningfully caught, and - //NullRef and OutOfMemory really shouldn't be caught. Out of these, OOM is the most correct one to call, but OOM is - //thrown by GDI+ for pretty much any problem, so isn't reliable as an actual indicator that you're out of memory. If - //you really are out of memory, it's very likely you'll get another OOM shortly. - ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorInvokingAction, _methodItem.DisplayName, Environment.NewLine + ex.Message)); - } - finally - { - ActionPanel.InMethodInvoke = false; - } - } - - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) - { - _actionList = actionList; - _methodItem = (DesignerActionMethodItem)actionItem; - toolTip.SetToolTip(_linkLabel, _methodItem.Description); - _linkLabel.Text = StripAmpersands(_methodItem.DisplayName); - _linkLabel.AccessibleDescription = actionItem.Description; - _linkLabel.TabIndex = currentTabIndex++; - } - - private sealed class MethodItemLinkLabel : LinkLabel - { - protected override bool ProcessDialogKey(Keys keyData) - { - if ((keyData & Keys.Control) == Keys.Control) - { - Keys keyCode = keyData & Keys.KeyCode; - switch (keyCode) - { - case Keys.Tab: - // We specifically ignore Ctrl+Tab because it prevents the window switcher dialog from showing up in VS. Normally the key combination is only needed when a LinkLabel contains multiple links, but that can't happen inside the DesignerActionPanel. - return false; - } - } - - return base.ProcessDialogKey(keyData); - } - } - } - - private abstract class PropertyLine : Line - { - private DesignerActionList _actionList; - private DesignerActionPropertyItem _propertyItem; - private object _value; - private bool _pushingValue; - private PropertyDescriptor _propDesc; - private ITypeDescriptorContext _typeDescriptorContext; - - public PropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - public sealed override string FocusId - { - get => "PROPERTY:" + _actionList.GetType().FullName + "." + _propertyItem.MemberName; - } - - protected PropertyDescriptor PropertyDescriptor - { - get - { - if (_propDesc is null) - { - _propDesc = TypeDescriptor.GetProperties(_actionList)[_propertyItem.MemberName]; - } - - return _propDesc; - } - } - - protected DesignerActionPropertyItem PropertyItem - { - get => _propertyItem; - } - - protected ITypeDescriptorContext TypeDescriptorContext - { - get - { - if (_typeDescriptorContext is null) - { - _typeDescriptorContext = new TypeDescriptorContext(ServiceProvider, PropertyDescriptor, _actionList); - } - - return _typeDescriptorContext; - } - } - - protected object Value - { - get => _value; - } - - protected abstract void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex); - - protected abstract void OnValueChanged(); - - protected void SetValue(object newValue) - { - if (_pushingValue || ActionPanel.DropDownActive) - { - return; - } - - _pushingValue = true; - try - { - // Only push the change if the values are different - if (newValue != null) - { - Type valueType = newValue.GetType(); - // If it's not assignable, try to convert it - if (!PropertyDescriptor.PropertyType.IsAssignableFrom(valueType)) - { - if (PropertyDescriptor.Converter != null) - { - // If we can't convert it, show an error - if (!PropertyDescriptor.Converter.CanConvertFrom(_typeDescriptorContext, valueType)) - { - ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_CouldNotConvertValue, newValue, _propDesc.PropertyType)); - return; - } - else - { - newValue = PropertyDescriptor.Converter.ConvertFrom(_typeDescriptorContext, CultureInfo.CurrentCulture, newValue); - } - } - } - } - - if (!object.Equals(_value, newValue)) - { - PropertyDescriptor.SetValue(_actionList, newValue); - // Update the value we're caching - _value = PropertyDescriptor.GetValue(_actionList); - OnValueChanged(); - } - } - catch (Exception e) - { - if (e is TargetInvocationException) - { - e = e.InnerException; - } - - ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorSettingValue, newValue, PropertyDescriptor.Name, e.Message)); - } - finally - { - _pushingValue = false; - } - } - - internal sealed override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) - { - _actionList = actionList; - _propertyItem = (DesignerActionPropertyItem)actionItem; - _propDesc = null; - _typeDescriptorContext = null; - _value = PropertyDescriptor.GetValue(actionList); - OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); - _pushingValue = true; - try - { - OnValueChanged(); - } - finally - { - _pushingValue = false; - } - } - } - - private sealed class CheckBoxPropertyLine : PropertyLine - { - private CheckBox _checkBox; - - public CheckBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - protected override void AddControls(List controls) - { - _checkBox = new CheckBox - { - BackColor = Color.Transparent, - CheckAlign = Drawing.ContentAlignment.MiddleLeft - }; - _checkBox.TextAlign = Drawing.ContentAlignment.MiddleLeft; - _checkBox.UseMnemonic = false; - _checkBox.ForeColor = ActionPanel.LabelForeColor; - controls.Add(_checkBox); - } - - public sealed override void Focus() => _checkBox.Focus(); - - public override Size LayoutControls(int top, int width, bool measureOnly) - { - Size checkBoxPreferredSize = _checkBox.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); - if (!measureOnly) - { - _checkBox.Location = new Point(LineLeftMargin, top + LineVerticalPadding / 2); - _checkBox.Size = checkBoxPreferredSize; - } - - return checkBoxPreferredSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); - } - - private void OnCheckBoxCheckedChanged(object sender, EventArgs e) - { - SetValue(_checkBox.Checked); - } - - protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) - { - _checkBox.Text = StripAmpersands(PropertyItem.DisplayName); - _checkBox.AccessibleDescription = PropertyItem.Description; - _checkBox.TabIndex = currentTabIndex++; - - toolTip.SetToolTip(_checkBox, PropertyItem.Description); - } - - protected override void OnValueChanged() - { - _checkBox.Checked = (bool)Value; - } - } - - private class TextBoxPropertyLine : PropertyLine - { - private TextBox _textBox; - private EditorLabel _readOnlyTextBoxLabel; - private Control _editControl; - private Label _label; - private int _editXPos; - private bool _textBoxDirty; - private Point _editRegionLocation; - private Point _editRegionRelativeLocation; - private Size _editRegionSize; - - public TextBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - protected Control EditControl - { - get => _editControl; - } - - protected Point EditRegionLocation - { - get => _editRegionLocation; - } - - protected Point EditRegionRelativeLocation - { - get => _editRegionRelativeLocation; - } - - protected Size EditRegionSize - { - get => _editRegionSize; - } - - protected override void AddControls(List controls) - { - _label = new Label - { - BackColor = Color.Transparent, - ForeColor = ActionPanel.LabelForeColor, - TextAlign = Drawing.ContentAlignment.MiddleLeft, - UseMnemonic = false - }; - _readOnlyTextBoxLabel = new EditorLabel - { - BackColor = Color.Transparent, - ForeColor = SystemColors.WindowText, - TabStop = true, - TextAlign = Drawing.ContentAlignment.TopLeft, - UseMnemonic = false, - Visible = false - }; - _readOnlyTextBoxLabel.MouseClick += new MouseEventHandler(OnReadOnlyTextBoxLabelClick); - _readOnlyTextBoxLabel.KeyDown += new KeyEventHandler(OnReadOnlyTextBoxLabelKeyDown); - - _textBox = new TextBox - { - BorderStyle = BorderStyle.None, - TextAlign = System.Windows.Forms.HorizontalAlignment.Left, - Visible = false - }; - _textBox.KeyDown += new KeyEventHandler(OnTextBoxKeyDown); - - controls.Add(_readOnlyTextBoxLabel); - controls.Add(_textBox); - controls.Add(_label); - } - - public sealed override void Focus() - { - _editControl.Focus(); - } - - internal int GetEditRegionXPos() - { - if (string.IsNullOrEmpty(_label.Text)) - { - return LineLeftMargin; - } - - return LineLeftMargin + _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Width + TextBoxLineCenterMargin; - } - - protected virtual int GetTextBoxLeftPadding(int textBoxHeight) => TextBoxLineInnerPadding; - - protected virtual int GetTextBoxRightPadding(int textBoxHeight) => TextBoxLineInnerPadding; - - public override Size LayoutControls(int top, int width, bool measureOnly) - { - // Figure out our minimum width, Compare to proposed width, If we are smaller, widen the textbox to fit the line based on the bonus - int textBoxPreferredHeight = _textBox.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Height; - textBoxPreferredHeight += TextBoxHeightFixup; - int height = textBoxPreferredHeight + LineVerticalPadding + TextBoxLineInnerPadding * 2 + 2; // 2 == border size - - int editRegionXPos = Math.Max(_editXPos, GetEditRegionXPos()); - int minimumWidth = editRegionXPos + EditInputWidth + LineRightMargin; - width = Math.Max(width, minimumWidth); - int textBoxWidthBonus = width - minimumWidth; - - if (!measureOnly) - { - _editRegionLocation = new Point(editRegionXPos, top + TextBoxTopPadding); - _editRegionRelativeLocation = new Point(editRegionXPos, TextBoxTopPadding); - _editRegionSize = new Size(EditInputWidth + textBoxWidthBonus, textBoxPreferredHeight + TextBoxLineInnerPadding * 2); - - _label.Location = new Point(LineLeftMargin, top); - int labelPreferredWidth = _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Width; - _label.Size = new Size(labelPreferredWidth, height); - int specialPadding = 0; - if (_editControl is TextBox) - { - specialPadding = 2; - } - - _editControl.Location = new Point(_editRegionLocation.X + GetTextBoxLeftPadding(textBoxPreferredHeight) + 1 + specialPadding, _editRegionLocation.Y + TextBoxLineInnerPadding + 1); - _editControl.Width = _editRegionSize.Width - GetTextBoxRightPadding(textBoxPreferredHeight) - GetTextBoxLeftPadding(textBoxPreferredHeight) - specialPadding; - _editControl.Height = _editRegionSize.Height - TextBoxLineInnerPadding * 2 - 1; - } - - return new Size(width, height); - } - - protected virtual bool IsReadOnly() => IsReadOnlyProperty(PropertyDescriptor); - - protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) - { - _label.Text = StripAmpersands(PropertyItem.DisplayName); - _label.TabIndex = currentTabIndex++; - toolTip.SetToolTip(_label, PropertyItem.Description); - _textBoxDirty = false; - - if (IsReadOnly()) - { - _readOnlyTextBoxLabel.Visible = true; - _textBox.Visible = false; - // REVIEW: Setting Visible to false doesn't seem to work, so position far away - _textBox.Location = new Point(int.MaxValue, int.MaxValue); - _editControl = _readOnlyTextBoxLabel; - } - else - { - _readOnlyTextBoxLabel.Visible = false; - // REVIEW: Setting Visible to false doesn't seem to work, so position far away - _readOnlyTextBoxLabel.Location = new Point(int.MaxValue, int.MaxValue); - _textBox.Visible = true; - _editControl = _textBox; - } - - _editControl.AccessibleDescription = PropertyItem.Description; - _editControl.AccessibleName = StripAmpersands(PropertyItem.DisplayName); - _editControl.TabIndex = currentTabIndex++; - _editControl.BringToFront(); - } - - protected virtual void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - Focus(); - } - } - - private void OnReadOnlyTextBoxLabelEnter(object sender, EventArgs e) - { - _readOnlyTextBoxLabel.ForeColor = SystemColors.HighlightText; - _readOnlyTextBoxLabel.BackColor = SystemColors.Highlight; - } - - private void OnReadOnlyTextBoxLabelLeave(object sender, EventArgs e) - { - _readOnlyTextBoxLabel.ForeColor = SystemColors.WindowText; - _readOnlyTextBoxLabel.BackColor = SystemColors.Window; - } - - protected TypeConverter.StandardValuesCollection GetStandardValues() - { - TypeConverter converter = PropertyDescriptor.Converter; - if (converter != null && - converter.GetStandardValuesSupported(TypeDescriptorContext)) - { - return converter.GetStandardValues(TypeDescriptorContext); - } - - return null; - } - - private void OnEditControlKeyDown(KeyEventArgs e) - { - if (e.KeyCode == Keys.Down) - { - e.Handled = true; - // Try to find the existing value and then pick the one after it - TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); - if (standardValues != null) - { - for (int i = 0; i < standardValues.Count; i++) - { - if (object.Equals(Value, standardValues[i])) - { - if (i < standardValues.Count - 1) - { - SetValue(standardValues[i + 1]); - } - - return; - } - } - - // Previous value wasn't found, select the first one by default - if (standardValues.Count > 0) - { - SetValue(standardValues[0]); - } - } - - return; - } - - if (e.KeyCode == Keys.Up) - { - e.Handled = true; - // Try to find the existing value and then pick the one before it - TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); - if (standardValues != null) - { - for (int i = 0; i < standardValues.Count; i++) - { - if (object.Equals(Value, standardValues[i])) - { - if (i > 0) - { - SetValue(standardValues[i - 1]); - } - - return; - } - } - - // Previous value wasn't found, select the first one by default - if (standardValues.Count > 0) - { - SetValue(standardValues[standardValues.Count - 1]); - } - } - - return; - } - } - - private void OnReadOnlyTextBoxLabelKeyDown(object sender, KeyEventArgs e) - { - // Delegate the rest of the processing to a common helper - OnEditControlKeyDown(e); - } - - private void OnTextBoxKeyDown(object sender, KeyEventArgs e) - { - if (ActionPanel.DropDownActive) - { - return; - } - - if (e.KeyCode == Keys.Enter) - { - UpdateValue(); - e.Handled = true; - return; - } - - // Delegate the rest of the processing to a common helper - OnEditControlKeyDown(e); - } - - private void OnTextBoxLostFocus(object sender, EventArgs e) - { - if (ActionPanel.DropDownActive) - { - return; - } - - UpdateValue(); - } - - private void OnTextBoxTextChanged(object sender, EventArgs e) => _textBoxDirty = true; - - protected override void OnValueChanged() => _editControl.Text = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, Value); - - public override void PaintLine(Graphics g, int lineWidth, int lineHeight) - { - Rectangle editRect = new Rectangle(EditRegionRelativeLocation, EditRegionSize); - g.FillRectangle(SystemBrushes.Window, editRect); - g.DrawRectangle(SystemPens.ControlDark, editRect); - } - - internal void SetEditRegionXPos(int xPos) - { - // Ignore the x-position if we have no text. This allows the textbox to span the entire width of the panel. - if (!string.IsNullOrEmpty(_label.Text)) - { - _editXPos = xPos; - } - else - { - _editXPos = LineLeftMargin; - } - } - - private void UpdateValue() - { - if (_textBoxDirty) - { - SetValue(_editControl.Text); - _textBoxDirty = false; - } - } - - /// - /// Custom label that provides accurate accessibility information and focus abilities. - /// - private sealed class EditorLabel : Label - { - public EditorLabel() - { - SetStyle(ControlStyles.Selectable, true); - } - - protected override AccessibleObject CreateAccessibilityInstance() => new EditorLabelAccessibleObject(this); - - protected override void OnGotFocus(EventArgs e) - { - base.OnGotFocus(e); - // Since we are not a standard focusable control, we have to raise our own accessibility events. - // objectID = OBJID_WINDOW, childID = CHILDID_SELF - 1 (the -1 is because WinForms always adds 1 to the value) (these consts are defined in winuser.h) - AccessibilityNotifyClients(AccessibleEvents.Focus, 0, -1); - } - - protected override bool IsInputKey(Keys keyData) - { - if (keyData == Keys.Down || - keyData == Keys.Up) - { - return true; - } - - return base.IsInputKey(keyData); - } - - private sealed class EditorLabelAccessibleObject : ControlAccessibleObject - { - public EditorLabelAccessibleObject(EditorLabel owner) : base(owner) - { - } - - public override string Value - { - get => Owner.Text; - } - } - } - } - - private sealed class EditorPropertyLine : TextBoxPropertyLine, IWindowsFormsEditorService, IServiceProvider - { - private EditorButton _button; - private UITypeEditor _editor; - private bool _hasSwatch; - private Image _swatch; - private FlyoutDialog _dropDownHolder; - private bool _ignoreNextSelectChange; - private bool _ignoreDropDownValue; - - public EditorPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - private void ActivateDropDown() - { - if (_editor != null) - { - try - { - object newValue = _editor.EditValue(TypeDescriptorContext, this, Value); - SetValue(newValue); - } - catch (Exception ex) - { - ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorActivatingDropDown, ex.Message)); - } - } - else - { - ListBox listBox = new ListBox - { - BorderStyle = BorderStyle.None, - IntegralHeight = false, - Font = ActionPanel.Font - }; - - listBox.KeyDown += new KeyEventHandler(OnListBoxKeyDown); - TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); - if (standardValues != null) - { - foreach (object o in standardValues) - { - string newItem = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, CultureInfo.CurrentCulture, o); - listBox.Items.Add(newItem); - - if ((o != null) && o.Equals(Value)) - { - listBox.SelectedItem = newItem; - } - } - } - - // All measurement code borrowed from WinForms PropertyGridView.cs - int maxWidth = 0; - - // The listbox draws with GDI, not GDI+. So, we use a normal DC here. - using (var hdc = new User32.GetDcScope(listBox.Handle)) - { - using var hFont = new Gdi32.ObjectScope(listBox.Font.ToHFONT()); - using var fontSelection = new Gdi32.SelectObjectScope(hdc, hFont); - - var tm = new Gdi32.TEXTMETRICW(); - - if (listBox.Items.Count > 0) - { - foreach (string s in listBox.Items) - { - var textSize = new Size(); - Gdi32.GetTextExtentPoint32W(hdc, s, s.Length, ref textSize); - maxWidth = Math.Max(textSize.Width, maxWidth); - } - } - - Gdi32.GetTextMetricsW(hdc, ref tm); - - // border + padding + scrollbar - maxWidth += 2 + tm.tmMaxCharWidth + SystemInformation.VerticalScrollBarWidth; - - listBox.Height = Math.Max(tm.tmHeight + 2, Math.Min(ListBoxMaximumHeight, listBox.PreferredHeight)); - listBox.Width = Math.Max(maxWidth, EditRegionSize.Width); - _ignoreDropDownValue = false; - } - - try - { - ShowDropDown(listBox, SystemColors.ControlDark); - } - finally - { - listBox.KeyDown -= new KeyEventHandler(OnListBoxKeyDown); - } - - if (!_ignoreDropDownValue) - { - if (listBox.SelectedItem != null) - { - SetValue(listBox.SelectedItem); - } - } - } - } - - protected override void AddControls(List controls) - { - base.AddControls(controls); - _button = new EditorButton(); - controls.Add(_button); - } - - private void CloseDropDown() - { - if (_dropDownHolder != null) - { - _dropDownHolder.Visible = false; - } - } - - protected override int GetTextBoxLeftPadding(int textBoxHeight) - { - if (_hasSwatch) - { - return base.GetTextBoxLeftPadding(textBoxHeight) + textBoxHeight + 2 * EditorLineSwatchPadding; - } - else - { - return base.GetTextBoxLeftPadding(textBoxHeight); - } - } - - protected override int GetTextBoxRightPadding(int textBoxHeight) => base.GetTextBoxRightPadding(textBoxHeight) + textBoxHeight + 2 * EditorLineButtonPadding; - - protected override bool IsReadOnly() - { - if (base.IsReadOnly()) - { - return true; - } - - // If we can't convert from string, we are readonly because we can't convert the user's input - bool converterReadOnly = !PropertyDescriptor.Converter.CanConvertFrom(TypeDescriptorContext, typeof(string)); - // If standard values are supported and are exclusive, we are readonly - bool standardValuesExclusive = - PropertyDescriptor.Converter.GetStandardValuesSupported(TypeDescriptorContext) && - PropertyDescriptor.Converter.GetStandardValuesExclusive(TypeDescriptorContext); - return converterReadOnly || standardValuesExclusive; - } - - public override Size LayoutControls(int top, int width, bool measureOnly) - { - Size size = base.LayoutControls(top, width, measureOnly); - if (!measureOnly) - { - int buttonHeight = EditRegionSize.Height - EditorLineButtonPadding * 2 - 1; - _button.Location = new Point(EditRegionLocation.X + EditRegionSize.Width - buttonHeight - EditorLineButtonPadding, EditRegionLocation.Y + EditorLineButtonPadding + 1); - _button.Size = new Size(buttonHeight, buttonHeight); - } - - return size; - } - - private void OnButtonClick(object sender, EventArgs e) - { - ActivateDropDown(); - } - - private void OnButtonGotFocus(object sender, EventArgs e) - { - if (!_button.Ellipsis) - { - Focus(); - } - } - - private void OnListBoxKeyDown(object sender, KeyEventArgs e) - { - // Always respect the enter key and F4 - if (e.KeyData == Keys.Enter) - { - _ignoreNextSelectChange = false; - CloseDropDown(); - e.Handled = true; - } - else - { - // Ignore selected index change events when the user is navigating via the keyboard - _ignoreNextSelectChange = true; - } - } - - private void OnListBoxSelectedIndexChanged(object sender, EventArgs e) - { - // If we're ignoring this selected index change, do nothing - if (_ignoreNextSelectChange) - { - _ignoreNextSelectChange = false; - } - else - { - CloseDropDown(); - } - } - - protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) - { - _editor = (UITypeEditor)PropertyDescriptor.GetEditor(typeof(UITypeEditor)); - base.OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); - if (_editor != null) - { - _button.Ellipsis = (_editor.GetEditStyle(TypeDescriptorContext) == UITypeEditorEditStyle.Modal); - _hasSwatch = _editor.GetPaintValueSupported(TypeDescriptorContext); - } - else - { - _button.Ellipsis = false; - } - - if (_button.Ellipsis) - { - EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.StaticText : AccessibleRole.Text); - } - else - { - EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.DropList : AccessibleRole.ComboBox); - } - - _button.TabStop = _button.Ellipsis; - _button.TabIndex = currentTabIndex++; - _button.AccessibleRole = (_button.Ellipsis ? AccessibleRole.PushButton : AccessibleRole.ButtonDropDown); - _button.AccessibleDescription = EditControl.AccessibleDescription; - _button.AccessibleName = EditControl.AccessibleName; - } - - protected override void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs e) - { - base.OnReadOnlyTextBoxLabelClick(sender, e); - if (e.Button == MouseButtons.Left) - { - if (ActionPanel.DropDownActive) - { - _ignoreDropDownValue = true; - CloseDropDown(); - } - else - { - ActivateDropDown(); - } - } - } - - protected override void OnValueChanged() - { - base.OnValueChanged(); - _swatch = null; - if (_hasSwatch) - { - ActionPanel.Invalidate(new Rectangle(EditRegionLocation, EditRegionSize), false); - } - } - - public override void PaintLine(Graphics g, int lineWidth, int lineHeight) - { - base.PaintLine(g, lineWidth, lineHeight); - if (_hasSwatch) - { - if (_swatch is null) - { - int width = EditRegionSize.Height - EditorLineSwatchPadding * 2; - int height = width - 1; - _swatch = new Bitmap(width, height); - Rectangle rect = new Rectangle(1, 1, width - 2, height - 2); - using (Graphics swatchGraphics = Graphics.FromImage(_swatch)) - { - _editor.PaintValue(Value, swatchGraphics, rect); - swatchGraphics.DrawRectangle(SystemPens.ControlDark, new Rectangle(0, 0, width - 1, height - 1)); - } - } - - g.DrawImage(_swatch, new Point(EditRegionRelativeLocation.X + 2, EditorLineSwatchPadding + 5)); - } - } - - protected internal override bool ProcessDialogKey(Keys keyData) - { - // Do this here rather than in OnKeyDown because if hierarchy is properly set, VS is going to eat the F4 in PreProcessMessage, preventing it from ever getting to an OnKeyDown on this control. Doing it here also allow to not hook up to multiple events for each button. - if (!_button.Focused && !_button.Ellipsis) - { - if ((keyData == (Keys.Alt | Keys.Down)) || (keyData == (Keys.Alt | Keys.Up)) || (keyData == Keys.F4)) - { - if (!ActionPanel.DropDownActive) - { - ActivateDropDown(); - } - else - { - CloseDropDown(); - } - - return true; - } - - // Not passing Alt key event to base class to prevent closing 'Combobox Tasks window' - else if ((keyData & Keys.Alt) == Keys.Alt) - { - return true; - } - } - - return base.ProcessDialogKey(keyData); - } - - private void ShowDropDown(Control hostedControl, Color borderColor) - { - hostedControl.Width = Math.Max(hostedControl.Width, EditRegionSize.Width - 2); - _dropDownHolder = new DropDownHolder(hostedControl, ActionPanel, borderColor, ActionPanel.Font, this); - if (ActionPanel.RightToLeft != RightToLeft.Yes) - { - Rectangle editorBounds = new Rectangle(Point.Empty, EditRegionSize); - Size dropDownSize = _dropDownHolder.Size; - Point editorLocation = ActionPanel.PointToScreen(EditRegionLocation); - Rectangle rectScreen = Screen.FromRectangle(ActionPanel.RectangleToScreen(editorBounds)).WorkingArea; - dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); - editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip - Math.Max(rectScreen.X, editorLocation.X + editorBounds.Right - dropDownSize.Width)); // max = left screen edge clip - editorLocation.Y += editorBounds.Y; - if (rectScreen.Bottom < (dropDownSize.Height + editorLocation.Y + editorBounds.Height)) - { - editorLocation.Y -= dropDownSize.Height + 1; - } - else - { - editorLocation.Y += editorBounds.Height; - } - - _dropDownHolder.Location = editorLocation; - } - else - { - _dropDownHolder.RightToLeft = ActionPanel.RightToLeft; - Rectangle editorBounds = new Rectangle(Point.Empty, EditRegionSize); - Size dropDownSize = _dropDownHolder.Size; - Point editorLocation = ActionPanel.PointToScreen(EditRegionLocation); - Rectangle rectScreen = Screen.FromRectangle(ActionPanel.RectangleToScreen(editorBounds)).WorkingArea; - dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); - editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip - Math.Max(rectScreen.X, editorLocation.X - editorBounds.Width)); // max = left screen edge clip - editorLocation.Y += editorBounds.Y; - if (rectScreen.Bottom < (dropDownSize.Height + editorLocation.Y + editorBounds.Height)) - { - editorLocation.Y -= dropDownSize.Height + 1; - } - else - { - editorLocation.Y += editorBounds.Height; - } - - _dropDownHolder.Location = editorLocation; - } - - ActionPanel.InMethodInvoke = true; - ActionPanel.SetDropDownActive(true); - try - { - _dropDownHolder.ShowDropDown(_button); - } - finally - { - _button.ResetMouseStates(); - ActionPanel.SetDropDownActive(false); - ActionPanel.InMethodInvoke = false; - } - } - - #region IWindowsFormsEditorService implementation - void IWindowsFormsEditorService.CloseDropDown() - { - CloseDropDown(); - } - - void IWindowsFormsEditorService.DropDownControl(Control control) - { - ShowDropDown(control, ActionPanel.BorderColor); - } - - DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) - { - IUIService uiService = (IUIService)ServiceProvider.GetService(typeof(IUIService)); - if (uiService != null) - { - return uiService.ShowDialog(dialog); - } - - return dialog.ShowDialog(); - } - #endregion - - #region IServiceProvider implementation - object IServiceProvider.GetService(Type serviceType) - { - // Inject this class as the IWindowsFormsEditroService so drop-down custom editors can work - if (serviceType == typeof(IWindowsFormsEditorService)) - { - return this; - } - - return ServiceProvider.GetService(serviceType); - } - #endregion - - private class DropDownHolder : FlyoutDialog - { - private readonly EditorPropertyLine _parent; - public DropDownHolder(Control hostedControl, Control parentControl, Color borderColor, Font font, EditorPropertyLine parent) : base(hostedControl, parentControl, borderColor, font) - { - _parent = parent; - _parent.ActionPanel.SetDropDownActive(true); - } - - protected override void OnClosed(EventArgs e) - { - base.OnClosed(e); - _parent.ActionPanel.SetDropDownActive(false); - } - - protected override bool ProcessDialogKey(Keys keyData) - { - if (keyData == Keys.Escape) - { - // Indicates that the selection was aborted so we should ignore the value - _parent._ignoreDropDownValue = true; - Visible = false; - return true; - } - - return base.ProcessDialogKey(keyData); - } - } - - internal class FlyoutDialog : Form, IHandle - { - private readonly Control _hostedControl; - private readonly Control _parentControl; - - public FlyoutDialog(Control hostedControl, Control parentControl, Color borderColor, Font font) - { - _hostedControl = hostedControl; - _parentControl = parentControl; - BackColor = SystemColors.Window; - ControlBox = false; - Font = font; - FormBorderStyle = FormBorderStyle.None; - MinimizeBox = false; - MaximizeBox = false; - ShowInTaskbar = false; - StartPosition = FormStartPosition.Manual; - Text = string.Empty; - SuspendLayout(); - try - { - Controls.Add(hostedControl); - int width = Math.Max(_hostedControl.Width, SystemInformation.MinimumWindowSize.Width); - int height = Math.Max(_hostedControl.Height, SystemInformation.MinimizedWindowSize.Height); - if (!borderColor.IsEmpty) - { - DockPadding.All = 1; - BackColor = borderColor; - width += 2; - height += 4; - } - - _hostedControl.Dock = DockStyle.Fill; - - Width = width; - Height = height; - } - finally - { - ResumeLayout(); - } - } - - protected override CreateParams CreateParams - { - get - { - CreateParams cp = base.CreateParams; - cp.ExStyle |= (int)User32.WS_EX.TOOLWINDOW; - cp.Style |= unchecked((int)(User32.WS.POPUP | User32.WS.BORDER)); - cp.ClassStyle |= (int)User32.CS.SAVEBITS; - if (_parentControl != null) - { - if (!_parentControl.IsDisposed) - { - cp.Parent = _parentControl.Handle; - } - } - - return cp; - } - } - - public virtual void FocusComponent() - { - if (_hostedControl != null && Visible) - { - _hostedControl.Focus(); - } - } - - // Lifted directly from PropertyGridView.DropDownHolder. Less destructive than using ShowDialog(). - public void DoModalLoop() - { - while (Visible) - { - Application.DoEvents(); - User32.MsgWaitForMultipleObjectsEx(0, IntPtr.Zero, 250, User32.QS.ALLINPUT, User32.MWMO.INPUTAVAILABLE); - } - } - - /// - /// General purpose method, based on Control.Contains()... Determines whether a given window (specified using native window handle) is a descendant of this control. This catches both contained descendants and 'owned' windows such as modal dialogs. Using window handles rather than Control objects allows it to catch un-managed windows as well. - /// - private bool OwnsWindow(IntPtr hWnd) - { - while (hWnd != IntPtr.Zero) - { - hWnd = User32.GetWindowLong(hWnd, User32.GWL.HWNDPARENT); - if (hWnd == IntPtr.Zero) - { - return false; - } - - if (hWnd == Handle) - { - return true; - } - } - - return false; - } - - protected override bool ProcessDialogKey(Keys keyData) - { - if ((keyData == (Keys.Alt | Keys.Down)) || - (keyData == (Keys.Alt | Keys.Up)) || - (keyData == Keys.F4)) - { - // Any of these keys indicates the selection is accepted - Visible = false; - return true; - } - - return base.ProcessDialogKey(keyData); - } - - public void ShowDropDown(Control parent) - { - try - { - User32.SetWindowLong(this, User32.GWL.HWNDPARENT, parent.Handle); - - // Lifted directly from Form.ShowDialog()... - IntPtr hWndCapture = User32.GetCapture(); - if (hWndCapture != IntPtr.Zero) - { - User32.SendMessageW(hWndCapture, User32.WM.CANCELMODE, IntPtr.Zero, IntPtr.Zero); - User32.ReleaseCapture(); - } - - Visible = true; // NOTE: Do this AFTER creating handle and setting parent - FocusComponent(); - DoModalLoop(); - } - finally - { - User32.SetWindowLong(this, User32.GWL.HWNDPARENT, IntPtr.Zero); - - // sometimes activation goes to LALA land - if our parent control is still around, remind it to take focus. - if (parent != null && parent.Visible) - { - parent.Focus(); - } - } - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int)User32.WM.ACTIVATE) - { - if (Visible && PARAM.LOWORD(m.WParam) == (int)User32.WA.INACTIVE) - { - if (!OwnsWindow(m.LParam)) - { - Visible = false; - if (m.LParam == IntPtr.Zero) - { //we 're switching process, also dismiss the parent - Control toplevel = _parentControl.TopLevelControl; - if (toplevel is ToolStripDropDown dropDown) - { - // if it's a toolstrip dropdown let it know that we have a specific close reason. - dropDown.Close(); - } - else if (toplevel != null) - { - toplevel.Visible = false; - } - } - - return; - } - } - } - - base.WndProc(ref m); - } - } - - // Class that renders either the ellipsis or dropdown button - internal sealed class EditorButton : Button - { - private bool _mouseOver; - private bool _mouseDown; - private bool _ellipsis; - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button == MouseButtons.Left) - { - _mouseDown = true; - } - } - - protected override void OnMouseEnter(EventArgs e) - { - base.OnMouseEnter(e); - _mouseOver = true; - } - - protected override void OnMouseLeave(EventArgs e) - { - base.OnMouseLeave(e); - _mouseOver = false; - } - - protected override void OnMouseUp(MouseEventArgs e) - { - base.OnMouseUp(e); - - if (e.Button == MouseButtons.Left) - { - _mouseDown = false; - } - } - - public bool Ellipsis - { - get => _ellipsis; - set => _ellipsis = value; - } - - protected override void OnPaint(PaintEventArgs e) - { - Graphics g = e.Graphics; - if (_ellipsis) - { - PushButtonState buttonState = PushButtonState.Normal; - if (_mouseDown) - { - buttonState = PushButtonState.Pressed; - } - else if (_mouseOver) - { - buttonState = PushButtonState.Hot; - } - - ButtonRenderer.DrawButton(g, new Rectangle(-1, -1, Width + 2, Height + 2), "…", Font, Focused, buttonState); - } - else - { - if (ComboBoxRenderer.IsSupported) - { - ComboBoxState state = ComboBoxState.Normal; - if (Enabled) - { - if (_mouseDown) - { - state = ComboBoxState.Pressed; - } - else if (_mouseOver) - { - state = ComboBoxState.Hot; - } - } - else - { - state = ComboBoxState.Disabled; - } - - ComboBoxRenderer.DrawDropDownButton(g, new Rectangle(0, 0, Width, Height), state); - } - else - { - PushButtonState buttonState = PushButtonState.Normal; - if (Enabled) - { - if (_mouseDown) - { - buttonState = PushButtonState.Pressed; - } - else if (_mouseOver) - { - buttonState = PushButtonState.Hot; - } - } - else - { - buttonState = PushButtonState.Disabled; - } - - ButtonRenderer.DrawButton(g, new Rectangle(-1, -1, Width + 2, Height + 2), string.Empty, Font, Focused, buttonState); - // Draw the arrow icon - try - { - Icon icon = new Icon(typeof(DesignerActionPanel), "Arrow.ico"); - try - { - Bitmap arrowBitmap = icon.ToBitmap(); - // Make sure we draw properly under high contrast by re-mapping the arrow color to the WindowText color - ImageAttributes attrs = new ImageAttributes(); - try - { - ColorMap cm = new ColorMap - { - OldColor = Color.Black, - NewColor = SystemColors.WindowText - }; - attrs.SetRemapTable(new ColorMap[] { cm }, ColorAdjustType.Bitmap); - int imageWidth = arrowBitmap.Width; - int imageHeight = arrowBitmap.Height; - g.DrawImage(arrowBitmap, new Rectangle((Width - imageWidth + 1) / 2, (Height - imageHeight + 1) / 2, imageWidth, imageHeight), - 0, 0, imageWidth, imageWidth, GraphicsUnit.Pixel, attrs, null, IntPtr.Zero); - } - finally - { - if (attrs != null) - { - attrs.Dispose(); - } - } - } - finally - { - if (icon != null) - { - icon.Dispose(); - } - } - } - catch - { - } - } - - if (Focused) - { - ControlPaint.DrawFocusRectangle(g, new Rectangle(2, 2, Width - 5, Height - 5)); - } - } - } - - public void ResetMouseStates() - { - _mouseDown = false; - _mouseOver = false; - Invalidate(); - } - } - } - - private class TextLine : Line - { - private Label _label; - private DesignerActionTextItem _textItem; - - public TextLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - public sealed override string FocusId - { - get => string.Empty; - } - - protected override void AddControls(List controls) - { - _label = new Label - { - BackColor = Color.Transparent, - ForeColor = ActionPanel.LabelForeColor, - TextAlign = Drawing.ContentAlignment.MiddleLeft, - UseMnemonic = false - }; - controls.Add(_label); - } - - public sealed override void Focus() - { - Debug.Fail("Should never try to focus a TextLine"); - } - - public override Size LayoutControls(int top, int width, bool measureOnly) - { - Size labelSize = _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); - if (!measureOnly) - { - _label.Location = new Point(LineLeftMargin, top + LineVerticalPadding / 2); - _label.Size = labelSize; - } - - return labelSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); - } - - private void OnParentControlFontChanged(object sender, EventArgs e) - { - if (_label != null && _label.Font != null) - { - _label.Font = GetFont(); - } - } - - protected virtual Font GetFont() - { - return ActionPanel.Font; - } - - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) - { - _textItem = (DesignerActionTextItem)actionItem; - _label.Text = StripAmpersands(_textItem.DisplayName); - _label.Font = GetFont(); - _label.TabIndex = currentTabIndex++; - toolTip.SetToolTip(_label, _textItem.Description); - } - } - - private sealed class HeaderLine : TextLine - { - public HeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - protected override Font GetFont() => new Font(ActionPanel.Font, FontStyle.Bold); - } - - private sealed class SeparatorLine : Line - { - private readonly bool _isSubSeparator; - public SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : this(serviceProvider, actionPanel, false) - { - } - - public SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel, bool isSubSeparator) : base(serviceProvider, actionPanel) - { - _isSubSeparator = isSubSeparator; - } - - public sealed override string FocusId - { - get => string.Empty; - } - - public bool IsSubSeparator => _isSubSeparator; - - protected override void AddControls(List controls) - { - } - - public sealed override void Focus() => Debug.Fail("Should never try to focus a SeparatorLine"); - - public override Size LayoutControls(int top, int width, bool measureOnly) => new Size(MinimumWidth, 1); - - public override void PaintLine(Graphics g, int lineWidth, int lineHeight) - { - using (Pen p = new Pen(ActionPanel.SeparatorColor)) - { - g.DrawLine(p, SeparatorHorizontalPadding, 0, lineWidth - (SeparatorHorizontalPadding + 1), 0); - } - } - - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) - { - } - } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs index 64bf39c59f7..b81440b42db 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs @@ -339,7 +339,7 @@ private void RecreatePanel(Glyph glyphWithPanelToRegen) // we don't want to do anything if the panel is not visible if (!IsDesignerActionPanelVisible) { - Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.RecreatePanel] panel is not visible, bail"); + Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.RecreatePanel] panel is not visible, bail"); return; } @@ -601,25 +601,25 @@ private void ToolStripDropDown_Closing(object sender, ToolStripDropDownClosingEv if (_cancelClose || e.Cancel) { e.Cancel = true; - Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] cancelClose true, bail"); + Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] cancelClose true, bail"); return; } if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) { e.Cancel = true; - Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] ItemClicked: e.Cancel set to: " + e.Cancel.ToString()); + Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] ItemClicked: e.Cancel set to: " + e.Cancel.ToString()); } if (e.CloseReason == ToolStripDropDownCloseReason.Keyboard) { e.Cancel = false; - Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] Keyboard: e.Cancel set to: " + e.Cancel.ToString()); + Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] Keyboard: e.Cancel set to: " + e.Cancel.ToString()); } if (e.Cancel == false) { // we WILL disappear - Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] Closing..."); + Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] Closing..."); Debug.Assert(_lastPanelComponent != null, "last panel component should not be null here... " + "(except if you're currently debugging VS where deactivation messages in the middle of the pump can mess up everything...)"); if (_lastPanelComponent is null) @@ -644,7 +644,7 @@ private void ToolStripDropDown_Closing(object sender, ToolStripDropDownClosingEv _lastPanelComponent = null; // panel is going away, pop the behavior that's on the stack... Debug.Assert(_dapkb != null, "why is dapkb null?"); - System.Windows.Forms.Design.Behavior.Behavior popBehavior = _behaviorService.PopBehavior(_dapkb); + Behavior popBehavior = _behaviorService.PopBehavior(_dapkb); Debug.Assert(popBehavior is DesignerActionKeyboardBehavior, "behavior returned is of the wrong kind?"); } } @@ -741,7 +741,7 @@ internal void ShowDesignerActionPanel(IComponent relatedComponent, DesignerActio if (_mainParentWindow != null && _mainParentWindow.Handle != IntPtr.Zero) { Debug.WriteLineIf(s_designeActionPanelTraceSwitch.TraceVerbose, "Assigning owner to mainParentWindow"); - Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "Assigning owner to mainParentWindow"); + Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "Assigning owner to mainParentWindow"); User32.SetWindowLong(designerActionHost, User32.GWL.HWNDPARENT, new HandleRef(_mainParentWindow, _mainParentWindow.Handle)); } @@ -956,7 +956,7 @@ public void SetDesignerActionPanel(DesignerActionPanel panel, Glyph relatedGlyph } } - private void PanelResized(object sender, System.EventArgs e) + private void PanelResized(object sender, EventArgs e) { Control ctrl = sender as Control; if (Size.Width != ctrl.Size.Width || Size.Height != ctrl.Size.Height) @@ -1041,7 +1041,7 @@ internal static string GetControlInformation(IntPtr hwnd) string windowText = User32.GetWindowText(hwnd); string typeOfControl = "Unknown"; string nameOfControl = string.Empty; - Control c = Control.FromHandle(hwnd); + Control c = FromHandle(hwnd); if (c != null) { typeOfControl = c.GetType().Name; @@ -1118,7 +1118,7 @@ protected override bool ProcessDialogKey(Keys keyData) if (keyData == Keys.Enter) { IntPtr focusedControlPtr = User32.GetFocus(); - Control focusedControl = Control.FromChildHandle(focusedControlPtr); + Control focusedControl = FromChildHandle(focusedControlPtr); if (focusedControl is IButtonControl button && button is Control) { button.PerformClick(); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs index 81216c114f6..45df97459f8 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections; -using System.ComponentModel.Design; namespace System.ComponentModel.Design { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs index 6e99e8b2ef2..915372016d0 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs @@ -371,7 +371,7 @@ DesignerCollection IDesignerEventService.Designers _events = new EventHandlerList(); } - _events[s_eventActiveDesignerChanged] = Delegate.Combine((Delegate)_events[s_eventActiveDesignerChanged], value); + _events[s_eventActiveDesignerChanged] = Delegate.Combine(_events[s_eventActiveDesignerChanged], value); } remove { @@ -380,7 +380,7 @@ DesignerCollection IDesignerEventService.Designers return; } - _events[s_eventActiveDesignerChanged] = Delegate.Remove((Delegate)_events[s_eventActiveDesignerChanged], value); + _events[s_eventActiveDesignerChanged] = Delegate.Remove(_events[s_eventActiveDesignerChanged], value); } } @@ -396,7 +396,7 @@ DesignerCollection IDesignerEventService.Designers _events = new EventHandlerList(); } - _events[s_eventDesignerCreated] = Delegate.Combine((Delegate)_events[s_eventDesignerCreated], value); + _events[s_eventDesignerCreated] = Delegate.Combine(_events[s_eventDesignerCreated], value); } remove { @@ -405,7 +405,7 @@ DesignerCollection IDesignerEventService.Designers return; } - _events[s_eventDesignerCreated] = Delegate.Remove((Delegate)_events[s_eventDesignerCreated], value); + _events[s_eventDesignerCreated] = Delegate.Remove(_events[s_eventDesignerCreated], value); } } @@ -421,7 +421,7 @@ DesignerCollection IDesignerEventService.Designers _events = new EventHandlerList(); } - _events[s_eventDesignerDisposed] = Delegate.Combine((Delegate)_events[s_eventDesignerDisposed], value); + _events[s_eventDesignerDisposed] = Delegate.Combine(_events[s_eventDesignerDisposed], value); } remove { @@ -430,7 +430,7 @@ DesignerCollection IDesignerEventService.Designers return; } - _events[s_eventDesignerDisposed] = Delegate.Remove((Delegate)_events[s_eventDesignerDisposed], value); + _events[s_eventDesignerDisposed] = Delegate.Remove(_events[s_eventDesignerDisposed], value); } } @@ -446,7 +446,7 @@ DesignerCollection IDesignerEventService.Designers _events = new EventHandlerList(); } - _events[s_eventSelectionChanged] = Delegate.Combine((Delegate)_events[s_eventSelectionChanged], value); + _events[s_eventSelectionChanged] = Delegate.Combine(_events[s_eventSelectionChanged], value); } remove { @@ -455,7 +455,7 @@ DesignerCollection IDesignerEventService.Designers return; } - _events[s_eventSelectionChanged] = Delegate.Remove((Delegate)_events[s_eventSelectionChanged], value); + _events[s_eventSelectionChanged] = Delegate.Remove(_events[s_eventSelectionChanged], value); } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs index 8cb21554c76..398a65d7a54 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs @@ -731,7 +731,7 @@ private void Unload() foreach (IComponent comp in components) { - if (!object.ReferenceEquals(comp, _rootComponent)) + if (!ReferenceEquals(comp, _rootComponent)) { if (_designers[comp] is IDesigner designer) { @@ -955,7 +955,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event EventHandler IDesignerHost.Activated { @@ -964,7 +964,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event EventHandler IDesignerHost.Deactivated { @@ -973,7 +973,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event EventHandler IDesignerHost.LoadComplete { @@ -982,7 +982,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event DesignerTransactionCloseEventHandler IDesignerHost.TransactionClosed { @@ -991,7 +991,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event DesignerTransactionCloseEventHandler IDesignerHost.TransactionClosing { @@ -1000,7 +1000,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event EventHandler IDesignerHost.TransactionOpened { @@ -1009,7 +1009,7 @@ string IDesignerHost.TransactionDescription } /// - /// Adds an event handler for the event. + /// Adds an event handler for the event. /// event EventHandler IDesignerHost.TransactionOpening { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs index 548393b346d..c283b7ebd4f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs @@ -212,7 +212,7 @@ public override void SetValue(object component, object value) ReferenceEventClosure key = new ReferenceEventClosure(component, this); string oldName = (string)ds.GetValue(key); - if (object.ReferenceEquals(oldName, name)) + if (ReferenceEquals(oldName, name)) { return; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs index 6a7642d989c..f70955d5d4d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs @@ -16,7 +16,7 @@ namespace System.ComponentModel.Design /// public abstract partial class EventBindingService : IEventBindingService { - private IServiceProvider _provider; + private readonly IServiceProvider _provider; private IComponent _showCodeComponent; private EventDescriptor _showCodeEventDescriptor; private string _showCodeMethodName; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs index 42fc46ac12a..25eb3c051f3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs @@ -24,7 +24,7 @@ public class InheritanceService : IInheritanceService, IDisposable private InheritanceAttribute _addingAttribute; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public InheritanceService() { @@ -32,7 +32,7 @@ public InheritanceService() } /// - /// Disposes of the resources (other than memory) used by the . + /// Disposes of the resources (other than memory) used by the . /// public void Dispose() { @@ -49,7 +49,7 @@ protected virtual void Dispose(bool disposing) } /// - /// Adds inherited components to the . + /// Adds inherited components to the . /// public void AddInheritedComponents(IComponent component, IContainer container) { @@ -57,7 +57,7 @@ public void AddInheritedComponents(IComponent component, IContainer container) } /// - /// Adds inherited components to the . + /// Adds inherited components to the . /// protected virtual void AddInheritedComponents(Type type, IComponent component, IContainer container) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs index e1770e27a25..1452e86c079 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs @@ -17,12 +17,12 @@ internal sealed class InheritedPropertyDescriptor : PropertyDescriptor { private PropertyDescriptor propertyDescriptor; private object _defaultValue; - private static readonly object s_noDefault = new Object(); + private static readonly object s_noDefault = new object(); private bool _initShouldSerialize; private object _originalValue; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public InheritedPropertyDescriptor(PropertyDescriptor propertyDescriptor, object component) : base(propertyDescriptor, Array.Empty()) { @@ -173,7 +173,7 @@ public override bool CanResetValue(object component) } else { - return !object.Equals(GetValue(component), _defaultValue); + return !Equals(GetValue(component), _defaultValue); } } @@ -321,7 +321,7 @@ public override bool ShouldSerializeValue(object component) } else { - return !object.Equals(GetValue(component), _defaultValue); + return !Equals(GetValue(component), _defaultValue); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs index ccadaebc53a..162cbde96ef 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs @@ -10,18 +10,18 @@ namespace System.ComponentModel.Design { /// - /// The menu command service allows designers to add and respond to - /// menu and toolbar items. It is based on two interfaces. Designers - /// request IMenuCommandService to add menu command handlers, while - /// the document or tool window forwards IOleCommandTarget requests - /// to this object. + /// The menu command service allows designers to add and respond to + /// menu and toolbar items. It is based on two interfaces. Designers + /// request IMenuCommandService to add menu command handlers, while + /// the document or tool window forwards IOleCommandTarget requests + /// to this object. /// public class MenuCommandService : IMenuCommandService, IDisposable { private IServiceProvider _serviceProvider; - private Dictionary _commandGroups; - private object _commandGroupsLock; - private EventHandler _commandChangedHandler; + private readonly Dictionary _commandGroups; + private readonly object _commandGroupsLock; + private readonly EventHandler _commandChangedHandler; private MenuCommandsChangedEventHandler _commandsChangedHandler; private ArrayList _globalVerbs; private ISelectionService _selectionService; @@ -41,20 +41,20 @@ public class MenuCommandService : IMenuCommandService, IDisposable private Type _verbSourceType; /// - /// Creates a new menu command service. + /// Creates a new menu command service. /// public MenuCommandService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; - _commandGroupsLock = new Object(); + _commandGroupsLock = new object(); _commandGroups = new Dictionary(); - _commandChangedHandler = new EventHandler(this.OnCommandChanged); - TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnTypeRefreshed); + _commandChangedHandler = new EventHandler(OnCommandChanged); + TypeDescriptor.Refreshed += new RefreshEventHandler(OnTypeRefreshed); } /// - /// This event is thrown whenever a MenuCommand is removed - /// or added + /// This event is thrown whenever a MenuCommand is removed + /// or added /// public event MenuCommandsChangedEventHandler MenuCommandsChanged { @@ -69,9 +69,9 @@ public MenuCommandService(IServiceProvider serviceProvider) } /// - /// Retrieves a set of verbs that are global to all objects on the design - /// surface. This set of verbs will be merged with individual component verbs. - /// In the case of a name conflict, the component verb will NativeMethods. + /// Retrieves a set of verbs that are global to all objects on the design + /// surface. This set of verbs will be merged with individual component verbs. + /// In the case of a name conflict, the component verb will NativeMethods. /// public virtual DesignerVerbCollection Verbs { @@ -83,8 +83,8 @@ public virtual DesignerVerbCollection Verbs } /// - /// Adds a menu command to the document. The menu command must already exist - /// on a menu; this merely adds a handler for it. + /// Adds a menu command to the document. The menu command must already exist + /// on a menu; this merely adds a handler for it. /// public virtual void AddCommand(MenuCommand command) { @@ -124,10 +124,10 @@ public virtual void AddCommand(MenuCommand command) } /// - /// Adds a verb to the set of global verbs. Individual components should - /// use the Verbs property of their designer, rather than call this method. - /// This method is intended for objects that want to offer a verb that is - /// available regardless of what components are selected. + /// Adds a verb to the set of global verbs. Individual components should + /// use the Verbs property of their designer, rather than call this method. + /// This method is intended for objects that want to offer a verb that is + /// available regardless of what components are selected. /// public virtual void AddVerb(DesignerVerb verb) { @@ -151,7 +151,7 @@ public virtual void AddVerb(DesignerVerb verb) } /// - /// Disposes of this service. + /// Disposes of this service. /// public void Dispose() { @@ -159,7 +159,7 @@ public void Dispose() } /// - /// Disposes of this service. + /// Disposes of this service. /// protected virtual void Dispose(bool disposing) { @@ -167,14 +167,14 @@ protected virtual void Dispose(bool disposing) { if (_selectionService != null) { - _selectionService.SelectionChanging -= new EventHandler(this.OnSelectionChanging); + _selectionService.SelectionChanging -= new EventHandler(OnSelectionChanging); _selectionService = null; } if (_serviceProvider != null) { _serviceProvider = null; - TypeDescriptor.Refreshed -= new RefreshEventHandler(this.OnTypeRefreshed); + TypeDescriptor.Refreshed -= new RefreshEventHandler(OnTypeRefreshed); } lock (_commandGroupsLock) @@ -194,7 +194,7 @@ protected virtual void Dispose(bool disposing) } /// - /// Ensures that the verb list has been created. + /// Ensures that the verb list has been created. /// protected void EnsureVerbs() { @@ -214,7 +214,7 @@ protected void EnsureVerbs() if (_selectionService != null) { - _selectionService.SelectionChanging += new EventHandler(this.OnSelectionChanging); + _selectionService.SelectionChanging += new EventHandler(OnSelectionChanging); } } @@ -339,8 +339,8 @@ protected void EnsureVerbs() } /// - /// Searches for the given command ID and returns the MenuCommand - /// associated with it. + /// Searches for the given command ID and returns the MenuCommand + /// associated with it. /// public MenuCommand FindCommand(CommandID commandID) { @@ -348,8 +348,8 @@ public MenuCommand FindCommand(CommandID commandID) } /// - /// Locates the requested command. This will throw an appropriate - /// ComFailException if the command couldn't be found. + /// Locates the requested command. This will throw an appropriate + /// ComFailException if the command couldn't be found. /// protected MenuCommand FindCommand(Guid guid, int id) { @@ -419,7 +419,7 @@ protected MenuCommand FindCommand(Guid guid, int id) } /// - /// Get the command list for a given GUID + /// Get the command list for a given GUID /// protected ICollection GetCommandList(Guid guid) { @@ -450,10 +450,10 @@ protected object GetService(Type serviceType) } /// - /// Invokes a command on the local form or in the global environment. - /// The local form is first searched for the given command ID. If it is - /// found, it is invoked. Otherwise the the command ID is passed to the - /// global environment command handler, if one is available. + /// Invokes a command on the local form or in the global environment. + /// The local form is first searched for the given command ID. If it is + /// found, it is invoked. Otherwise the the command ID is passed to the + /// global environment command handler, if one is available. /// public virtual bool GlobalInvoke(CommandID commandID) { @@ -469,10 +469,10 @@ public virtual bool GlobalInvoke(CommandID commandID) } /// - /// Invokes a command on the local form or in the global environment. - /// The local form is first searched for the given command ID. If it is - /// found, it is invoked. Otherwise the the command ID is passed to the - /// global environment command handler, if one is available. + /// Invokes a command on the local form or in the global environment. + /// The local form is first searched for the given command ID. If it is + /// found, it is invoked. Otherwise the the command ID is passed to the + /// global environment command handler, if one is available. /// public virtual bool GlobalInvoke(CommandID commandId, object arg) { @@ -488,7 +488,7 @@ public virtual bool GlobalInvoke(CommandID commandId, object arg) } /// - /// This is called by a menu command when it's status has changed. + /// This is called by a menu command when it's status has changed. /// private void OnCommandChanged(object sender, EventArgs e) { @@ -508,8 +508,8 @@ protected virtual void OnCommandsChanged(MenuCommandsChangedEventArgs e) } /// - /// Called by TypeDescriptor when a type changes. If this type is currently holding - /// our verb, invalidate the list. + /// Called by TypeDescriptor when a type changes. If this type is currently holding + /// our verb, invalidate the list. /// private void OnTypeRefreshed(RefreshEventArgs e) { @@ -520,8 +520,8 @@ private void OnTypeRefreshed(RefreshEventArgs e) } /// - /// This is called by the selection service when the selection has changed. Here - /// we invalidate our verb list. + /// This is called by the selection service when the selection has changed. Here + /// we invalidate our verb list. /// private void OnSelectionChanging(object sender, EventArgs e) { @@ -533,7 +533,7 @@ private void OnSelectionChanging(object sender, EventArgs e) } /// - /// Removes the given menu command from the document. + /// Removes the given menu command from the document. /// public virtual void RemoveCommand(MenuCommand command) { @@ -573,7 +573,7 @@ public virtual void RemoveCommand(MenuCommand command) } /// - /// Removes the given verb from the document. + /// Removes the given verb from the document. /// public virtual void RemoveVerb(DesignerVerb verb) { @@ -600,8 +600,8 @@ public virtual void RemoveVerb(DesignerVerb verb) } /// - /// Shows the context menu with the given command ID at the given - /// location. + /// Shows the context menu with the given command ID at the given + /// location. /// public virtual void ShowContextMenu(CommandID menuID, int x, int y) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs index dcbc8379e51..3cd4123db9b 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs @@ -5,16 +5,16 @@ namespace System.ComponentModel.Design { /// - /// This EventArgs class is used by the MenuCommandService to signify - /// that there has been a change in MenuCommands (added or removed) - /// on the related object. + /// This EventArgs class is used by the MenuCommandService to signify + /// that there has been a change in MenuCommands (added or removed) + /// on the related object. /// public class MenuCommandsChangedEventArgs : EventArgs { /// - /// Constructor that requires the object in question, the type of change - /// and the remaining commands left for the object. "command" can be null - /// to signify multiple commands changed at once. + /// Constructor that requires the object in question, the type of change + /// and the remaining commands left for the object. "command" can be null + /// to signify multiple commands changed at once. /// public MenuCommandsChangedEventArgs(MenuCommandsChangedType changeType, MenuCommand command) { @@ -23,13 +23,13 @@ public MenuCommandsChangedEventArgs(MenuCommandsChangedType changeType, MenuComm } /// - /// The type of changed that caused the related event - /// to be thrown. + /// The type of changed that caused the related event + /// to be thrown. /// public MenuCommandsChangedType ChangeType { get; } /// - /// The command that was added/removed/changed. This can be null if more than one command changed at once. + /// The command that was added/removed/changed. This can be null if more than one command changed at once. /// public MenuCommand Command { get; } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs index 25a5d5a8a28..74789cc2e65 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs @@ -5,8 +5,8 @@ namespace System.ComponentModel.Design { /// - /// This event is thown by the MenuCommandService when a shortcut - /// is either added or removed to/from the related object. + /// This event is thown by the MenuCommandService when a shortcut + /// is either added or removed to/from the related object. /// public delegate void MenuCommandsChangedEventHandler(object sender, MenuCommandsChangedEventArgs e); } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs index 6b5bc4c8990..0cc7b275106 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs @@ -5,23 +5,23 @@ namespace System.ComponentModel.Design { /// - /// An enum that defines what time of action happend to the - /// related object's MenuCommands collection. + /// An enum that defines what time of action happend to the + /// related object's MenuCommands collection. /// public enum MenuCommandsChangedType { /// - /// Signifies that one or more DesignerShortcut was added. + /// Signifies that one or more DesignerShortcut was added. /// CommandAdded, /// - /// Signifies that one or more DesignerShortcut was removed. + /// Signifies that one or more DesignerShortcut was removed. /// CommandRemoved, /// - /// Signifies that one or more commands have changed their status. + /// Signifies that one or more commands have changed their status. /// CommandChanged, } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs index 990f82579a6..80483e88167 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs @@ -284,7 +284,7 @@ public override Size MinimumSize Rectangle workingArea = Screen.GetWorkingArea(this); _minimumSize = new Size( (int)Math.Min(Math.Ceiling(WatermarkSize.Width * 1.75), workingArea.Width / 3), - (int)Math.Min(Font.Height * 10, workingArea.Height / 3)); + Math.Min(Font.Height * 10, workingArea.Height / 3)); } return _minimumSize; @@ -346,7 +346,7 @@ public void ProcessSurrogateFonts(int start, int length) if (replaceFont != null) { int selectionLength = (i == surrogates.Length - 1) ? value.Length - surrogates[i] : surrogates[i + 1] - surrogates[i]; - base.Select(surrogates[i], selectionLength); + Select(surrogates[i], selectionLength); SelectionFont = replaceFont; } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs index 48945bf0ebd..598ed87acc4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs @@ -175,7 +175,7 @@ private void OnComponentRename(object sender, ComponentRenameEventArgs cevent) { foreach (ReferenceHolder reference in _references) { - if (object.ReferenceEquals(reference.SitedComponent, cevent.Component)) + if (ReferenceEquals(reference.SitedComponent, cevent.Component)) { reference.ResetName(); return; @@ -193,7 +193,7 @@ private void RemoveReferences(IComponent component) int size = _references.Count; for (int i = size - 1; i >= 0; i--) { - if (object.ReferenceEquals(((ReferenceHolder)_references[i]).SitedComponent, component)) + if (ReferenceEquals(((ReferenceHolder)_references[i]).SitedComponent, component)) { _references.RemoveAt(i); } @@ -233,7 +233,7 @@ IComponent IReferenceService.GetComponent(object reference) EnsureReferences(); foreach (ReferenceHolder holder in _references) { - if (object.ReferenceEquals(holder.Reference, reference)) + if (ReferenceEquals(holder.Reference, reference)) { return holder.SitedComponent; } @@ -255,7 +255,7 @@ string IReferenceService.GetName(object reference) EnsureReferences(); foreach (ReferenceHolder holder in _references) { - if (object.ReferenceEquals(holder.Reference, reference)) + if (ReferenceEquals(holder.Reference, reference)) { return holder.Name; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs index 59a955e2634..e9634086ba4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs @@ -184,7 +184,7 @@ internal void RemoveSelection(object sel) private void ApplicationIdle(object source, EventArgs args) { UpdateHelpKeyword(false); - Windows.Forms.Application.Idle -= new EventHandler(ApplicationIdle); + Application.Idle -= new EventHandler(ApplicationIdle); } /// @@ -199,7 +199,7 @@ private void UpdateHelpKeyword(bool tryLater) // we don't have an help service YET, we need to wait for it... // hook up to the application.idle event // yes this is UGLY but we don't have a choice, vs is always returning a UserContext, so even if we manage to instanciate the HelpService beforehand and class pushcontext on it (trying to stack up help context in the helpservice to be flushed when we get the documentactivation event we just don't know if that's going to work or not... so we just wait...) :((( - Windows.Forms.Application.Idle += new EventHandler(ApplicationIdle); + Application.Idle += new EventHandler(ApplicationIdle); } return; @@ -328,7 +328,7 @@ int ISelectionService.SelectionCount } /// - /// Adds a event handler to the selection service. + /// Adds a event handler to the selection service. /// event EventHandler ISelectionService.SelectionChanged { @@ -462,7 +462,7 @@ void ISelectionService.SetSelectedComponents(ICollection components, SelectionTy throw new ArgumentNullException(nameof(components)); } - if (object.ReferenceEquals(comp, item)) + if (ReferenceEquals(comp, item)) { remove = false; break; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs index a63888b39f9..7a61e9a82b7 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs @@ -733,7 +733,7 @@ private void OnIdle(object sender, EventArgs e) if (mgr != null && thisSurface != null) { - if (!object.ReferenceEquals(mgr.ActiveDesignSurface, thisSurface)) + if (!ReferenceEquals(mgr.ActiveDesignSurface, thisSurface)) { //somehow, we got deactivated and weren't told. _state[s_stateActiveDocument] = false; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs index 79a1dc95013..af7689dadd1 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs @@ -612,7 +612,7 @@ internal static void TraceCode(string name, object code) return; } - System.CodeDom.Compiler.ICodeGenerator codeGenerator = new Microsoft.CSharp.CSharpCodeProvider().CreateGenerator(); + CodeDom.Compiler.ICodeGenerator codeGenerator = new Microsoft.CSharp.CSharpCodeProvider().CreateGenerator(); using var sw = new StringWriter(CultureInfo.InvariantCulture); Trace("Stored CodeDom for {0}: ", name); Debug.Indent(); @@ -753,7 +753,7 @@ internal void Deserialize(IDesignerSerializationManager manager, IDictionary obj _statementsTable = new Hashtable(); // generate statement table keyed on component name - CodeDomSerializerBase.FillStatementTable(manager, _statementsTable, mappedStatements); + FillStatementTable(manager, _statementsTable, mappedStatements); // We need to also ensure that for every entry in the statement table we have a corresponding entry in objectNames. Otherwise, we won't deserialize completely. ArrayList completeNames = new ArrayList(objectNames); @@ -1696,13 +1696,13 @@ protected override object CreateInstance(Type type, ICollection arguments, strin return base.CreateInstance(type, arguments, name, addToContainer); } - private Nullable TypeResolutionAvailable + private bool? TypeResolutionAvailable { get { if (!_typeSvcAvailable.HasValue) { - _typeSvcAvailable = new Nullable(GetService(typeof(ITypeResolutionService)) != null); + _typeSvcAvailable = new bool?(GetService(typeof(ITypeResolutionService)) != null); } return _typeSvcAvailable.Value; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs index 57e4e148bcb..43563f2a038 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs @@ -42,7 +42,7 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul => GetConverter(context).ConvertTo(context, culture, value, destinationType); /// - /// Re-creates an given a set of property values for the + /// Re-creates an given a set of property values for the /// object. /// public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) @@ -76,7 +76,7 @@ private TypeConverter GetConverter(ITypeDescriptorContext context) /// /// Gets a value indicating whether changing a value on this object requires a - /// call to to create a new value, + /// call to to create a new value, /// using the specified context. /// public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) @@ -141,7 +141,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex /// /// Gets a value indicating whether the collection of standard values returned from - /// is an exclusive + /// is an exclusive /// list of possible values, using the specified context. /// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs index 0927a632b52..50a54d8ce92 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs @@ -95,7 +95,7 @@ public override void Dispose() { if (GetService(typeof(IComponentChangeService)) is IComponentChangeService cs) { - cs.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved); + cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); cs.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); } @@ -738,7 +738,7 @@ protected override void OnBeginLoad() if (cs != null) { - cs.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved); + cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); cs.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); } @@ -822,7 +822,7 @@ protected override void OnEndLoad(bool successful, ICollection errors) return; } - cs.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved); + cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); cs.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs index 8cdbb863664..4a7c37d702a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs @@ -20,8 +20,8 @@ namespace System.ComponentModel.Design.Serialization public sealed class CodeDomLocalizationProvider : IDisposable, IDesignerSerializationProvider { private IExtenderProviderService _providerService; - private CodeDomLocalizationModel _model; - private CultureInfo[] _supportedCultures; + private readonly CodeDomLocalizationModel _model; + private readonly CultureInfo[] _supportedCultures; private LanguageExtenders _extender; private Hashtable _memberSerializers; private Hashtable _nopMemberSerializers; @@ -205,8 +205,7 @@ private object GetMemberCodeDomSerializer(IDesignerSerializationManager manager, _nopMemberSerializers = new Hashtable(); } - object newSerializer = null; - + object newSerializer; if (model == CodeDomLocalizationModel.None) { newSerializer = _nopMemberSerializers[currentSerializer]; @@ -260,10 +259,10 @@ object IDesignerSerializationProvider.GetSerializer(IDesignerSerializationManage [ProvideProperty("Localizable", typeof(IComponent))] internal class LanguageExtenders : IExtenderProvider { - private IServiceProvider _serviceProvider; - private IDesignerHost _host; + private readonly IServiceProvider _serviceProvider; + private readonly IDesignerHost _host; private IComponent _lastRoot; - private TypeConverter.StandardValuesCollection _supportedCultures; + private readonly TypeConverter.StandardValuesCollection _supportedCultures; private bool _localizable; private CultureInfo _language; private CultureInfo _loadLanguage; @@ -358,7 +357,7 @@ private void CheckRoot() [DesignOnly(true)] [TypeConverter(typeof(LanguageCultureInfoConverter))] [Category("Design")] - [SRDescriptionAttribute("LocalizationProviderLanguageDescr")] + [SRDescription("LocalizationProviderLanguageDescr")] public CultureInfo GetLanguage(IComponent o) { CheckRoot(); @@ -391,7 +390,7 @@ public CultureInfo GetLoadLanguage(IComponent o) /// [DesignOnly(true)] [Category("Design")] - [SRDescriptionAttribute("LocalizationProviderLocalizableDescr")] + [SRDescription("LocalizationProviderLocalizableDescr")] public bool GetLocalizable(IComponent o) { CheckRoot(); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs index 12f5bad6de0..af860dcd4f6 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs @@ -198,7 +198,7 @@ public virtual object Serialize(IDesignerSerializationManager manager, object va } // We need to find out if SerializeCreationExpression returned a preset expression. - if (manager.Context[typeof(ExpressionContext)] is ExpressionContext cxt && object.ReferenceEquals(cxt.PresetValue, value)) + if (manager.Context[typeof(ExpressionContext)] is ExpressionContext cxt && ReferenceEquals(cxt.PresetValue, value)) { isPreset = true; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs index a9e5cc3383d..b31c0673e5f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs @@ -1849,12 +1849,12 @@ private object ExecuteMathOperator(IConvertible left, IConvertible right, CodeBi string leftString = left as string; string rightString = right as string; - if (leftString is null && left is Char) + if (leftString is null && left is char) { leftString = left.ToString(); } - if (rightString is null && right is Char) + if (rightString is null && right is char) { rightString = right.ToString(); } @@ -2017,7 +2017,7 @@ internal static void TraceWarning(string message, params object[] values) // relationship, which isn't a problem during normal serialization (since it not very // likely the property has already been assigned to), but it does affect undo. MemberRelationship oldRelation = MemberRelationship.Empty; - MemberRelationshipService relationships = null; + MemberRelationshipService relationships; if (statement.Right is CodePropertyReferenceExpression) { relationships = manager.GetService(typeof(MemberRelationshipService)) as MemberRelationshipService; @@ -2129,7 +2129,7 @@ protected CodeExpression GetExpression(IDesignerSerializationManager manager, ob // Check to see if this object represents the root context. if (expression is null) { - if (manager.Context[typeof(RootContext)] is RootContext rootEx && object.ReferenceEquals(rootEx.Value, value)) + if (manager.Context[typeof(RootContext)] is RootContext rootEx && ReferenceEquals(rootEx.Value, value)) { expression = rootEx.Expression; TraceIf(expression != null, "Resolved through root expression context : {0}", expression); @@ -2184,7 +2184,7 @@ protected CodeExpression GetExpression(IDesignerSerializationManager manager, ob // Finally, the expression context. if (expression is null) { - if (manager.Context[typeof(ExpressionContext)] is ExpressionContext cxt && object.ReferenceEquals(cxt.PresetValue, value)) + if (manager.Context[typeof(ExpressionContext)] is ExpressionContext cxt && ReferenceEquals(cxt.PresetValue, value)) { expression = cxt.Expression; } @@ -2200,8 +2200,7 @@ protected CodeExpression GetExpression(IDesignerSerializationManager manager, ob if (parentEntry != null && parentEntry.Component != value /* don't make ourselves dependent with ourselves */ && cache != null) { - ComponentCache.Entry entry = null; - entry = cache.GetEntryAll(value); + ComponentCache.Entry entry = cache.GetEntryAll(value); if (entry != null && parentEntry.Component != null) { entry.AddDependency(parentEntry.Component); @@ -2376,7 +2375,7 @@ protected CodeExpression SerializeCreationExpression(IDesignerSerializationManag TypeConverter converter = TypeDescriptor.GetConverter(value); // See if there is an ExpressionContext with a preset value we're interested in. If so, that will dictate our creation expression. - if (manager.Context[typeof(ExpressionContext)] is ExpressionContext cxt && object.ReferenceEquals(cxt.PresetValue, value)) + if (manager.Context[typeof(ExpressionContext)] is ExpressionContext cxt && ReferenceEquals(cxt.PresetValue, value)) { CodeExpression expression = cxt.Expression; //Okay, we found a preset creation expression. We just need to find if it isComplete. diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs index 9297ed25517..fa9b5c01092 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs @@ -354,8 +354,6 @@ protected virtual object SerializeCollection(IDesignerSerializationManager manag { result = arrayCreate; } - - serialized = true; } } else if (valuesToSerialize.Count > 0) @@ -494,7 +492,7 @@ private CodeArrayCreateExpression SerializeArray(IDesignerSerializationManager m expression = new CodeCastExpression(elementType, expression); } - arrayCreate.Initializers.Add((CodeExpression)expression); + arrayCreate.Initializers.Add(expression); } else { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs index 64740fb44b4..e223fabee90 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs @@ -963,7 +963,7 @@ private sealed class ReferenceComparer : IEqualityComparer { bool IEqualityComparer.Equals(object x, object y) { - return object.ReferenceEquals(x, y); + return ReferenceEquals(x, y); } int IEqualityComparer.GetHashCode(object x) diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs index cb26f783aef..d066a61f579 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs @@ -76,7 +76,7 @@ public override object Serialize(IDesignerSerializationManager manager, object v foreach (Enum term in values) { string termString = enumConverter?.ConvertToString(term); - CodeExpression newExpression = !String.IsNullOrEmpty(termString) ? new CodeFieldReferenceExpression(enumType, termString) : null; + CodeExpression newExpression = !string.IsNullOrEmpty(termString) ? new CodeFieldReferenceExpression(enumType, termString) : null; if (newExpression != null) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs index b36eca74c4e..61f9c480c0d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs @@ -64,9 +64,9 @@ public override void Serialize(IDesignerSerializationManager manager, object val if (methodName != null) { - CodeDomSerializer.Trace("Event {0} bound to {1}", eventToSerialize.Name, methodName); + Trace("Event {0} bound to {1}", eventToSerialize.Name, methodName); CodeExpression eventTarget = SerializeToExpression(manager, value); - CodeDomSerializer.TraceWarningIf(eventTarget is null, "Object has no name and no propery ref in context so we cannot serialize events: {0}", value); + TraceWarningIf(eventTarget is null, "Object has no name and no propery ref in context so we cannot serialize events: {0}", value); if (eventTarget != null) { CodeTypeReference delegateTypeRef = new CodeTypeReference(eventToSerialize.EventType); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs index 1cc04d86cbd..7af3f72409f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.CodeDom; -using System.Diagnostics; namespace System.ComponentModel.Design.Serialization { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs index f917c802518..8b161138cd9 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs @@ -81,7 +81,7 @@ private class ReferenceComparer : IEqualityComparer { bool IEqualityComparer.Equals(object x, object y) { - return object.ReferenceEquals(x, y); + return ReferenceEquals(x, y); } int IEqualityComparer.GetHashCode(object x) diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs index 621de0f63ac..1a19d93bc43 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs @@ -103,12 +103,10 @@ public override object Serialize(IDesignerSerializationManager manager, object v // reflecting model. In this case we'll skip it and fall through to the // property assignment model. bool skipPropertyReflect = false; - ExtenderProvidedPropertyAttribute attr = null; if (desc != null) { - attr = desc.Attributes[typeof(ExtenderProvidedPropertyAttribute)] as ExtenderProvidedPropertyAttribute; - + var attr = desc.Attributes[typeof(ExtenderProvidedPropertyAttribute)] as ExtenderProvidedPropertyAttribute; if (attr != null && attr.ExtenderProperty != null) { skipPropertyReflect = true; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs index 62c7b01bf95..f1e5709a52b 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs @@ -168,8 +168,6 @@ private void SerializeContentProperty(IDesignerSerializationManager manager, obj // For persist contents objects, we don't just serialize the properties on the object; we // serialize everything. // - CodeDomSerializer serializer = null; - if (propertyValue is null) { CodeDomSerializer.TraceError("Property {0} is marked as Visibility.Content but it is returning null.", property.Name); @@ -185,7 +183,7 @@ private void SerializeContentProperty(IDesignerSerializationManager manager, obj } else { - serializer = (CodeDomSerializer)manager.GetSerializer(propertyValue.GetType(), typeof(CodeDomSerializer)); + var serializer = (CodeDomSerializer)manager.GetSerializer(propertyValue.GetType(), typeof(CodeDomSerializer)); if (serializer != null) { // Create a property reference expression and push it on the context stack. diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs index 65e22b055a3..802a4d117e2 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs @@ -14,9 +14,9 @@ namespace System.ComponentModel.Design.Serialization /// internal class ResourcePropertyMemberCodeDomSerializer : MemberCodeDomSerializer { - private CodeDomLocalizationModel _model; - private MemberCodeDomSerializer _serializer; - private CodeDomLocalizationProvider.LanguageExtenders _extender; + private readonly CodeDomLocalizationModel _model; + private readonly MemberCodeDomSerializer _serializer; + private readonly CodeDomLocalizationProvider.LanguageExtenders _extender; private CultureInfo localizationLanguage; internal ResourcePropertyMemberCodeDomSerializer(MemberCodeDomSerializer serializer, CodeDomLocalizationProvider.LanguageExtenders extender, CodeDomLocalizationModel model) diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs b/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs new file mode 100644 index 00000000000..ca06a386651 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs @@ -0,0 +1,254 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Configuration; +using System.Drawing.Configuration; +using System.IO; +using System.Reflection; + +namespace System.Drawing +{ + /// + /// Provides methods to select from multiple bitmaps depending on a "bitmapSuffix" config setting. + /// + internal static class BitmapSelector + { + /// + /// Gets the bitmap ID suffix defined in the application configuration, or string.Empty if + /// the suffix is not specified. Internal for unit tests + /// + /// + /// For performance, the suffix is cached in a static variable so it only has to be read + /// once per appdomain. + /// + private static string _suffix; + internal static string Suffix + { + get + { + if (_suffix == null) + { + _suffix = string.Empty; + var section = ConfigurationManager.GetSection("system.drawing") as SystemDrawingSection; + if (section != null) + { + var value = section.BitmapSuffix; + if (value != null && value is string) + { + _suffix = value; + } + } + } + + return _suffix; + } + set + { + // So unit tests can clear the cached suffix + _suffix = value; + } + } + + /// + /// Appends the current suffix to . The suffix is appended + /// before the existing extension (if any). Internal for unit tests. + /// + /// + /// The new path with the suffix included. If there is no suffix defined or there are + /// invalid characters in the original path, the original path is returned. + /// + internal static string AppendSuffix(string filePath) + { + try + { + return Path.ChangeExtension(filePath, Suffix + Path.GetExtension(filePath)); + } + catch (ArgumentException) + { // there are invalid characters in the path + return filePath; + } + } + + /// + /// Returns with the current suffix appended (before the + /// existing extension) if the resulting file path exists; otherwise the original path is + /// returned. + /// + public static string GetFileName(string originalPath) + { + if (Suffix == string.Empty) + return originalPath; + + string newPath = AppendSuffix(originalPath); + return File.Exists(newPath) ? newPath : originalPath; + } + + // Calls assembly.GetManifestResourceStream in a try/catch and returns null if not found + private static Stream GetResourceStreamHelper(Assembly assembly, Type type, string name) + { + Stream stream = null; + try + { + stream = assembly.GetManifestResourceStream(type, name); + } + catch (FileNotFoundException) + { + } + + return stream; + } + + private static bool DoesAssemblyHaveCustomAttribute(Assembly assembly, string typeName) + { + return DoesAssemblyHaveCustomAttribute(assembly, assembly.GetType(typeName)); + } + + private static bool DoesAssemblyHaveCustomAttribute(Assembly assembly, Type attrType) + { + if (attrType != null) + { + var attr = assembly.GetCustomAttributes(attrType, false); + if (attr.Length > 0) + { + return true; + } + } + + return false; + } + + // internal for unit tests + internal static bool SatelliteAssemblyOptIn(Assembly assembly) + { + // Try 4.5 public attribute type first + if (DoesAssemblyHaveCustomAttribute(assembly, typeof(BitmapSuffixInSatelliteAssemblyAttribute))) + { + return true; + } + + // Also load attribute type by name for dlls compiled against older frameworks + return DoesAssemblyHaveCustomAttribute(assembly, "System.Drawing.BitmapSuffixInSatelliteAssemblyAttribute"); + } + + // internal for unit tests + internal static bool SameAssemblyOptIn(Assembly assembly) + { + // Try 4.5 public attribute type first + if (DoesAssemblyHaveCustomAttribute(assembly, typeof(BitmapSuffixInSameAssemblyAttribute))) + { + return true; + } + + // Also load attribute type by name for dlls compiled against older frameworks + return DoesAssemblyHaveCustomAttribute(assembly, "System.Drawing.BitmapSuffixInSameAssemblyAttribute"); + } + + /// + /// Returns a resource stream loaded from the appropriate location according to the current + /// suffix. + /// + /// The assembly from which the stream is loaded + /// The type whose namespace is used to scope the manifest resource name + /// The name of the manifest resource being requested + /// + /// The manifest resource stream corresponding to with the + /// current suffix applied; or if that is not found, the stream corresponding to . + /// + public static Stream GetResourceStream(Assembly assembly, Type type, string originalName) + { + if (Suffix != string.Empty) + { + try + { + // Resource with suffix has highest priority + if (SameAssemblyOptIn(assembly)) + { + string newName = AppendSuffix(originalName); + Stream stream = GetResourceStreamHelper(assembly, type, newName); + if (stream != null) + { + return stream; + } + } + } + catch + { + // Ignore failures and continue to try other options + } + + try + { + // Satellite assembly has second priority, using the original name + if (SatelliteAssemblyOptIn(assembly)) + { + AssemblyName assemblyName = assembly.GetName(); + assemblyName.Name += Suffix; + assemblyName.ProcessorArchitecture = ProcessorArchitecture.None; + Assembly satellite = Assembly.Load(assemblyName); + if (satellite != null) + { + Stream stream = GetResourceStreamHelper(satellite, type, originalName); + if (stream != null) + { + return stream; + } + } + } + } + catch + { + // Ignore failures and continue to try other options + } + } + + // Otherwise fall back to specified assembly and original name requested + return assembly.GetManifestResourceStream(type, originalName); + } + + /// + /// Returns a resource stream loaded from the appropriate location according to the current + /// suffix. + /// + /// The type from whose assembly the stream is loaded and whose namespace is used to scope the resource name + /// The name of the manifest resource being requested + /// + /// The manifest resource stream corresponding to with the + /// current suffix applied; or if that is not found, the stream corresponding to . + /// + public static Stream GetResourceStream(Type type, string originalName) + { + return GetResourceStream(type.Module.Assembly, type, originalName); + } + + /// + /// Returns an Icon created from a resource stream loaded from the appropriate location according to the current + /// suffix. + /// + /// The type from whose assembly the stream is loaded and whose namespace is used to scope the resource name + /// The name of the manifest resource being requested + /// + /// The icon created from a manifest resource stream corresponding to with the + /// current suffix applied; or if that is not found, the stream corresponding to . + /// + public static Icon CreateIcon(Type type, string originalName) + { + return new Icon(GetResourceStream(type, originalName)); + } + + /// + /// Returns an Bitmap created from a resource stream loaded from the appropriate location according to the current + /// suffix. + /// + /// The type from whose assembly the stream is loaded and whose namespace is used to scope the resource name + /// The name of the manifest resource being requested + /// + /// The bitmap created from a manifest resource stream corresponding to with the + /// current suffix applied; or if that is not found, the stream corresponding to . + /// + public static Bitmap CreateBitmap(Type type, string originalName) + { + return new Bitmap(GetResourceStream(type, originalName)); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs index e1133189100..58a122c8f1c 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs @@ -319,7 +319,7 @@ private void InvalidateFocus() NotifyWinEvent((uint)AccessibleEvents.Focus, new HandleRef(this, Handle), OBJID.CLIENT, 1 + Get1DFrom2D(focus.X, focus.Y)); } - protected override bool IsInputKey(System.Windows.Forms.Keys keyData) + protected override bool IsInputKey(Keys keyData) { switch (keyData) { @@ -757,8 +757,8 @@ private void AdjustColorUIHeight() Size size = pal.Size; Rectangle rectItemSize = tabControl.GetTabRect(0); int CMARGIN = 0; - this.Size = new Size(size.Width + 2 * CMARGIN, size.Height + 2 * CMARGIN + rectItemSize.Height); - tabControl.Size = this.Size; + Size = new Size(size.Width + 2 * CMARGIN, size.Height + 2 * CMARGIN + rectItemSize.Height); + tabControl.Size = Size; } private void AdjustListBoxItemHeight() @@ -838,8 +838,8 @@ private void InitializeComponent() Sorted = false }; lbSystem.Click += new EventHandler(OnListClick); - lbSystem.DrawItem += new DrawItemEventHandler(this.OnListDrawItem); - lbSystem.KeyDown += new KeyEventHandler(this.OnListKeyDown); + lbSystem.DrawItem += new DrawItemEventHandler(OnListDrawItem); + lbSystem.KeyDown += new KeyEventHandler(OnListKeyDown); lbSystem.Dock = DockStyle.Fill; lbSystem.FontChanged += new EventHandler(OnFontChanged); @@ -851,8 +851,8 @@ private void InitializeComponent() Sorted = false }; lbCommon.Click += new EventHandler(OnListClick); - lbCommon.DrawItem += new DrawItemEventHandler(this.OnListDrawItem); - lbCommon.KeyDown += new KeyEventHandler(this.OnListKeyDown); + lbCommon.DrawItem += new DrawItemEventHandler(OnListDrawItem); + lbCommon.KeyDown += new KeyEventHandler(OnListKeyDown); lbCommon.Dock = DockStyle.Fill; Array.Sort(ColorValues, new StandardColorComparer()); @@ -877,7 +877,7 @@ private void InitializeComponent() systemTabPage.Controls.Add(lbSystem); commonTabPage.Controls.Add(lbCommon); - this.Controls.Add(tabControl); + Controls.Add(tabControl); } protected override void OnGotFocus(EventArgs e) @@ -1052,7 +1052,7 @@ public void Start(IWindowsFormsEditorService edSvc, object value) private class ColorEditorListBox : ListBox { - protected override bool IsInputKey(System.Windows.Forms.Keys keyData) + protected override bool IsInputKey(Keys keyData) { switch (keyData) { @@ -1072,7 +1072,7 @@ public ColorEditorTabControl() : base() protected override void OnGotFocus(EventArgs e) { - TabPage selectedTab = this.SelectedTab; + TabPage selectedTab = SelectedTab; if (selectedTab != null && selectedTab.Controls.Count > 0) { selectedTab.Controls[0].Focus(); diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs index 5f22aea74a7..0d3d829a955 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs @@ -8,7 +8,7 @@ namespace System.Drawing.Design { /// - /// Provides a for visually editing content alignment. + /// Provides a for visually editing content alignment. /// public partial class ContentAlignmentEditor : UITypeEditor { diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs index 7db8915741c..19125d5e785 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs @@ -63,14 +63,14 @@ private class CursorUI : ListBox private object value; private IWindowsFormsEditorService edSvc; private readonly TypeConverter cursorConverter; - private UITypeEditor editor; + private readonly UITypeEditor editor; public CursorUI(UITypeEditor editor) { this.editor = editor; Height = 310; - ItemHeight = (int)Math.Max(4 + Cursors.Default.Size.Height, Font.Height); + ItemHeight = Math.Max(4 + Cursors.Default.Size.Height, Font.Height); DrawMode = DrawMode.OwnerDrawFixed; BorderStyle = BorderStyle.None; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs index 8cbf2827782..1ee91f4e44b 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs @@ -13,7 +13,7 @@ namespace System.Drawing.Design /// [ComImport] [Guid("4BACD258-DE64-4048-BC4E-FEDBEF9ACB76")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IToolboxService { /// diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs index 93d2235d132..4c8b38808ed 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs @@ -20,8 +20,8 @@ namespace System.Drawing.Design /// public class IconEditor : UITypeEditor { - private static List s_iconExtensions = new List() { "ico" }; - private static Type[] s_imageExtenders = Array.Empty(); + private static readonly List s_iconExtensions = new List() { "ico" }; + private static readonly Type[] s_imageExtenders = Array.Empty(); private FileDialog _fileDialog; protected static string CreateExtensionsString(string[] extensions, string sep) diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs index e9518e17b35..e8e1cdb72cc 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs @@ -15,7 +15,7 @@ public class ToolboxComponentsCreatedEventArgs : EventArgs private readonly IComponent[] _components; /// - /// Initializes a new instance of the + /// Initializes a new instance of the /// public ToolboxComponentsCreatedEventArgs(IComponent[] components) { diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs index ddc32dc8be7..943e03495e0 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs @@ -5,7 +5,7 @@ namespace System.Drawing.Design { /// - /// Represents a method that will handle the event. + /// Represents a method that will handle the event. /// public delegate void ToolboxComponentsCreatedEventHandler(object sender, ToolboxComponentsCreatedEventArgs e); } diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs index 7473e1fb7b1..e7195d658c1 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs @@ -13,7 +13,7 @@ namespace System.Drawing.Design public class ToolboxComponentsCreatingEventArgs : EventArgs { /// - /// Initializes a new instance of the object. + /// Initializes a new instance of the object. /// public ToolboxComponentsCreatingEventArgs(IDesignerHost host) { diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs index de02476558b..bcc8f60a52c 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs @@ -5,7 +5,7 @@ namespace System.Drawing.Design { /// - /// Represents a method that will handle the event. + /// Represents a method that will handle the event. /// public delegate void ToolboxComponentsCreatingEventHandler(object sender, ToolboxComponentsCreatingEventArgs e); } diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs index 1214e839a7d..9a5276dd1ee 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs @@ -127,7 +127,7 @@ public Bitmap OriginalBitmap } /// - /// Gets or sets the company name for this . + /// Gets or sets the company name for this . /// This defaults to the companyname attribute retrieved from type.Assembly, if set. /// public string Company @@ -170,7 +170,7 @@ public string Description } /// - /// Gets or sets the display name for this . + /// Gets or sets the display name for this . /// public string DisplayName { @@ -860,7 +860,7 @@ protected virtual void Serialize(SerializationInfo info, StreamingContext contex /// /// Raises the OnComponentsCreated event. This - /// will be called when this creates a component. + /// will be called when this creates a component. /// protected virtual void OnComponentsCreated(ToolboxComponentsCreatedEventArgs args) { @@ -869,7 +869,7 @@ protected virtual void OnComponentsCreated(ToolboxComponentsCreatedEventArgs arg /// /// Raises the OnCreateComponentsInvoked event. This - /// will be called before this creates a component. + /// will be called before this creates a component. /// protected virtual void OnComponentsCreating(ToolboxComponentsCreatingEventArgs args) { diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs index f2bab8b4bd6..a0fd20baff7 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs @@ -7,12 +7,12 @@ namespace System.Drawing.Design { /// - /// A collection that stores objects. + /// A collection that stores objects. /// public sealed class ToolboxItemCollection : ReadOnlyCollectionBase { /// - /// Initializes a new instance of based on another . + /// Initializes a new instance of based on another . /// public ToolboxItemCollection(ToolboxItemCollection value) { @@ -20,7 +20,7 @@ public ToolboxItemCollection(ToolboxItemCollection value) } /// - /// Initializes a new instance of containing any array of objects. + /// Initializes a new instance of containing any array of objects. /// public ToolboxItemCollection(ToolboxItem[] value) { @@ -28,7 +28,7 @@ public ToolboxItemCollection(ToolboxItem[] value) } /// - /// Represents the entry at the specified index of the . + /// Represents the entry at the specified index of the . /// public ToolboxItem this[int index] { @@ -40,7 +40,7 @@ public ToolboxItemCollection(ToolboxItem[] value) /// /// Gets a value indicating whether the - /// contains the specified . + /// contains the specified . /// public bool Contains(ToolboxItem value) { @@ -48,7 +48,7 @@ public bool Contains(ToolboxItem value) } /// - /// Copies the values to a one-dimensional instance at the + /// Copies the values to a one-dimensional instance at the /// specified index. /// public void CopyTo(ToolboxItem[] array, int index) @@ -57,8 +57,8 @@ public void CopyTo(ToolboxItem[] array, int index) } /// - /// Returns the index of a in - /// the . + /// Returns the index of a in + /// the . /// public int IndexOf(ToolboxItem value) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs index 91c4dac5319..d74f9030faa 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs @@ -9,7 +9,7 @@ namespace System.Windows.Forms.Design { /// - /// Provides a design-time editor for specifying the + /// Provides a design-time editor for specifying the /// property. /// [CLSCompliant(false)] diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs index ec06e34fd86..c30d8e0bb2b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; namespace System.Windows.Forms.Design { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs index 0f4db2eef70..c4f33d66643 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs @@ -311,7 +311,7 @@ public override Image Image /// /// Items OnClick event, to select the Parent Control. /// - protected override void OnClick(System.EventArgs e) + protected override void OnClick(EventArgs e) { if (_serviceProvider.GetService(typeof(ISelectionService)) is ISelectionService selectionService) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs index 34d087d47f2..507d25e9681 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs @@ -12,12 +12,14 @@ namespace System.Windows.Forms.Design.Behavior /// public sealed class BehaviorServiceAdornerCollection : CollectionBase { + private readonly BehaviorService behaviorService; + /// /// Initializes a new instance of . /// public BehaviorServiceAdornerCollection(BehaviorService behaviorService) { - throw new NotImplementedException(SR.NotImplementedByDesign); + this.behaviorService = behaviorService; } /// @@ -26,7 +28,7 @@ public BehaviorServiceAdornerCollection(BehaviorService behaviorService) /// public BehaviorServiceAdornerCollection(BehaviorServiceAdornerCollection value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + AddRange(value); } /// @@ -38,7 +40,7 @@ public BehaviorServiceAdornerCollection(BehaviorServiceAdornerCollection value) /// public BehaviorServiceAdornerCollection(Adorner[] value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + AddRange(value); } /// @@ -55,8 +57,14 @@ public BehaviorServiceAdornerCollection(Adorner[] value) /// public Adorner this[int index] { - get => throw new NotImplementedException(SR.NotImplementedByDesign); - set => throw new NotImplementedException(SR.NotImplementedByDesign); + get + { + return ((Adorner)(List[index])); + } + set + { + List[index] = value; + } } /// @@ -67,10 +75,11 @@ public BehaviorServiceAdornerCollection(Adorner[] value) /// /// The index at which the new element was inserted. /// - /// + /// public int Add(Adorner value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + value.BehaviorService = behaviorService; + return List.Add(value); } /// @@ -87,7 +96,10 @@ public int Add(Adorner value) /// public void AddRange(Adorner[] value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + for (int i = 0; (i < value.Length); i = (i + 1)) + { + Add(value[i]); + } } /// @@ -105,7 +117,10 @@ public void AddRange(Adorner[] value) /// public void AddRange(BehaviorServiceAdornerCollection value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + for (int i = 0; (i < value.Count); i = (i + 1)) + { + Add(value[i]); + } } /// @@ -122,7 +137,7 @@ public void AddRange(BehaviorServiceAdornerCollection value) /// public bool Contains(Adorner value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return List.Contains(value); } /// @@ -134,7 +149,7 @@ public bool Contains(Adorner value) /// The one-dimensional that is the destination of the values copied from /// . /// - /// The index in where copying begins. + /// The index in where copying begins. /// /// None. /// @@ -153,7 +168,7 @@ public bool Contains(Adorner value) /// public void CopyTo(Adorner[] array, int index) { - throw new NotImplementedException(SR.NotImplementedByDesign); + List.CopyTo(array, index); } /// @@ -169,14 +184,14 @@ public void CopyTo(Adorner[] array, int index) /// public int IndexOf(Adorner value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return List.IndexOf(value); } /// /// Inserts a into the /// at the specified index. /// - /// The zero-based index where should be inserted. + /// The zero-based index where should be inserted. /// The to insert. /// /// None. @@ -184,7 +199,7 @@ public int IndexOf(Adorner value) /// public void Insert(int index, Adorner value) { - throw new NotImplementedException(SR.NotImplementedByDesign); + List.Insert(index, value); } /// @@ -197,7 +212,7 @@ public void Insert(int index, Adorner value) /// public new BehaviorServiceAdornerCollectionEnumerator GetEnumerator() { - throw new NotImplementedException(SR.NotImplementedByDesign); + return new BehaviorServiceAdornerCollectionEnumerator(this); } /// @@ -214,29 +229,7 @@ public new BehaviorServiceAdornerCollectionEnumerator GetEnumerator() /// is not found in the Collection. public void Remove(Adorner value) { - throw new NotImplementedException(SR.NotImplementedByDesign); - } - } - - public class BehaviorServiceAdornerCollectionEnumerator : object, IEnumerator - { - public BehaviorServiceAdornerCollectionEnumerator(BehaviorServiceAdornerCollection mappings) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } - - public Adorner Current => throw new NotImplementedException(SR.NotImplementedByDesign); - - object IEnumerator.Current => throw new NotImplementedException(); - - public bool MoveNext() - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } - - public void Reset() - { - throw new NotImplementedException(SR.NotImplementedByDesign); + List.Remove(value); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs index d42c7b31115..ae7863095a8 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.ComponentModel.Design; using System.Drawing; @@ -14,6 +16,9 @@ namespace System.Windows.Forms.Design.Behavior /// public abstract class Behavior { + private readonly bool _callParentBehavior; + private readonly BehaviorService? _behaviorService; + protected Behavior() { } @@ -22,44 +27,98 @@ protected Behavior() /// `true` if the parentBehavior should be called if it exists. The parentBehavior is the next behavior on /// the behaviorService stack.If true, must be non-null. /// - protected Behavior(bool callParentBehavior, BehaviorService behaviorService) + protected Behavior(bool callParentBehavior, BehaviorService? behaviorService) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if ((callParentBehavior == true) && (behaviorService == null)) + { + throw new ArgumentException(null, nameof(behaviorService)); + } + + _callParentBehavior = callParentBehavior; + _behaviorService = behaviorService; } - private Behavior GetNextBehavior => throw new NotImplementedException(SR.NotImplementedByDesign); + private Behavior? GetNextBehavior => _behaviorService?.GetNextBehavior(this); /// /// The cursor that should be displayed for this behavior. /// - public virtual Cursor Cursor => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual Cursor Cursor => Cursors.Default; /// /// Rerturning true from here indicates to the BehaviorService that all MenuCommands the designer receives /// should have their state set to 'Enabled = false' when this Behavior is active. /// - public virtual bool DisableAllCommands => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool DisableAllCommands + { + get + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.DisableAllCommands; + } + else + { + return false; + } + } + } /// /// Called from the BehaviorService, this function provides an opportunity for the Behavior to return its /// own custom MenuCommand thereby intercepting this message. /// - public virtual MenuCommand FindCommand(CommandID commandId) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual MenuCommand? FindCommand(CommandID commandId) + { + try + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.FindCommand(commandId); + } + else + { + return null; + } + } + catch //Catch any exception and return null MenuCommand. + { + return null; + } + } + + /// + /// The heuristic we will follow when any of these methods are called + /// is that we will attempt to pass the message along to the glyph. + /// This is a helper method to ensure validity before forwarding the message. + /// + private Behavior? GetGlyphBehavior(Glyph? g) + { + return g?.Behavior != null && g.Behavior != this ? g.Behavior : null; + } /// /// A behavior can request mouse capture through the behavior service by pushing itself with /// PushCaptureBehavior. If it does so, it will be notified through OnLoseCapture when capture is lost. /// Generally the behavior pops itself at this time. Capture is lost when one of the following occurs: /// - /// 1. Someone else requests capture. - /// 2. Another behavior is pushed. - /// 3. This behavior is popped. + /// 1. Someone else requests capture. + /// 2. Another behavior is pushed. + /// 3. This behavior is popped. /// /// In each of these cases OnLoseCapture on the behavior will be called. /// - public virtual void OnLoseCapture(Glyph g, EventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnLoseCapture(Glyph? g, EventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnLoseCapture(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnLoseCapture(g, e); + } + } /// /// When any MouseDown message enters the BehaviorService's AdornerWindow (nclbuttondown, lbuttondown, @@ -67,8 +126,21 @@ public virtual void OnLoseCapture(Glyph g, EventArgs e) /// Returning 'true' from this function signifies that the Message was 'handled' by the Behavior and should /// not continue to be processed. /// - public virtual bool OnMouseDoubleClick(Glyph g, MouseButtons button, Point mouseLoc) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseDoubleClick(Glyph? g, MouseButtons button, Point mouseLoc) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseDoubleClick(g, button, mouseLoc); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseDoubleClick(g, button, mouseLoc); + } + else + { + return false; + } + } /// /// When any MouseDown message enters the BehaviorService's AdornerWindow (nclbuttondown, lbuttondown, @@ -76,37 +148,102 @@ public virtual bool OnMouseDoubleClick(Glyph g, MouseButtons button, Point mouse /// Returning 'true' from this function signifies that the Message was 'handled' by the Behavior and /// should not continue to be processed. /// - public virtual bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseDown(Glyph? g, MouseButtons button, Point mouseLoc) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseDown(g, button, mouseLoc); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseDown(g, button, mouseLoc); + } + else + { + return false; + } + } /// /// When the mouse pointer's location is positively hit-tested with a different Glyph than previous /// hit-tests, this event is fired on the Behavior associated with the Glyph. /// - public virtual bool OnMouseEnter(Glyph g) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseEnter(Glyph? g) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseEnter(g); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseEnter(g); + } + else + { + return false; + } + } /// /// When a MouseHover message enters the BehaviorService's AdornerWindow it is first passed here, to the /// top-most Behavior in the BehaviorStack. Returning 'true' from this function signifies that the Message /// was 'handled' by the Behavior and should not continue to be processed. /// - public virtual bool OnMouseHover(Glyph g, Point mouseLoc) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseHover(Glyph? g, Point mouseLoc) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseHover(g, mouseLoc); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseHover(g, mouseLoc); + } + else + { + return false; + } + } /// /// When the mouse pointer leaves a positively hit-tested Glyph with a valid Behavior, this method is invoked. /// - public virtual bool OnMouseLeave(Glyph g) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseLeave(Glyph? g) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseLeave(g); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseLeave(g); + } + else + { + return false; + } + } /// /// When any MouseMove message enters the BehaviorService's AdornerWindow (mousemove, ncmousemove) it is /// first passed here, to the top-most Behavior in the BehaviorStack. Returning 'true' from this method /// signifies that the Message was 'handled' by the Behavior and should not continue to be processed. /// - public virtual bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseMove(Glyph? g, MouseButtons button, Point mouseLoc) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseMove(g, button, mouseLoc); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseMove(g, button, mouseLoc); + } + else + { + return false; + } + } /// /// When any MouseUp message enters the BehaviorService's AdornerWindow @@ -115,45 +252,116 @@ public virtual bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) /// 'true' from this function signifies that the Message was 'handled' by /// the Behavior and should not continue to be processed. /// - public virtual bool OnMouseUp(Glyph g, MouseButtons button) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual bool OnMouseUp(Glyph? g, MouseButtons button) + { + if (_callParentBehavior && GetNextBehavior != null) + { + return GetNextBehavior.OnMouseUp(g, button); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + return behavior.OnMouseUp(g, button); + } + else + { + return false; + } + } // OLE DragDrop virtual methods /// /// OnDragDrop can be overridden so that a Behavior can specify its own Drag/Drop rules. /// - public virtual void OnDragDrop(Glyph g, DragEventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnDragDrop(Glyph? g, DragEventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnDragDrop(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnDragDrop(g, e); + } + } /// /// OnDragEnter can be overridden so that a Behavior can specify its own Drag/Drop rules. /// - public virtual void OnDragEnter(Glyph g, DragEventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnDragEnter(Glyph? g, DragEventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnDragEnter(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnDragEnter(g, e); + } + } /// /// OnDragLeave can be overridden so that a Behavior can specify its own Drag/Drop rules. /// - public virtual void OnDragLeave(Glyph g, EventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnDragLeave(Glyph? g, EventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnDragLeave(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnDragLeave(g, e); + } + } /// /// OnDragOver can be overridden so that a Behavior can specify its own Drag/Drop rules. /// - public virtual void OnDragOver(Glyph g, DragEventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnDragOver(Glyph? g, DragEventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnDragOver(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnDragOver(g, e); + } + else if (e.Effect != DragDropEffects.None) + { + e.Effect = (Control.ModifierKeys == Keys.Control) ? DragDropEffects.Copy : DragDropEffects.Move; + } + } /// /// OnGiveFeedback can be overridden so that a Behavior can specify its own Drag/Drop rules. /// - public virtual void OnGiveFeedback(Glyph g, GiveFeedbackEventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnGiveFeedback(Glyph? g, GiveFeedbackEventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnGiveFeedback(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnGiveFeedback(g, e); + } + } /// /// QueryContinueDrag can be overridden so that a Behavior can specify its own Drag/Drop rules. /// - public virtual void OnQueryContinueDrag(Glyph g, QueryContinueDragEventArgs e) - => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual void OnQueryContinueDrag(Glyph? g, QueryContinueDragEventArgs e) + { + if (_callParentBehavior && GetNextBehavior != null) + { + GetNextBehavior.OnQueryContinueDrag(g, e); + } + else if (GetGlyphBehavior(g) is Behavior behavior) + { + behavior.OnQueryContinueDrag(g, e); + } + } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs index b46d3aba7e1..e1e6a3147f4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; - namespace System.Windows.Forms.Design.Behavior { /// diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs index 2002dc1f0a7..bc6f43a516f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs @@ -77,7 +77,7 @@ private void HookMouse() User32.WH.MOUSE, hook, IntPtr.Zero, - (uint)AppDomain.GetCurrentThreadId()); + Kernel32.GetCurrentThreadId()); if (_mouseHookHandle != IntPtr.Zero) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs index 64ebc6431ad..c1f5cef7543 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.ComponentModel.Design; using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs index 71fb9426ad7..735d2b39817 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections; -using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; @@ -861,17 +860,17 @@ private void TestHook_SetText(ref Message m, string text) if (Marshal.SystemDefaultCharSize == 1) { - bytes = System.Text.Encoding.Default.GetBytes(text); - nullBytes = System.Text.Encoding.Default.GetBytes(nullChar); + bytes = Text.Encoding.Default.GetBytes(text); + nullBytes = Text.Encoding.Default.GetBytes(nullChar); } else { - bytes = System.Text.Encoding.Unicode.GetBytes(text); - nullBytes = System.Text.Encoding.Unicode.GetBytes(nullChar); + bytes = Text.Encoding.Unicode.GetBytes(text); + nullBytes = Text.Encoding.Unicode.GetBytes(nullChar); } Marshal.Copy(bytes, 0, m.LParam, bytes.Length); - Marshal.Copy(nullBytes, 0, unchecked((IntPtr)((long)m.LParam + (long)bytes.Length)), nullBytes.Length); + Marshal.Copy(nullBytes, 0, unchecked((IntPtr)((long)m.LParam + bytes.Length)), nullBytes.Length); m.Result = (IntPtr)((bytes.Length + nullBytes.Length) / Marshal.SystemDefaultCharSize); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs new file mode 100644 index 00000000000..8963914f80b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; + +namespace System.Windows.Forms.Design.Behavior +{ + public class BehaviorServiceAdornerCollectionEnumerator : object, IEnumerator + { + private readonly IEnumerator baseEnumerator; + private readonly IEnumerable temp; + + public BehaviorServiceAdornerCollectionEnumerator(BehaviorServiceAdornerCollection mappings) + { + temp = mappings; + baseEnumerator = temp.GetEnumerator(); + } + + public Adorner Current + { + get + { + return ((Adorner)(baseEnumerator.Current)); + } + } + + object IEnumerator.Current + { + get + { + return baseEnumerator.Current; + } + } + + public bool MoveNext() + { + return baseEnumerator.MoveNext(); + } + + bool IEnumerator.MoveNext() + { + return baseEnumerator.MoveNext(); + } + + public void Reset() + { + baseEnumerator.Reset(); + } + + void IEnumerator.Reset() + { + baseEnumerator.Reset(); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BodyGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BodyGlyph.cs deleted file mode 100644 index 039f5a56296..00000000000 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BodyGlyph.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.ComponentModel; -using System.Drawing; - -namespace System.Windows.Forms.Design.Behavior -{ - /// - /// This Glyph is placed on every control sized to the exact bounds of - /// the control. - /// - public class ControlBodyGlyph : ComponentGlyph - { - /// - /// Standard Constructor. - /// - public ControlBodyGlyph(Rectangle bounds, Cursor cursor, IComponent relatedComponent, ControlDesigner designer) - : base(relatedComponent, new ControlDesigner.TransparentBehavior(designer)) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } - - public ControlBodyGlyph(Rectangle bounds, Cursor cursor, IComponent relatedComponent, Behavior behavior) : base( - relatedComponent, behavior) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } - - /// - /// The bounds of this glyph. - /// - public override Rectangle Bounds => throw new NotImplementedException(SR.NotImplementedByDesign); - - /// - /// Simple hit test rule: if the point is contained within the bounds - /// AND the component is Visible (controls on some tab pages may - /// not be, for ex) then it is a positive hit test. - /// - public override Cursor GetHitTest(Point p) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } - } -} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs index 1292e39dfb2..3d94b7a97ef 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs @@ -1,7 +1,9 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.ComponentModel; using System.Drawing; @@ -15,38 +17,38 @@ namespace System.Windows.Forms.Design.Behavior /// public class ComponentGlyph : Glyph { + private readonly IComponent? _relatedComponent; + /// /// Standard constructor. /// - public ComponentGlyph(IComponent relatedComponent, Behavior behavior) : base(behavior) + public ComponentGlyph(IComponent? relatedComponent, Behavior? behavior) + : base(behavior) { - throw new NotImplementedException(SR.NotImplementedByDesign); + _relatedComponent = relatedComponent; } - public ComponentGlyph(IComponent relatedComponent) : base(null) + public ComponentGlyph(IComponent? relatedComponent) + : base(null) { - throw new NotImplementedException(SR.NotImplementedByDesign); + _relatedComponent = relatedComponent; } /// /// Returns the Component this Glyph is related to. /// - public IComponent RelatedComponent => throw new NotImplementedException(SR.NotImplementedByDesign); + public IComponent? RelatedComponent => _relatedComponent; /// /// Overrides GetHitTest - this implementation does nothing. /// - public override Cursor GetHitTest(Point p) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + public override Cursor? GetHitTest(Point p) => null; /// /// Overrides Glyph::Paint - this implementation does nothing. /// public override void Paint(PaintEventArgs pe) { - throw new NotImplementedException(SR.NotImplementedByDesign); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs index 8890be4ed65..4ff831c2eb5 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + +using System.Diagnostics; using System.Drawing; namespace System.Windows.Forms.Design.Behavior @@ -9,17 +12,20 @@ namespace System.Windows.Forms.Design.Behavior /// /// This is the glyph used to drag container controls around the designer. This glyph (and associated behavior) is created by the ParentControlDesigner. /// + [DebuggerDisplay("{GetType().Name}:: Component: {_component}, Cursor: {_hitTestCursor}")] internal sealed class ContainerSelectorGlyph : Glyph { private Rectangle _glyphBounds; - private readonly ContainerSelectorBehavior _relatedBehavior; + private Bitmap? _glyph; + private readonly ContainerSelectorBehavior? _relatedBehavior; /// /// ContainerSelectorGlyph constructor. /// - internal ContainerSelectorGlyph(Rectangle containerBounds, int glyphSize, int glyphOffset, ContainerSelectorBehavior behavior) : base(behavior) + internal ContainerSelectorGlyph(Rectangle containerBounds, int glyphSize, int glyphOffset, ContainerSelectorBehavior? behavior) + : base(behavior) { - _relatedBehavior = (ContainerSelectorBehavior)behavior; + _relatedBehavior = behavior; _glyphBounds = new Rectangle(containerBounds.X + glyphOffset, containerBounds.Y - (int)(glyphSize * .5), glyphSize, glyphSize); } @@ -31,7 +37,7 @@ public override Rectangle Bounds get => _glyphBounds; } - public Behavior RelatedBehavior + public Behavior? RelatedBehavior { get => _relatedBehavior; } @@ -39,9 +45,9 @@ public Behavior RelatedBehavior /// /// Simple hit test rule: if the point is contained within the bounds - then it is a positive hit test. /// - public override Cursor GetHitTest(Point p) + public override Cursor? GetHitTest(Point p) { - if (_glyphBounds.Contains(p) || _relatedBehavior.OkToMove) + if (_glyphBounds.Contains(p) || _relatedBehavior?.OkToMove == true) { return Cursors.SizeAll; } @@ -49,14 +55,13 @@ public override Cursor GetHitTest(Point p) return null; } - private Bitmap _glyph; private Bitmap MoveGlyph { get { if (_glyph is null) { - _glyph = new Icon(typeof(ContainerSelectorGlyph), "MoverGlyph").ToBitmap(); + _glyph = new Bitmap(typeof(ContainerSelectorGlyph), "MoverGlyph"); } return _glyph; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs new file mode 100644 index 00000000000..743b1d00558 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable enable + +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; + +namespace System.Windows.Forms.Design.Behavior +{ + /// + /// This Glyph is placed on every control sized to the exact bounds of + /// the control. + /// + [DebuggerDisplay("{GetType().Name, nq}:: Behavior={Behavior.GetType().Name, nq}, {_hitTestCursor}")] + public class ControlBodyGlyph : ComponentGlyph + { + private Rectangle _bounds; //bounds of the related control + private readonly Cursor? _hitTestCursor; //cursor used to hit test + private readonly IComponent? _component; + + /// + /// Standard Constructor. + /// + public ControlBodyGlyph(Rectangle bounds, Cursor? cursor, IComponent? relatedComponent, ControlDesigner? designer) + : base(relatedComponent, new ControlDesigner.TransparentBehavior(designer)) + { + _bounds = bounds; + _hitTestCursor = cursor; + _component = relatedComponent; + } + + public ControlBodyGlyph(Rectangle bounds, Cursor? cursor, IComponent? relatedComponent, Behavior? behavior) + : base(relatedComponent, behavior) + { + _bounds = bounds; + _hitTestCursor = cursor; + _component = relatedComponent; + } + + /// + /// The bounds of this glyph. + /// + public override Rectangle Bounds => _bounds; + + /// + /// Simple hit test rule: if the point is contained within the bounds + /// AND the component is Visible (controls on some tab pages may + /// not be, for ex) then it is a positive hit test. + /// + public override Cursor? GetHitTest(Point p) + { + bool isVisible = (_component is Control control) ? control.Visible : true; /*non-controls are always visible here*/ + + if (isVisible && _bounds.Contains(p)) + { + return _hitTestCursor; + } + + return null; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs index 51ad3549644..6020123984c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs @@ -2,42 +2,53 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.ComponentModel; -using System.ComponentModel.Design; using System.Drawing; namespace System.Windows.Forms.Design.Behavior { /// - /// This Glyph represents the UI appended to a control when DesignerActions are available. Each image that represents these states are demand created. This is done because it is entirely possible that a DesignerActionGlyph will only ever be in one of these states during its lifetime... kind of sad really. + /// This Glyph represents the UI appended to a control when DesignerActions are available. Each image that represents + /// these states are demand created. This is done because it is entirely possible that a DesignerActionGlyph will + /// only ever be in one of these states during its lifetime... kind of sad really. /// internal sealed class DesignerActionGlyph : Glyph { - internal const int CONTROLOVERLAP_X = 5; // number of pixels the anchor should be offset to the left of the control's upper-right - internal const int CONTROLOVERLAP_Y = 2; // number of pixels the anchor overlaps the control in the y-direction - - private Rectangle _bounds; // the bounds of our glyph - private readonly Adorner _adorner; // A ptr back to our adorner - so when we decide to change state, we can invalidate - private bool _mouseOver; // on mouse over, we shade our image differently, this is used to track that state - private Rectangle _alternativeBounds = Rectangle.Empty; // if !empty, this represents the bounds of the tray control this gyph is related to - private readonly Control _alternativeParent; // if this is valid - then the glyph will invalidate itself here instead of on the adorner + internal const int CONTROLOVERLAP_X = 5; // number of pixels the anchor should be offset to the left of the control's upper-right + internal const int CONTROLOVERLAP_Y = 2; // number of pixels the anchor overlaps the control in the y-direction + + private Rectangle _alternativeBounds = Rectangle.Empty; // if !empty, this represents the bounds of the tray control this gyph is related to + private Rectangle _bounds; // the bounds of our glyph + private readonly Adorner? _adorner; // A ptr back to our adorner - so when we decide to change state, we can invalidate + private readonly Control? _alternativeParent; // if this is valid - then the glyph will invalidate itself here instead of on the adorner + private bool _mouseOver; // on mouse over, we shade our image differently, this is used to track that state private bool _insidePaint; private DockStyle _dockStyle; - private Bitmap _glyphImageClosed; - private Bitmap _glyphImageOpened; + private Bitmap? _glyphImageClosed; + private Bitmap? _glyphImageOpened; /// - /// Constructor that passes empty alternative bounds and parents. Typically this is done for control on the designer's surface since component tray glyphs will have these alternative values. + /// Constructor that passes empty alternative bounds and parents. + /// Typically this is done for control on the designer's surface since component tray glyphs will have these + /// alternative values. /// - public DesignerActionGlyph(DesignerActionBehavior behavior, Adorner adorner) : this(behavior, adorner, Rectangle.Empty, null) - { } - public DesignerActionGlyph(DesignerActionBehavior behavior, Rectangle alternativeBounds, Control alternativeParent) : this(behavior, null, alternativeBounds, alternativeParent) - { } + public DesignerActionGlyph(DesignerActionBehavior? behavior, Adorner? adorner) + : this(behavior, adorner, Rectangle.Empty, null) + { + } + + public DesignerActionGlyph(DesignerActionBehavior? behavior, Rectangle alternativeBounds, Control? alternativeParent) + : this(behavior, null, alternativeBounds, alternativeParent) + { + } /// /// Constructor that sets the dropdownbox size, creates a our hottrack brush and invalidates the glyph (to configure location). /// - private DesignerActionGlyph(DesignerActionBehavior behavior, Adorner adorner, Rectangle alternativeBounds, Control alternativeParent) : base(behavior) + private DesignerActionGlyph(DesignerActionBehavior? behavior, Adorner? adorner, Rectangle alternativeBounds, Control? alternativeParent) + : base(behavior) { _adorner = adorner; _alternativeBounds = alternativeBounds; @@ -46,7 +57,8 @@ private DesignerActionGlyph(DesignerActionBehavior behavior, Adorner adorner, Re } /// - /// Returns the bounds of our glyph. This is used by the related Behavior to determine where to show the contextmenu (list of actions). + /// Returns the bounds of our glyph. This is used by the related Behavior to determine where to show the + /// contextmenu (list of actions). /// public override Rectangle Bounds { @@ -71,9 +83,10 @@ public bool IsInComponentTray } /// - /// Standard hit test logic that returns true if the point is contained within our bounds. This is also used to manage out mouse over state. + /// Standard hit test logic that returns true if the point is contained within our bounds. + /// This is also used to manage out mouse over state. /// - public override Cursor GetHitTest(Point p) + public override Cursor? GetHitTest(Point p) { if (_bounds.Contains(p)) { @@ -127,20 +140,25 @@ private Image GlyphImageOpened internal void InvalidateOwnerLocation() { if (_alternativeParent != null) - { // alternative parent and adoner are exclusive... + { + // alternative parent and adoner are exclusive... _alternativeParent.Invalidate(_bounds); } else { - _adorner.Invalidate(_bounds); + _adorner?.Invalidate(_bounds); } } /// - /// Called when the state for this DesignerActionGlyph changes. Or when the related component's size or location change. Here, we re-calculate the Glyph's bounds and change our image. + /// Called when the state for this DesignerActionGlyph changes. Or when the related component's size or + /// location change. Here, we re-calculate the Glyph's bounds and change our image. /// internal void Invalidate() { + if (Behavior is null) + return; + IComponent relatedComponent = ((DesignerActionBehavior)Behavior).RelatedComponent; Point topRight = Point.Empty; //handle the case that our comp is a control @@ -150,7 +168,8 @@ internal void Invalidate() topRight.X += relatedControl.Width; } - // ISSUE: we can't have this special cased here - we should find a more generic approach to solving this problem special logic here for our comp being a toolstrip item + // ISSUE: we can't have this special cased here - we should find a more generic approach to solving this + // problem special logic here for our comp being a toolstrip item else { // update alternative bounds if possible... @@ -174,7 +193,8 @@ internal void Invalidate() } /// - /// Used to manage the mouse-pointer-is-over-glyph state. If this is true, then we will shade our BoxImage in the Paint logic. + /// Used to manage the mouse-pointer-is-over-glyph state. If this is true, then we will shade our BoxImage + /// in the Paint logic. /// private bool MouseOver { @@ -191,20 +211,21 @@ private bool MouseOver } /// - /// Responds to a paint event. This Glyph will paint its current image and, if MouseHover is true, we'll paint over the image with the 'hoverBrush'. + /// Responds to a paint event. This Glyph will paint its current image and, if MouseHover is true, + /// we'll paint over the image with the 'hoverBrush'. /// public override void Paint(PaintEventArgs pe) { Image image; - if (Behavior is DesignerActionBehavior) + if (Behavior is DesignerActionBehavior behavior) { if (_insidePaint) { return; } - IComponent panelComponent = ((DesignerActionUI)((DesignerActionBehavior)Behavior).ParentUI).LastPanelComponent; - IComponent relatedComponent = ((DesignerActionBehavior)Behavior).RelatedComponent; + IComponent panelComponent = behavior.ParentUI.LastPanelComponent; + IComponent relatedComponent = behavior.RelatedComponent; if (panelComponent != null && panelComponent == relatedComponent) { image = GlyphImageOpened; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs index a8a5c99472b..b3466174cbb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs @@ -47,7 +47,7 @@ public override MenuCommand FindCommand(CommandID commandId) } // in case of a ctrl-tab we need to close the DAP - if (_daUISvc != null && commandId.Guid == DesignerActionKeyboardBehavior.s_vSStandardCommandSet97 && commandId.ID == 1124) + if (_daUISvc != null && commandId.Guid == s_vSStandardCommandSet97 && commandId.ID == 1124) { _daUISvc.HideUI(null); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs index c22c2f023ca..f5ac9310dee 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs @@ -256,9 +256,9 @@ private Line[] EraseOldSnapLines(Line[] lines, ArrayList tempLines) { for (int i = 0; i < lines.Length; i++) { - Rectangle invalidRect = Rectangle.Empty; bool foundMatch = false; Line line = lines[i]; + Rectangle invalidRect; if (tempLines != null) { for (int j = 0; j < tempLines.Count; j++) @@ -626,13 +626,12 @@ internal Point OffsetToNearestSnapLocation(Control targetControl, Point directio private static int FindSmallestValidDistance(ArrayList snapLines, int[] distances, int min, int max, int direction) { - int distanceValue = 0; - int snapLineIndex = 0; // loop while we still have valid distance to check and try to find the smallest valid distance while (true) { + int distanceValue; // get the next smallest snapline index - snapLineIndex = SmallestDistanceIndex(distances, direction, out distanceValue); + int snapLineIndex = SmallestDistanceIndex(distances, direction, out distanceValue); if (snapLineIndex == INVALID_VALUE) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs index b0a8ccf79e9..9a26a8dadb9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs @@ -74,7 +74,7 @@ private struct DragComponent /// internal DropSourceBehavior(ICollection dragComponents, Control source, Point initialMouseLocation) { - serviceProviderSource = source.Site as IServiceProvider; + serviceProviderSource = source.Site; if (serviceProviderSource is null) { Debug.Fail("DragBehavior could not be created because the source ServiceProvider was not found"); @@ -300,7 +300,7 @@ private void EndDragDrop(bool allowSetChildIndexOnDrop) if (serviceProviderTarget is null) { Debug.Fail("EndDragDrop - how can serviceProviderTarget be null?"); - serviceProviderTarget = dragTarget.Site as IServiceProvider; + serviceProviderTarget = dragTarget.Site; if (serviceProviderTarget is null) { Debug.Fail("EndDragDrop - how can serviceProviderTarget be null?"); @@ -644,7 +644,7 @@ internal void GiveFeedback(object sender, GiveFeedbackEventArgs e) { if (!data.Target.Equals(lastDropTarget)) { - serviceProviderTarget = target.Site as IServiceProvider; + serviceProviderTarget = target.Site; if (serviceProviderTarget is null) { return; @@ -834,7 +834,7 @@ internal void GiveFeedback(object sender, GiveFeedbackEventArgs e) if (statusCommandUITarget != null) { - statusCommandUITarget.SetStatusInformation(c as Component, dropPoint); + statusCommandUITarget.SetStatusInformation(c, dropPoint); } } @@ -1017,7 +1017,7 @@ private void InitiateDrag(Point initialMouseLocation, ICollection dragComps) imageHeight = 1; } - dragImage = new Bitmap(imageWidth, imageHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); + dragImage = new Bitmap(imageWidth, imageHeight, Drawing.Imaging.PixelFormat.Format32bppPArgb); using (Graphics g = Graphics.FromImage(dragImage)) { g.Clear(Color.Chartreuse); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs index d6af694f60f..2285cbc47f6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; using System.Drawing; namespace System.Windows.Forms.Design.Behavior @@ -17,25 +16,27 @@ namespace System.Windows.Forms.Design.Behavior /// public abstract class Glyph { + private Behavior _behavior; + /// /// Glyph's default constructor takes a Behavior. /// protected Glyph(Behavior behavior) { - throw new NotImplementedException(SR.NotImplementedByDesign); + _behavior = behavior; } /// /// This read-only property will return the Behavior associated with /// this Glyph. The Behavior can be null. /// - public virtual Behavior Behavior => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual Behavior Behavior => _behavior; /// /// This read-only property will return the Bounds associated with /// this Glyph. The Bounds can be empty. /// - public virtual Rectangle Bounds => throw new NotImplementedException(SR.NotImplementedByDesign); + public virtual Rectangle Bounds => Rectangle.Empty; /// /// Abstract method that forces Glyph implementations to provide @@ -60,7 +61,7 @@ protected Glyph(Behavior behavior) /// protected void SetBehavior(Behavior behavior) { - throw new NotImplementedException(SR.NotImplementedByDesign); + _behavior = behavior; } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs index dee9e3ae316..5bbc162bbac 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs @@ -85,7 +85,7 @@ public bool Contains(Glyph value) /// /// Copies the Behavior.GlyphCollection values to a one-dimensional - /// instance at the specified index. + /// instance at the specified index. /// public void CopyTo(Glyph[] array, int index) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs index baf7c95e5f1..9c49f9baa65 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs @@ -2,14 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Diagnostics; using System.Drawing; namespace System.Windows.Forms.Design.Behavior { /// - /// The GrabHandleGlyph represents the 8 handles of our new seleciton model. Note that the pen and brush are created once per instance of this class and re-used in our painting logic for perf. reasonse. + /// The GrabHandleGlyph represents the 8 handles of our new seleciton model. + /// Note that the pen and brush are created once per instance of this class and re-used in our painting logic + /// for perf reasons. /// + [DebuggerDisplay("{GetType().Name, nq}:: Behavior={Behavior.GetType().Name, nq}, {rules}, {hitTestCursor}")] internal class GrabHandleGlyph : SelectionGlyphBase { private readonly bool _isPrimary; @@ -18,7 +23,8 @@ internal class GrabHandleGlyph : SelectionGlyphBase /// GrabHandleGlyph's constructor takes additional parameters: 'type' and 'primary selection'. /// Also, we create/cache our pen and brush here to avoid this action with every paint message. /// - internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Behavior behavior, bool primarySelection) : base(behavior) + internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Behavior? behavior, bool primarySelection) + : base(behavior) { _isPrimary = primarySelection; hitTestCursor = Cursors.Default; @@ -28,12 +34,12 @@ internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Beha switch (type) { case GrabHandleGlyphType.UpperLeft: - bounds = new Rectangle((controlBounds.X + DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, (controlBounds.Y + DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); + bounds = new Rectangle(controlBounds.X + DesignerUtils.HANDLEOVERLAP - DesignerUtils.HANDLESIZE, controlBounds.Y + DesignerUtils.HANDLEOVERLAP - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNWSE; rules = SelectionRules.TopSizeable | SelectionRules.LeftSizeable; break; case GrabHandleGlyphType.UpperRight: - bounds = new Rectangle(controlBounds.Right - DesignerUtils.HANDLEOVERLAP, (controlBounds.Y + DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); + bounds = new Rectangle(controlBounds.Right - DesignerUtils.HANDLEOVERLAP, controlBounds.Y + DesignerUtils.HANDLEOVERLAP - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNESW; rules = SelectionRules.TopSizeable | SelectionRules.RightSizeable; break; @@ -43,7 +49,7 @@ internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Beha rules = SelectionRules.BottomSizeable | SelectionRules.RightSizeable; break; case GrabHandleGlyphType.LowerLeft: - bounds = new Rectangle((controlBounds.X + DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, controlBounds.Bottom - DesignerUtils.HANDLEOVERLAP, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); + bounds = new Rectangle(controlBounds.X + DesignerUtils.HANDLEOVERLAP - DesignerUtils.HANDLESIZE, controlBounds.Bottom - DesignerUtils.HANDLEOVERLAP, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNESW; rules = SelectionRules.BottomSizeable | SelectionRules.LeftSizeable; break; @@ -51,7 +57,7 @@ internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Beha // Only add this one if there's room enough. Room is enough is as follows: 2*HANDLEOVERLAP for UpperLeft and UpperRight handles, 1 HANDLESIZE for the MiddleTop handle, 1 HANDLESIZE for padding if (controlBounds.Width >= (2 * DesignerUtils.HANDLEOVERLAP) + (2 * DesignerUtils.HANDLESIZE)) { - bounds = new Rectangle(controlBounds.X + (controlBounds.Width / 2) - (DesignerUtils.HANDLESIZE / 2), (controlBounds.Y + DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); + bounds = new Rectangle(controlBounds.X + (controlBounds.Width / 2) - (DesignerUtils.HANDLESIZE / 2), controlBounds.Y + DesignerUtils.HANDLEOVERLAP - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNS; rules = SelectionRules.TopSizeable; } @@ -71,7 +77,7 @@ internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Beha // Only add this one if there's room enough. Room is enough is as follows: 2*HANDLEOVERLAP for UpperLeft and LowerLeft handles, 1 HANDLESIZE for the MiddleLeft handle, 1 HANDLESIZE for padding if (controlBounds.Height >= (2 * DesignerUtils.HANDLEOVERLAP) + (2 * DesignerUtils.HANDLESIZE)) { - bounds = new Rectangle((controlBounds.X + DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, controlBounds.Y + (controlBounds.Height / 2) - (DesignerUtils.HANDLESIZE / 2), DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); + bounds = new Rectangle(controlBounds.X + DesignerUtils.HANDLEOVERLAP - DesignerUtils.HANDLESIZE, controlBounds.Y + (controlBounds.Height / 2) - (DesignerUtils.HANDLESIZE / 2), DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeWE; rules = SelectionRules.LeftSizeable; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs index e0a0118fb1d..77134822ea2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs @@ -2,19 +2,24 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior { /// - /// The LockedBorderGlyph draws one side (depending on type) of a SelectionBorder in the 'Locked' mode The constructor will initialize and cache the pen and brush objects to avoid unnecessary recreations. + /// The LockedBorderGlyph draws one side (depending on type) of a SelectionBorder in the 'Locked' mode. + /// The constructor will initialize and cache the pen and brush objects to avoid unnecessary recreations. /// internal class LockedBorderGlyph : SelectionGlyphBase { /// - /// This constructor extends from the standard SelectionGlyphBase constructor. Note that a primarySelection flag is passed in - this will be used when determining the colors of the borders. + /// This constructor extends from the standard SelectionGlyphBase constructor. + /// Note that a primarySelection flag is passed in - this will be used when determining the colors of the borders. /// - internal LockedBorderGlyph(Rectangle controlBounds, SelectionBorderGlyphType type) : base(null) + internal LockedBorderGlyph(Rectangle controlBounds, SelectionBorderGlyphType type) + : base(null) { InitializeGlyph(controlBounds, type); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs index 0b8469d56e0..7e9b6ef0ffb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs index 1a7d19cd862..232f7c472df 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs @@ -2,23 +2,32 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior { /// - /// The LockedBorderGlyph draws one side (depending on type) of a SelectionBorder in the 'Locked' mode. The constructor will initialize and cache the pen and brush objects to avoid unnecessary recreations. + /// The LockedBorderGlyph draws one side (depending on type) of a SelectionBorder in the 'Locked' mode. + /// The constructor will initialize and cache the pen and brush objects to avoid unnecessary recreations. /// internal class MiniLockedBorderGlyph : SelectionGlyphBase { private SelectionBorderGlyphType _type; - internal SelectionBorderGlyphType Type { get => _type; set => _type = value; } + internal SelectionBorderGlyphType Type + { + get => _type; + set => _type = value; + } /// - /// This constructor extends from the standard SelectionGlyphBase constructor. Note that a primarySelection flag is passed in - this will be used when determining the colors of the borders. + /// This constructor extends from the standard SelectionGlyphBase constructor. + /// Note that a primarySelection flag is passed in - this will be used when determining the colors of the borders. /// - internal MiniLockedBorderGlyph(Rectangle controlBounds, SelectionBorderGlyphType type, Behavior behavior, bool primarySelection) : base(behavior) + internal MiniLockedBorderGlyph(Rectangle controlBounds, SelectionBorderGlyphType type, Behavior behavior, bool primarySelection) + : base(behavior) { InitializeGlyph(controlBounds, type); } @@ -30,8 +39,10 @@ private void InitializeGlyph(Rectangle controlBounds, SelectionBorderGlyphType t { hitTestCursor = Cursors.Default; // always default cursor for locked rules = SelectionRules.None; // never change sel rules for locked + int borderSize = 1; Type = type; + // this will return the rect representing the bounds of the glyph bounds = DesignerUtils.GetBoundsForSelectionType(controlBounds, type, borderSize); hitBounds = bounds; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs index 663d297ce34..858a1f67c43 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs @@ -2,12 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior { /// - /// The NoResizeHandleGlyph represents the handle for a non-resizeable control in our new seleciton model. Note that the pen and brush are created once per instance of this class and re-used in our painting logic for perf. reasonse. + /// The NoResizeHandleGlyph represents the handle for a non-resizeable control in our new seleciton model. + /// Note that the pen and brush are created once per instance of this class and re-used in our painting logic + /// for perf reasons. /// internal class NoResizeHandleGlyph : SelectionGlyphBase { @@ -17,7 +21,8 @@ internal class NoResizeHandleGlyph : SelectionGlyphBase /// NoResizeHandleGlyph's constructor takes additional parameters: 'type' and 'primary selection'. /// Also, we create/cache our pen and brush here to avoid this action with every paint message. /// - internal NoResizeHandleGlyph(Rectangle controlBounds, SelectionRules selRules, bool primarySelection, Behavior behavior) : base(behavior) + internal NoResizeHandleGlyph(Rectangle controlBounds, SelectionRules selRules, bool primarySelection, Behavior? behavior) + : base(behavior) { _isPrimary = primarySelection; hitTestCursor = Cursors.Default; @@ -29,7 +34,11 @@ internal NoResizeHandleGlyph(Rectangle controlBounds, SelectionRules selRules, b } // The handle is always upperleft - bounds = new Rectangle(controlBounds.X - DesignerUtils.NORESIZEHANDLESIZE, controlBounds.Y - DesignerUtils.NORESIZEHANDLESIZE, DesignerUtils.NORESIZEHANDLESIZE, DesignerUtils.NORESIZEHANDLESIZE); + bounds = new Rectangle( + controlBounds.X - DesignerUtils.NORESIZEHANDLESIZE, + controlBounds.Y - DesignerUtils.NORESIZEHANDLESIZE, + DesignerUtils.NORESIZEHANDLESIZE, + DesignerUtils.NORESIZEHANDLESIZE); hitBounds = bounds; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs index 67e6a2a70b6..a09f79dc702 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior @@ -14,7 +16,8 @@ internal class NoResizeSelectionBorderGlyph : SelectionGlyphBase /// /// This constructor extends from the standard SelectionGlyphBase constructor. /// - internal NoResizeSelectionBorderGlyph(Rectangle controlBounds, SelectionRules rules, SelectionBorderGlyphType type, Behavior behavior) : base(behavior) + internal NoResizeSelectionBorderGlyph(Rectangle controlBounds, SelectionRules rules, SelectionBorderGlyphType type, Behavior? behavior) + : base(behavior) { InitializeGlyph(controlBounds, rules, type); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs index 1d389f2aba3..8b42d4de12b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs @@ -766,7 +766,7 @@ public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) if (control == _primaryControl && _statusCommandUI != null) { - _statusCommandUI.SetStatusInformation(control as Component); + _statusCommandUI.SetStatusInformation(control); } } finally @@ -891,7 +891,7 @@ public override bool OnMouseUp(Glyph g, MouseButtons button) if (_resizeComponents[i].resizeControl == _primaryControl && _statusCommandUI != null) { - _statusCommandUI.SetStatusInformation(_primaryControl as Component); + _statusCommandUI.SetStatusInformation(_primaryControl); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs index f7a969c06fd..86240225b9d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior @@ -14,7 +16,8 @@ internal class SelectionBorderGlyph : SelectionGlyphBase /// /// This constructor extends from the standard SelectionGlyphBase constructor. /// - internal SelectionBorderGlyph(Rectangle controlBounds, SelectionRules rules, SelectionBorderGlyphType type, Behavior behavior) : base(behavior) + internal SelectionBorderGlyph(Rectangle controlBounds, SelectionRules rules, SelectionBorderGlyphType type, Behavior? behavior) + : base(behavior) { InitializeGlyph(controlBounds, rules, type); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs index 1ae6cb0e5e3..4159de6b87f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System.Drawing; namespace System.Windows.Forms.Design.Behavior @@ -11,15 +13,15 @@ namespace System.Windows.Forms.Design.Behavior /// internal abstract class SelectionGlyphBase : Glyph { - protected Rectangle bounds; // defines the bounds of the selection glyph - protected Rectangle hitBounds; // defines the bounds used for hittest - it could be different than the bounds of the glyph itself - protected Cursor hitTestCursor; // the cursor returned if hit test is positive - protected SelectionRules rules; // the selection rules - defining how the control can change + protected Rectangle bounds; // defines the bounds of the selection glyph + protected Rectangle hitBounds; // defines the bounds used for hittest - it could be different than the bounds of the glyph itself + protected Cursor? hitTestCursor; // the cursor returned if hit test is positive + protected SelectionRules rules; // the selection rules - defining how the control can change /// /// Standard constructor. /// - internal SelectionGlyphBase(Behavior behavior) : base(behavior) + internal SelectionGlyphBase(Behavior? behavior) : base(behavior) { } @@ -34,7 +36,7 @@ public SelectionRules SelectionRules /// /// Simple hit test rule: if the point is contained within the bounds - then it is a positive hit test. /// - public override Cursor GetHitTest(Point p) + public override Cursor? GetHitTest(Point p) { if (hitBounds.Contains(p)) { @@ -47,7 +49,7 @@ public override Cursor GetHitTest(Point p) /// /// Returns the HitTestCursor for this glyph. /// - public Cursor HitTestCursor + public Cursor? HitTestCursor { get => hitTestCursor; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs index d304c5b9454..6b17414391b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -15,63 +15,77 @@ namespace System.Windows.Forms.Design.Behavior /// internal sealed class SelectionManager : IDisposable { - private Adorner selectionAdorner;//used to provide all selection glyphs - private Adorner bodyAdorner;//used to track all body glyphs for each control - private BehaviorService behaviorService;//ptr back to our BehaviorService - private IServiceProvider serviceProvider;//standard service provider - private readonly Hashtable componentToDesigner;//used for quick look up of designers related to comps - private readonly Control rootComponent;//root component being designed - private ISelectionService selSvc;//we cache the selection service for perf. - private IDesignerHost designerHost;//we cache the designerhost for perf. - private bool needRefresh; // do we need to refresh? - private Rectangle[] prevSelectionBounds;//used to only repaint the changing part of the selection - private object prevPrimarySelection; //used to check if the primary selection changed - private Rectangle[] curSelectionBounds; - private int curCompIndex; - private DesignerActionUI designerActionUI; // the "container" for all things related to the designer action (smartags) UI - private bool selectionChanging; //we dont want the OnSelectionChanged to be recursively called. + private Adorner _selectionAdorner; //used to provide all selection glyphs + private Adorner _bodyAdorner; //used to track all body glyphs for each control + private BehaviorService _behaviorService; //ptr back to our BehaviorService + private IServiceProvider _serviceProvider; //standard service provider + private readonly Hashtable _componentToDesigner; //used for quick look up of designers related to comps + private readonly Control _rootComponent; //root component being designed + private ISelectionService _selSvc; //we cache the selection service for perf. + private IDesignerHost _designerHost; //we cache the designerhost for perf. + private bool _needRefresh; // do we need to refresh? + private Rectangle[] _prevSelectionBounds; //used to only repaint the changing part of the selection + private object _prevPrimarySelection; //used to check if the primary selection changed + private Rectangle[] _curSelectionBounds; + private int _curCompIndex; + private DesignerActionUI _designerActionUI; // the "container" for all things related to the designer action (smartags) UI + private bool _selectionChanging; //we dont want the OnSelectionChanged to be recursively called. /// /// Constructor. Here we query for necessary services and cache them for perf. reasons. We also hook to Component Added/Removed/Changed notifications so we can keep in sync when the designers' components change. Also, we create our custom Adorner and add it to the BehaviorService. /// public SelectionManager(IServiceProvider serviceProvider, BehaviorService behaviorService) { - prevSelectionBounds = null; - prevPrimarySelection = null; - this.behaviorService = behaviorService; - this.serviceProvider = serviceProvider; + _prevSelectionBounds = null; + _prevPrimarySelection = null; + _behaviorService = behaviorService; + _serviceProvider = serviceProvider; - selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService)); - designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); + _selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService)); + _designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); - if (designerHost is null || selSvc is null) + if (_designerHost is null || _selSvc is null) { Debug.Fail("SelectionManager - Host or SelSvc is null, can't continue"); } //sync the BehaviorService's begindrag event behaviorService.BeginDrag += new BehaviorDragDropEventHandler(OnBeginDrag); + //sync the BehaviorService's Synchronize event behaviorService.Synchronize += new EventHandler(OnSynchronize); - selSvc.SelectionChanged += new EventHandler(OnSelectionChanged); - rootComponent = (Control)designerHost.RootComponent; - // create and add both of our adorners, one for selection, one for bodies - selectionAdorner = new Adorner(); - bodyAdorner = new Adorner(); - behaviorService.Adorners.Add(bodyAdorner); - behaviorService.Adorners.Add(selectionAdorner); //adding this will cause the adorner to get setup with a ptr to the beh.svc. + _selSvc.SelectionChanged += new EventHandler(OnSelectionChanged); + _rootComponent = (Control)_designerHost.RootComponent; + + //create and add both of our adorners, + //one for selection, one for bodies + _selectionAdorner = new Adorner(); + _bodyAdorner = new Adorner(); + behaviorService.Adorners.Add(_bodyAdorner); + behaviorService.Adorners.Add(_selectionAdorner); //adding this will cause the adorner to get setup with a ptr + //to the beh.svc. + + _componentToDesigner = new Hashtable(); + + IComponentChangeService cs = (IComponentChangeService)serviceProvider.GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded += new ComponentEventHandler(OnComponentAdded); + cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + } + + _designerHost.TransactionClosed += new DesignerTransactionCloseEventHandler(OnTransactionClosed); - componentToDesigner = new Hashtable(); - designerHost.TransactionClosed += new DesignerTransactionCloseEventHandler(OnTransactionClosed); // designeraction UI - if (designerHost.GetService(typeof(DesignerOptionService)) is DesignerOptionService options) + if (_designerHost.GetService(typeof(DesignerOptionService)) is DesignerOptionService options) { PropertyDescriptor p = options.Options.Properties["UseSmartTags"]; if (p != null && p.PropertyType == typeof(bool) && (bool)p.GetValue(null)) { - designerActionUI = new DesignerActionUI(serviceProvider, selectionAdorner); - behaviorService.DesignerActionUI = designerActionUI; + _designerActionUI = new DesignerActionUI(serviceProvider, _selectionAdorner); + behaviorService.DesignerActionUI = _designerActionUI; } } } @@ -81,16 +95,21 @@ public SelectionManager(IServiceProvider serviceProvider, BehaviorService behavi /// internal Adorner BodyGlyphAdorner { - get => bodyAdorner; + get => _bodyAdorner; } /// - /// There are certain cases like Adding Item to ToolStrips through InSitu Editor, where there is ParentTransaction that has to be cancelled depending upon the user action When this parent transaction is cancelled, there may be no reason to REFRESH the selectionManager which actually clears all the glyphs and readds them This REFRESH causes a lot of flicker and can be avoided by setting this property to false. Since this property is checked in the TransactionClosed, the SelectionManager won't REFRESH and hence just eat up the refresh thus avoiding unnecessary flicker. + /// There are certain cases like Adding Item to ToolStrips through InSitu Editor, where there is + /// ParentTransaction that has to be cancelled depending upon the user action When this parent transaction is + /// cancelled, there may be no reason to REFRESH the selectionManager which actually clears all the glyphs and + /// readds them This REFRESH causes a lot of flicker and can be avoided by setting this property to false. + /// Since this property is checked in the TransactionClosed, the SelectionManager won't REFRESH and hence + /// just eat up the refresh thus avoiding unnecessary flicker. /// internal bool NeedRefresh { - get => needRefresh; - set => needRefresh = value; + get => _needRefresh; + set => _needRefresh = value; } /// @@ -98,11 +117,12 @@ internal bool NeedRefresh /// internal Adorner SelectionGlyphAdorner { - get => selectionAdorner; + get => _selectionAdorner; } /// - /// This method fist calls the recursive AddControlGlyphs() method. When finished, we add the final glyph(s) to the root comp. + /// This method fist calls the recursive AddControlGlyphs() method. When finished, we add the final glyph(s) + /// to the root comp. /// private void AddAllControlGlyphs(Control parent, ArrayList selComps, object primarySelection) { @@ -132,23 +152,23 @@ private void AddAllControlGlyphs(Control parent, ArrayList selComps, object prim /// private void AddControlGlyphs(Control c, GlyphSelectionType selType) { - ControlDesigner cd = (ControlDesigner)componentToDesigner[c]; + ControlDesigner cd = (ControlDesigner)_componentToDesigner[c]; if (cd != null) { ControlBodyGlyph bodyGlyph = cd.GetControlGlyphInternal(selType); if (bodyGlyph != null) { - bodyAdorner.Glyphs.Add(bodyGlyph); + _bodyAdorner.Glyphs.Add(bodyGlyph); if (selType == GlyphSelectionType.SelectedPrimary || selType == GlyphSelectionType.Selected) { - if (curSelectionBounds[curCompIndex] == Rectangle.Empty) + if (_curSelectionBounds[_curCompIndex] == Rectangle.Empty) { - curSelectionBounds[curCompIndex] = bodyGlyph.Bounds; + _curSelectionBounds[_curCompIndex] = bodyGlyph.Bounds; } else { - curSelectionBounds[curCompIndex] = Rectangle.Union(curSelectionBounds[curCompIndex], bodyGlyph.Bounds); + _curSelectionBounds[_curCompIndex] = Rectangle.Union(_curSelectionBounds[_curCompIndex], bodyGlyph.Bounds); } } } @@ -156,13 +176,13 @@ private void AddControlGlyphs(Control c, GlyphSelectionType selType) GlyphCollection glyphs = cd.GetGlyphs(selType); if (glyphs != null) { - selectionAdorner.Glyphs.AddRange(glyphs); + _selectionAdorner.Glyphs.AddRange(glyphs); if (selType == GlyphSelectionType.SelectedPrimary || selType == GlyphSelectionType.Selected) { foreach (Glyph glyph in glyphs) { - curSelectionBounds[curCompIndex] = Rectangle.Union(curSelectionBounds[curCompIndex], glyph.Bounds); + _curSelectionBounds[_curCompIndex] = Rectangle.Union(_curSelectionBounds[_curCompIndex], glyph.Bounds); } } } @@ -170,7 +190,7 @@ private void AddControlGlyphs(Control c, GlyphSelectionType selType) if (selType == GlyphSelectionType.SelectedPrimary || selType == GlyphSelectionType.Selected) { - curCompIndex++; + _curCompIndex++; } } @@ -180,48 +200,56 @@ private void AddControlGlyphs(Control c, GlyphSelectionType selType) // We don't need to Dispose rootComponent. public void Dispose() { - if (designerHost != null) + if (_designerHost != null) { - designerHost.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnTransactionClosed); - designerHost = null; + _designerHost.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnTransactionClosed); + _designerHost = null; } - if (serviceProvider != null) + if (_serviceProvider != null) { - if (selSvc != null) + IComponentChangeService cs = (IComponentChangeService)_serviceProvider.GetService(typeof(IComponentChangeService)); + if (cs != null) { - selSvc.SelectionChanged -= new EventHandler(OnSelectionChanged); - selSvc = null; + cs.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); + cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); } - serviceProvider = null; + if (_selSvc != null) + { + _selSvc.SelectionChanged -= new EventHandler(OnSelectionChanged); + _selSvc = null; + } + + _serviceProvider = null; } - if (behaviorService != null) + if (_behaviorService != null) { - behaviorService.Adorners.Remove(bodyAdorner); - behaviorService.Adorners.Remove(selectionAdorner); - behaviorService.BeginDrag -= new BehaviorDragDropEventHandler(OnBeginDrag); - behaviorService.Synchronize -= new EventHandler(OnSynchronize); - behaviorService = null; + _behaviorService.Adorners.Remove(_bodyAdorner); + _behaviorService.Adorners.Remove(_selectionAdorner); + _behaviorService.BeginDrag -= new BehaviorDragDropEventHandler(OnBeginDrag); + _behaviorService.Synchronize -= new EventHandler(OnSynchronize); + _behaviorService = null; } - if (selectionAdorner != null) + if (_selectionAdorner != null) { - selectionAdorner.Glyphs.Clear(); - selectionAdorner = null; + _selectionAdorner.Glyphs.Clear(); + _selectionAdorner = null; } - if (bodyAdorner != null) + if (_bodyAdorner != null) { - bodyAdorner.Glyphs.Clear(); - bodyAdorner = null; + _bodyAdorner.Glyphs.Clear(); + _bodyAdorner = null; } - if (designerActionUI != null) + if (_designerActionUI != null) { - designerActionUI.Dispose(); - designerActionUI = null; + _designerActionUI.Dispose(); + _designerActionUI = null; } } @@ -240,10 +268,10 @@ public void Refresh() private void OnComponentAdded(object source, ComponentEventArgs ce) { IComponent component = ce.Component; - IDesigner designer = designerHost.GetDesigner(component); + IDesigner designer = _designerHost.GetDesigner(component); if (designer is ControlDesigner) { - componentToDesigner.Add(component, designer); + _componentToDesigner.Add(component, designer); } } @@ -254,7 +282,7 @@ private void OnBeginDrag(object source, BehaviorDragDropEventArgs e) { ArrayList dragComps = new ArrayList(e.DragComponents); ArrayList glyphsToRemove = new ArrayList(); - foreach (ControlBodyGlyph g in bodyAdorner.Glyphs) + foreach (ControlBodyGlyph g in _bodyAdorner.Glyphs) { if (g.RelatedComponent is Control) { @@ -268,7 +296,7 @@ private void OnBeginDrag(object source, BehaviorDragDropEventArgs e) foreach (Glyph g in glyphsToRemove) { - bodyAdorner.Glyphs.Remove(g); + _bodyAdorner.Glyphs.Remove(g); } } @@ -283,9 +311,9 @@ internal void OnBeginDrag(BehaviorDragDropEventArgs e) /// private void OnComponentChanged(object source, ComponentChangedEventArgs ce) { - if (selSvc.GetComponentSelected(ce.Component)) + if (_selSvc.GetComponentSelected(ce.Component)) { - if (!designerHost.InTransaction) + if (!_designerHost.InTransaction) { Refresh(); } @@ -301,15 +329,15 @@ private void OnComponentChanged(object source, ComponentChangedEventArgs ce) /// private void OnComponentRemoved(object source, ComponentEventArgs ce) { - if (componentToDesigner.Contains(ce.Component)) + if (_componentToDesigner.Contains(ce.Component)) { - componentToDesigner.Remove(ce.Component); + _componentToDesigner.Remove(ce.Component); } //remove the associated designeractionpanel - if (designerActionUI != null) + if (_designerActionUI != null) { - designerActionUI.RemoveActionGlyph(ce.Component); + _designerActionUI.RemoveActionGlyph(ce.Component); } } @@ -321,25 +349,29 @@ private Region DetermineRegionToRefresh(object primarySelection) Region toRefresh = new Region(Rectangle.Empty); Rectangle[] larger; Rectangle[] smaller; - if (curSelectionBounds.Length >= prevSelectionBounds.Length) + if (_curSelectionBounds.Length >= _prevSelectionBounds.Length) { - larger = curSelectionBounds; - smaller = prevSelectionBounds; + larger = _curSelectionBounds; + smaller = _prevSelectionBounds; } else { - larger = prevSelectionBounds; - smaller = curSelectionBounds; + larger = _prevSelectionBounds; + smaller = _curSelectionBounds; } - // we need to make sure all of the rects in the smaller array are accounted for. Any that don't intersect a rect in the larger array need to be included in the region to repaint. + // we need to make sure all of the rects in the smaller array are + // accounted for. Any that don't intersect a rect in the larger + // array need to be included in the region to repaint. bool[] intersected = new bool[smaller.Length]; for (int i = 0; i < smaller.Length; i++) { intersected[i] = false; } - // determine which rects in the larger array need to be included in the region to invalidate by intersecting with rects in the smaller array. + // determine which rects in the larger array need to be + // included in the region to invalidate by intersecting + // with rects in the smaller array. for (int l = 0; l < larger.Length; l++) { bool largeIntersected = false; @@ -376,14 +408,14 @@ private Region DetermineRegionToRefresh(object primarySelection) } } - using (Graphics g = behaviorService.AdornerWindowGraphics) + using (Graphics g = _behaviorService.AdornerWindowGraphics) { - //If all that changed was the primary selection, then the refresh region was empty, but we do need to update the 2 controls. - if (toRefresh.IsEmpty(g) && primarySelection != null && !primarySelection.Equals(prevPrimarySelection)) + // If all that changed was the primary selection, then the refresh region was empty, but we do need to update the 2 controls. + if (toRefresh.IsEmpty(g) && primarySelection != null && !primarySelection.Equals(_prevPrimarySelection)) { - for (int i = 0; i < curSelectionBounds.Length; i++) + for (int i = 0; i < _curSelectionBounds.Length; i++) { - toRefresh.Union(curSelectionBounds[i]); + toRefresh.Union(_curSelectionBounds[i]); } } } @@ -404,63 +436,69 @@ private void OnSynchronize(object sender, EventArgs e) /// private void OnSelectionChanged(object sender, EventArgs e) { - // Note: selectionChanging would guard against a re-entrant code... Since we dont want to be in messed up state when adding new Glyphs. - if (!selectionChanging) + // Note: selectionChanging would guard against a re-entrant code... + // Since we dont want to be in messed up state when adding new Glyphs. + if (!_selectionChanging) { - selectionChanging = true; - selectionAdorner.Glyphs.Clear(); - bodyAdorner.Glyphs.Clear(); - ArrayList selComps = new ArrayList(selSvc.GetSelectedComponents()); - object primarySelection = selSvc.PrimarySelection; + _selectionChanging = true; + + _selectionAdorner.Glyphs.Clear(); + _bodyAdorner.Glyphs.Clear(); + + ArrayList selComps = new ArrayList(_selSvc.GetSelectedComponents()); + object primarySelection = _selSvc.PrimarySelection; + //add all control glyphs to all controls on rootComp - curCompIndex = 0; - curSelectionBounds = new Rectangle[selComps.Count]; - AddAllControlGlyphs(rootComponent, selComps, primarySelection); - if (prevSelectionBounds != null) + _curCompIndex = 0; + _curSelectionBounds = new Rectangle[selComps.Count]; + AddAllControlGlyphs(_rootComponent, selComps, primarySelection); + + if (_prevSelectionBounds != null) { Region toUpdate = DetermineRegionToRefresh(primarySelection); - using (Graphics g = behaviorService.AdornerWindowGraphics) + using (Graphics g = _behaviorService.AdornerWindowGraphics) { if (!toUpdate.IsEmpty(g)) { - selectionAdorner.Invalidate(toUpdate); + _selectionAdorner.Invalidate(toUpdate); } } } else { - // There was no previous selection, so just invalidate the current selection - if (curSelectionBounds.Length > 0) + // There was no previous selection, so just invalidate + // the current selection + if (_curSelectionBounds.Length > 0) { - Rectangle toUpdate = curSelectionBounds[0]; - for (int i = 1; i < curSelectionBounds.Length; i++) + Rectangle toUpdate = _curSelectionBounds[0]; + for (int i = 1; i < _curSelectionBounds.Length; i++) { - toUpdate = Rectangle.Union(toUpdate, curSelectionBounds[i]); + toUpdate = Rectangle.Union(toUpdate, _curSelectionBounds[i]); } if (toUpdate != Rectangle.Empty) { - selectionAdorner.Invalidate(toUpdate); + _selectionAdorner.Invalidate(toUpdate); } } else { - selectionAdorner.Invalidate(); + _selectionAdorner.Invalidate(); } } - prevPrimarySelection = primarySelection; - if (curSelectionBounds.Length > 0) + _prevPrimarySelection = primarySelection; + if (_curSelectionBounds.Length > 0) { - prevSelectionBounds = new Rectangle[curSelectionBounds.Length]; - Array.Copy(curSelectionBounds, prevSelectionBounds, curSelectionBounds.Length); + _prevSelectionBounds = new Rectangle[_curSelectionBounds.Length]; + Array.Copy(_curSelectionBounds, _prevSelectionBounds, _curSelectionBounds.Length); } else { - prevSelectionBounds = null; + _prevSelectionBounds = null; } - selectionChanging = false; + _selectionChanging = false; } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs index c014ac514d7..9b070496914 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; - namespace System.Windows.Forms.Design.Behavior { /// diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs new file mode 100644 index 00000000000..3ae0c7d9075 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs @@ -0,0 +1,383 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel.Design; +using System.Drawing; + +namespace System.Windows.Forms.Design.Behavior +{ + /// + /// This class implements the behavior provided by DocumentDesigner + /// when the user is dragging a valid toolbox item. Here, we'll render a + /// default 'box' beneath the cursor that snaps to edges of other + /// components on the designer's surface. + /// + internal class ToolboxItemSnapLineBehavior : Behavior + { + private readonly IServiceProvider serviceProvider;//used for snaplines + private readonly BehaviorService behaviorService;//pointer to our big & bad service + private readonly ControlDesigner designer;//used for snaplines as well + private bool isPushed;//used to track if this is currently on the stack or not + private Rectangle lastRectangle;//cache the last mouse loc - so we can ignore when mouse doesn't move + private Point lastOffset;//cache the last snap so we know where to create our control if dropped + private DragAssistanceManager dragManager; //used to apply snaplines when dragging a new tool rect on the designer's surface + private readonly bool targetAllowsSnapLines;//indicates if the drop target allows snaplines (flowpanels don't for ex) + private readonly StatusCommandUI statusCommandUI; //used to update the StatusBar Information. + private readonly bool targetAllowsDragBox; //indicates if the drop target allows the generic drag box to be drawn + + /// + /// Constructor that caches the designer (which invoked us) and a ptr + /// to the BehaviorService. + /// + public ToolboxItemSnapLineBehavior(IServiceProvider serviceProvider, BehaviorService behaviorService) + { + this.serviceProvider = serviceProvider; + this.behaviorService = behaviorService; + designer = null; + isPushed = false; + lastRectangle = Rectangle.Empty; + lastOffset = Point.Empty; + statusCommandUI = new StatusCommandUI(serviceProvider); + targetAllowsDragBox = true; + targetAllowsSnapLines = true; + } + + public ToolboxItemSnapLineBehavior(IServiceProvider serviceProvider, BehaviorService behaviorService, ControlDesigner controlDesigner) + : this(serviceProvider, behaviorService) + { + designer = controlDesigner; + //check to see if the current designer participate with SnapLines + if (controlDesigner != null && !controlDesigner.ParticipatesWithSnapLines) + { + targetAllowsSnapLines = false; + } + } + + public ToolboxItemSnapLineBehavior(IServiceProvider serviceProvider, BehaviorService behaviorService, ControlDesigner controlDesigner, bool allowDragBox) + : this(serviceProvider, behaviorService, controlDesigner) + { + designer = controlDesigner; + targetAllowsDragBox = allowDragBox; + } + + /// + /// OnDragDrop can be overridden so that a Behavior can specify its own + /// Drag/Drop rules. + /// CONSIDER: Should we have the BehaivorService fire push/pop events on Behaviors??? + /// + public bool IsPushed + { + get + { + return isPushed; + } + set + { + isPushed = value; + + if (isPushed) + { + if (dragManager == null) + { + dragManager = new DragAssistanceManager(serviceProvider); + } + } + else + { + //clean up all our temp objects + if (!lastRectangle.IsEmpty) + { + behaviorService.Invalidate(lastRectangle); + } + + lastOffset = Point.Empty; + lastRectangle = Rectangle.Empty; + + //destroy the snapline engine (if we used it) + if (dragManager != null) + { + dragManager.OnMouseUp(); + dragManager = null; + } + } + } + } + + /// + /// Called on a DragDrop - this generates our extra drag info + /// to pass along to the base class. Basically, we get the + /// last-rendered snaplines before the drop and attempt to + /// identify to which direction the mouse was snapped. + /// + private ToolboxSnapDragDropEventArgs CreateToolboxSnapArgs(DragEventArgs e, Point mouseLoc) + { + //we're trying to set these two vars here... + ToolboxSnapDragDropEventArgs.SnapDirection snapDirections = ToolboxSnapDragDropEventArgs.SnapDirection.None; + Point offset = Point.Empty; + + //as soon as these vars are true - we can stop looking at lines + bool horizontalComponentIdentified = false; + bool verticalComponentIdentified = false; + + if (dragManager != null) + { + DragAssistanceManager.Line[] lines = dragManager.GetRecentLines(); + + foreach (DragAssistanceManager.Line line in lines) + { + if (line.LineType == DragAssistanceManager.LineType.Standard) + { + if (!horizontalComponentIdentified && line.x1 == line.x2) + { + //check for vertical equality + if (line.x1 == lastRectangle.Left) + { + //we had a line on the left of the box - so we must have snapped left + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Left; + offset.X = lastRectangle.Left - mouseLoc.X; + } + else + {//MUST BE RIGHT? if (lines.x1 == lastRectangle.Right) { + //we had a line on the right of the box - so we must have snapped right + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Right; + offset.X = lastRectangle.Right - mouseLoc.X; + } + + horizontalComponentIdentified = true; + } + else if (!verticalComponentIdentified && line.y1 == line.y2) + { + //check for vertical equality + if (line.y1 == lastRectangle.Top) + { + //we had a line on the top of the box - so we must have snapped top + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Top; + offset.Y = lastRectangle.Top - mouseLoc.Y; + } + else if (line.y1 == lastRectangle.Bottom) + { + //we had a line on the bottom of the box - so we must have snapped bottom + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Bottom; + offset.Y = lastRectangle.Bottom - mouseLoc.Y; + } + + verticalComponentIdentified = true; + } + } + else if ((line.LineType == DragAssistanceManager.LineType.Margin) || + (line.LineType == DragAssistanceManager.LineType.Padding)) + { + if (!verticalComponentIdentified && line.x1 == line.x2) + { + //now, we're looking at a vertical margin line - is it above? + if (Math.Max(line.y1, line.y2) <= lastRectangle.Top) + { + //aha - we had a margin line at the top of the box + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Top; + offset.Y = lastRectangle.Top - mouseLoc.Y; + } + else + { + //aha - we had a margin line at the bottom of the box + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Bottom; + offset.Y = lastRectangle.Bottom - mouseLoc.Y; + } + + verticalComponentIdentified = true; + } + else if (!horizontalComponentIdentified && line.y1 == line.y2) + { + //now, we're looking at a horz margin line - is it left? + if (Math.Max(line.x1, line.x2) <= lastRectangle.Left) + { + //aha - we had a margin line at the left of the box + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Left; + offset.X = lastRectangle.Left - mouseLoc.X; + } + else + { + //aha - we had a margin line at the right of the box + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Right; + offset.X = lastRectangle.Right - mouseLoc.X; + } + + horizontalComponentIdentified = true; + } + } + + if (horizontalComponentIdentified && verticalComponentIdentified) + { + //we've found both components - stop looping + break; + } + } + } + + //set default values is we haven't identified any 'snaps' + if (!horizontalComponentIdentified) + { + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Left; + offset.X = lastRectangle.Left - mouseLoc.X; + } + + if (!verticalComponentIdentified) + { + snapDirections |= ToolboxSnapDragDropEventArgs.SnapDirection.Top; + offset.Y = lastRectangle.Top - mouseLoc.Y; + } + + //create our arg and pass it back + return new ToolboxSnapDragDropEventArgs(snapDirections, offset, e); + } + + /// + /// Used when dragging a new tool rect on the designer's surface - + /// this will return some generic snaplines Allowing the rect to + /// snap to existing control edges on the surface. + /// + private SnapLine[] GenerateNewToolSnapLines(Rectangle r) + { + return new SnapLine[] + { + new SnapLine(SnapLineType.Left, r.Left), + new SnapLine(SnapLineType.Right, r.Right), + new SnapLine(SnapLineType.Bottom, r.Bottom), + new SnapLine(SnapLineType.Top, r.Top), + new SnapLine(SnapLineType.Horizontal, r.Top -4, SnapLine.MarginTop, SnapLinePriority.Always), + new SnapLine(SnapLineType.Horizontal, r.Bottom + 3, SnapLine.MarginBottom, SnapLinePriority.Always), + new SnapLine(SnapLineType.Vertical, r.Left -4, SnapLine.MarginLeft, SnapLinePriority.Always), + new SnapLine(SnapLineType.Vertical, r.Right + 3, SnapLine.MarginRight, SnapLinePriority.Always) + }; + } + + /// + /// OnDragDrop can be overridden so that a Behavior can specify its own + /// Drag/Drop rules. + /// + public override void OnDragDrop(Glyph g, DragEventArgs e) + { + behaviorService.PopBehavior(this); + + try + { + //offset the mouse loc to screen coords for calculations on drops + Point screenOffset = behaviorService.AdornerWindowToScreen(); + + //build up our extra-special event args + ToolboxSnapDragDropEventArgs se = CreateToolboxSnapArgs(e, new Point(e.X - screenOffset.X, e.Y - screenOffset.Y)); + + base.OnDragDrop(g, se); + } + finally + { + //clear everything up + IsPushed = false; + } + } + + // When we begin a drag we need to remove the glyphs that do not allow drops. + // VSWhidbey #487816 + public void OnBeginDrag() + { + Adorner bodyAdorner = null; + SelectionManager selMgr = (SelectionManager)serviceProvider.GetService(typeof(SelectionManager)); + if (selMgr != null) + { + bodyAdorner = selMgr.BodyGlyphAdorner; + } + + ArrayList glyphsToRemove = new ArrayList(); + foreach (ControlBodyGlyph body in bodyAdorner.Glyphs) + { + Control ctl = body.RelatedComponent as Control; + if (ctl != null) + { + if (!ctl.AllowDrop) + { + glyphsToRemove.Add(body); + } + } + } + + foreach (Glyph glyph in glyphsToRemove) + { + bodyAdorner.Glyphs.Remove(glyph); + } + } + + public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) + { + bool altKeyPressed = Control.ModifierKeys == Keys.Alt; + + if (altKeyPressed && dragManager != null) + { + //erase any snaplines (if we had any) + dragManager.EraseSnapLines(); + } + + //call base + bool retValue = base.OnMouseMove(g, button, mouseLoc); + + //identify where the new box should be... + Rectangle newRectangle = new Rectangle(mouseLoc.X - DesignerUtils.BOXIMAGESIZE / 2, mouseLoc.Y - DesignerUtils.BOXIMAGESIZE / 2, + DesignerUtils.BOXIMAGESIZE, DesignerUtils.BOXIMAGESIZE); + + //don't do anything if the loc is the same + if (newRectangle != lastRectangle) + { + if (dragManager != null && targetAllowsSnapLines && !altKeyPressed) + { + lastOffset = dragManager.OnMouseMove(newRectangle, GenerateNewToolSnapLines(newRectangle)); + newRectangle.Offset(lastOffset.X, lastOffset.Y); + } + + //erase old + if (!lastRectangle.IsEmpty) + { + //build up the invalid region + using (Region invalidRegion = new Region(lastRectangle)) + { + invalidRegion.Exclude(newRectangle); + behaviorService.Invalidate(invalidRegion); + } + } + + if (targetAllowsDragBox) + { + using (Graphics graphics = behaviorService.AdornerWindowGraphics) + { + graphics.DrawImage(DesignerUtils.BoxImage, newRectangle.Location); + } + } + + //offset the mouse loc to screen coords for calculations on drops + IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); + if (host != null) + { + Control baseControl = host.RootComponent as Control; + if (baseControl != null) + { + Point adornerServiceOrigin = behaviorService.MapAdornerWindowPoint(baseControl.Handle, new Point(0, 0)); + Rectangle statusRect = new Rectangle(newRectangle.X - adornerServiceOrigin.X, newRectangle.Y - adornerServiceOrigin.Y, 0, 0); + if (statusCommandUI != null) + { + statusCommandUI.SetStatusInformation(statusRect); + } + } + } + + if (dragManager != null && targetAllowsSnapLines && !altKeyPressed) + { + dragManager.RenderSnapLinesInternal(); + } + + //store this off for the next time around + lastRectangle = newRectangle; + } + + return retValue; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs new file mode 100644 index 00000000000..1f23a94b97e --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs @@ -0,0 +1,236 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// Provides a designer that can design components + /// that extend ButtonBase. + /// + internal class ButtonBaseDesigner : ControlDesigner + { + // private DesignerActionListCollection _actionlists; + + public ButtonBaseDesigner() + { + AutoResizeHandles = true; + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["UseVisualStyleBackColor"]; + if (prop != null && prop.PropertyType == typeof(bool) && !prop.IsReadOnly && prop.IsBrowsable) + { + // Dev10 Bug 685319: We should set the UseVisualStyleBackColor to trun only + // when this property has not been set/changed by user + // + if (!prop.ShouldSerializeValue(Component)) + { + prop.SetValue(Component, true); + } + } + } + + /// + /// Adds a baseline SnapLine to the list of SnapLines related + /// to this control. + /// + public override IList SnapLines + { + get + { + ArrayList snapLines = base.SnapLines as ArrayList; + FlatStyle flatStyle = FlatStyle.Standard; + ContentAlignment alignment = ContentAlignment.MiddleCenter; + + PropertyDescriptor prop; + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(Component); + + if ((prop = props["TextAlign"]) != null) + { + alignment = (ContentAlignment)prop.GetValue(Component); + } + + if ((prop = props["FlatStyle"]) != null) + { + flatStyle = (FlatStyle)prop.GetValue(Component); + } + + int baseline = DesignerUtils.GetTextBaseline(Control, alignment); + + //based on the type of control and it's style, we need to add certain deltas to make + //the snapline appear in the right place. Rather than adding a class for each control + //we special case it here - for perf reasons. + + if ((Control is CheckBox) || (Control is RadioButton)) + { + Appearance appearance = Appearance.Normal; + if ((prop = props["Appearance"]) != null) + { + appearance = (Appearance)prop.GetValue(Component); + } + + if (appearance == Appearance.Normal) + { + if (Control is CheckBox) + { + baseline += CheckboxBaselineOffset(alignment, flatStyle); + } + else + { + baseline += RadiobuttonBaselineOffset(alignment, flatStyle); + } + } + else + { + baseline += DefaultBaselineOffset(alignment, flatStyle); + } + } + else + { //default case + baseline += DefaultBaselineOffset(alignment, flatStyle); + } + + snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium)); + + return snapLines; + } + } + + private int CheckboxBaselineOffset(ContentAlignment alignment, FlatStyle flatStyle) + { + if ((alignment & DesignerUtils.AnyMiddleAlignment) != 0) + { + if ((flatStyle == FlatStyle.Standard) || (flatStyle == FlatStyle.System)) + { + return -1; + } + else + { + return 0; //FlatStyle.Flat || FlatStyle.Popup || Unknown FlatStyle + } + } + else if ((alignment & DesignerUtils.AnyTopAlignment) != 0) + { + if (flatStyle == FlatStyle.Standard) + { + return 1; + } + else if (flatStyle == FlatStyle.System) + { + return 0; + } + else if ((flatStyle == FlatStyle.Flat) || (flatStyle == FlatStyle.Popup)) + { + return 2; + } + else + { + Debug.Fail("Unknown FlatStyle"); + return 0; //Unknown FlatStyle + } + } + else + {//bottom alignment + if (flatStyle == FlatStyle.Standard) + { + return -3; + } + else if (flatStyle == FlatStyle.System) + { + return 0; + } + else if ((flatStyle == FlatStyle.Flat) || (flatStyle == FlatStyle.Popup)) + { + return -2; + } + else + { + Debug.Fail("Unknown FlatStyle"); + return 0; //Unknown FlatStyle + } + } + } + + private int RadiobuttonBaselineOffset(ContentAlignment alignment, FlatStyle flatStyle) + { + if ((alignment & DesignerUtils.AnyMiddleAlignment) != 0) + { + if (flatStyle == FlatStyle.System) + { + return -1; + } + else + { + return 0; //FlatStyle.Standard || FlatStyle.Flat || FlatStyle.Popup || Unknown FlatStyle + } + } + else + {// Top or bottom alignment + if ((flatStyle == FlatStyle.Standard) || (flatStyle == FlatStyle.Flat) || (flatStyle == FlatStyle.Popup)) + { + return ((alignment & DesignerUtils.AnyTopAlignment) != 0) ? 2 : -2; + } + else if (flatStyle == FlatStyle.System) + { + return 0; + } + else + { + Debug.Fail("Unknown FlatStyle"); + return 0; //Unknown FlatStyle + } + } + } + + private int DefaultBaselineOffset(ContentAlignment alignment, FlatStyle flatStyle) + { + if ((alignment & DesignerUtils.AnyMiddleAlignment) != 0) + { + return 0; + } + else + { // Top or bottom alignment + if ((flatStyle == FlatStyle.Standard) || (flatStyle == FlatStyle.Popup)) + { + return ((alignment & DesignerUtils.AnyTopAlignment) != 0) ? 4 : -4; + } + else if (flatStyle == FlatStyle.System) + { + return ((alignment & DesignerUtils.AnyTopAlignment) != 0) ? 3 : -3; + } + else if (flatStyle == FlatStyle.Flat) + { + return ((alignment & DesignerUtils.AnyTopAlignment) != 0) ? 5 : -5; + } + else + { + Debug.Fail("Unknown FlatStyle"); + return 0; //Unknown FlatStyle + } + } + } + + /* + public override DesignerActionListCollection ActionLists { + get { + if(_actionlists == null) { + _actionlists = new DesignerActionListCollection(); + _actionlists.Add(new ButtonBaseActionList()); + } + return _actionlists; + } + } + */ + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs index ebd4a9cbc20..6e15eeeb4bc 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs @@ -5,7 +5,6 @@ using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Drawing.Design; namespace System.Windows.Forms.Design @@ -58,7 +57,7 @@ public void ChangeParent() } // Get OleDragHandler ... - ToolboxItem tbi = new ToolboxItem(typeof(System.Windows.Forms.ToolStripContainer)); + ToolboxItem tbi = new ToolboxItem(typeof(ToolStripContainer)); OleDragDropHandler ddh = rootDesigner.GetOleDragHandler(); if (ddh != null) { @@ -104,7 +103,7 @@ public void ChangeParent() } catch (Exception e) { - if (e is System.InvalidOperationException) + if (e is InvalidOperationException) { IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService)); uiService.ShowError(e.Message); @@ -121,7 +120,6 @@ public void ChangeParent() if (changeParent != null) { changeParent.Commit(); - changeParent = null; } Cursor.Current = current; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs index e08a79bdc40..7fcec53094a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs @@ -10,7 +10,7 @@ namespace System.Windows.Forms.Design internal class ColumnHeaderCollectionEditor : CollectionEditor { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public ColumnHeaderCollectionEditor(Type type) : base(type) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs new file mode 100644 index 00000000000..b4b1d3ca6a0 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs @@ -0,0 +1,153 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Collections; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// Provides a designer that can design components + /// that extend ComboBox. + /// + internal class ComboBoxDesigner : ControlDesigner + { + private EventHandler propChanged; // Delegate used to dirty the selectionUIItem when needed. + + /// + /// Adds a baseline SnapLine to the list of SnapLines related + /// to this control. + /// + public override IList SnapLines + { + get + { + ArrayList snapLines = base.SnapLines as ArrayList; + + //a single text-baseline for the label (and linklabel) control + int baseline = DesignerUtils.GetTextBaseline(Control, Drawing.ContentAlignment.TopLeft); + baseline += 3; + snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium)); + + return snapLines; + } + } + + /// + /// Disposes of this object. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + // Hook up the property change notification so that we can dirty the SelectionUIItem when needed. + if (propChanged != null) + { + ((ComboBox)Control).StyleChanged -= propChanged; + } + } + + base.Dispose(disposing); + } + + /// + /// Called by the host when we're first initialized. + /// + public override void Initialize(IComponent component) + { + base.Initialize(component); + + AutoResizeHandles = true; + + // Hook up the property change notification so that we can dirty the SelectionUIItem when needed. + propChanged = new EventHandler(OnControlPropertyChanged); + ((ComboBox)Control).StyleChanged += propChanged; + } + + /// + /// We override this so we can clear the text field set by controldesigner. + /// + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + // in Whidbey, formattingEnabled is TRUE + ((ComboBox)Component).FormattingEnabled = true; + + PropertyDescriptor textProp = TypeDescriptor.GetProperties(Component)["Text"]; + if (textProp != null && textProp.PropertyType == typeof(string) && !textProp.IsReadOnly && textProp.IsBrowsable) + { + textProp.SetValue(Component, ""); + } + } + + /// + /// For controls, we sync their property changed event so our component can track their location. + /// + private void OnControlPropertyChanged(object sender, EventArgs e) + { + if (BehaviorService != null) + { + BehaviorService.SyncSelection(); + } + } + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + object component = Component; + + PropertyDescriptor propStyle = TypeDescriptor.GetProperties(component)["DropDownStyle"]; + if (propStyle != null) + { + ComboBoxStyle style = (ComboBoxStyle)propStyle.GetValue(component); + + // Height is not user-changable for these styles + if (style == ComboBoxStyle.DropDown || style == ComboBoxStyle.DropDownList) + rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable); + } + + return rules; + } + } + + private DesignerActionListCollection _actionLists; + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + + // TODO: investigate necessity and possibility of porting databinding infra +#if DESIGNER_DATABINDING + // Requires: + // - System.Windows.Forms.Design.DataMemberFieldEditor + // - System.Windows.Forms.Design.DesignBindingConverter + // - System.Windows.Forms.Design.DesignBindingEditor + // + _actionLists.Add(new ListControlBoundActionList(this)); +#else + _actionLists.Add(new ListControlUnboundActionList(this)); +#endif + } + + return _actionLists; + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs new file mode 100644 index 00000000000..03d8b94498a --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs @@ -0,0 +1,4375 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization.Formatters.Binary; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.ComponentModel.Design; +using System.ComponentModel.Design.Serialization; +using System.Windows.Forms.Design.Behavior; +using System.Drawing; +using System.Drawing.Design; +using System.Collections; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// This class implements the standard set of menu commands for + /// the form designer. This set of command is shared between + /// the form designer (and other UI-based form packages), and + /// composition designer, which doesn't manipulate controls. + /// Therefore, this set of command should only contain commands + /// that are common to both functions. + /// + /// + internal class CommandSet : IDisposable + { + protected ISite site; + private readonly CommandSetItem[] commandSet; + private IMenuCommandService menuService; + private IEventHandlerService eventService; + + // Selection service fields. We keep some state about the + // currently selected components so we can determine proper + // command enabling quickly. + // + private ISelectionService selectionService; + protected int selCount; // the current selection count + protected IComponent primarySelection; // the primary selection, or null + private bool selectionInherited; // the selection contains inherited components + protected bool controlsOnlySelection; // is the selection containing only controls or are there components in it? + private int selectionVersion = 1; // the counter of selection changes. + + // Selection sort constants + // + private const int SORT_HORIZONTAL = 0; + private const int SORT_VERTICAL = 1; + private const int SORT_ZORDER = 2; + + private const string CF_DESIGNER = "CF_DESIGNERCOMPONENTS_V2"; // See VSWhidbey #172531 + + //these are used for snapping control via keyboard movement + protected DragAssistanceManager dragManager;//point to the snapline engine (only valid between keydown and timer expiration) + private Timer snapLineTimer;//used to track the time from when a snapline is rendered until it should expire + private BehaviorService behaviorService;//demand created pointer to the behaviorservice + private StatusCommandUI statusCommandUI; //Used to update the statusBar Information. + private readonly IUIService uiService; + + /// + /// Creates a new CommandSet object. This object implements the set + /// of commands that the UI.Win32 form designer offers. + /// + public CommandSet(ISite site) + { + this.site = site; + + eventService = (IEventHandlerService)site.GetService(typeof(IEventHandlerService)); + Debug.Assert(eventService != null, "Command set must have the event service. Is command set being initialized too early?"); + + eventService.EventHandlerChanged += new EventHandler(OnEventHandlerChanged); + + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (host != null) + { + host.Activated += new EventHandler(UpdateClipboardItems); + } + + statusCommandUI = new StatusCommandUI(site); + + uiService = site.GetService(typeof(IUIService)) as IUIService; + + // Establish our set of commands + // + commandSet = new CommandSetItem[] + { + // Editing commands + new CommandSetItem( + this, + new EventHandler(OnStatusDelete), + new EventHandler(OnMenuDelete), + StandardCommands.Delete, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusCopy), + new EventHandler(OnMenuCopy), + StandardCommands.Copy, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusCut), + new EventHandler(OnMenuCut), + StandardCommands.Cut, + uiService), + + new ImmediateCommandSetItem( + this, + new EventHandler(OnStatusPaste), + new EventHandler(OnMenuPaste), + StandardCommands.Paste, + uiService), + + // Miscellaneous commands + new CommandSetItem( + this, + new EventHandler(OnStatusSelectAll), + new EventHandler(OnMenuSelectAll), + StandardCommands.SelectAll, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnMenuDesignerProperties), + MenuCommands.DesignerProperties, + uiService), + + // Keyboard commands + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeyCancel), + MenuCommands.KeyCancel, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeyCancel), + MenuCommands.KeyReverseCancel, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusPrimarySelection), + new EventHandler(OnKeyDefault), + MenuCommands.KeyDefaultAction, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyMoveUp, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyMoveDown, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyMoveLeft, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyMoveRight, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyNudgeUp, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyNudgeDown, true, + uiService), + + new CommandSetItem( + + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyNudgeLeft, true, + uiService), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnySelection), + new EventHandler(OnKeyMove), + MenuCommands.KeyNudgeRight, true, + uiService), + }; + + selectionService = (ISelectionService)site.GetService(typeof(ISelectionService)); + Debug.Assert(selectionService != null, "CommandSet relies on the selection service, which is unavailable."); + if (selectionService != null) + { + selectionService.SelectionChanged += new EventHandler(OnSelectionChanged); + } + + menuService = (IMenuCommandService)site.GetService(typeof(IMenuCommandService)); + if (menuService != null) + { + for (int i = 0; i < commandSet.Length; i++) + { + menuService.AddCommand(commandSet[i]); + } + } + + // Now setup the default command GUID for this designer. This GUID is also used in our toolbar + // definition file to identify toolbars we own. We store the GUID in a command ID here in the + // dictionary of the root component. Our host may pull this GUID out and use it. + // + IDictionaryService ds = site.GetService(typeof(IDictionaryService)) as IDictionaryService; + Debug.Assert(ds != null, "No dictionary service"); + if (ds != null) + { + ds.SetValue(typeof(CommandID), new CommandID(new Guid("BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F"), 0)); + } + } + + /// + /// Demand creates a pointer to the BehaviorService + /// + protected BehaviorService BehaviorService + { + get + { + if (behaviorService == null) + { + behaviorService = GetService(typeof(BehaviorService)) as BehaviorService; + } + + return behaviorService; + } + } + + /// + /// Retrieves the menu command service, which the command set + /// typically uses quite a bit. + /// + protected IMenuCommandService MenuService + { + get + { + if (menuService == null) + { + menuService = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + } + + return menuService; + } + } + + /// + /// Retrieves the selection service, which the command set + /// typically uses quite a bit. + /// + protected ISelectionService SelectionService + { + get + { + return selectionService; + } + } + + protected int SelectionVersion + { + get + { + return selectionVersion; + } + } + + /// + /// This property demand creates our snaplinetimer used to + /// track how long we'll leave snaplines on the screen before + /// erasing them + /// + protected Timer SnapLineTimer + { + get + { + if (snapLineTimer == null) + { + //instantiate our snapline timer + snapLineTimer = new Timer(); + snapLineTimer.Interval = DesignerUtils.SNAPELINEDELAY; + snapLineTimer.Tick += new EventHandler(OnSnapLineTimerExpire); + } + + return snapLineTimer; + } + } + + /// + /// Checks if an object supports ComponentEditors, and optionally launches + /// the editor. + /// + private bool CheckComponentEditor(object obj, bool launchEditor) + { + if (obj is IComponent) + { + try + { + if (!launchEditor) + { + return true; + } + + ComponentEditor editor = (ComponentEditor)TypeDescriptor.GetEditor(obj, typeof(ComponentEditor)); + if (editor == null) + { + return false; + } + + bool success = false; + IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + + if (changeService != null) + { + try + { + changeService.OnComponentChanging(obj, null); + } + catch (CheckoutException coEx) + { + if (coEx == CheckoutException.Canceled) + { + return false; + } + + throw; + } + catch + { + Debug.Fail("non-CLS compliant exception"); + throw; + } + } + + WindowsFormsComponentEditor winEditor = editor as WindowsFormsComponentEditor; + if (winEditor != null) + { + IWin32Window parent = null; + + //REVIEW: This smells wrong + if (obj is IWin32Window) + { +#pragma warning disable 1717 // assignment to self + parent = parent; +#pragma warning restore 1717 + + } + + success = winEditor.EditComponent(obj, parent); + } + else + { + success = editor.EditComponent(obj); + } + + if (success && changeService != null) + { + // Now notify the change service that the change was successful. + // + changeService.OnComponentChanged(obj, null, null, null); + } + + return true; + } + catch (Exception ex) + { + if (ClientUtils.IsCriticalException(ex)) + { + throw; + } + } + } + + return false; + } + + /// + /// Disposes of this object, removing all commands from the menu service. + /// + + // We don't need to Dispose snapLineTimer + public virtual void Dispose() + { + if (menuService != null) + { + for (int i = 0; i < commandSet.Length; i++) + { + menuService.RemoveCommand(commandSet[i]); + commandSet[i].Dispose(); + } + + menuService = null; + } + + if (selectionService != null) + { + selectionService.SelectionChanged -= new EventHandler(OnSelectionChanged); + selectionService = null; + } + + if (eventService != null) + { + eventService.EventHandlerChanged -= new EventHandler(OnEventHandlerChanged); + eventService = null; + } + + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + if (host != null) + { + host.Activated -= new EventHandler(UpdateClipboardItems); + } + + if (snapLineTimer != null) + { + snapLineTimer.Stop(); + snapLineTimer.Tick -= new EventHandler(OnSnapLineTimerExpire); + snapLineTimer = null; + } + + EndDragManager(); + statusCommandUI = null; + site = null; + } + + /// + /// Properly cleans up our drag engine. + /// + protected void EndDragManager() + { + if (dragManager != null) + { + if (snapLineTimer != null) + { + snapLineTimer.Stop(); + } + + dragManager.EraseSnapLines(); + dragManager.OnMouseUp(); + dragManager = null; + } + } + + // Returns true if the action is successful, false otherwise + internal static bool ExecuteSafely(Action action, bool throwOnException) + { + if (action != null) + { + try + { + action(); + return true; + } + catch + { + if (throwOnException) + { + throw; + } + + return false; + } + } + + return false; + } + + // This function will return true if call to func is successful, false otherwise + // Output of call to func is available in result out parameter + private static bool ExecuteSafely(Func func, bool throwOnException, out T result) + { + if (func != null) + { + try + { + result = func(); + return true; + } + catch + { + if (throwOnException) + { + throw; + } + } + } + + result = default(T); + return false; + } + + /// + /// Filters the set of selected components. The selection service will retrieve all + /// components that are currently selected. This method allows you to filter this + /// set down to components that match your criteria. The selectionRules parameter + /// must contain one or more flags from the SelectionRules class. These flags + /// allow you to constrain the set of selected objects to visible, movable, + /// sizeable or all objects. + /// + private object[] FilterSelection(object[] components, SelectionRules selectionRules) + { + object[] selection = null; + + if (components == null) + return Array.Empty(); + + // Mask off any selection object that doesn't adhere to the given ruleset. + // We can ignore this if the ruleset is zero, as all components would be accepted. + // + if (selectionRules != SelectionRules.None) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + ArrayList list = new ArrayList(); + + foreach (IComponent comp in components) + { + ControlDesigner des = host.GetDesigner(comp) as ControlDesigner; + if (des != null && (des.SelectionRules & selectionRules) == selectionRules) + { + list.Add(comp); + } + } + + selection = list.ToArray(); + } + } + + return selection == null ? Array.Empty() : selection; + } + + /// + /// Used to retrieve the selection for a copy. The default implementation + /// retrieves the current selection. + /// + protected virtual ICollection GetCopySelection() + { + ICollection selectedComponents = SelectionService.GetSelectedComponents(); + bool sort = false; + object[] comps = new object[selectedComponents.Count]; + selectedComponents.CopyTo(comps, 0); + + foreach (object comp in comps) + { + if (comp is Control) + { + sort = true; + break; + } + } + + if (sort) + { + SortSelection(comps, SORT_ZORDER); + } + + selectedComponents = comps; + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + if (host != null) + { + ArrayList copySelection = new ArrayList(); + foreach (IComponent comp in selectedComponents) + { + copySelection.Add(comp); + GetAssociatedComponents(comp, host, copySelection); + } + + selectedComponents = copySelection; + } + + return selectedComponents; + } + + private void GetAssociatedComponents(IComponent component, IDesignerHost host, ArrayList list) + { + ComponentDesigner designer = host.GetDesigner(component) as ComponentDesigner; + if (designer == null) + { + return; + } + + foreach (IComponent childComp in designer.AssociatedComponents) + { + if (childComp.Site != null) + { + list.Add(childComp); + GetAssociatedComponents(childComp, host, list); + } + } + } + + /// + /// Used to retrieve the current location of the given component. + /// + private Point GetLocation(IComponent comp) + { + PropertyDescriptor prop = GetProperty(comp, "Location"); + + if (prop != null) + { + try + { + return (Point)prop.GetValue(comp); + } + catch (Exception e) + { + Debug.Fail("Commands may be disabled, the location property was not accessible", e.ToString()); + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + } + } + + return Point.Empty; + } + + /// + /// Retrieves the given property on the given component. + /// + protected PropertyDescriptor GetProperty(object comp, string propName) + { + return TypeDescriptor.GetProperties(comp)[propName]; + } + + /// + /// Retrieves the requested service. + /// + protected virtual object GetService(Type serviceType) + { + if (site != null) + { + return site.GetService(serviceType); + } + + return null; + } + + /// + /// Used to retrieve the current size of the given component. + /// + private Size GetSize(IComponent comp) + { + PropertyDescriptor prop = GetProperty(comp, "Size"); + if (prop != null) + { + return (Size)prop.GetValue(comp); + } + + return Size.Empty; + } + + /// + /// Retrieves the snap information for the given component. + /// + protected virtual void GetSnapInformation(IDesignerHost host, IComponent component, out Size snapSize, out IComponent snapComponent, out PropertyDescriptor snapProperty) + { + PropertyDescriptorCollection props; + + // This implementation is shared by all. It just looks for snap properties on the base component. + // + IComponent currentSnapComponent = host.RootComponent; + props = TypeDescriptor.GetProperties(currentSnapComponent); + + PropertyDescriptor currentSnapProp = props["SnapToGrid"]; + if (currentSnapProp != null && currentSnapProp.PropertyType != typeof(bool)) + { + currentSnapProp = null; + } + + PropertyDescriptor gridSizeProp = props["GridSize"]; + if (gridSizeProp != null && gridSizeProp.PropertyType != typeof(Size)) + { + gridSizeProp = null; + } + + // Finally, now that we've got the various properties and components, dole out the + // values. + // + snapComponent = currentSnapComponent; + snapProperty = currentSnapProp; + if (gridSizeProp != null) + { + snapSize = (Size)gridSizeProp.GetValue(snapComponent); + } + else + { + snapSize = Size.Empty; + } + } + + /// + /// Called before doing any change to multiple controls + /// to check if we have the right to make any change + /// otherwise we would get a checkout message for each control we call setvalue on + /// + protected bool CanCheckout(IComponent comp) + { + // look if it's ok to change + IComponentChangeService changeSvc = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + // is it ok to change? + if (changeSvc != null) + { + try + { + changeSvc.OnComponentChanging(comp, null); + } + catch (CheckoutException chkex) + { + if (chkex == CheckoutException.Canceled) + return false; + throw; + } + } + + return true; + } + + /// + /// Called by the event handler service when the current event handler + /// has changed. Here we invalidate all of our menu items so that + /// they can pick up the new event handler. + /// + private void OnEventHandlerChanged(object sender, EventArgs e) + { + OnUpdateCommandStatus(); + } + + /// + /// Called for the two cancel commands we support. + /// + private void OnKeyCancel(object sender, EventArgs e) + { + OnKeyCancel(sender); + } + + /// + /// Called for the two cancel commands we support. Returns true + /// If we did anything with the cancel, or false if not. + /// + protected virtual bool OnKeyCancel(object sender) + { + bool handled = false; + + // The base implementation here just checks to see if we are dragging. + // If we are, then we abort the drag. + // + if (BehaviorService != null && BehaviorService.HasCapture) + { + BehaviorService.OnLoseCapture(); + handled = true; + } + else + { + IToolboxService tbx = (IToolboxService)GetService(typeof(IToolboxService)); + if (tbx != null && tbx.GetSelectedToolboxItem((IDesignerHost)GetService(typeof(IDesignerHost))) != null) + { + tbx.SelectedToolboxItemUsed(); + + User32.GetCursorPos(out Point p); + IntPtr hwnd = User32.WindowFromPoint(p); + if (hwnd != IntPtr.Zero) + { + User32.SendMessageW(hwnd, User32.WM.SETCURSOR, hwnd, (IntPtr)User32.HT.CLIENT); + } + else + { + Cursor.Current = Cursors.Default; + } + + handled = true; + } + } + + return handled; + } + + /// + /// Called for the "default" command, typically the Enter key. + /// + protected void OnKeyDefault(object sender, EventArgs e) + { + // Return key. Handle it like a double-click on the + // primary selection + // + ISelectionService selSvc = SelectionService; + + if (selSvc != null) + { + IComponent pri = selSvc.PrimarySelection as IComponent; + if (pri != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + IDesigner designer = host.GetDesigner(pri); + + if (designer != null) + { + designer.DoDefaultAction(); + } + } + } + } + } + + /// + /// Called for all cursor movement commands. + /// + protected virtual void OnKeyMove(object sender, EventArgs e) + { + // Arrow keys. Begin a drag if the selection isn't locked. + // + ISelectionService selSvc = SelectionService; + + if (selSvc != null) + { + IComponent comp = selSvc.PrimarySelection as IComponent; + if (comp != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + PropertyDescriptor lockedProp = TypeDescriptor.GetProperties(comp)["Locked"]; + if (lockedProp == null || (lockedProp.PropertyType == typeof(bool) && ((bool)lockedProp.GetValue(comp))) == false) + { + CommandID cmd = ((MenuCommand)sender).CommandID; + bool invertSnap = false; + int moveOffsetX = 0; + int moveOffsetY = 0; + + if (cmd.Equals(MenuCommands.KeyMoveUp)) + { + moveOffsetY = -1; + } + else if (cmd.Equals(MenuCommands.KeyMoveDown)) + { + moveOffsetY = 1; + } + else if (cmd.Equals(MenuCommands.KeyMoveLeft)) + { + moveOffsetX = -1; + } + else if (cmd.Equals(MenuCommands.KeyMoveRight)) + { + moveOffsetX = 1; + } + else if (cmd.Equals(MenuCommands.KeyNudgeUp)) + { + moveOffsetY = -1; + invertSnap = true; + } + else if (cmd.Equals(MenuCommands.KeyNudgeDown)) + { + moveOffsetY = 1; + invertSnap = true; + } + else if (cmd.Equals(MenuCommands.KeyNudgeLeft)) + { + moveOffsetX = -1; + invertSnap = true; + } + else if (cmd.Equals(MenuCommands.KeyNudgeRight)) + { + moveOffsetX = 1; + invertSnap = true; + } + else + { + Debug.Fail("Unknown command mapped to OnKeyMove: " + cmd.ToString()); + } + + DesignerTransaction trans; + + if (selSvc.SelectionCount > 1) + { + trans = host.CreateTransaction(string.Format(SR.DragDropMoveComponents, selSvc.SelectionCount)); + } + else + { + trans = host.CreateTransaction(string.Format(SR.DragDropMoveComponent, comp.Site.Name)); + } + + try + { + //if we can find the behaviorservice, then we can use it and the SnapLineEngine to help us + //move these controls... + if (BehaviorService != null) + { + Control primaryControl = comp as Control; //this can be null (when we are moving a component in the ComponenTray) + + bool useSnapLines = BehaviorService.UseSnapLines; + + // If we have previous snaplines, we always want to erase them, no matter what. VS Whidbey #397709 + if (dragManager != null) + { + EndDragManager(); + } + + //If we CTRL+Arrow and we're using SnapLines - snap to the next location + //Don't snap if we are moving a component in the ComponentTray + if (invertSnap && useSnapLines && primaryControl != null) + { + ArrayList selComps = new ArrayList(selSvc.GetSelectedComponents()); + + //create our snapline engine + dragManager = new DragAssistanceManager(comp.Site, selComps); + + //ask our snapline engine to find the nearest snap position with the given direction + Point snappedOffset = dragManager.OffsetToNearestSnapLocation(primaryControl, new Point(moveOffsetX, moveOffsetY)); + + //update the offset according to the snapline engine + + // This is the offset assuming origin is in the upper-left. + moveOffsetX = snappedOffset.X; + moveOffsetY = snappedOffset.Y; + + // If the parent is mirrored then we need to negate moveOffsetX. + // This is because moveOffsetX assumes that the origin + // is upper left. That is, when moveOffsetX is positive, we + // are moving right, negative when moving left. + + // The parent container's origin depends on its mirroring property. + // Thus when we call propLoc.setValue below, we need to make sure + // that our moveOffset.X correctly reflects the placement of the + // parent container's origin. + + // We need to do this AFTER we calculate the snappedOffset. + // This is because the dragManager calculations are all based + // on an origin in the upper-left. + if (primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + } + + //if we used a regular arrow key and we're in SnapToGrid mode... + + else if (!invertSnap && !useSnapLines) + { + bool snapOn = false; + Size snapSize = Size.Empty; + IComponent snapComponent = null; + PropertyDescriptor snapProperty = null; + + GetSnapInformation(host, comp, out snapSize, out snapComponent, out snapProperty); + + if (snapProperty != null) + { + snapOn = (bool)snapProperty.GetValue(snapComponent); + } + + if (snapOn && !snapSize.IsEmpty) + { + moveOffsetX *= snapSize.Width; + moveOffsetY *= snapSize.Height; + + if (primaryControl != null) + { + ParentControlDesigner parentDesigner = host.GetDesigner(primaryControl.Parent) as ParentControlDesigner; + //ask the parent to adjust our wanna-be snapped position + if (parentDesigner != null) + { + Point loc = primaryControl.Location; + + // If the parent is mirrored then we need to negate moveOffsetX. + // This is because moveOffsetX assumes that the origin + // is upper left. That is, when moveOffsetX is positive, we + // are moving right, negative when moving left. + + // The parent container's origin depends on its mirroring property. + // Thus when we call propLoc.setValue below, we need to make sure + // that our moveOffset.X correctly reflects the placement of the + // parent container's origin. + + // Should do this BEFORE we get the snapped point. + if (primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + + loc.Offset(moveOffsetX, moveOffsetY); + + loc = parentDesigner.GetSnappedPoint(loc); + + //reset our offsets now that we've snapped correctly + if (moveOffsetX != 0) + { + moveOffsetX = loc.X - primaryControl.Location.X; + } + + if (moveOffsetY != 0) + { + moveOffsetY = loc.Y - primaryControl.Location.Y; + } + } + } + } + else + { + // In this case we are just going to move 1 pixel, so let's adjust for Mirroring + if (primaryControl != null && primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + } + } + else + { + if (primaryControl != null && primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + } + + SelectionRules rules = SelectionRules.Moveable | SelectionRules.Visible; + foreach (IComponent component in selSvc.GetSelectedComponents()) + { + ControlDesigner des = host.GetDesigner(component) as ControlDesigner; + if (des != null && ((des.SelectionRules & rules) != rules)) + { + //the control must match the rules, if not, then we don't move it + continue; + } + + // Components are always moveable and visible + + PropertyDescriptor propLoc = TypeDescriptor.GetProperties(component)["Location"]; + if (propLoc != null) + { + Point loc = (Point)propLoc.GetValue(component); + loc.Offset(moveOffsetX, moveOffsetY); + propLoc.SetValue(component, loc); + } + + //change the Status information .... + if (component == selSvc.PrimarySelection && statusCommandUI != null) + { + statusCommandUI.SetStatusInformation(component as Component); + } + } + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + + if (dragManager != null) + { + //start our timer for the snaplines + SnapLineTimer.Start(); + + //render any lines + dragManager.RenderSnapLinesInternal(); + } + } + } + } + } + } + } + + /// + /// Called for all alignment operations that key off of a primary + /// selection. + /// + protected void OnMenuAlignByPrimary(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + CommandID id = cmd.CommandID; + + //Need to get the location for the primary control, we do this here + //(instead of onselectionchange) because the control could be dragged + //around once it is selected and might have a new location + Point primaryLocation = GetLocation(primarySelection); + Size primarySize = GetSize(primarySelection); + + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + // Now loop through each of the components. + // + ICollection comps = SelectionService.GetSelectedComponents(); + + // Inform the designer that we are about to monkey with a ton + // of properties. + // + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + DesignerTransaction trans = null; + try + { + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.CommandSetAlignByPrimary, comps.Count)); + } + + bool firstTry = true; + Point loc = Point.Empty; + foreach (object obj in comps) + { + if (obj == primarySelection) + { + continue; + } + + IComponent comp = obj as IComponent; + + if (comp != null && host != null) + { + ControlDesigner des = host.GetDesigner(comp) as ControlDesigner; + if (des == null) + { + continue; + } + } + + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(comp); + + PropertyDescriptor locProp = props["Location"]; + PropertyDescriptor sizeProp = props["Size"]; + PropertyDescriptor lockProp = props["Locked"]; + + // Skip all components that are locked + // + if (lockProp != null) + { + if ((bool)lockProp.GetValue(comp)) + continue; + } + + // Skip all components that don't have a location property + // + if (locProp == null || locProp.IsReadOnly) + { + continue; + } + + // Skip all components that don't have size if we're + // doing a size operation. + // + if (id.Equals(StandardCommands.AlignBottom) || + id.Equals(StandardCommands.AlignHorizontalCenters) || + id.Equals(StandardCommands.AlignVerticalCenters) || + id.Equals(StandardCommands.AlignRight)) + { + if (sizeProp == null || sizeProp.IsReadOnly) + { + continue; + } + } + + // Align bottom + // + if (id.Equals(StandardCommands.AlignBottom)) + { + loc = (Point)locProp.GetValue(comp); + Size size = (Size)sizeProp.GetValue(comp); + loc.Y = primaryLocation.Y + primarySize.Height - size.Height; + } + + // Align horizontal centers + // + else if (id.Equals(StandardCommands.AlignHorizontalCenters)) + { + loc = (Point)locProp.GetValue(comp); + Size size = (Size)sizeProp.GetValue(comp); + loc.Y = primarySize.Height / 2 + primaryLocation.Y - size.Height / 2; + } + + // Align left + // + else if (id.Equals(StandardCommands.AlignLeft)) + { + loc = (Point)locProp.GetValue(comp); + loc.X = primaryLocation.X; + } + + // Align right + // + else if (id.Equals(StandardCommands.AlignRight)) + { + loc = (Point)locProp.GetValue(comp); + Size size = (Size)sizeProp.GetValue(comp); + loc.X = primaryLocation.X + primarySize.Width - size.Width; + } + + // Align top + // + else if (id.Equals(StandardCommands.AlignTop)) + { + loc = (Point)locProp.GetValue(comp); + loc.Y = primaryLocation.Y; + } + + // Align vertical centers + // + else if (id.Equals(StandardCommands.AlignVerticalCenters)) + { + loc = (Point)locProp.GetValue(comp); + Size size = (Size)sizeProp.GetValue(comp); + loc.X = primarySize.Width / 2 + primaryLocation.X - size.Width / 2; + } + else + { + Debug.Fail("Unrecognized command: " + id.ToString()); + } + + if (firstTry && !CanCheckout(comp)) + { + return; + } + + firstTry = false; + + locProp.SetValue(comp, loc); + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the align->to grid menu item is selected. + /// + protected void OnMenuAlignToGrid(object sender, EventArgs e) + { + Size gridSize = Size.Empty; + int delta; + + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + ICollection selectedComponents = SelectionService.GetSelectedComponents(); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + DesignerTransaction trans = null; + + try + { + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.CommandSetAlignToGrid, selectedComponents.Count)); + + Control baseComponent = host.RootComponent as Control; + if (baseComponent != null) + { + PropertyDescriptor prop = GetProperty(baseComponent, "GridSize"); + if (prop != null) + { + gridSize = (Size)prop.GetValue(baseComponent); + } + + if (prop == null || gridSize.IsEmpty) + { + //bail silently here + return; + } + } + } + + bool firstTry = true; + // for each component, we round to the nearest snap offset for x and y + foreach (object comp in selectedComponents) + { + // first check to see if the component is locked, if so - don't move it... + PropertyDescriptor lockedProp = GetProperty(comp, "Locked"); + if (lockedProp != null && ((bool)lockedProp.GetValue(comp)) == true) + { + continue; + } + + // if the designer for this component isn't a ControlDesigner (maybe + // it's something in the component tray) then don't try to align it to grid. + // + IComponent component = comp as IComponent; + if (component != null && host != null) + { + ControlDesigner des = host.GetDesigner(component) as ControlDesigner; + if (des == null) + { + continue; + } + } + + // get the location property + PropertyDescriptor locProp = GetProperty(comp, "Location"); + + // get the current value + if (locProp == null || locProp.IsReadOnly) + { + continue; + } + + var loc = (Point)locProp.GetValue(comp); + + // round the x to the snap size + delta = loc.X % gridSize.Width; + if (delta < (gridSize.Width / 2)) + { + loc.X -= delta; + } + else + { + loc.X += (gridSize.Width - delta); + } + + // round the y to the gridsize + delta = loc.Y % gridSize.Height; + if (delta < (gridSize.Height / 2)) + { + loc.Y -= delta; + } + else + { + loc.Y += (gridSize.Height - delta); + } + + // look if it's ok to change + if (firstTry && !CanCheckout(component)) + { + return; + } + + firstTry = false; + + // set the value + locProp.SetValue(comp, loc); + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the center horizontally or center vertically menu item is selected. + /// + protected void OnMenuCenterSelection(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + CommandID cmdID = cmd.CommandID; + + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + // NOTE: this only works on Control types + ICollection selectedComponents = SelectionService.GetSelectedComponents(); + Control viewParent = null; + Size size = Size.Empty; + Point loc = Point.Empty; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + DesignerTransaction trans = null; + + try + { + if (host != null) + { + string batchString; + + if (cmdID == StandardCommands.CenterHorizontally) + { + batchString = string.Format(SR.WindowsFormsCommandCenterX, selectedComponents.Count); + } + else + { + batchString = string.Format(SR.WindowsFormsCommandCenterY, selectedComponents.Count); + } + + trans = host.CreateTransaction(batchString); + } + + //subhag calculate the union REctangle : ASURT 67753 + // + int top = int.MaxValue; + int left = int.MaxValue; + int right = int.MinValue; + int bottom = int.MinValue; + + foreach (object obj in selectedComponents) + { + if (obj is Control) + { + IComponent comp = (IComponent)obj; + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(comp); + + PropertyDescriptor locProp = props["Location"]; + PropertyDescriptor sizeProp = props["Size"]; + + // Skip all components that don't have location and size properties + // + if (locProp == null || sizeProp == null || locProp.IsReadOnly || sizeProp.IsReadOnly) + { + continue; + } + + // Also, skip all locked componenents... + // + PropertyDescriptor lockProp = props["Locked"]; + if (lockProp != null && (bool)lockProp.GetValue(comp) == true) + { + continue; + } + + size = (Size)sizeProp.GetValue(comp); + loc = (Point)locProp.GetValue(comp); + + //cache the first parent we see - if there's a mix of different parents - we'll + //just center based on the first one + if (viewParent == null) + { + viewParent = ((Control)comp).Parent; + } + + if (loc.X < left) + left = loc.X; + if (loc.Y < top) + top = loc.Y; + if (loc.X + size.Width > right) + right = loc.X + size.Width; + if (loc.Y + size.Height > bottom) + bottom = loc.Y + size.Height; + } + } + + //if we never found a viewParent (some read-only inherited scenarios + //then simply bail + if (viewParent == null) + { + return; + } + + int centerOfUnionRectX = (left + right) / 2; + int centerOfUnionRectY = (top + bottom) / 2; + + int centerOfParentX = (viewParent.ClientSize.Width) / 2; + int centerOfParentY = (viewParent.ClientSize.Height) / 2; + + int deltaX = 0; + int deltaY = 0; + + bool shiftRight = false; + bool shiftBottom = false; + + if (centerOfParentX >= centerOfUnionRectX) + { + deltaX = centerOfParentX - centerOfUnionRectX; + shiftRight = true; + } + else + deltaX = centerOfUnionRectX - centerOfParentX; + + if (centerOfParentY >= centerOfUnionRectY) + { + deltaY = centerOfParentY - centerOfUnionRectY; + shiftBottom = true; + } + else + deltaY = centerOfUnionRectY - centerOfParentY; + + bool firstTry = true; + foreach (object obj in selectedComponents) + { + if (obj is Control) + { + IComponent comp = (IComponent)obj; + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(comp); + + PropertyDescriptor locProp = props["Location"]; + if (locProp.IsReadOnly) + { + continue; + } + + loc = (Point)locProp.GetValue(comp); + + if (cmdID == StandardCommands.CenterHorizontally) + { + if (shiftRight) + loc.X += deltaX; + else + loc.X -= deltaX; + } + else if (cmdID == StandardCommands.CenterVertically) + { + if (shiftBottom) + loc.Y += deltaY; + else + loc.Y -= deltaY; + } + + // look if it's ok to change the first time + if (firstTry && !CanCheckout(comp)) + { + return; + } + + firstTry = false; + // do the change + locProp.SetValue(comp, loc); + } + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the copy menu item is selected. + /// + protected void OnMenuCopy(object sender, EventArgs e) + { + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + ICollection selectedComponents = GetCopySelection(); + + selectedComponents = PrependComponentNames(selectedComponents); + + IDesignerSerializationService ds = (IDesignerSerializationService)GetService(typeof(IDesignerSerializationService)); + Debug.Assert(ds != null, "No designer serialization service -- we cannot copy to clipboard"); + if (ds != null) + { + object serializationData = ds.Serialize(selectedComponents); + MemoryStream stream = new MemoryStream(); + BinaryFormatter formatter = new BinaryFormatter(); +#pragma warning disable SYSLIB0011 // Type or member is obsolete + formatter.Serialize(stream, serializationData); +#pragma warning restore SYSLIB0011 // Type or member is obsolete + stream.Seek(0, SeekOrigin.Begin); + byte[] bytes = stream.GetBuffer(); + IDataObject dataObj = new DataObject(CF_DESIGNER, bytes); + if (ExecuteSafely(() => Clipboard.SetDataObject(dataObj), throwOnException: false) == false) + { + uiService?.ShowError(SR.ClipboardError); + } + } + + UpdateClipboardItems(null, null); + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the cut menu item is selected. + /// + protected void OnMenuCut(object sender, EventArgs e) + { + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + ICollection selectedComponents = GetCopySelection(); + int cutCount = selectedComponents.Count; + + selectedComponents = PrependComponentNames(selectedComponents); + IDesignerSerializationService ds = (IDesignerSerializationService)GetService(typeof(IDesignerSerializationService)); + Debug.Assert(ds != null, "No designer serialization service -- we cannot copy to clipboard"); + if (ds != null) + { + object serializationData = ds.Serialize(selectedComponents); + MemoryStream stream = new MemoryStream(); + BinaryFormatter formatter = new BinaryFormatter(); +#pragma warning disable SYSLIB0011 // Type or member is obsolete + formatter.Serialize(stream, serializationData); +#pragma warning restore SYSLIB0011 // Type or member is obsolete + stream.Seek(0, SeekOrigin.Begin); + byte[] bytes = stream.GetBuffer(); + IDataObject dataObj = new DataObject(CF_DESIGNER, bytes); + + if (ExecuteSafely(() => Clipboard.SetDataObject(dataObj), throwOnException: false)) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Control commonParent = null; + + if (host != null) + { + IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + DesignerTransaction trans = null; + + ArrayList designerList = new ArrayList(); + try + { + trans = host.CreateTransaction(string.Format(SR.CommandSetCutMultiple, cutCount)); + + // clear the selected components so we aren't browsing them + // + SelectionService.SetSelectedComponents(Array.Empty(), SelectionTypes.Replace); + + object[] selComps = new object[selectedComponents.Count]; + selectedComponents.CopyTo(selComps, 0); + + for (int i = 0; i < selComps.Length; i++) + { + object obj = selComps[i]; + IComponent component = obj as IComponent; + // We should never delete the base component. + // + if (obj == host.RootComponent || component == null) + { + continue; + } + + //Perf: We suspend Component Changing Events on parent for bulk changes to avoid unnecessary serialization\deserialization for undo + // see bug 488115 + Control c = obj as Control; + if (c != null) + { + Control parent = c.Parent; + if (parent != null) + { + ParentControlDesigner designer = host.GetDesigner(parent) as ParentControlDesigner; + if (designer != null && !designerList.Contains(designer)) + { + designer.SuspendChangingEvents(); + designerList.Add(designer); + designer.ForceComponentChanging(); + } + } + } + } + + // go backward so we destroy parents before children + + for (int i = 0; i < selComps.Length; i++) + { + object obj = selComps[i]; + IComponent component = obj as IComponent; + // We should never delete the base component. + // + if (obj == host.RootComponent || component == null) + { + continue; + } + + Control c = obj as Control; + //VSWhidbey # 370813. + //Cannot use idx = 1 to check (see diff) due to the call to PrependComponentNames, which + //adds non IComponent objects to the beginning of selectedComponents. Thus when we finally get + //here idx would be > 1. + if (commonParent == null && c != null) + { + commonParent = c.Parent; + } + else if (commonParent != null && c != null) + { + Control selectedControl = c; + + if (selectedControl.Parent != commonParent && !commonParent.Contains(selectedControl)) + { + // look for internal parenting + if (selectedControl == commonParent || selectedControl.Contains(commonParent)) + { + commonParent = selectedControl.Parent; + } + else + { + commonParent = null; + } + } + } + + if (component != null) + { + ArrayList al = new ArrayList(); + GetAssociatedComponents(component, host, al); + foreach (IComponent comp in al) + { + changeService.OnComponentChanging(comp, null); + } + + host.DestroyComponent(component); + } + } + } + finally + { + if (trans != null) + trans.Commit(); + foreach (ParentControlDesigner des in designerList) + { + if (des != null) + { + des.ResumeChangingEvents(); + } + } + } + + if (commonParent != null) + { + SelectionService.SetSelectedComponents(new object[] { commonParent }, SelectionTypes.Replace); + } + else if (SelectionService.PrimarySelection == null) + { + SelectionService.SetSelectedComponents(new object[] { host.RootComponent }, SelectionTypes.Replace); + } + } + } + else + { + uiService?.ShowError(SR.ClipboardError); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the delete menu item is selected. + /// + protected void OnMenuDelete(object sender, EventArgs e) + { + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + if (site != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (SelectionService == null) + { + return; + } + + if (host != null) + { + IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + + ICollection comps = SelectionService.GetSelectedComponents(); + string desc = string.Format(SR.CommandSetDelete, comps.Count); + + DesignerTransaction trans = null; + IComponent commonParent = null; + bool commonParentSet = false; + ArrayList designerList = new ArrayList(); + try + { + trans = host.CreateTransaction(desc); + SelectionService.SetSelectedComponents(Array.Empty(), SelectionTypes.Replace); + foreach (object obj in comps) + { + IComponent comp = obj as IComponent; + if (comp == null || comp.Site == null) + { + continue; + } + + //Perf: We suspend Component Changing Events on parent for bulk changes to avoid unnecessary serialization\deserialization for undo + // see bug 488115 + Control c = obj as Control; + if (c != null) + { + Control parent = c.Parent; + if (parent != null) + { + ParentControlDesigner designer = host.GetDesigner(parent) as ParentControlDesigner; + if (designer != null && !designerList.Contains(designer)) + { + designer.SuspendChangingEvents(); + designerList.Add(designer); + designer.ForceComponentChanging(); + } + } + } + } + + foreach (object obj in comps) + { + // If it's not a component, we can't delete it. It also may have already been deleted + // as part of a parent operation, so we skip it. + // + IComponent c = obj as IComponent; + if (c == null || c.Site == null) + { + continue; + } + + // We should never delete the base component. + // + if (obj == host.RootComponent) + { + continue; + } + + Control control = obj as Control; + if (!commonParentSet) + { + if (control != null) + { + commonParent = control.Parent; + } + else + { + // if this is not a Control, see if we can get an ITreeDesigner from it, + // and figure out the Component from that. + // + ITreeDesigner designer = host.GetDesigner((IComponent)obj) as ITreeDesigner; + if (designer != null) + { + IDesigner parentDesigner = designer.Parent; + if (parentDesigner != null) + { + commonParent = parentDesigner.Component; + } + } + } + + commonParentSet = (commonParent != null); + } + else if (commonParent != null) + { + if (control != null && commonParent is Control) + { + Control selectedControl = control; + Control controlCommonParent = (Control)commonParent; + + if (selectedControl.Parent != controlCommonParent && !controlCommonParent.Contains(selectedControl)) + { + // look for internal parenting + if (selectedControl == controlCommonParent || selectedControl.Contains(controlCommonParent)) + { + commonParent = selectedControl.Parent; + } + else + { + // start walking up until we find a common parent + while (controlCommonParent != null && !controlCommonParent.Contains(selectedControl)) + { + controlCommonParent = controlCommonParent.Parent; + } + + commonParent = controlCommonParent; + } + } + } + else + { + ITreeDesigner designer = host.GetDesigner((IComponent)obj) as ITreeDesigner; + ITreeDesigner commonParentDesigner = host.GetDesigner(commonParent) as ITreeDesigner; + + // for these we aren't as thorough as we are with the Control-based ones. + // we just walk up the chain until we find that parent or the root component. + // + if (designer != null && commonParentDesigner != null && designer.Parent != commonParentDesigner) + { + ArrayList designerChain = new ArrayList(); + ArrayList parentDesignerChain = new ArrayList(); + + // walk the chain of designers from the current parent designer + // up to the root component, and for the current component designer. + // + for (designer = designer.Parent as ITreeDesigner; + designer != null; + designer = designer.Parent as ITreeDesigner) + { + designerChain.Add(designer); + } + + for (commonParentDesigner = commonParentDesigner.Parent as ITreeDesigner; + commonParentDesigner != null; + commonParentDesigner = commonParentDesigner.Parent as ITreeDesigner) + { + parentDesignerChain.Add(commonParentDesigner); + } + + // now that we've got the trees built up, start comparing them from the ends to see where + // they diverge. + // + ArrayList shorterList = designerChain.Count < parentDesignerChain.Count ? designerChain : parentDesignerChain; + ArrayList longerList = (shorterList == designerChain ? parentDesignerChain : designerChain); + commonParentDesigner = null; + + if (shorterList.Count > 0 && longerList.Count > 0) + { + int shortIndex = Math.Max(0, shorterList.Count - 1); + int longIndex = Math.Max(0, longerList.Count - 1); + while (shortIndex >= 0 && longIndex >= 0) + { + if (shorterList[shortIndex] != longerList[longIndex]) + { + break; + } + + commonParentDesigner = (ITreeDesigner)shorterList[shortIndex]; + shortIndex--; + longIndex--; + } + } + + // alright, what have we got? + // + if (commonParentDesigner != null) + { + commonParent = commonParentDesigner.Component; + } + else + { + commonParent = null; + } + } + } + } + + ArrayList al = new ArrayList(); + GetAssociatedComponents((IComponent)obj, host, al); + foreach (IComponent comp in al) + { + changeService.OnComponentChanging(comp, null); + } + + host.DestroyComponent((IComponent)obj); + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + + foreach (ParentControlDesigner des in designerList) + { + if (des != null) + { + des.ResumeChangingEvents(); + } + } + } + + if (commonParent != null && SelectionService.PrimarySelection == null) + { + ITreeDesigner commonParentDesigner = host.GetDesigner(commonParent) as ITreeDesigner; + if (commonParentDesigner != null && commonParentDesigner.Children != null) + { + // choose the first child of the common parent if it has any. + // + foreach (IDesigner designer in commonParentDesigner.Children) + { + IComponent component = designer.Component; + if (component.Site != null) + { + commonParent = component; + break; + } + } + } + else if (commonParent is Control) + { + Control controlCommonParent = (Control)commonParent; + // if we have a common parent, select it's first child + // + if (controlCommonParent.Controls.Count > 0) + { + controlCommonParent = controlCommonParent.Controls[0]; + + // 126240 -- make sure we've got a sited thing. + // + while (controlCommonParent != null && controlCommonParent.Site == null) + { + controlCommonParent = controlCommonParent.Parent; + } + + commonParent = controlCommonParent; + } + } + + if (commonParent != null) + { + SelectionService.SetSelectedComponents(new object[] { commonParent }, SelectionTypes.Replace); + } + else + { + SelectionService.SetSelectedComponents(new object[] { host.RootComponent }, SelectionTypes.Replace); + } + } + else + { + if (SelectionService.PrimarySelection == null) + { + SelectionService.SetSelectedComponents(new object[] { host.RootComponent }, SelectionTypes.Replace); + } + } + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the paste menu item is selected. + /// + + [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2301:DoNotCallBinaryFormatterDeserializeWithoutFirstSettingBinaryFormatterBinder", Justification = "data is trusted")] + protected void OnMenuPaste(object sender, EventArgs e) + { + Cursor oldCursor = Cursor.Current; + ArrayList designerList = new ArrayList(); + try + { + Cursor.Current = Cursors.WaitCursor; + // If a control fails to get pasted; then we should remember its associatedComponents + // so that they are not pasted. + // Refer VsWhidbey : 477583 + ICollection associatedCompsOfFailedContol = null; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + if (host == null) + return; // nothing we can do here! + + IDataObject dataObj = null; + bool clipboardOperationSuccessful = ExecuteSafely(() => Clipboard.GetDataObject(), false, out dataObj); + + if (clipboardOperationSuccessful) + { + ICollection components = null; + bool createdItems = false; + + ComponentTray tray = null; + int numberOfOriginalTrayControls = 0; + // Get the current number of controls in the Component Tray in the target + tray = GetService(typeof(ComponentTray)) as ComponentTray; + numberOfOriginalTrayControls = tray != null ? tray.Controls.Count : 0; + + // We understand two things: CF_DESIGNER, and toolbox items. + // + object data = dataObj.GetData(CF_DESIGNER); + + using (DesignerTransaction trans = host.CreateTransaction(SR.CommandSetPaste)) + { + byte[] bytes = data as byte[]; + if (bytes != null) + { + MemoryStream s = new MemoryStream(bytes); + if (s != null) + { + // CF_DESIGNER was put on the clipboard by us using the designer + // serialization service. + // + IDesignerSerializationService ds = (IDesignerSerializationService)GetService(typeof(IDesignerSerializationService)); + if (ds != null) + { + BinaryFormatter formatter = new BinaryFormatter(); + s.Seek(0, SeekOrigin.Begin); +#pragma warning disable SYSLIB0011 // Type or member is obsolete + object serializationData = formatter.Deserialize(s); +#pragma warning restore SYSLIB0011 // Type or member is obsolete + using (DpiHelper.EnterDpiAwarenessScope(User32.DPI_AWARENESS_CONTEXT.SYSTEM_AWARE)) + { + components = ds.Deserialize(serializationData); + } + } + } + } + else + { + // Now check for a toolbox item. + // + IToolboxService ts = (IToolboxService)GetService(typeof(IToolboxService)); + + if (ts != null && ts.IsSupported(dataObj, host)) + { + ToolboxItem ti = ts.DeserializeToolboxItem(dataObj, host); + if (ti != null) + { + using (DpiHelper.EnterDpiAwarenessScope(User32.DPI_AWARENESS_CONTEXT.SYSTEM_AWARE)) + { + components = ti.CreateComponents(host); + } + + createdItems = true; + } + } + } + + // Now, if we got some components, hook 'em up! + // + if (components != null && components.Count > 0) + { + IComponent curComp; + string name; + + //Make copy of Items in Array.. + object[] allComponents = new object[components.Count]; + components.CopyTo(allComponents, 0); + + ArrayList selectComps = new ArrayList(); + ArrayList controls = new ArrayList(); + string[] componentNames = null; + int idx = 0; + + // if the selected item is a frame designer, add to that, otherwise + // add to the form + IComponent selectedComponent = null; + IDesigner designer = null; + bool dragClient = false; + + IComponent baseComponent = host.RootComponent; + selectedComponent = (IComponent)SelectionService.PrimarySelection; + + if (selectedComponent == null) + { + selectedComponent = baseComponent; + } + + dragClient = false; + ITreeDesigner tree = host.GetDesigner(selectedComponent) as ITreeDesigner; + + while (!dragClient && tree != null) + { + if (tree is IOleDragClient) + { + designer = tree; + dragClient = true; + } + else + { + if (tree == tree.Parent) + break; + tree = tree.Parent as ITreeDesigner; + } + } + + foreach (object obj in components) + { + name = null; + curComp = obj as IComponent; + + // see if we can fish out the original name. When we + // serialized, we serialized an array of names at the + // head of the list. This array matches the components + // that were created. + if (obj is IComponent) + { + if (componentNames != null && idx < componentNames.Length) + { + name = componentNames[idx++]; + } + } + else + { + string[] sa = obj as string[]; + if (componentNames == null && sa != null) + { + componentNames = sa; + idx = 0; + continue; + } + } + + IEventBindingService evs = GetService(typeof(IEventBindingService)) as IEventBindingService; + if (evs != null) + { + PropertyDescriptorCollection eventProps = evs.GetEventProperties(TypeDescriptor.GetEvents(curComp)); + foreach (PropertyDescriptor pd in eventProps) + { + // If we couldn't find a property for this event, or of the property is read only, then + // abort. + // + if (pd == null || pd.IsReadOnly) + { + continue; + } + + string handler = pd.GetValue(curComp) as string; + if (handler != null) + { + pd.SetValue(curComp, null); + } + } + } + + if (dragClient) + { + bool foundAssociatedControl = false; + // If we have failed to add a control in this Paste operation ... + if (associatedCompsOfFailedContol != null) + { + // then dont add its children controls. + foreach (Component comp in associatedCompsOfFailedContol) + { + if (comp == obj as Component) + { + foundAssociatedControl = true; + break; + } + } + } + + if (foundAssociatedControl) + { + continue; //continue from here so that we dont add the associted compoenet of a control that failed paste operation. + } + + ComponentDesigner cDesigner = host.GetDesigner(curComp) as ComponentDesigner; + ICollection designerComps = null; + // VSWhidbey 390442 - DGV has columns which are sited IComponents that don't + // have designers. in this case, ignore them. + + if (cDesigner == null) + { + continue; + } + + //store associatedComponents. + designerComps = cDesigner.AssociatedComponents; + + ComponentDesigner parentCompDesigner = ((ITreeDesigner)cDesigner).Parent as ComponentDesigner; + Component parentComp = null; + if (parentCompDesigner != null) + { + parentComp = parentCompDesigner.Component as Component; + } + + ArrayList associatedComps = new ArrayList(); + + if (parentComp != null) + { + if (parentCompDesigner != null) + { + foreach (IComponent childComp in parentCompDesigner.AssociatedComponents) + { + associatedComps.Add(childComp as Component); + } + } + } + + if (parentComp == null || !(associatedComps.Contains(curComp))) + { + if (parentComp != null) + { + ParentControlDesigner parentDesigner = host.GetDesigner(parentComp) as ParentControlDesigner; + if (parentDesigner != null && !designerList.Contains(parentDesigner)) + { + parentDesigner.SuspendChangingEvents(); + designerList.Add(parentDesigner); + parentDesigner.ForceComponentChanging(); + } + } + + if (!((IOleDragClient)designer).AddComponent(curComp, name, createdItems)) + { + //cache the associatedComponents only for FAILED control. + associatedCompsOfFailedContol = designerComps; + // now we will jump out of the using block and call trans.Dispose() + // which in turn calls trans.Cancel for an uncommited transaction, + // We want to cancel the transaction because otherwise we'll have + // un-parented controls + return; + } + + Control designerControl = ((IOleDragClient)designer).GetControlForComponent(curComp); + if (designerControl != null) + { + controls.Add(designerControl); + } + + // Select the newly Added top level component + if ((TypeDescriptor.GetAttributes(curComp).Contains(DesignTimeVisibleAttribute.Yes)) || curComp is ToolStripItem) + { + selectComps.Add(curComp); + } + } + + // if Parent is not selected... select the curcomp. + else if (associatedComps.Contains(curComp) && Array.IndexOf(allComponents, parentComp) == -1) + { + selectComps.Add(curComp); + } + + Control c = curComp as Control; + bool changeName = false; + + if (c != null) + { + // if the text is the same as the name, remember it. + // After we add the control, we'll update the text with + // the new name. + // + if (name != null && name.Equals(c.Text)) + { + changeName = true; + } + } + + if (changeName) + { + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(curComp); + PropertyDescriptor nameProp = props["Name"]; + if (nameProp != null && nameProp.PropertyType == typeof(string)) + { + string newName = (string)nameProp.GetValue(curComp); + if (!newName.Equals(name)) + { + PropertyDescriptor textProp = props["Text"]; + if (textProp != null && textProp.PropertyType == nameProp.PropertyType) + { + textProp.SetValue(curComp, nameProp.GetValue(curComp)); + } + } + } + } + } + } + + // Find those controls that have ControlDesigners and center them on the designer surface + ArrayList compsWithControlDesigners = new ArrayList(); + foreach (Control c in controls) + { + IDesigner des = host.GetDesigner(c); + if (des is ControlDesigner) + { + compsWithControlDesigners.Add(c); + } + } + + if (compsWithControlDesigners.Count > 0) + { + // Update the control positions. We want to keep the entire block + // of controls relative to each other, but relocate them within + // the container. + // + UpdatePastePositions(compsWithControlDesigners); + } + + // Figure out if we added components to the component tray, and have the + // tray adjust their position. + // MartinTh - removed the old check, since ToolStrips breaks the scenario. + // ToolStrips have a ControlDesigner, but also add a component to the tray. + // The old code wouldn't detect that, so the tray location wouldn't get adjusted. + // Rather than fixing this up in ToolStripKeyboardHandlingService.OnCommandPaste, + // we do it here, since doing it in the service, wouldn't handle cross-form paste. + + if (tray == null) + { + // the paste target did not have a tray already, so let's go get it - if there is one + tray = GetService(typeof(ComponentTray)) as ComponentTray; + } + + if (tray != null) + { + int numberOfTrayControlsAdded = tray.Controls.Count - numberOfOriginalTrayControls; + + if (numberOfTrayControlsAdded > 0) + { + ArrayList listOfTrayControls = new ArrayList(); + for (int i = 0; i < numberOfTrayControlsAdded; i++) + { + listOfTrayControls.Add(tray.Controls[numberOfOriginalTrayControls + i]); + } + + tray.UpdatePastePositions(listOfTrayControls); + } + } + + // Update the tab indices of all the components. We must first sort the + // components by their existing tab indices or else we will not preserve their + // original intent. + // + controls.Sort(new TabIndexCompare()); + foreach (Control c in controls) + { + UpdatePasteTabIndex(c, c.Parent); + } + + // finally select all the components we added + SelectionService.SetSelectedComponents(selectComps.ToArray(), SelectionTypes.Replace); + + // and bring them to the front - but only if we can mess with the Z-order. VSWhidbey 515990 + ParentControlDesigner parentControlDesigner = designer as ParentControlDesigner; + if (parentControlDesigner != null && parentControlDesigner.AllowSetChildIndexOnDrop) + { + MenuCommand btf = MenuService.FindCommand(StandardCommands.BringToFront); + if (btf != null) + { + btf.Invoke(); + } + } + + trans.Commit(); + } + } + } + else + { + uiService?.ShowError(SR.ClipboardError); + } + } + finally + { + Cursor.Current = oldCursor; + foreach (ParentControlDesigner des in designerList) + { + if (des != null) + { + des.ResumeChangingEvents(); + } + } + } + } + + /// + /// Called when the select all menu item is selected. + /// + protected void OnMenuSelectAll(object sender, EventArgs e) + { + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + if (site != null) + { + Debug.Assert(SelectionService != null, "We need the SelectionService, but we can't find it!"); + if (SelectionService == null) + { + return; + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (host != null) + { + ComponentCollection components = host.Container.Components; + object[] selComps; + if (components == null || components.Count == 0) + { + selComps = Array.Empty(); + } + else + { + selComps = new object[components.Count - 1]; + object baseComp = host.RootComponent; + + int j = 0; + foreach (IComponent comp in components) + { + if (baseComp == comp) + continue; + selComps[j++] = comp; + } + } + + SelectionService.SetSelectedComponents(selComps, SelectionTypes.Replace); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the show grid menu item is selected. + /// + protected void OnMenuShowGrid(object sender, EventArgs e) + { + if (site != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (host != null) + { + DesignerTransaction trans = null; + + try + { + trans = host.CreateTransaction(); + + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor prop = GetProperty(baseComponent, "DrawGrid"); + if (prop != null) + { + bool drawGrid = (bool)prop.GetValue(baseComponent); + prop.SetValue(baseComponent, !drawGrid); + ((MenuCommand)sender).Checked = !drawGrid; + } + } + } + finally + { + if (trans != null) + trans.Commit(); + } + } + } + } + + /// + /// Handles the various size to commands. + /// + protected void OnMenuSizingCommand(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + CommandID cmdID = cmd.CommandID; + + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + ICollection sel = SelectionService.GetSelectedComponents(); + object[] selectedObjects = new object[sel.Count]; + sel.CopyTo(selectedObjects, 0); + + selectedObjects = FilterSelection(selectedObjects, SelectionRules.Visible); + + object selPrimary = SelectionService.PrimarySelection; + + Size primarySize = Size.Empty; + Size itemSize = Size.Empty; + PropertyDescriptor sizeProp; + IComponent component = selPrimary as IComponent; + if (component != null) + { + sizeProp = GetProperty(component, "Size"); + if (sizeProp == null) + { + //if we couldn't get a valid size for our primary selection, we'll fail silently + return; + } + + primarySize = (Size)sizeProp.GetValue(component); + } + + if (selPrimary == null) + { + return; + } + + Debug.Assert(null != selectedObjects, "queryStatus should have disabled this"); + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + DesignerTransaction trans = null; + + try + { + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.CommandSetSize, selectedObjects.Length)); + } + + foreach (object obj in selectedObjects) + { + if (obj.Equals(selPrimary)) + continue; + + IComponent comp = obj as IComponent; + + if (comp == null) + { + continue; + } + + //if the component is locked, no sizing is allowed... + PropertyDescriptor lockedDesc = GetProperty(obj, "Locked"); + if (lockedDesc != null && (bool)lockedDesc.GetValue(obj)) + { + continue; + } + + sizeProp = GetProperty(comp, "Size"); + + // Skip all components that don't have a size property + // + if (sizeProp == null || sizeProp.IsReadOnly) + { + continue; + } + + itemSize = (Size)sizeProp.GetValue(comp); + + if (cmdID == StandardCommands.SizeToControlHeight || + cmdID == StandardCommands.SizeToControl) + { + itemSize.Height = primarySize.Height; + } + + if (cmdID == StandardCommands.SizeToControlWidth || + cmdID == StandardCommands.SizeToControl) + { + itemSize.Width = primarySize.Width; + } + + sizeProp.SetValue(comp, itemSize); + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the size->to grid menu item is selected. + /// + protected void OnMenuSizeToGrid(object sender, EventArgs e) + { + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + DesignerTransaction trans = null; + + try + { + Cursor.Current = Cursors.WaitCursor; + + ICollection sel = SelectionService.GetSelectedComponents(); + object[] selectedObjects = new object[sel.Count]; + sel.CopyTo(selectedObjects, 0); + selectedObjects = FilterSelection(selectedObjects, SelectionRules.Visible); + + Size size = Size.Empty; + Point loc = Point.Empty; + + Debug.Assert(null != selectedObjects, "queryStatus should have disabled this"); + Size grid = Size.Empty; + PropertyDescriptor sizeProp = null; + PropertyDescriptor locProp = null; + + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.CommandSetSizeToGrid, selectedObjects.Length)); + + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor prop = GetProperty(baseComponent, "CurrentGridSize"); + if (prop != null) + { + grid = (Size)prop.GetValue(baseComponent); + } + } + } + + if (!grid.IsEmpty) + { + foreach (object obj in selectedObjects) + { + IComponent comp = obj as IComponent; + + if (obj == null) + { + continue; + } + + sizeProp = GetProperty(comp, "Size"); + locProp = GetProperty(comp, "Location"); + + Debug.Assert(sizeProp != null, "No size property on component"); + Debug.Assert(locProp != null, "No location property on component"); + + if (sizeProp == null || locProp == null || sizeProp.IsReadOnly || locProp.IsReadOnly) + { + continue; + } + + size = (Size)sizeProp.GetValue(comp); + loc = (Point)locProp.GetValue(comp); + + size.Width = ((size.Width + (grid.Width / 2)) / grid.Width) * grid.Width; + size.Height = ((size.Height + (grid.Height / 2)) / grid.Height) * grid.Height; + loc.X = (loc.X / grid.Width) * grid.Width; + loc.Y = (loc.Y / grid.Height) * grid.Height; + + sizeProp.SetValue(comp, size); + locProp.SetValue(comp, loc); + } + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the properties menu item is selected on the Context menu + /// + protected void OnMenuDesignerProperties(object sender, EventArgs e) + { + // first, look if the currently selected object has a component editor... + object obj = SelectionService.PrimarySelection; + + if (CheckComponentEditor(obj, true)) + { + return; + } + + IMenuCommandService menuSvc = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (menuSvc != null) + { + if (menuSvc.GlobalInvoke(StandardCommands.PropertiesWindow)) + { + return; + } + } + + Debug.Assert(false, "Invoking pbrs command failed"); + } + + /// + /// Called when the snap to grid menu item is selected. + /// + protected void OnMenuSnapToGrid(object sender, EventArgs e) + { + if (site != null) + { + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + + if (host != null) + { + DesignerTransaction trans = null; + + try + { + trans = host.CreateTransaction(string.Format(SR.CommandSetPaste, 0)); + + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor prop = GetProperty(baseComponent, "SnapToGrid"); + if (prop != null) + { + bool snapToGrid = (bool)prop.GetValue(baseComponent); + prop.SetValue(baseComponent, !snapToGrid); + ((MenuCommand)sender).Checked = !snapToGrid; + } + } + } + finally + { + if (trans != null) + trans.Commit(); + } + } + } + } + + /// + /// Called when a spacing command is selected + /// + /// + protected void OnMenuSpacingCommand(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + CommandID cmdID = cmd.CommandID; + DesignerTransaction trans = null; + + if (SelectionService == null) + { + return; + } + + Cursor oldCursor = Cursor.Current; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + try + { + Cursor.Current = Cursors.WaitCursor; + + // Inform the designer that we are about to monkey with a ton + // of properties. + // + Size grid = Size.Empty; + ICollection sel = SelectionService.GetSelectedComponents(); + object[] selectedObjects = new object[sel.Count]; + sel.CopyTo(selectedObjects, 0); + + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.CommandSetFormatSpacing, selectedObjects.Length)); + + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor prop = GetProperty(baseComponent, "CurrentGridSize"); + if (prop != null) + { + grid = (Size)prop.GetValue(baseComponent); + } + } + } + + selectedObjects = FilterSelection(selectedObjects, SelectionRules.Visible); + + int nEqualDelta = 0; + + Debug.Assert(null != selectedObjects, "queryStatus should have disabled this"); + + PropertyDescriptor curSizeDesc = null, lastSizeDesc = null; + PropertyDescriptor curLocDesc = null, lastLocDesc = null; + Size curSize = Size.Empty, lastSize = Size.Empty; + Point curLoc = Point.Empty, lastLoc = Point.Empty; + Point primaryLoc = Point.Empty; + IComponent curComp = null, lastComp = null; + int sort = -1; + + // Must sort differently if we're horizontal or vertical... + // + if (cmdID == StandardCommands.HorizSpaceConcatenate || + cmdID == StandardCommands.HorizSpaceDecrease || + cmdID == StandardCommands.HorizSpaceIncrease || + cmdID == StandardCommands.HorizSpaceMakeEqual) + { + sort = SORT_HORIZONTAL; + } + else if (cmdID == StandardCommands.VertSpaceConcatenate || + cmdID == StandardCommands.VertSpaceDecrease || + cmdID == StandardCommands.VertSpaceIncrease || + cmdID == StandardCommands.VertSpaceMakeEqual) + { + sort = SORT_VERTICAL; + } + else + { + throw new ArgumentException(SR.CommandSetUnknownSpacingCommand); + } + + SortSelection(selectedObjects, sort); + + //now that we're sorted, lets get our primary selection and it's index + // + object primary = SelectionService.PrimarySelection; + int primaryIndex = 0; + if (primary != null) + primaryIndex = Array.IndexOf(selectedObjects, primary); + + // And compute delta values for Make Equal + if (cmdID == StandardCommands.HorizSpaceMakeEqual || + cmdID == StandardCommands.VertSpaceMakeEqual) + { + int total, n; + + total = 0; + for (n = 0; n < selectedObjects.Length; n++) + { + curSize = Size.Empty; + + IComponent component = selectedObjects[n] as IComponent; + + if (component != null) + { + curComp = component; + + curSizeDesc = GetProperty(curComp, "Size"); + if (curSizeDesc != null) + { + curSize = (Size)curSizeDesc.GetValue(curComp); + } + } + + if (sort == SORT_HORIZONTAL) + { + total += curSize.Width; + } + else + { + total += curSize.Height; + } + } + + lastComp = curComp = null; + curSize = Size.Empty; + curLoc = Point.Empty; + + for (n = 0; n < selectedObjects.Length; n++) + { + curComp = selectedObjects[n] as IComponent; + if (curComp != null) + { + // only get the descriptors if we've changed component types + if (lastComp == null || curComp.GetType() != lastComp.GetType()) + { + curSizeDesc = GetProperty(curComp, "Size"); + curLocDesc = GetProperty(curComp, "Location"); + } + + lastComp = curComp; + + if (curLocDesc != null) + { + curLoc = (Point)curLocDesc.GetValue(curComp); + } + else + { + continue; + } + + if (curSizeDesc != null) + { + curSize = (Size)curSizeDesc.GetValue(curComp); + } + else + { + continue; + } + + if (!curSize.IsEmpty && !curLoc.IsEmpty) + { + break; + } + } + } + + for (n = selectedObjects.Length - 1; n >= 0; n--) + { + curComp = selectedObjects[n] as IComponent; + if (curComp != null) + { + // only get the descriptors if we've changed component types + if (lastComp == null || curComp.GetType() != lastComp.GetType()) + { + curSizeDesc = GetProperty(curComp, "Size"); + curLocDesc = GetProperty(curComp, "Location"); + } + + lastComp = curComp; + + if (curLocDesc != null) + { + lastLoc = (Point)curLocDesc.GetValue(curComp); + } + else + { + continue; + } + + if (curSizeDesc != null) + { + lastSize = (Size)curSizeDesc.GetValue(curComp); + } + else + { + continue; + } + + if (curSizeDesc != null && curLocDesc != null) + { + break; + } + } + } + + if (curSizeDesc != null && curLocDesc != null) + { + if (sort == SORT_HORIZONTAL) + { + nEqualDelta = (lastSize.Width + lastLoc.X - curLoc.X - total) / (selectedObjects.Length - 1); + } + else + { + nEqualDelta = (lastSize.Height + lastLoc.Y - curLoc.Y - total) / (selectedObjects.Length - 1); + } + + if (nEqualDelta < 0) + nEqualDelta = 0; + } + } + + curComp = lastComp = null; + + if (primary != null) + { + PropertyDescriptor primaryLocDesc = GetProperty(primary, "Location"); + if (primaryLocDesc != null) + { + primaryLoc = (Point)primaryLocDesc.GetValue(primary); + } + } + + // Finally move the components + // + for (int n = 0; n < selectedObjects.Length; n++) + { + curComp = (IComponent)selectedObjects[n]; + + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(curComp); + + //Check to see if the component we are about to move is locked... + // + PropertyDescriptor lockedDesc = props["Locked"]; + if (lockedDesc != null && (bool)lockedDesc.GetValue(curComp)) + { + continue; // locked property of our component is true, so don't move it + } + + if (lastComp == null || lastComp.GetType() != curComp.GetType()) + { + curSizeDesc = props["Size"]; + curLocDesc = props["Location"]; + } + else + { + curSizeDesc = lastSizeDesc; + curLocDesc = lastLocDesc; + } + + if (curLocDesc != null) + { + curLoc = (Point)curLocDesc.GetValue(curComp); + } + else + { + continue; + } + + if (curSizeDesc != null) + { + curSize = (Size)curSizeDesc.GetValue(curComp); + } + else + { + continue; + } + + int lastIndex = Math.Max(0, n - 1); + lastComp = (IComponent)selectedObjects[lastIndex]; + if (lastComp.GetType() != curComp.GetType()) + { + lastSizeDesc = GetProperty(lastComp, "Size"); + lastLocDesc = GetProperty(lastComp, "Location"); + } + else + { + lastSizeDesc = curSizeDesc; + lastLocDesc = curLocDesc; + } + + if (lastLocDesc != null) + { + lastLoc = (Point)lastLocDesc.GetValue(lastComp); + } + else + { + continue; + } + + if (lastSizeDesc != null) + { + lastSize = (Size)lastSizeDesc.GetValue(lastComp); + } + else + { + continue; + } + + if (cmdID == StandardCommands.HorizSpaceConcatenate && n > 0) + { + curLoc.X = lastLoc.X + lastSize.Width; + } + else if (cmdID == StandardCommands.HorizSpaceDecrease) + { + if (primaryIndex < n) + { + curLoc.X -= grid.Width * (n - primaryIndex); + if (curLoc.X < primaryLoc.X) + curLoc.X = primaryLoc.X; + } + else if (primaryIndex > n) + { + curLoc.X += grid.Width * (primaryIndex - n); + if (curLoc.X > primaryLoc.X) + curLoc.X = primaryLoc.X; + } + } + else if (cmdID == StandardCommands.HorizSpaceIncrease) + { + if (primaryIndex < n) + { + curLoc.X += grid.Width * (n - primaryIndex); + } + else if (primaryIndex > n) + { + curLoc.X -= grid.Width * (primaryIndex - n); + } + } + else if (cmdID == StandardCommands.HorizSpaceMakeEqual && n > 0) + { + curLoc.X = lastLoc.X + lastSize.Width + nEqualDelta; + } + else if (cmdID == StandardCommands.VertSpaceConcatenate && n > 0) + { + curLoc.Y = lastLoc.Y + lastSize.Height; + } + else if (cmdID == StandardCommands.VertSpaceDecrease) + { + if (primaryIndex < n) + { + curLoc.Y -= grid.Height * (n - primaryIndex); + if (curLoc.Y < primaryLoc.Y) + curLoc.Y = primaryLoc.Y; + } + else if (primaryIndex > n) + { + curLoc.Y += grid.Height * (primaryIndex - n); + if (curLoc.Y > primaryLoc.Y) + curLoc.Y = primaryLoc.Y; + } + } + else if (cmdID == StandardCommands.VertSpaceIncrease) + { + if (primaryIndex < n) + { + curLoc.Y += grid.Height * (n - primaryIndex); + } + else if (primaryIndex > n) + { + curLoc.Y -= grid.Height * (primaryIndex - n); + } + } + else if (cmdID == StandardCommands.VertSpaceMakeEqual && n > 0) + { + curLoc.Y = lastLoc.Y + lastSize.Height + nEqualDelta; + } + + if (!curLocDesc.IsReadOnly) + { + curLocDesc.SetValue(curComp, curLoc); + } + + lastComp = curComp; + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + + Cursor.Current = oldCursor; + } + } + + /// + /// Called when the current selection changes. Here we determine what + /// commands can and can't be enabled. + /// + protected void OnSelectionChanged(object sender, EventArgs e) + { + if (SelectionService == null/*: UNDONE: BehaviorWork || SelectionUIService == null*/) + { + return; + } + + selectionVersion++; + + // Update our cached selection counts. + // + selCount = SelectionService.SelectionCount; + + IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(designerHost != null, "Failed to get designer host"); + + // if the base component is selected, we'll say that nothing's selected + // so we don't get wierd behavior + if (selCount > 0 && designerHost != null) + { + object baseComponent = designerHost.RootComponent; + if (baseComponent != null && SelectionService.GetComponentSelected(baseComponent)) + { + selCount = 0; + } + } + + primarySelection = SelectionService.PrimarySelection as IComponent; + selectionInherited = false; + controlsOnlySelection = true; + + if (selCount > 0) + { + ICollection selection = SelectionService.GetSelectedComponents(); + foreach (object obj in selection) + { + if (!(obj is Control)) + { + controlsOnlySelection = false; + } + + if (!TypeDescriptor.GetAttributes(obj)[typeof(InheritanceAttribute)].Equals(InheritanceAttribute.NotInherited)) + { + selectionInherited = true; + break; + } + } + } + + OnUpdateCommandStatus(); + } + + /// + /// When this timer expires, this tells us that we need to + /// erase any snaplines we have drawn. First, we need + /// to marshal this back to the correct thread. + /// + private void OnSnapLineTimerExpire(object sender, EventArgs e) + { + Control marshalControl = BehaviorService.AdornerWindowControl; + + if (marshalControl != null && marshalControl.IsHandleCreated) + { + marshalControl.BeginInvoke(new EventHandler(OnSnapLineTimerExpireMarshalled), new object[] { sender, e }); + } + } + + /// + /// Called when our snapline timer expires - this method has been call + /// has been properly marshalled back to the correct thread. + /// + private void OnSnapLineTimerExpireMarshalled(object sender, EventArgs e) + { + snapLineTimer.Stop(); + EndDragManager(); + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are always enabled. + /// + protected void OnStatusAlways(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = true; + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled when one or more objects are selected. + /// + protected void OnStatusAnySelection(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = selCount > 0; + } + + /// + /// Status for the copy command. This is enabled when + /// there is something juicy selected. + /// + protected void OnStatusCopy(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + bool enable = false; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (!selectionInherited && host != null && !host.Loading) + { + ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || selSvc != null, "ISelectionService not found"); + + if (selSvc != null) + { + // There must also be a component in the mix, and not the base component + // + ICollection selectedComponents = selSvc.GetSelectedComponents(); + + object baseComp = host.RootComponent; + if (!selSvc.GetComponentSelected(baseComp)) + { + foreach (object obj in selectedComponents) + { + // if the object is not sited to the same thing as the host container + // then don't allow copy. VSWhidbey# 275790 + IComponent comp = obj as IComponent; + if (comp != null && comp.Site != null && comp.Site.Container == host.Container) + { + enable = true; + break; + } + } + } + } + } + + cmd.Enabled = enable; + } + + /// + /// Status for the cut command. This is enabled when + /// there is something juicy selected and that something + /// does not contain any inherited components. + /// + protected void OnStatusCut(object sender, EventArgs e) + { + OnStatusDelete(sender, e); + if (((MenuCommand)sender).Enabled) + { + OnStatusCopy(sender, e); + } + } + + /// + /// Status for the delete command. This is enabled when there + /// is something selected and that something does not contain + /// inherited components. + /// + protected void OnStatusDelete(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + if (selectionInherited) + { + cmd.Enabled = false; + } + else + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService)); + if (selSvc != null) + { + ICollection selectedComponents = selSvc.GetSelectedComponents(); + foreach (object obj in selectedComponents) + { + // if the object is not sited to the same thing as the host container + // then don't allow delete. VSWhidbey# 275790 + IComponent comp = obj as IComponent; + if (comp != null && (comp.Site == null || (comp.Site != null && comp.Site.Container != host.Container))) + { + cmd.Enabled = false; + return; + } + } + } + } + + OnStatusAnySelection(sender, e); + } + } + +#if UNUSED + + // Let's keep this in case we need it in the future + + /// + /// Determines the status of a menu command. Commands with this event are + /// considered to be not yet implemented and are disabled. + /// + protected void OnStatusNYI(object sender, EventArgs e) { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = false; + } +#endif + + /// + /// Determines the status of a menu command. Commands with this event are + /// enabled when there is something yummy on the clipboard. + /// + protected void OnStatusPaste(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + // Before we even look at the data format, check to see if the thing we're going to paste + // into is privately inherited. If it is, then we definitely cannot paste. + // + if (primarySelection != null) + { + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (host != null && host.GetDesigner(primarySelection) is ParentControlDesigner) + { + // This component is a target for our paste operation. We must ensure + // that it is not privately inherited. + // + InheritanceAttribute attr = (InheritanceAttribute)TypeDescriptor.GetAttributes(primarySelection)[typeof(InheritanceAttribute)]; + Debug.Assert(attr != null, "Type descriptor gave us a null attribute -- problem in type descriptor"); + if (attr.InheritanceLevel == InheritanceLevel.InheritedReadOnly) + { + cmd.Enabled = false; + return; + } + } + } + + // Not being inherited. Now look at the contents of the data + // + IDataObject dataObj = null; + bool clipboardOperationSuccessful = ExecuteSafely(() => Clipboard.GetDataObject(), false, out dataObj); + + bool enable = false; + + if (clipboardOperationSuccessful && dataObj != null) + { + if (dataObj.GetDataPresent(CF_DESIGNER)) + { + enable = true; + } + else + { + // Not ours, check to see if the toolbox service understands this + // + IToolboxService ts = (IToolboxService)GetService(typeof(IToolboxService)); + if (ts != null) + { + enable = (host != null ? ts.IsSupported(dataObj, host) : ts.IsToolboxItem(dataObj)); + } + } + } + + cmd.Enabled = enable; + } + + private void OnStatusPrimarySelection(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = primarySelection != null; + } + + protected virtual void OnStatusSelectAll(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + cmd.Enabled = host.Container.Components.Count > 1; + } + + /// + /// This is called when the selection has changed. Anyone using CommandSetItems + /// that need to update their status based on selection changes should override + /// this and update their own commands at this time. The base implementaion + /// runs through all base commands and calls UpdateStatus on them. + /// + protected virtual void OnUpdateCommandStatus() + { + // Now whip through all of the commands and ask them to update. + // + for (int i = 0; i < commandSet.Length; i++) + { + commandSet[i].UpdateStatus(); + } + } + + /// + /// This method grows the objects collection by one. It prepends the + /// collection with a string[] which contains the component names in order + /// for each component in the list. + /// + private ICollection PrependComponentNames(ICollection objects) + { + object[] newObjects = new object[objects.Count + 1]; + int idx = 1; + ArrayList names = new ArrayList(objects.Count); + + foreach (object o in objects) + { + IComponent comp = o as IComponent; + if (comp != null) + { + string name = null; + if (comp.Site != null) + { + name = comp.Site.Name; + } + + names.Add(name); + } + + newObjects[idx++] = o; + } + + string[] nameArray = new string[names.Count]; + names.CopyTo(nameArray, 0); + newObjects[0] = nameArray; + return newObjects; + } + + /// + /// called by the formatting commands when we need a given selection array sorted. + /// Sorting the array sorts by x from left to right, and by Y from top to bottom. + /// + private void SortSelection(object[] selectedObjects, int nSortBy) + { + IComparer comp; + switch (nSortBy) + { + case SORT_HORIZONTAL: + comp = new ComponentLeftCompare(); + break; + case SORT_VERTICAL: + comp = new ComponentTopCompare(); + break; + case SORT_ZORDER: + comp = new ControlZOrderCompare(); + break; + default: + return; + } + + Array.Sort(selectedObjects, comp); + } + +#if UNUSED + private void TestCommandCut(string[] args) { + this.OnMenuCut(null, EventArgs.Empty); + } + + private void TestCommandCopy(string[] args) { + this.OnMenuCopy(null, EventArgs.Empty); + } + + private void TestCommandPaste(string[] args) { + this.OnMenuPaste(null, EventArgs.Empty); + } +#endif + + /// + /// Common function that updates the status of clipboard menu items only + /// + private void UpdateClipboardItems(object s, EventArgs e) + { + int itemCount = 0; + CommandSetItem curItem; + for (int i = 0; itemCount < 3 && i < commandSet.Length; i++) + { + curItem = commandSet[i]; + if (curItem.CommandID == StandardCommands.Paste || + curItem.CommandID == StandardCommands.Copy || + curItem.CommandID == StandardCommands.Cut) + { + itemCount++; + curItem.UpdateStatus(); + } + } + } + + private void UpdatePastePositions(ArrayList controls) + { + if (controls.Count == 0) + { + return; + } + + // Find the offset to apply to these controls. The offset + // is the location needed to center the controls in the parent. + // If there is no parent, we relocate to 0, 0. + // + Control parentControl = ((Control)controls[0]).Parent; + Point min = ((Control)controls[0]).Location; + Point max = min; + foreach (Control c in controls) + { + Point loc = c.Location; + Size size = c.Size; + if (min.X > loc.X) + { + min.X = loc.X; + } + + if (min.Y > loc.Y) + { + min.Y = loc.Y; + } + + if (max.X < loc.X + size.Width) + { + max.X = loc.X + size.Width; + } + + if (max.Y < loc.Y + size.Height) + { + max.Y = loc.Y + size.Height; + } + } + + // We have the bounding rect for the controls. Next, + // offset this rect so that we center it in the parent. + // If we have no parent, the offset will position the + // control at 0, 0, to whatever parent we eventually + // get. + // + Point offset = new Point(-min.X, -min.Y); + + // Look to ensure that we're not going to paste this control over + // the top of another control. We only do this for the first + // control because preserving the relationship between controls + // is more important than obscuring a control. + // + if (parentControl != null) + { + bool bumpIt; + bool wrapped = false; + Size parentSize = parentControl.ClientSize; + Size gridSize = Size.Empty; + Point parentOffset = new Point(parentSize.Width / 2, parentSize.Height / 2); + parentOffset.X -= (max.X - min.X) / 2; + parentOffset.Y -= (max.Y - min.Y) / 2; + + do + { + bumpIt = false; + + // Cycle through the controls on the parent. We're + // interested in controls that (a) are not in our + // set of controls and (b) have a location == + // to our current bumpOffset OR (c) are the same + // size as our parent. If we find such a + // control, we increment the bump offset by one + // grid size. + // + foreach (Control child in parentControl.Controls) + { + Rectangle childBounds = child.Bounds; + + if (controls.Contains(child)) + { + // We still want to bump if the child is the same size as the parent. + // Otherwise the child would overlay exactly on top of the parent. + // + if (!child.Size.Equals(parentSize)) + { + continue; + } + + // We're dealing with our own pasted control, so + // offset its bounds. We don't use parent offset here + // because, well, we're comparing against the parent! + // + childBounds.Offset(offset); + } + + // We need only compare against one of our pasted controls, so + // pick the first one. + // + Control pasteControl = (Control)controls[0]; + Rectangle pasteControlBounds = pasteControl.Bounds; + pasteControlBounds.Offset(offset); + pasteControlBounds.Offset(parentOffset); + + if (pasteControlBounds.Equals(childBounds)) + { + bumpIt = true; + + if (gridSize.IsEmpty) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor gs = GetProperty(baseComponent, "GridSize"); + if (gs != null) + { + gridSize = (Size)gs.GetValue(baseComponent); + } + } + + if (gridSize.IsEmpty) + { + gridSize.Width = 8; + gridSize.Height = 8; + } + } + + parentOffset += gridSize; + + // Extra check: If the end of our control group is > the + // parent size, bump back to zero. We still allow further + // bumps after this so we can continue to offset, but if + // we cycle again then we quit so we won't loop indefinitely. + // We only do this if we're a group. If we're a single control + // we use the beginning of the control + a grid size. + // + int groupEndX; + int groupEndY; + + if (controls.Count > 1) + { + groupEndX = parentOffset.X + max.X - min.X; + groupEndY = parentOffset.Y + max.Y - min.Y; + } + else + { + groupEndX = parentOffset.X + gridSize.Width; + groupEndY = parentOffset.Y + gridSize.Height; + } + + if (groupEndX > parentSize.Width || groupEndY > parentSize.Height) + { + parentOffset.X = 0; + parentOffset.Y = 0; + + if (wrapped) + { + bumpIt = false; + } + else + { + wrapped = true; + } + } + + break; + } + } + } + while (bumpIt); + + offset.Offset(parentOffset.X, parentOffset.Y); + } + + // Now, for each control, update the offset. + // + + if (parentControl != null) + { + parentControl.SuspendLayout(); + } + + try + { + foreach (Control c in controls) + { + Point newLoc = c.Location; + newLoc.Offset(offset.X, offset.Y); + c.Location = newLoc; + } + } + finally + { + if (parentControl != null) + { + parentControl.ResumeLayout(); + } + } + } + + private void UpdatePasteTabIndex(Control componentControl, object parentComponent) + { + Control parentControl = parentComponent as Control; + + if (parentControl == null || componentControl == null) + { + return; + } + + bool tabIndexCollision = false; + int tabIndexOriginal = componentControl.TabIndex; + + // Find the next highest tab index + // + int nextTabIndex = 0; + foreach (Control c in parentControl.Controls) + { + int t = c.TabIndex; + if (nextTabIndex <= t) + { + nextTabIndex = t + 1; + } + + if (t == tabIndexOriginal) + { + tabIndexCollision = true; + } + } + + if (tabIndexCollision) + { + componentControl.TabIndex = nextTabIndex; + } + } + + /// + /// + /// We extend MenuCommand for our command set items. A command set item + /// is a menu command with an added delegate that is used to determine the + /// flags for the menu item. We have different classes of delegates here. + /// For example, many menu items may be enabled when there is at least + /// one object selected, while others are only enabled if there is more than + /// one object or if there is a primary selection. + /// + protected class CommandSetItem : MenuCommand + { + private readonly EventHandler statusHandler; + private readonly IEventHandlerService eventService; + private readonly IUIService uiService; + + private readonly CommandSet commandSet; + private static Hashtable commandStatusHash; // list of the command statuses we are tracking. + private bool updatingCommand; // flag we set when we're updating the command so we don't call back on the status handler. + + public CommandSetItem(CommandSet commandSet, EventHandler statusHandler, EventHandler invokeHandler, CommandID id, IUIService uiService) : this(commandSet, statusHandler, invokeHandler, id, false, uiService) + { + } + + public CommandSetItem(CommandSet commandSet, EventHandler statusHandler, EventHandler invokeHandler, CommandID id) : this(commandSet, statusHandler, invokeHandler, id, false, null) + { + } + + public CommandSetItem(CommandSet commandSet, EventHandler statusHandler, EventHandler invokeHandler, CommandID id, bool optimizeStatus) : this(commandSet, statusHandler, invokeHandler, id, optimizeStatus, null) + { + } + + /// + /// Creates a new CommandSetItem. + /// + + // Per SBurke... + public CommandSetItem(CommandSet commandSet, EventHandler statusHandler, EventHandler invokeHandler, CommandID id, bool optimizeStatus, IUIService uiService) + : base(invokeHandler, id) + { + this.uiService = uiService; + eventService = commandSet.eventService; + this.statusHandler = statusHandler; + + // when we optimize, it's because status is fully based on selection. + // so what we do is only call the status handler once per selection change to prevent + // doing the same work over and over again. we do this by hashing up the command statuses + // and then filling in the results we get, so we can easily retrieve them when + // the selection hasn't changed. + // + if (optimizeStatus && statusHandler != null) + { + // we use this as our sentinel of when we're doing this. + // + this.commandSet = commandSet; + + // create the hash if needed. + // + lock (typeof(CommandSetItem)) + { + if (commandStatusHash == null) + { + commandStatusHash = new Hashtable(); + } + } + + // + // UNDONE:CommandSetItem is put in a static hashtable, and CommandSetItem + // references CommandSet, CommandSet reference FormDesigner. If we don't + // remove the CommandSetItem from the static hashtable, FormDesigner is + // leaked. This demonstrates a bad design. We should not keep a static + // hashtable for all the items, instead, we should keep a hashtable per + // Designer. When designer is disposed, all command items got disposed + // automatically. However, at this time, we would pick a simple way with + // low risks to fix this. + // + // if this handler isn't already in there, add it. + // + StatusState state = commandStatusHash[statusHandler] as StatusState; + if (state == null) + { + state = new StatusState(); + commandStatusHash.Add(statusHandler, state); + } + + state.refCount++; + } + } + + /// + /// Checks if the status for this command is valid, meaning we don't need to call the status handler. + /// + private bool CommandStatusValid + { + get + { + // check to see if this is a command we have hashed up and if it's version stamp + // is the same as our current selection version. + // + if (commandSet != null && commandStatusHash.Contains(statusHandler)) + { + StatusState state = commandStatusHash[statusHandler] as StatusState; + if (state != null && state.SelectionVersion == commandSet.SelectionVersion) + { + return true; + } + } + + return false; + } + } + + /// + /// Applys the cached status to this item. + /// + private void ApplyCachedStatus() + { + if (commandSet != null && commandStatusHash.Contains(statusHandler)) + { + try + { + // set our our updating flag so it doesn't call the status handler again. + // + updatingCommand = true; + + // and push the state into this command. + // + StatusState state = commandStatusHash[statusHandler] as StatusState; + state.ApplyState(this); + } + finally + { + updatingCommand = false; + } + } + } + + /// + /// This may be called to invoke the menu item. + /// + public override void Invoke() + { + // We allow outside parties to override the availability of particular menu commands. + // + try + { + if (eventService != null) + { + IMenuStatusHandler msh = (IMenuStatusHandler)eventService.GetHandler(typeof(IMenuStatusHandler)); + if (msh != null && msh.OverrideInvoke(this)) + { + return; + } + } + + base.Invoke(); + } + catch (Exception e) + { + if (uiService != null) + { + uiService.ShowError(e, string.Format(SR.CommandSetError, e.Message)); + } + + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + } + } + + /// + /// Only pass this down to the base when we're not doing the cached update. + /// + protected override void OnCommandChanged(EventArgs e) + { + if (!updatingCommand) + { + base.OnCommandChanged(e); + } + } + + /// + /// Saves the status for this command to the statusstate that's stored in the hashtable + /// based on our status handler delegate. + /// + private void SaveCommandStatus() + { + if (commandSet != null) + { + StatusState state; + + // see if we need to create one of these StatusState dudes. + // + if (commandStatusHash.Contains(statusHandler)) + { + state = commandStatusHash[statusHandler] as StatusState; + } + else + { + state = new StatusState(); + } + + // and save the enabled, visible, checked, and supported state. + // + state.SaveState(this, commandSet.SelectionVersion); + } + } + + /// + /// Called when the status of this command should be re-queried. + /// + public void UpdateStatus() + { + // We allow outside parties to override the availability of particular menu commands. + // + if (eventService != null) + { + IMenuStatusHandler msh = (IMenuStatusHandler)eventService.GetHandler(typeof(IMenuStatusHandler)); + if (msh != null && msh.OverrideStatus(this)) + { + return; + } + } + + if (statusHandler != null) + { + // if we need to update our status, + // call the status handler. otherwise, + // get the cached status and push it into this + // command. + // + if (!CommandStatusValid) + { + try + { + statusHandler(this, EventArgs.Empty); + SaveCommandStatus(); + } + catch + { + } + } + else + { + ApplyCachedStatus(); + } + } + } + + /// + /// Remove this command item from the static hashtable to avoid leaking this object. + /// + public virtual void Dispose() + { + StatusState state = commandStatusHash[statusHandler] as StatusState; + if (state != null) + { + state.refCount--; + if (state.refCount == 0) + { + commandStatusHash.Remove(statusHandler); + } + } + } + + /// + /// This class saves the state for a given command. It keeps track of the results + /// of the last status handler invocation and what "selection version" that happened on. + /// + private class StatusState + { + // these are the command's possible values. + // + private const int Enabled = 0x01; + private const int Visible = 0x02; + private const int Checked = 0x04; + private const int Supported = 0x08; + private const int NeedsUpdate = 0x10; + + private int selectionVersion; // the version of the selection that this was initialized with. + private int statusFlags = NeedsUpdate; // our flags. + + // Multiple CommandSetItem instances can share a same status handler within a designer host. + // We use a simple ref count to make sure the CommandSetItem can be properly removed. + internal int refCount; + + /// + /// Just what it says... + /// + public int SelectionVersion + { + get + { + return selectionVersion; + } + } + + /// + /// Pushes the state stored in this object into the given command item. + /// + internal void ApplyState(CommandSetItem item) + { + Debug.Assert((statusFlags & NeedsUpdate) != NeedsUpdate, "Updating item when StatusState is not valid."); + + item.Enabled = ((statusFlags & Enabled) == Enabled); + item.Visible = ((statusFlags & Visible) == Visible); + item.Checked = ((statusFlags & Checked) == Checked); + item.Supported = ((statusFlags & Supported) == Supported); + } + + /// + /// Updates this status object with the state from the given item, + /// and saves teh seletion version. + /// + internal void SaveState(CommandSetItem item, int version) + { + selectionVersion = version; + statusFlags = 0; + if (item.Enabled) + { + statusFlags |= Enabled; + } + + if (item.Visible) + { + statusFlags |= Visible; + } + + if (item.Checked) + { + statusFlags |= Checked; + } + + if (item.Supported) + { + statusFlags |= Supported; + } + } + } + } + + /// + /// + /// The immediate command set item is used for commands that cannot be cached. Commands + /// such as Paste that get outside stimulus cannot be cached by our menu system, so + /// they get an ImmediateCommandSetItem instead of a CommandSetItem. + /// + protected class ImmediateCommandSetItem : CommandSetItem + { + /// + /// Creates a new ImmediateCommandSetItem. + /// + public ImmediateCommandSetItem(CommandSet commandSet, EventHandler statusHandler, EventHandler invokeHandler, CommandID id, IUIService uiService) + : base(commandSet, statusHandler, invokeHandler, id, uiService) + { + } + + /// + /// Overrides OleStatus in MenuCommand to invoke our status handler first. + /// + public override int OleStatus + { + get + { + UpdateStatus(); + return base.OleStatus; + } + } + } + + /// + /// Component comparer that compares the left property of a component. + /// + private class ComponentLeftCompare : IComparer + { + public int Compare(object p, object q) + { + PropertyDescriptor pProp = TypeDescriptor.GetProperties(p)["Location"]; + PropertyDescriptor qProp = TypeDescriptor.GetProperties(q)["Location"]; + + Point pLoc = (Point)pProp.GetValue(p); + Point qLoc = (Point)qProp.GetValue(q); + + //if our lefts are equal, then compare tops + if (pLoc.X == qLoc.X) + { + return pLoc.Y - qLoc.Y; + } + + return pLoc.X - qLoc.X; + } + } + + /// + /// Component comparer that compares the top property of a component. + /// + private class ComponentTopCompare : IComparer + { + public int Compare(object p, object q) + { + PropertyDescriptor pProp = TypeDescriptor.GetProperties(p)["Location"]; + PropertyDescriptor qProp = TypeDescriptor.GetProperties(q)["Location"]; + + Point pLoc = (Point)pProp.GetValue(p); + Point qLoc = (Point)qProp.GetValue(q); + + //if our tops are equal, then compare lefts + if (pLoc.Y == qLoc.Y) + { + return pLoc.X - qLoc.X; + } + + return pLoc.Y - qLoc.Y; + } + } + + private class ControlZOrderCompare : IComparer + { + public int Compare(object p, object q) + { + if (p == null) + { + return -1; + } + else if (q == null) + { + return 1; + } + else if (p == q) + { + return 0; + } + + Control c1 = p as Control; + Control c2 = q as Control; + + if (c1 == null || c2 == null) + { + return 1; + } + + if (c1.Parent == c2.Parent && c1.Parent != null) + { + return c1.Parent.Controls.GetChildIndex(c1) - c1.Parent.Controls.GetChildIndex(c2); + } + + return 1; + } + } + + private class TabIndexCompare : IComparer + { + public int Compare(object p, object q) + { + Control c1 = p as Control; + Control c2 = q as Control; + + if (c1 == c2) + { + return 0; + } + + if (c1 == null) + { + return -1; + } + + if (c2 == null) + { + return 1; + } + + return c1.TabIndex - c2.TabIndex; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs index d9f5565c2cd..91d79b4cb2b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs @@ -222,7 +222,7 @@ private void OnSystemSettingChanged(object sender, EventArgs e) private void ResetTrayControls() { - ControlCollection children = (ControlCollection)Controls; + ControlCollection children = Controls; if (children is null) { return; @@ -655,7 +655,7 @@ void ISelectionUIHandler.OnSelectionDoubleClick(IComponent component) void ISelectionUIHandler.ShowContextMenu(IComponent component) { - Point cur = Control.MousePosition; + Point cur = MousePosition; OnContextMenu(cur.X, cur.Y, true); } @@ -1153,8 +1153,8 @@ protected override void OnDragEnter(DragEventArgs de) if (mouseDragTool != null) { - Debug.Assert(0 != (int)(de.AllowedEffect & (DragDropEffects.Move | DragDropEffects.Copy)), "DragDropEffect.Move | .Copy isn't allowed?"); - if ((int)(de.AllowedEffect & DragDropEffects.Move) != 0) + Debug.Assert(0 != (de.AllowedEffect & (DragDropEffects.Move | DragDropEffects.Copy)), "DragDropEffect.Move | .Copy isn't allowed?"); + if ((de.AllowedEffect & DragDropEffects.Move) != 0) { de.Effect = DragDropEffects.Move; } @@ -1187,7 +1187,7 @@ protected override void OnDragOver(DragEventArgs de) { if (mouseDragTool != null) { - Debug.Assert(0 != (int)(de.AllowedEffect & DragDropEffects.Copy), "DragDropEffect.Move isn't allowed?"); + Debug.Assert(0 != (de.AllowedEffect & DragDropEffects.Copy), "DragDropEffect.Move isn't allowed?"); de.Effect = DragDropEffects.Copy; } else @@ -1672,7 +1672,7 @@ protected override void WndProc(ref Message m) if (x == -1 && y == -1) { // for shift-F10 - Point mouse = Control.MousePosition; + Point mouse = MousePosition; x = mouse.X; y = mouse.Y; } @@ -1713,7 +1713,7 @@ private bool TabOrderActive IMenuCommandService mcs = MenuService; if (mcs != null) { - tabOrderCommand = mcs.FindCommand(MenuCommands.TabOrder); + tabOrderCommand = mcs.FindCommand(StandardCommands.TabOrder); } } @@ -2629,7 +2629,7 @@ protected override void WndProc(ref Message m) if (x == -1 && y == -1) { // for shift-F10 - Point mouse = Control.MousePosition; + Point mouse = MousePosition; x = mouse.X; y = mouse.Y; } @@ -2993,14 +2993,14 @@ protected override bool CanDropDataObject(IDataObject dataObj) { if (dataObj is ComponentDataObjectWrapper cdow) { - ComponentDataObject cdo = (ComponentDataObject)cdow.InnerData; + ComponentDataObject cdo = cdow.InnerData; comps = cdo.Components; } else { try { - object serializationData = dataObj.GetData(OleDragDropHandler.DataFormat, true); + object serializationData = dataObj.GetData(DataFormat, true); if (serializationData is null) { return false; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs index 30d7e493d0b..eda2f876bf7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs @@ -5,7 +5,6 @@ using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; -using System.Diagnostics.CodeAnalysis; using System.Drawing.Design; namespace System.Windows.Forms.Design @@ -114,7 +113,7 @@ bool ITypeDescriptorFilterService.FilterProperties(IComponent component, IDictio /// /// Disposes of the resources (other than memory) used by - /// the . + /// the . /// protected override void Dispose(bool disposing) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs index e47eb681fa3..8665c5cec16 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs @@ -5,7 +5,7 @@ namespace System.Windows.Forms.Design { /// - /// Provides data for the event. + /// Provides data for the event. /// internal class ContainerSelectorActiveEventArgs : EventArgs { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs index 50858f38388..01143838e2a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs @@ -64,7 +64,7 @@ public bool ShowImageMargin { if (value != ShowImageMargin) { - ChangeProperty(nameof(ShowImageMargin), (object)value); + ChangeProperty(nameof(ShowImageMargin), value); } } } @@ -76,7 +76,7 @@ public bool ShowCheckMargin { if (value != ShowCheckMargin) { - ChangeProperty(nameof(ShowCheckMargin), (object)value); + ChangeProperty(nameof(ShowCheckMargin), value); } } } @@ -88,7 +88,7 @@ public ToolStripRenderMode RenderMode { if (value != RenderMode) { - ChangeProperty(nameof(RenderMode), (object)value); + ChangeProperty(nameof(RenderMode), value); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs new file mode 100644 index 00000000000..11c36db1f6b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs @@ -0,0 +1,1836 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.Diagnostics; +using System.Collections; +using System.ComponentModel.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// This class implements menu commands that are specific to designers that + /// manipulate controls. + /// + internal class ControlCommandSet : CommandSet + { + private readonly CommandSetItem[] commandSet; + private TabOrder tabOrder; + private readonly Control baseControl; + private StatusCommandUI statusCommandUI; //used to update the StatusBarInfo. + + /// + /// Creates a new CommandSet object. This object implements the set + /// of commands that the UI.Win32 form designer offers. + /// + + // Since we don't override GetService it is okay to suppress this. + public ControlCommandSet(ISite site) : base(site) + { + statusCommandUI = new StatusCommandUI(site); + + // Establish our set of commands + // + commandSet = new CommandSetItem[] + { + // Allignment commands + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuAlignByPrimary), + StandardCommands.AlignLeft, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuAlignByPrimary), + StandardCommands.AlignTop, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusControlsOnlySelectionAndGrid), + new EventHandler(OnMenuAlignToGrid), + StandardCommands.AlignToGrid, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuAlignByPrimary), + StandardCommands.AlignBottom, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuAlignByPrimary), + StandardCommands.AlignHorizontalCenters, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuAlignByPrimary), + StandardCommands.AlignRight, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuAlignByPrimary), + StandardCommands.AlignVerticalCenters, true), + + // Centering commands + new CommandSetItem( + this, + new EventHandler(OnStatusControlsOnlySelection), + new EventHandler(OnMenuCenterSelection), + StandardCommands.CenterHorizontally, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusControlsOnlySelection), + new EventHandler(OnMenuCenterSelection), + StandardCommands.CenterVertically, true), + + // Spacing commands + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.HorizSpaceConcatenate, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.HorizSpaceDecrease, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.HorizSpaceIncrease, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.HorizSpaceMakeEqual, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.VertSpaceConcatenate, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.VertSpaceDecrease, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.VertSpaceIncrease, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectNonContained), + new EventHandler(OnMenuSpacingCommand), + StandardCommands.VertSpaceMakeEqual, true), + + // Sizing commands + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuSizingCommand), + StandardCommands.SizeToControl, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuSizingCommand), + StandardCommands.SizeToControlWidth, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusMultiSelectPrimary), + new EventHandler(OnMenuSizingCommand), + StandardCommands.SizeToControlHeight, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusControlsOnlySelectionAndGrid), + new EventHandler(OnMenuSizeToGrid), + StandardCommands.SizeToGrid, true), + + // Z-Order commands + new CommandSetItem( + this, + new EventHandler(OnStatusZOrder), + new EventHandler(OnMenuZOrderSelection), + StandardCommands.BringToFront, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusZOrder), + new EventHandler(OnMenuZOrderSelection), + StandardCommands.SendToBack, true), + + // Miscellaneous commands + new CommandSetItem( + this, + new EventHandler(OnStatusShowGrid), + new EventHandler(OnMenuShowGrid), + StandardCommands.ShowGrid, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusSnapToGrid), + new EventHandler(OnMenuSnapToGrid), + StandardCommands.SnapToGrid, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusAnyControls), + new EventHandler(OnMenuTabOrder), + StandardCommands.TabOrder, true), + + new CommandSetItem( + this, + new EventHandler(OnStatusLockControls), + new EventHandler(OnMenuLockControls), + StandardCommands.LockControls, true), + + // Keyboard commands + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeySizeWidthIncrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeySizeHeightIncrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeySizeWidthDecrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeySizeHeightDecrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeyNudgeWidthIncrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeyNudgeHeightIncrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeyNudgeWidthDecrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySize), + MenuCommands.KeyNudgeHeightDecrease), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySelect), + MenuCommands.KeySelectNext), + + new CommandSetItem( + this, + new EventHandler(OnStatusAlways), + new EventHandler(OnKeySelect), + MenuCommands.KeySelectPrevious), + }; + + if (MenuService != null) + { + for (int i = 0; i < commandSet.Length; i++) + { + MenuService.AddCommand(commandSet[i]); + } + } + + // Get the base control object. + // + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + Control comp = host.RootComponent as Control; + if (comp != null) + { + baseControl = comp; + } + } + } + + /// + /// Ensures there are no items in the selection that are children of another item in the selection + /// + /// + private bool CheckSelectionParenting() + { + ICollection sel = SelectionService.GetSelectedComponents(); + + Hashtable itemHash = new Hashtable(sel.Count); + foreach (object obj in sel) + { + Control c = obj as Control; + + if (c == null || c.Site == null) + { + return false; + } + + itemHash.Add(obj, obj); + } + + Control okParent = null; + + // just walk up the chain for each selected item...if any other items + // are in that chain, fail. + // + foreach (object component in sel) + { + Control c = component as Control; + + if (c == null || c.Site == null) + { + return false; + } + + // walk up the parent chain, checking each component to see if it's + // in the selection list. If it is, we've got a bad selection. + // + for (Control parent = c.Parent; parent != null; parent = parent.Parent) + { + // if this parent has already been okayed, skip it. + // + if (parent == okParent) + { + continue; + } + + object hashItem = itemHash[parent]; + if (hashItem != null && hashItem != component) + { + return false; + } + } + + // mark that this compoent checked out okay, so any siblings (or children of siblings) of this control + // are ok. + // + okParent = c.Parent; + } + + return true; + } + + /// + /// Disposes of this object, removing all commands from the menu service. + /// + + // We don't need to Dispose baseControl + public override void Dispose() + { + if (MenuService != null) + { + for (int i = 0; i < commandSet.Length; i++) + { + MenuService.RemoveCommand(commandSet[i]); + commandSet[i].Dispose(); + } + } + + if (tabOrder != null) + { + tabOrder.Dispose(); + tabOrder = null; + } + + statusCommandUI = null; + base.Dispose(); + } + + /// + /// Retrieves the snap information for the given component. + /// + protected override void GetSnapInformation(IDesignerHost host, IComponent component, out Size snapSize, out IComponent snapComponent, out PropertyDescriptor snapProperty) + { + IComponent currentSnapComponent = null; + IContainer container = component.Site.Container; + PropertyDescriptor gridSizeProp = null; + PropertyDescriptor currentSnapProp = null; + PropertyDescriptorCollection props; + + // This implementation is specific to controls. It looks in the parent hierarchy for an object with a + // snap property. If it fails to find one, it just gets the base component. + // + Control ctrl = component as Control; + if (ctrl != null) + { + Control c = ctrl.Parent; + while (c != null && currentSnapComponent == null) + { + props = TypeDescriptor.GetProperties(c); + currentSnapProp = props["SnapToGrid"]; + if (currentSnapProp != null) + { + if (currentSnapProp.PropertyType == typeof(bool) && c.Site != null && c.Site.Container == container) + { + currentSnapComponent = c; + } + else + { + currentSnapProp = null; + } + } + + c = c.Parent; + } + } + + if (currentSnapComponent == null) + { + currentSnapComponent = host.RootComponent; + } + + props = TypeDescriptor.GetProperties(currentSnapComponent); + + if (currentSnapProp == null) + { + currentSnapProp = props["SnapToGrid"]; + if (currentSnapProp != null && currentSnapProp.PropertyType != typeof(bool)) + { + currentSnapProp = null; + } + } + + if (gridSizeProp == null) + { + gridSizeProp = props["GridSize"]; + if (gridSizeProp != null && gridSizeProp.PropertyType != typeof(Size)) + { + gridSizeProp = null; + } + } + + // Finally, now that we've got the various properties and components, dole out the + // values. + // + snapComponent = currentSnapComponent; + snapProperty = currentSnapProp; + if (gridSizeProp != null) + { + snapSize = (Size)gridSizeProp.GetValue(snapComponent); + } + else + { + snapSize = Size.Empty; + } + } + + /// + /// Called for the two cancel commands we support. + /// + protected override bool OnKeyCancel(object sender) + { + // The base implementation here just checks to see if we are dragging. + // If we are, then we abort the drag. + // + if (!base.OnKeyCancel(sender)) + { + MenuCommand cmd = (MenuCommand)sender; + bool reverse = (cmd.CommandID.Equals(MenuCommands.KeyReverseCancel)); + RotateParentSelection(reverse); + return true; + } + + return false; + } + + /// + /// Builds up an array of snaplines used during resize to adjust/snap + /// the controls bounds. + /// + private ArrayList GenerateSnapLines(SelectionRules rules, Control primaryControl, int directionOffsetX, int directionOffsetY) + { + ArrayList lines = new ArrayList(2); + + Point pt = BehaviorService.ControlToAdornerWindow(primaryControl); + bool fRTL = (primaryControl.Parent != null && primaryControl.Parent.IsMirrored); + + //remember that snaplines must be in adornerwindow coordinates + + if (directionOffsetX != 0) + { + Debug.Assert(directionOffsetY == 0, "Can only resize in one direction at a time using the keyboard"); + + //we are resizing in the x-dir, so add the vertical snaplines for the right edge + if (!fRTL) + { + if ((rules & SelectionRules.RightSizeable) != 0) + { + lines.Add(new SnapLine(SnapLineType.Right, pt.X + primaryControl.Width - 1)); + lines.Add(new SnapLine(SnapLineType.Vertical, pt.X + primaryControl.Width + primaryControl.Margin.Right, SnapLine.MarginRight, SnapLinePriority.Always)); + } + } + else + { + if ((rules & SelectionRules.LeftSizeable) != 0) + { + lines.Add(new SnapLine(SnapLineType.Left, pt.X)); + lines.Add(new SnapLine(SnapLineType.Vertical, pt.X - primaryControl.Margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always)); + } + } + } + + if (directionOffsetY != 0) + { + Debug.Assert(directionOffsetX == 0, "Can only resize in one direction at a time using the keyboard"); + + //we are resizing in the y-dir, so add the horizonal snaplines for the bottom edge + if ((rules & SelectionRules.BottomSizeable) != 0) + { + lines.Add(new SnapLine(SnapLineType.Bottom, pt.Y + primaryControl.Height - 1)); + lines.Add(new SnapLine(SnapLineType.Horizontal, pt.Y + primaryControl.Height + primaryControl.Margin.Bottom, SnapLine.MarginBottom, SnapLinePriority.Always)); + } + } + + return lines; + } + + /// + /// Called for the various sizing commands we support. + /// + protected void OnKeySize(object sender, EventArgs e) + { + // Arrow keys. Begin a drag if the selection isn't locked. + // + ISelectionService selSvc = SelectionService; + if (selSvc != null) + { + IComponent comp = selSvc.PrimarySelection as IComponent; + if (comp != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + //This will exluded components in the ComponentTray, but that's okay, they are not resizable to begin with. + ControlDesigner des = host.GetDesigner(comp) as ControlDesigner; + if (des != null && ((des.SelectionRules & SelectionRules.Locked) == 0)) + { + //Possibly flip our size adjustments depending on the dock prop of the control. + //EX: If the control is docked right, then shift+left arrow will cause + //the control's width to decrease when it should increase + bool flipOffset = false; + PropertyDescriptor dockProp = TypeDescriptor.GetProperties(comp)["Dock"]; + if (dockProp != null) + { + DockStyle docked = (DockStyle)dockProp.GetValue(comp); + flipOffset = (docked == DockStyle.Bottom) || (docked == DockStyle.Right); + } + + SelectionRules rules = SelectionRules.Visible; + CommandID cmd = ((MenuCommand)sender).CommandID; + bool invertSnap = false; + int moveOffsetX = 0; + int moveOffsetY = 0; + + bool checkForIntegralHeight = false; + + if (cmd.Equals(MenuCommands.KeySizeHeightDecrease)) + { + moveOffsetY = flipOffset ? 1 : -1; + rules |= SelectionRules.BottomSizeable; + } + else if (cmd.Equals(MenuCommands.KeySizeHeightIncrease)) + { + moveOffsetY = flipOffset ? -1 : 1; + rules |= SelectionRules.BottomSizeable; + } + else if (cmd.Equals(MenuCommands.KeySizeWidthDecrease)) + { + moveOffsetX = flipOffset ? 1 : -1; + rules |= SelectionRules.RightSizeable; + } + else if (cmd.Equals(MenuCommands.KeySizeWidthIncrease)) + { + moveOffsetX = flipOffset ? -1 : 1; + rules |= SelectionRules.RightSizeable; + } + else if (cmd.Equals(MenuCommands.KeyNudgeHeightDecrease)) + { + moveOffsetY = -1; + invertSnap = true; + rules |= SelectionRules.BottomSizeable; + } + else if (cmd.Equals(MenuCommands.KeyNudgeHeightIncrease)) + { + moveOffsetY = 1; + invertSnap = true; + rules |= SelectionRules.BottomSizeable; + } + else if (cmd.Equals(MenuCommands.KeyNudgeWidthDecrease)) + { + moveOffsetX = -1; + invertSnap = true; + rules |= SelectionRules.RightSizeable; + } + else if (cmd.Equals(MenuCommands.KeyNudgeWidthIncrease)) + { + moveOffsetX = 1; + invertSnap = true; + rules |= SelectionRules.RightSizeable; + } + else + { + Debug.Fail("Unknown command mapped to OnKeySize: " + cmd.ToString()); + } + + DesignerTransaction trans; + if (selSvc.SelectionCount > 1) + { + trans = host.CreateTransaction(string.Format(SR.DragDropSizeComponents, selSvc.SelectionCount)); + } + else + { + trans = host.CreateTransaction(string.Format(SR.DragDropSizeComponent, comp.Site.Name)); + } + + try + { + //if we can find the behaviorservice, then we can use it and the SnapLineEngine to help us + //move these controls... + if (BehaviorService != null) + { + Control primaryControl = comp as Control; + + bool useSnapLines = BehaviorService.UseSnapLines; + + // If we have previous snaplines, we always want to erase them, no matter what. VS Whidbey #397709 + if (dragManager != null) + { + EndDragManager(); + } + + //If we CTRL+Arrow and we're using SnapLines - snap to the next location + if (invertSnap && useSnapLines) + { + ArrayList selComps = new ArrayList(selSvc.GetSelectedComponents()); + + //create our snapline engine + dragManager = new DragAssistanceManager(des.Component.Site, selComps); + + ArrayList targetSnaplines = GenerateSnapLines(des.SelectionRules, primaryControl, moveOffsetX, moveOffsetY); + + //ask our snapline engine to find the nearest snap position with the given direction + Point snappedOffset = dragManager.OffsetToNearestSnapLocation(primaryControl, targetSnaplines, new Point(moveOffsetX, moveOffsetY)); + + //update the offset according to the snapline engine - but only if the new size is not smaller than the minimum control size + //E.g. Say button 1 is above button 2 (in the y direction). Button 2 is selected. + //If the user does a ctrl-shift-up arrow, then OffsetToNearestSnapLocation would return a match to the bottom snapline for button 1 + //resulting in button2's size to be negative + + Size primaryControlsize = primaryControl.Size; + primaryControlsize += new Size(snappedOffset.X, snappedOffset.Y); + if ((primaryControlsize.Width <= 0) || (primaryControlsize.Height <= 0)) + { + // simulate that there is nothing to snap to + moveOffsetX = 0; + moveOffsetY = 0; + EndDragManager(); + } + else + { + // This is the offset assuming origin is in the upper-left. + moveOffsetX = snappedOffset.X; + moveOffsetY = snappedOffset.Y; + } + + // If the parent is mirrored then we need to negate moveOffsetX. + // This is because moveOffsetX assumes that the origin + // is upper left. That is, when moveOffsetX is positive, we + // are moving right, negative when moving left. + + // The parent container's origin depends on its mirroring property. + // Thus when we call propSize.setValue below, we need to make sure + // that our moveOffset.X correctly reflects the placement of the + // parent container's origin. + + // We need to do this AFTER we calculate the snappedOffset. + // This is because the dragManager calculations are all based + // on an origin in the upper-left. + if (primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + } + + //if we used a regular arrow key and we're in SnapToGrid mode... + + else if (!invertSnap && !useSnapLines) + { + bool snapOn = false; + Size snapSize = Size.Empty; + IComponent snapComponent = null; + PropertyDescriptor snapProperty = null; + + GetSnapInformation(host, comp, out snapSize, out snapComponent, out snapProperty); + + if (snapProperty != null) + { + snapOn = (bool)snapProperty.GetValue(snapComponent); + } + + if (snapOn && !snapSize.IsEmpty) + { + ParentControlDesigner parentDesigner = host.GetDesigner(primaryControl.Parent) as ParentControlDesigner; + if (parentDesigner != null) + { + //ask the parent to adjust our wanna-be snapped position + moveOffsetX *= snapSize.Width; + moveOffsetY *= snapSize.Height; + + // If the parent is mirrored then we need to negate moveOffsetX. + // This is because moveOffsetX assumes that the origin + // is upper left. That is, when moveOffsetX is positive, we + // are moving right, negative when moving left. + + // The parent container's origin depends on its mirroring property. + // Thus when we call propLoc.setValue below, we need to make sure + // that our moveOffset.X correctly reflects the placement of the + // parent container's origin. + + // Should do this BEFORE we get the snapped point. + if (primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + + Rectangle dragRect = new Rectangle(primaryControl.Location.X, primaryControl.Location.Y, + primaryControl.Width + moveOffsetX, primaryControl.Height + moveOffsetY); + + Rectangle newRect = parentDesigner.GetSnappedRect(primaryControl.Bounds, dragRect, true); + + //reset our offsets now that we've snapped correctly + if (moveOffsetX != 0) + { + moveOffsetX = newRect.Width - primaryControl.Width; + } + + if (moveOffsetY != 0) + { + moveOffsetY = newRect.Height - primaryControl.Height; + } + } + } + else + { + //In this case we are just moving 1 pixel + checkForIntegralHeight = true; + if (primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + } + } + else + { + checkForIntegralHeight = true; + if (primaryControl.Parent.IsMirrored) + { + moveOffsetX *= -1; + } + } + + foreach (IComponent component in selSvc.GetSelectedComponents()) + { + des = host.GetDesigner(component) as ControlDesigner; + if (des != null && ((des.SelectionRules & rules) != rules)) + { + //the control must match the rules, if not, then we don't resize it + continue; + } + + Control control = component as Control; + + if (control != null) + { + int offsetY = moveOffsetY; //we don't want to change moveOFfsetY for all subsequent controls, so cache it off + + if (checkForIntegralHeight) + { + PropertyDescriptor propIntegralHeight = TypeDescriptor.GetProperties(component)["IntegralHeight"]; + if (propIntegralHeight != null) + { + object value = propIntegralHeight.GetValue(component); + if (value is bool && (bool)value == true) + { + PropertyDescriptor propItemHeight = TypeDescriptor.GetProperties(component)["ItemHeight"]; + if (propItemHeight != null) + { + offsetY *= (int)propItemHeight.GetValue(component); //adjust for integralheight + } + } + } + } + + PropertyDescriptor propSize = TypeDescriptor.GetProperties(component)["Size"]; + if (propSize != null) + { + Size size = (Size)propSize.GetValue(component); + size += new Size(moveOffsetX, offsetY); + propSize.SetValue(component, size); + } + } + + //change the Status information .... + if (control == selSvc.PrimarySelection && statusCommandUI != null) + { + statusCommandUI.SetStatusInformation(control); + } + } + } + } + + finally + { + if (trans != null) + { + trans.Commit(); + } + + if (dragManager != null) + { + //start our timer for the snaplines + SnapLineTimer.Start(); + + //render any lines + dragManager.RenderSnapLinesInternal(); + } + } + } + } + } + } + } + + /// + /// Called for selection via the tab key. + /// + protected void OnKeySelect(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + bool reverse = (cmd.CommandID.Equals(MenuCommands.KeySelectPrevious)); + RotateTabSelection(reverse); + } + + /// + /// Called for selection via the tab key. + /// + protected override void OnKeyMove(object sender, EventArgs e) + { + base.OnKeyMove(sender, e); + } + + /// + /// Called when the lock controls menu item is selected. + /// + protected void OnMenuLockControls(object sender, EventArgs e) + { + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + if (host != null) + { + ComponentCollection components = host.Container.Components; + + if (components != null && components.Count > 0) + { + DesignerTransaction trans = null; + + try + { + trans = host.CreateTransaction(string.Format(SR.CommandSetLockControls, components.Count)); + MenuCommand cmd = (MenuCommand)sender; + bool targetValue = !cmd.Checked; + + // do the change + bool firstTry = true; + foreach (IComponent comp in components) + { + PropertyDescriptor prop = GetProperty(comp, "Locked"); + //check to see the prop is not null & not readonly + if (prop == null) + { + continue; + } + + if (prop.IsReadOnly) + { + continue; + } + + // look if it's ok to change + if (firstTry && !CanCheckout(comp)) + { + return; + } + + firstTry = false; + + // do the change + prop.SetValue(comp, targetValue); + } + + cmd.Checked = targetValue; + } + finally + { + if (trans != null) + trans.Commit(); + } + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + +#if UNUSED + /// + /// This should never be called. It is a placeholder for + /// menu items that we temporarially want to disable. + /// + private void OnMenuNever(object sender, EventArgs e) { + Debug.Fail("This menu item should never be invoked."); + } +#endif + + /// + /// Called to display or destroy the tab order UI. + /// + private void OnMenuTabOrder(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + if (cmd.Checked) + { + Debug.Assert(tabOrder != null, "Tab order and menu enabling are out of sync"); + if (tabOrder != null) + { + tabOrder.Dispose(); + tabOrder = null; + } + + cmd.Checked = false; + } + else + { + //if we're creating a tab order view, set the focus to the base comp, + //this prevents things such as the menu editor service getting broken. + // + ISelectionService selSvc = SelectionService; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null && selSvc != null) + { + object baseComp = host.RootComponent; + if (baseComp != null) + { + selSvc.SetSelectedComponents(new object[] { baseComp }, SelectionTypes.Replace); + } + } + + using (DpiHelper.EnterDpiAwarenessScope(User32.DPI_AWARENESS_CONTEXT.SYSTEM_AWARE)) + { + tabOrder = new TabOrder((IDesignerHost)GetService(typeof(IDesignerHost))); + } + + cmd.Checked = true; + } + } + + /// + /// Called when the zorder->send to back menu item is selected. + /// + private void OnMenuZOrderSelection(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + CommandID cmdID = cmd.CommandID; + + Debug.Assert(SelectionService != null, "Need SelectionService for sizing command"); + + if (SelectionService == null) + { + return; + } + + ArrayList layoutParentList = new ArrayList(); + ArrayList parentList = new ArrayList(); + Cursor oldCursor = Cursor.Current; + try + { + Cursor.Current = Cursors.WaitCursor; + + IComponentChangeService ccs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); + DesignerTransaction trans = null; + + try + { + string batchString; + + // NOTE: this only works on Control types + ICollection sel = SelectionService.GetSelectedComponents(); + object[] selectedComponents = new object[sel.Count]; + sel.CopyTo(selectedComponents, 0); + + if (cmdID == StandardCommands.BringToFront) + { + batchString = string.Format(SR.CommandSetBringToFront, selectedComponents.Length); + } + else + { + batchString = string.Format(SR.CommandSetSendToBack, selectedComponents.Length); + } + + // sort the components by their current zOrder + Array.Sort(selectedComponents, new ControlComparer()); + + trans = designerHost.CreateTransaction(batchString); + + if (selectedComponents.Length > 0) + { + int len = selectedComponents.Length; + for (int i = len - 1; i >= 0; i--) + { + Control control = selectedComponents[i] as Control; + // Check for NestedComponents like SplitterPanels. + // If SplitterPanel is selected and you choose the SendToBack (or BringToFront) option then it should + // perform the operation on the Owner (namely SplitContainer) + IComponent selComp = selectedComponents[i] as IComponent; + if (selComp != null) + { + INestedSite nestedSite = selComp.Site as INestedSite; + if (nestedSite != null) + { + INestedContainer nestedContainer = nestedSite.Container as INestedContainer; + if (nestedContainer != null) + { + control = nestedContainer.Owner as Control; + selectedComponents[i] = control; // set this so that we dont have to re-do this logic in the BrintToFront case down. + } + } + } + + if (control != null) + { + Control parent = control.Parent; + PropertyDescriptor controlsProp = null; + if (parent != null) + { + if (ccs != null) + { + try + { + if (!parentList.Contains(parent)) + { + controlsProp = TypeDescriptor.GetProperties(parent)["Controls"]; + if (controlsProp != null) + { + // For a perf improvement, we will + // call OnComponentChanging only once per parent to make sure we do not do unnecessaru serialization for Undo + //this makes bulk operations way faster (see bug 532657) + + parentList.Add(parent); + ccs.OnComponentChanging(parent, controlsProp); + } + } + } + catch (CheckoutException ex) + { + if (ex == CheckoutException.Canceled) + { + // If the user canceled the check out then cancel the transaction + if (trans != null) + trans.Cancel(); + return; + } + + throw; + } + } + + if (!layoutParentList.Contains(parent)) + { + // For a perf improvement, we will + // suspendlayout on parentControls. + // Calling BringToFront() forces a layout on the parent each time + // so for many controls this will happen a lot. + + layoutParentList.Add(parent); + parent.SuspendLayout(); + } + } + } + } + + for (int i = len - 1; i >= 0; i--) + { + if (cmdID == StandardCommands.BringToFront) + { + // we do this backwards to maintain zorder + Control otherControl = selectedComponents[len - i - 1] as Control; + + if (otherControl != null) + { + otherControl.BringToFront(); + } + } + else if (cmdID == StandardCommands.SendToBack) + { + Control control = selectedComponents[i] as Control; + if (control != null) + { + control.SendToBack(); + } + } + } + } + } + finally + { + // Do not fire changed events if the transaction was canceled + if ((null != trans) && !trans.Canceled) + { + foreach (Control parent in parentList) + { + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(parent)["Controls"]; + Debug.Assert(ccs != null && controlsProp != null, "Wrong parent in parent list"); + if (ccs != null && controlsProp != null) + { + ccs.OnComponentChanged(parent, controlsProp, null, null); + } + } + + foreach (Control parent in layoutParentList) + { + parent.ResumeLayout(); + } + + // now we need to regenerate so the ordering is right. + trans.Commit(); + } + } + } + finally + { + Cursor.Current = oldCursor; + } + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled when there is one or more controls on the design + /// surface. + /// + protected void OnStatusAnyControls(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + bool enabled = false; + if (baseControl != null && baseControl.Controls.Count > 0) + { + enabled = true; + } + + cmd.Enabled = enabled; + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled when one or more objects are selected. + /// + protected void OnStatusControlsOnlySelection(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = (selCount > 0) && controlsOnlySelection; + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled when one or more objects are selected and + /// SnapToGrid is selected. + /// + protected void OnStatusControlsOnlySelectionAndGrid(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + + cmd.Enabled = (selCount > 0) && controlsOnlySelection && (!BehaviorService.UseSnapLines); + } + + protected void OnStatusLockControls(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + + if (baseControl == null) + { + cmd.Enabled = false; + return; + } + + cmd.Enabled = controlsOnlySelection; + cmd.Checked = false; + + //Get the locked property of the base control first... + // + PropertyDescriptor lockedProp = TypeDescriptor.GetProperties(baseControl)["Locked"]; + if (lockedProp != null && ((bool)lockedProp.GetValue(baseControl)) == true) + { + cmd.Checked = true; + return; + } + + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + + if (host == null) + { + return; + } + + ComponentDesigner baseDesigner = host.GetDesigner(baseControl) as ComponentDesigner; + + foreach (object component in baseDesigner.AssociatedComponents) + { + lockedProp = TypeDescriptor.GetProperties(component)["Locked"]; + if (lockedProp != null && ((bool)lockedProp.GetValue(component)) == true) + { + cmd.Checked = true; + return; + } + } + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled when more than one object is selected. + /// + protected void OnStatusMultiSelect(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = controlsOnlySelection && selCount > 1; + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled when more than one object is selected and one + /// of them is marked as the primary selection. + /// + protected void OnStatusMultiSelectPrimary(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = controlsOnlySelection && selCount > 1 && primarySelection != null; + } + + /// + /// Determines the status of a menu command. Ensures that all the selected controls have the same parent. + /// + private void OnStatusMultiSelectNonContained(object sender, EventArgs e) + { + OnStatusMultiSelect(sender, e); + MenuCommand cmd = (MenuCommand)sender; + if (cmd.Enabled) + { + cmd.Enabled = CheckSelectionParenting(); + } + } + + /// + /// Determines the status of a menu command. This event handler is + /// dedicated to the ShowGrid item. + /// + protected void OnStatusShowGrid(object sender, EventArgs e) + { + if (site != null) + { + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (host != null) + { + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor prop = GetProperty(baseComponent, "DrawGrid"); + if (prop != null) + { + bool drawGrid = (bool)prop.GetValue(baseComponent); + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = true; + cmd.Checked = drawGrid; + } + } + } + } + } + + /// + /// Determines the status of a menu command. This event handler is + /// dedicated to the SnapToGrid item. + /// + protected void OnStatusSnapToGrid(object sender, EventArgs e) + { + if (site != null) + { + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); + + if (host != null) + { + IComponent baseComponent = host.RootComponent; + if (baseComponent != null && baseComponent is Control) + { + PropertyDescriptor prop = GetProperty(baseComponent, "SnapToGrid"); + if (prop != null) + { + bool snapToGrid = (bool)prop.GetValue(baseComponent); + MenuCommand cmd = (MenuCommand)sender; + cmd.Enabled = controlsOnlySelection; + cmd.Checked = snapToGrid; + } + } + } + } + } + + /// + /// Determines the status of a menu command. Commands with this event + /// handler are enabled for zordering. The rules are: + /// + /// 1) More than one component on the form + /// 2) At least one Control-derived component must be selected + /// 3) The form must not be selected + /// + private void OnStatusZOrder(object sender, EventArgs e) + { + MenuCommand cmd = (MenuCommand)sender; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + ComponentCollection comps = host.Container.Components; + object baseComp = host.RootComponent; + + // The form by itself is one component, so this means + // we need more than two. + bool enable = (comps != null && comps.Count > 2 && controlsOnlySelection); + + if (enable) + { + Debug.Assert(SelectionService != null, "Need SelectionService for sizing command"); + + if (SelectionService == null) + { + return; + } + + // There must also be a control in the mix, and not the base component, and + // it cannot be privately inherited. + // + ICollection selectedComponents = SelectionService.GetSelectedComponents(); + + enable = false; + foreach (object obj in selectedComponents) + { + if (obj is Control && + !TypeDescriptor.GetAttributes(obj)[typeof(InheritanceAttribute)].Equals(InheritanceAttribute.InheritedReadOnly)) + { + enable = true; + } + + // if the form is in there we're always false. + if (obj == baseComp) + { + enable = false; + break; + } + } + } + + cmd.Enabled = enable; + return; + } + + cmd.Enabled = false; + } + + /// + /// This is called when the selection has changed. Anyone using CommandSetItems + /// that need to update their status based on selection changes should override + /// this and update their own commands at this time. The base implementaion + /// runs through all base commands and calls UpdateStatus on them. + /// + protected override void OnUpdateCommandStatus() + { + // Now whip through all of the commands and ask them to update. + // + for (int i = 0; i < commandSet.Length; i++) + { + commandSet[i].UpdateStatus(); + } + + base.OnUpdateCommandStatus(); + } + + /// + /// Rotates the selection to the next parent element. If backwards is + /// set, this will rotate to the first child element. + /// + private void RotateParentSelection(bool backwards) + { + object next = null; + + ISelectionService selSvc = SelectionService; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + if (selSvc == null || host == null || !(host.RootComponent is Control)) + { + return; + } + + IContainer container = host.Container; + + Control component = selSvc.PrimarySelection as Control; + Control current; + if (component != null) + { + current = component; + } + else + { + current = (Control)host.RootComponent; + } + + if (backwards) + { + if (current != null) + { + if (current.Controls.Count > 0) + { + next = current.Controls[0]; + } + else + { + next = current; + } + } + } + else + { + if (current != null) + { + next = current.Parent; + Control nextControl = next as Control; + IContainer controlSiteContainer = null; + if (nextControl != null && nextControl.Site != null) + { + controlSiteContainer = DesignerUtils.CheckForNestedContainer(nextControl.Site.Container); // ...necessary to support SplitterPanel components + } + + if (nextControl == null || nextControl.Site == null || controlSiteContainer != container) + { + next = current; + } + } + } + + selSvc.SetSelectedComponents(new object[] { next }, SelectionTypes.Replace); + } + + /// + /// Rotates the selection to the element next in the tab index. If backwards + /// is set, this will rotate to the previous tab index. + /// + private void RotateTabSelection(bool backwards) + { + Control ctl; + Control baseCtl; + object targetSelection = null; + object currentSelection; + + ISelectionService selSvc = SelectionService; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (selSvc == null || host == null || !(host.RootComponent is Control)) + { + return; + } + + baseCtl = (Control)host.RootComponent; + + // We must handle two cases of logic here. We are responsible for handling + // selection within ourself, and also for components on the tray. For our + // own tabbing around, we want to go by tab-order. When we get to the end + // of the form, however, we go by selection order into the tray. And, + // when we're at the end of the tray we start back at the form. We must + // reverse this logic to go backwards. + + currentSelection = selSvc.PrimarySelection; + ctl = currentSelection as Control; + + if (targetSelection == null && ctl != null && (baseCtl.Contains(ctl) || baseCtl == currentSelection)) + { + // Our current selection is a control. Select the next control in + // the z-order. + // + while (null != (ctl = GetNextControlInTab(baseCtl, ctl, !backwards))) + { + if (ctl.Site != null && ctl.Site.Container == ctl.Container) + { + break; + } + } + + targetSelection = ctl; + } + + if (targetSelection == null) + { + ComponentTray tray = (ComponentTray)GetService(typeof(ComponentTray)); + if (tray != null) + { + targetSelection = tray.GetNextComponent((IComponent)currentSelection, !backwards); + if (targetSelection != null) + { + IComponent selection = targetSelection as IComponent; + ControlDesigner controlDesigner = host.GetDesigner(selection) as ControlDesigner; + // In Whidbey controls like ToolStrips have componentTray presence, So dont select them again + // through compoenent tray since here we select only Components. Hence only + // components that have ComponentDesigners should be selected via the ComponentTray. + while (controlDesigner != null) + { + // if the targetSelection from the Tray is a control .. try the next one. + selection = tray.GetNextComponent(selection, !backwards); + if (selection != null) + { + controlDesigner = host.GetDesigner(selection) as ControlDesigner; + } + else + { + controlDesigner = null; + } + } + } + } + + if (targetSelection == null) + { + targetSelection = baseCtl; + } + } + + selSvc.SetSelectedComponents(new object[] { targetSelection }, SelectionTypes.Replace); + } + + private Control GetNextControlInTab(Control basectl, Control ctl, bool forward) + { + if (forward) + { + Control.ControlCollection ctlControls = ctl.Controls; + + if (ctlControls != null && ctlControls.Count > 0) + { + Control found = null; + + // Cycle through the controls in z-order looking for the lowest tab index. + // + for (int c = 0; c < ctlControls.Count; c++) + { + if (found == null || found.TabIndex > ctlControls[c].TabIndex) + { + found = ctlControls[c]; + } + } + + return found; + } + + while (ctl != basectl) + { + int targetIndex = ctl.TabIndex; + bool hitCtl = false; + Control found = null; + Control p = ctl.Parent; + + // Cycle through the controls in z-order looking for the one with the next highest + // tab index. Because there can be dups, we have to start with the existing tab index and + // remember to exclude the current control. + // + int parentControlCount = 0; + + Control.ControlCollection parentControls = p.Controls; + + if (parentControls != null) + { + parentControlCount = parentControls.Count; + } + + for (int c = 0; c < parentControlCount; c++) + { + // The logic for this is a bit lengthy, so I have broken it into separate + // caluses: + + // We are not interested in ourself. + // + if (parentControls[c] != ctl) + { + // We are interested in controls with >= tab indexes to ctl. We must include those + // controls with equal indexes to account for duplicate indexes. + // + if (parentControls[c].TabIndex >= targetIndex) + { + // Check to see if this control replaces the "best match" we've already + // found. + // + if (found == null || found.TabIndex > parentControls[c].TabIndex) + { + // Finally, check to make sure that if this tab index is the same as ctl, + // that we've already encountered ctl in the z-order. If it isn't the same, + // than we're more than happy with it. + // + if (parentControls[c].TabIndex != targetIndex || hitCtl) + { + found = parentControls[c]; + } + } + } + } + else + { + // We track when we have encountered "ctl". We never want to select ctl again, but + // we want to know when we've seen it in case we find another control with the same tab index. + // + hitCtl = true; + } + } + + if (found != null) + { + return found; + } + + ctl = ctl.Parent; + } + } + else + { + if (ctl != basectl) + { + int targetIndex = ctl.TabIndex; + bool hitCtl = false; + Control found = null; + Control p = ctl.Parent; + + // Cycle through the controls in reverse z-order looking for the next lowest tab index. We must + // start with the same tab index as ctl, because there can be dups. + // + int parentControlCount = 0; + + Control.ControlCollection parentControls = p.Controls; + + if (parentControls != null) + { + parentControlCount = parentControls.Count; + } + + for (int c = parentControlCount - 1; c >= 0; c--) + { + // The logic for this is a bit lengthy, so I have broken it into separate + // caluses: + + // We are not interested in ourself. + // + if (parentControls[c] != ctl) + { + // We are interested in controls with <= tab indexes to ctl. We must include those + // controls with equal indexes to account for duplicate indexes. + // + if (parentControls[c].TabIndex <= targetIndex) + { + // Check to see if this control replaces the "best match" we've already + // found. + // + if (found == null || found.TabIndex < parentControls[c].TabIndex) + { + // Finally, check to make sure that if this tab index is the same as ctl, + // that we've already encountered ctl in the z-order. If it isn't the same, + // than we're more than happy with it. + // + if (parentControls[c].TabIndex != targetIndex || hitCtl) + { + found = parentControls[c]; + } + } + } + } + else + { + // We track when we have encountered "ctl". We never want to select ctl again, but + // we want to know when we've seen it in case we find another control with the same tab index. + // + hitCtl = true; + } + } + + // If we were unable to find a control we should return the control's parent. However, if that parent is us, return + // NULL. + // + if (found != null) + { + ctl = found; + } + else + { + if (p == basectl) + { + return null; + } + else + { + return p; + } + } + } + + // We found a control. Walk into this control to find the proper sub control within it to select. + // + Control.ControlCollection ctlControls = ctl.Controls; + + while (ctlControls != null && ctlControls.Count > 0) + { + Control found = null; + + // Cycle through the controls in reverse z-order looking for the one with the highest + // tab index. + // + for (int c = ctlControls.Count - 1; c >= 0; c--) + { + if (found == null || found.TabIndex < ctlControls[c].TabIndex) + { + found = ctlControls[c]; + } + } + + ctl = found; + + ctlControls = ctl.Controls; + } + } + + return ctl == basectl ? null : ctl; + } + + /// + /// Compares two controls for equality. + /// + private class ControlComparer : IComparer + { + /// + /// Compares two controls for equality. + /// + public int Compare(object x, object y) + { + // we want to sort items here based on their z-order + // + + // if they have the same parent, + // return the comparison based on z-order + // + // otherwise based on parent handles so parent groupings + // will be together + // + // otherwise just put non-controls ahead of controls. + if (x == y) + { + return 0; + } + + Control cX = x as Control; + Control cY = y as Control; + if (cX != null && cY != null) + { + if (cX.Parent == cY.Parent) + { + Control parent = cX.Parent; + if (parent == null) + { + return 0; + } + else if (parent.Controls.GetChildIndex(cX) > parent.Controls.GetChildIndex(cY)) + { + return -1; + } + else + { + return 1; + } + } + else if (cX.Parent == null || cX.Contains(cY)) + { + return 1; + } + else if (cY.Parent == null || cY.Contains(cX)) + { + return -1; + } + else + { + //REVIEW This doesn't look 64-bit safe + return (int)cX.Parent.Handle - (int)cY.Parent.Handle; + } + } + else if (cY != null) + { + return -1; + } + else if (cX != null) + { + return 1; + } + else + { + return 0; + } + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs index 610960ab893..2e002517a7b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs @@ -25,7 +25,7 @@ public ChildSubClass(ControlDesigner designer, IntPtr hwnd) AssignHandle(hwnd); } - void IDesignerTarget.DefWndProc(ref Message m) => base.DefWndProc(ref m); + void IDesignerTarget.DefWndProc(ref Message m) => DefWndProc(ref m); public void Dispose() => _designer = null; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs index 4656688b1da..c39a27c305f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs @@ -35,6 +35,7 @@ public partial class ControlDesigner : ComponentDesigner // ...which would cause a cycle. private bool _hasLocation; // Do we have a location property? private bool _locationChecked; // And did we check it + private bool _locked; // Signifies if this control is locked or not private bool _enabledchangerecursionguard; // Behavior work @@ -70,7 +71,11 @@ public partial class ControlDesigner : ComponentDesigner private bool _removalNotificationHooked; private bool _revokeDragDrop = true; private bool _hadDragDrop; + + private DesignerControlCollection _controls; + private static bool s_inContextMenu; + private DockingActionList _dockingAction; private StatusCommandUI _statusCommandUI; // UI for setting the StatusBar Information.. private Dictionary _subclassedChildren; @@ -79,6 +84,37 @@ public partial class ControlDesigner : ComponentDesigner internal bool ForceVisible { get; set; } = true; + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + private DesignerControlCollection Controls => _controls ??= new DesignerControlCollection(Control); + + private Point Location + { + get + { + Point loc = Control.Location; + + ScrollableControl p = Control.Parent as ScrollableControl; + if (p != null) + { + Point pt = p.AutoScrollPosition; + loc.Offset(-pt.X, -pt.Y); + } + + return loc; + } + set + { + ScrollableControl p = Control.Parent as ScrollableControl; + if (p != null) + { + Point pt = p.AutoScrollPosition; + value.Offset(pt.X, pt.Y); + } + + Control.Location = value; + } + } + /// /// Retrieves a list of associated components. These are components that should be incluced /// in a cut or copy operation on this component. @@ -125,6 +161,38 @@ public virtual AccessibleObject AccessibilityObject /// protected virtual bool EnableDragRect => false; + /// + /// Gets / Sets this controls locked property + /// + private bool Locked + { + get => _locked; + set + { + if (_locked != value) + { + _locked = value; + } + } + } + + private string Name + { + get + { + return Component.Site.Name; + } + set + { + // don't do anything here during loading, if a refactor changed it we don't want to do anything + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host == null || (host != null && !host.Loading)) + { + Component.Site.Name = value; + } + } + } + /// /// Returns the parent component for this control designer. The default implementation just checks to see if /// the component being designed is a control, and if it is it returns its parent. This property can return @@ -265,6 +333,9 @@ internal Point GetOffsetToClientArea() return (new Point(Math.Abs(nativeOffset.X - offset.X), nativeOffset.Y - offset.Y)); } + /// + /// Per AutoSize spec, determines if a control is resizable. + /// private bool IsResizableConsiderAutoSize(PropertyDescriptor autoSizeProp, PropertyDescriptor autoSizeModeProp) { object component = Component; @@ -713,7 +784,7 @@ public virtual GlyphCollection GetGlyphs(GlyphSelectionType selectionType) bool primarySelection = (selectionType == GlyphSelectionType.SelectedPrimary); SelectionRules rules = SelectionRules; - if ((Locked) || (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)) + if (Locked || (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)) { // the lock glyph glyphs.Add(new LockedHandleGlyph(translatedBounds, primarySelection)); @@ -808,6 +879,11 @@ public virtual GlyphCollection GetGlyphs(GlyphSelectionType selectionType) return glyphs; } + /// + /// Demand creates the StandardBehavior related to this + /// ControlDesigner. This is used to associate the designer's + /// selection glyphs to a common Behavior (resize in this case). + /// internal virtual Behavior.Behavior StandardBehavior => _resizeBehavior ??= new ResizeBehavior(Component.Site); internal virtual bool SerializePerformLayout => false; @@ -1057,6 +1133,9 @@ private bool AllowDrop set => ShadowProperties[nameof(AllowDrop)] = value; } + /// + /// Accessor method for the enabled property on control. We shadow this property at design time. + /// private bool Enabled { get => (bool)ShadowProperties[nameof(Enabled)]; @@ -1520,10 +1599,10 @@ protected virtual void OnPaintAdornments(PaintEventArgs pe) /// /// 1. If the toolbox service has a tool selected, it will allow the toolbox service to set the cursor. /// 2. If the selection UI service shows a locked selection, or if there is no location property on the - /// control, then the default arrow will be set. + /// control, then the default arrow will be set. /// 3. Otherwise, the four headed arrow will be set to indicate that the component can be clicked and moved. /// 4. If the user is currently dragging a component, the crosshair cursor will be used instead of the four - /// headed arrow. + /// headed arrow. /// protected virtual void OnSetCursor() { @@ -1567,8 +1646,6 @@ protected virtual void OnSetCursor() Cursor.Current = Cursors.SizeAll; } - private bool Locked { get; set; } - /// /// Allows a designer to filter the set of properties the component it is designing will expose through the /// TypeDescriptor object. This method is called immediately before its corresponding "Post" method. If you diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs index 74418fba2d7..5e0cf749617 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs @@ -18,7 +18,7 @@ internal class DataGridViewCellStyleBuilder : Form private Button _okButton; private Button _cancelButton; private Label _label1; - private DataGridView _listenerDataGridView; + private readonly DataGridView _listenerDataGridView; private DataGridView _sampleDataGridView; private DataGridView _sampleDataGridViewSelected; private TableLayoutPanel _sampleViewTableLayoutPanel; @@ -27,9 +27,9 @@ internal class DataGridViewCellStyleBuilder : Form private TableLayoutPanel _sampleViewGridsTableLayoutPanel; private Label _normalLabel; private Label _selectedLabel; - private IHelpService _helpService; - private IComponent _comp; - private IServiceProvider _serviceProvider; + private readonly IHelpService _helpService; + private readonly IComponent _comp; + private readonly IServiceProvider _serviceProvider; private DataGridViewCellStyle _cellStyle; private ITypeDescriptorContext _context; @@ -41,7 +41,7 @@ public DataGridViewCellStyleBuilder(IServiceProvider serviceProvider, IComponent // Adds columns and rows to the grid, also resizes them InitializeGrids(); - _listenerDataGridView = new System.Windows.Forms.DataGridView(); + _listenerDataGridView = new DataGridView(); _serviceProvider = serviceProvider; _comp = comp; @@ -55,8 +55,8 @@ public DataGridViewCellStyleBuilder(IServiceProvider serviceProvider, IComponent private void InitializeGrids() { - _sampleDataGridViewSelected.Size = new System.Drawing.Size(100, Font.Height + 9); - _sampleDataGridView.Size = new System.Drawing.Size(100, Font.Height + 9); + _sampleDataGridViewSelected.Size = new Drawing.Size(100, Font.Height + 9); + _sampleDataGridView.Size = new Drawing.Size(100, Font.Height + 9); _sampleDataGridView.AccessibilityObject.Name = SR.CellStyleBuilderNormalPreviewAccName; DataGridViewRow row = new DataGridViewRow(); @@ -280,7 +280,7 @@ private void DataGridViewCellStyleBuilder_HelpButtonClicked(object sender, Cance DataGridViewCellStyleBuilder_HelpRequestHandled(); } - private void DataGridViewCellStyleBuilder_HelpRequested(object sender, System.Windows.Forms.HelpEventArgs e) + private void DataGridViewCellStyleBuilder_HelpRequested(object sender, HelpEventArgs e) { e.Handled = true; DataGridViewCellStyleBuilder_HelpRequestHandled(); @@ -294,7 +294,7 @@ private void DataGridViewCellStyleBuilder_HelpRequestHandled() } } - private void DataGridViewCellStyleBuilder_Load(object sender, System.EventArgs e) + private void DataGridViewCellStyleBuilder_Load(object sender, EventArgs e) { // The cell inside the sampleDataGridView should not be selected. _sampleDataGridView.ClearSelection(); @@ -307,11 +307,11 @@ private void DataGridViewCellStyleBuilder_Load(object sender, System.EventArgs e _sampleDataGridViewSelected.Columns[0].Width = _sampleDataGridViewSelected.Width; // sync the Layout event for both sample DataGridView's so that when the sample DataGridView's are laid out we know to change the size of their cells - _sampleDataGridView.Layout += new System.Windows.Forms.LayoutEventHandler(sampleDataGridView_Layout); - _sampleDataGridViewSelected.Layout += new System.Windows.Forms.LayoutEventHandler(sampleDataGridView_Layout); + _sampleDataGridView.Layout += new LayoutEventHandler(sampleDataGridView_Layout); + _sampleDataGridViewSelected.Layout += new LayoutEventHandler(sampleDataGridView_Layout); } - private void sampleDataGridView_CellStateChanged(object sender, System.Windows.Forms.DataGridViewCellStateChangedEventArgs e) + private void sampleDataGridView_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e) { Debug.Assert(e.Cell == _sampleDataGridView.Rows[0].Cells[0], "the sample data grid view has only one cell"); Debug.Assert(sender == _sampleDataGridView, "did we forget to unhook notification"); @@ -322,7 +322,7 @@ private void sampleDataGridView_CellStateChanged(object sender, System.Windows.F } } - private void sampleDataGridView_Layout(object sender, System.Windows.Forms.LayoutEventArgs e) + private void sampleDataGridView_Layout(object sender, LayoutEventArgs e) { DataGridView dataGridView = (DataGridView)sender; dataGridView.Rows[0].Height = dataGridView.Height; @@ -342,7 +342,7 @@ protected override AccessibleObject CreateAccessibilityInstance() return _accObj; } - private class DialogDataGridViewCellAccessibleObject : DataGridViewCell.DataGridViewCellAccessibleObject + private class DialogDataGridViewCellAccessibleObject : DataGridViewCellAccessibleObject { public DialogDataGridViewCellAccessibleObject(DataGridViewCell owner) : base(owner) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs index e2b0eb57f6c..7b3b1cfc5fc 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs @@ -19,22 +19,22 @@ public DataGridViewComponentPropertyGridSite(IServiceProvider sp, IComponent com } /// - /// When implemented by a class, gets the component associated with the . + /// When implemented by a class, gets the component associated with the . /// public IComponent Component { get => _comp; } /// - /// When implemented by a class, gets the container associated with the . + /// When implemented by a class, gets the container associated with the . /// public IContainer Container { get => null; } /// - /// When implemented by a class, determines whether the component is in design mode. + /// When implemented by a class, determines whether the component is in design mode. /// public bool DesignMode { get => false; } /// - /// When implemented by a class, gets or sets the name of the component associated with the . + /// When implemented by a class, gets or sets the name of the component associated with the . /// public string Name { get; set; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs new file mode 100644 index 00000000000..7b828e58090 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.Drawing.Design; + +namespace System.Windows.Forms.Design +{ + internal partial class DesignBindingValueUIHandler + { + class LocalUIItem : PropertyValueUIItem + { + readonly Binding binding; + + internal LocalUIItem(DesignBindingValueUIHandler handler, Binding binding) : base(handler.DataBitmap, new PropertyValueUIItemInvokeHandler(handler.OnPropertyValueUIItemInvoke), GetToolTip(binding)) + { + this.binding = binding; + } + + internal Binding Binding + { + get + { + return binding; + } + } + + static string GetToolTip(Binding binding) + { + string name = ""; + if (binding.DataSource is IComponent) + { + IComponent comp = (IComponent)binding.DataSource; + if (comp.Site != null) + { + name = comp.Site.Name; + } + } + + if (name.Length == 0) + { + name = "(List)"; + } + + name += " - " + binding.BindingMemberInfo.BindingMember; + return name; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs new file mode 100644 index 00000000000..a98142c4207 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; +using System.Drawing.Design; +using System.Drawing; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// + internal partial class DesignBindingValueUIHandler : IDisposable + { + private Bitmap dataBitmap; + + internal Bitmap DataBitmap + { + get + { + if (dataBitmap == null) + { + dataBitmap = new Bitmap(typeof(DesignBindingValueUIHandler), "BoundProperty.bmp"); + dataBitmap.MakeTransparent(); + } + + return dataBitmap; + } + } + + internal void OnGetUIValueItem(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList) + { + if (context.Instance is Control) + { + Control control = (Control)context.Instance; + foreach (Binding binding in control.DataBindings) + { + // Only add the binding if it is one of the data source types we recognize. Otherwise, our drop-down list won't show it as + // an option, which is confusing. + if ((binding.DataSource is IListSource || binding.DataSource is IList || binding.DataSource is Array) && binding.PropertyName.Equals(propDesc.Name)) + { + valueUIItemList.Add(new LocalUIItem(this, binding)); + } + } + } + } + + private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem) + { + // TODO: design a way for consumers to register own AdvancedBindingEditor +#if DESIGNER_DATABINDING + LocalUIItem localItem = (LocalUIItem)invokedItem; + IServiceProvider sop = null; + Control control = localItem.Binding.Control; + if (control.Site != null) + { + sop = (IServiceProvider)control.Site.GetService(typeof(IServiceProvider)); + } + + if (sop != null) + { + AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, sop, control.DataBindings); + } +#endif + } + + public void Dispose() + { + if (dataBitmap != null) + { + dataBitmap.Dispose(); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs new file mode 100644 index 00000000000..250d893546f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs @@ -0,0 +1,106 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal partial class DesignerExtenders + { + /// + /// This is the base extender provider for all winform document + /// designers. It provides the "Name" property. + /// + [ProvideProperty("Name", typeof(IComponent))] + private class NameExtenderProvider : IExtenderProvider + { + private IComponent baseComponent; + + /// + /// Creates a new DocumentExtenderProvider. + /// + internal NameExtenderProvider() + { + } + + protected IComponent GetBaseComponent(object o) + { + if (baseComponent == null) + { + ISite site = ((IComponent)o).Site; + if (site != null) + { + IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); + if (host != null) + { + baseComponent = host.RootComponent; + } + } + } + + return baseComponent; + } + + /// + /// Determines if ths extender provider can extend the given object. We extend + /// all objects, so we always return true. + /// + public virtual bool CanExtend(object o) + { + // We always extend the root + // + IComponent baseComp = GetBaseComponent(o); + if (baseComp == o) + { + return true; + } + + // See if this object is inherited. If so, then we don't want to + // extend. + // + if (!TypeDescriptor.GetAttributes(o)[typeof(InheritanceAttribute)].Equals(InheritanceAttribute.NotInherited)) + { + return false; + } + + return true; + } + + /// + /// This is an extender property that we offer to all components + /// on the form. It implements the "Name" property. + /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [ParenthesizePropertyName(true)] + [MergableProperty(false)] + [SRDescription(nameof(SR.DesignerPropName))] + [Category("Design")] + public virtual string GetName(IComponent comp) + { + ISite site = comp.Site; + if (site != null) + { + return site.Name; + } + + return null; + } + + /// + /// This is an extender property that we offer to all components + /// on the form. It implements the "Name" property. + /// + public void SetName(IComponent comp, string newName) + { + ISite site = comp.Site; + if (site != null) + { + site.Name = newName; + } + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs new file mode 100644 index 00000000000..d082b279f93 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; + +namespace System.Windows.Forms.Design +{ + internal partial class DesignerExtenders + { + /// + /// This extender provider offers up read-only versions of "Name" property + /// for inherited components. + /// + private class NameInheritedExtenderProvider : NameExtenderProvider + { + /// + /// Creates a new DocumentInheritedExtenderProvider. + /// + internal NameInheritedExtenderProvider() + { + } + + /// + /// Determines if ths extender provider can extend the given object. We extend + /// all objects, so we always return true. + /// + public override bool CanExtend(object o) + { + // We never extend the root + // + IComponent baseComp = GetBaseComponent(o); + if (baseComp == o) + { + return false; + } + + // See if this object is inherited. If so, then we are interested in it. + // + if (!TypeDescriptor.GetAttributes(o)[typeof(InheritanceAttribute)].Equals(InheritanceAttribute.NotInherited)) + { + return true; + } + + return false; + } + + [ReadOnly(true)] + public override string GetName(IComponent comp) + { + return base.GetName(comp); + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs new file mode 100644 index 00000000000..721a8f7902d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + /// + /// This class provides the Modifiers property to components. It is shared between + /// the document designer and the component document designer. + /// + internal partial class DesignerExtenders + { + private IExtenderProvider[] providers; + private IExtenderProviderService extenderService; + + /// + /// This is called by a root designer to add the correct extender providers. + /// + public DesignerExtenders(IExtenderProviderService ex) + { + extenderService = ex; + if (providers == null) + { + providers = new IExtenderProvider[] + { + new NameExtenderProvider(), + new NameInheritedExtenderProvider() + }; + } + + for (int i = 0; i < providers.Length; i++) + { + ex.AddExtenderProvider(providers[i]); + } + } + + /// + /// This is called at the appropriate time to remove any extra extender + /// providers previously added to the designer host. + /// + public void Dispose() + { + if (extenderService != null && providers != null) + { + for (int i = 0; i < providers.Length; i++) + { + extenderService.RemoveExtenderProvider(providers[i]); + } + + providers = null; + extenderService = null; + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs index 4238e82b3c2..5172b02ab5c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs @@ -34,7 +34,7 @@ internal class DesignerFrame : Control, IOverlayService, ISplitWindowService, IC private readonly IUIService _uiService; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public DesignerFrame(ISite site) { @@ -256,7 +256,7 @@ protected override void WndProc(ref Message m) if ((msg == User32.WM.VSCROLL) || (msg == User32.WM.HSCROLL)) { // Send a message to ourselves to scroll - User32.SendMessageW(_designerRegion.Handle, (User32.WM)msg, (IntPtr)PARAM.ToInt((int)wScrollNotify, 0), IntPtr.Zero); + User32.SendMessageW(_designerRegion.Handle, msg, (IntPtr)PARAM.ToInt((int)wScrollNotify, 0), IntPtr.Zero); return; } @@ -602,7 +602,7 @@ protected override void WndProc(ref Message m) } } - public class OverlayControlAccessibleObject : Control.ControlAccessibleObject + public class OverlayControlAccessibleObject : ControlAccessibleObject { public OverlayControlAccessibleObject(OverlayControl owner) : base(owner) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs index 5ebcce16d24..c83903ea18d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.Drawing; -using System.Runtime.InteropServices; namespace System.Windows.Forms.Design { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs index d080a3955d5..22e7ffdfeb8 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs @@ -29,7 +29,7 @@ protected override Size DefaultSize get => new Size(92, 22); } - internal GlyphCollection GetGlyphs(ToolStrip parent, GlyphCollection glyphs, System.Windows.Forms.Design.Behavior.Behavior standardBehavior) + internal GlyphCollection GetGlyphs(ToolStrip parent, GlyphCollection glyphs, Behavior.Behavior standardBehavior) { if (_behaviorService is null) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs index 826676b4d94..f1c2bc1721e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs @@ -112,7 +112,7 @@ public static Image BoxImage { if (s_boxImage is null) { - s_boxImage = new Bitmap(BOXIMAGESIZE, BOXIMAGESIZE, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); + s_boxImage = new Bitmap(BOXIMAGESIZE, BOXIMAGESIZE, PixelFormat.Format32bppPArgb); using (Graphics g = Graphics.FromImage(s_boxImage)) { g.FillRectangle(new SolidBrush(SystemColors.InactiveBorder), 0, 0, BOXIMAGESIZE, BOXIMAGESIZE); @@ -436,7 +436,7 @@ public static void GenerateSnapShotWithBitBlt(Control control, ref Image image) public static bool GenerateSnapShotWithWM_PRINT(Control control, ref Image image) { IntPtr hWnd = control.Handle; - image = new Bitmap(Math.Max(control.Width, MINCONTROLBITMAPSIZE), Math.Max(control.Height, MINCONTROLBITMAPSIZE), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); + image = new Bitmap(Math.Max(control.Width, MINCONTROLBITMAPSIZE), Math.Max(control.Height, MINCONTROLBITMAPSIZE), PixelFormat.Format32bppPArgb); //Have to do this BEFORE we set the testcolor. if (control.BackColor == Color.Transparent) @@ -537,12 +537,12 @@ private static Rectangle GetBoundsForSelectionType(Rectangle originalBounds, Sel /// public static Rectangle GetBoundsForSelectionType(Rectangle originalBounds, SelectionBorderGlyphType type) { - return GetBoundsForSelectionType(originalBounds, type, DesignerUtils.SELECTIONBORDERSIZE, SELECTIONBORDEROFFSET); + return GetBoundsForSelectionType(originalBounds, type, SELECTIONBORDERSIZE, SELECTIONBORDEROFFSET); } public static Rectangle GetBoundsForNoResizeSelectionType(Rectangle originalBounds, SelectionBorderGlyphType type) { - return GetBoundsForSelectionType(originalBounds, type, DesignerUtils.SELECTIONBORDERSIZE, NORESIZEBORDEROFFSET); + return GetBoundsForSelectionType(originalBounds, type, SELECTIONBORDERSIZE, NORESIZEBORDEROFFSET); } /// @@ -553,10 +553,6 @@ public static int GetTextBaseline(Control ctrl, ContentAlignment alignment) //determine the actual client area we are working in (w/padding) Rectangle face = ctrl.ClientRectangle; - //get the font metrics via gdi - int fontAscent = 0; - int fontHeight = 0; - using Graphics g = ctrl.CreateGraphics(); using var dc = new DeviceContextHdcScope(g, applyGraphicsState: false); using var hFont = new Gdi32.ObjectScope(ctrl.Font.ToHFONT()); @@ -565,9 +561,10 @@ public static int GetTextBaseline(Control ctrl, ContentAlignment alignment) var metrics = new Gdi32.TEXTMETRICW(); Gdi32.GetTextMetricsW(dc, ref metrics); + //get the font metrics via gdi // Add the font ascent to the baseline - fontAscent = metrics.tmAscent + 1; - fontHeight = metrics.tmHeight; + int fontAscent = metrics.tmAscent + 1; + int fontHeight = metrics.tmHeight; // Now add it all up if ((alignment & AnyTopAlignment) != 0) @@ -780,8 +777,7 @@ public static ICollection CopyDragObjects(ICollection objects, IServiceProvider Debug.Assert(host != null, "No host -- we cannot copy the objects"); if (css != null && host != null) { - SerializationStore store = null; - store = css.CreateStore(); + SerializationStore store = css.CreateStore(); // Get all the objects, meaning we want the children too ICollection copyObjects = GetCopySelection(objects, host); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs index eb10d4c758d..ca3be5e311b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs @@ -30,7 +30,7 @@ public void RefreshItem() } } - protected override void OnClick(System.EventArgs e) + protected override void OnClick(EventArgs e) { if (_verb != null) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs index 9795ee5a5af..329776ff020 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs @@ -9,7 +9,7 @@ namespace System.Windows.Forms.Design { /// - /// Implements the design time editor for specifying the + /// Implements the design time editor for specifying the /// property. /// [CLSCompliant(false)] diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs new file mode 100644 index 00000000000..57858fecba2 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs @@ -0,0 +1,392 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.Drawing.Design; +using System.Globalization; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices.ComTypes; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; +using Microsoft.Win32; +using static Interop; + +namespace System.Windows.Forms.Design +{ + public partial class DocumentDesigner + { + private class AxToolboxItem : ToolboxItem + { + private string clsid; + private Type axctlType; + private string version = string.Empty; + + public AxToolboxItem(string clsid) : base(typeof(AxHost)) + { + this.clsid = clsid; + Company = null; //we don't get any company info for ax controls. + LoadVersionInfo(); + } + + // Since we don't call the base constructor here, which does call Deserialize which we + // override, we should be okay. + private AxToolboxItem(SerializationInfo info, StreamingContext context) + { + Deserialize(info, context); + } + + /// + /// The Component Type is ".Net Component" -- unless otherwise specified by a derived toolboxitem + /// + public override string ComponentType + { + get + { + return SR.Ax_Control; + } + } + + public override string Version + { + get + { + return version; + } + } + + private void LoadVersionInfo() + { + string controlKey = "CLSID\\" + clsid; + RegistryKey key = Registry.ClassesRoot.OpenSubKey(controlKey); + + //fail later -- not for tooltip info... + if (key != null) + { + RegistryKey verKey = key.OpenSubKey("Version"); + if (verKey != null) + { + version = (string)verKey.GetValue(""); + verKey.Close(); + } + + key.Close(); + } + } + + /// + /// Creates an instance of the ActiveX control. Calls VS7 project system + /// to generate the wrappers if they are needed.. + /// + protected override IComponent[] CreateComponentsCore(IDesignerHost host) + { + Debug.Assert(host != null, "Designer host is null!!!"); + + // Get the DTE References object + // + object references = GetReferences(host); + if (references != null) + { + try + { + TYPELIBATTR tlibAttr = GetTypeLibAttr(); + + object[] args = new object[5]; + args[0] = "{" + tlibAttr.guid.ToString() + "}"; + args[1] = (int)tlibAttr.wMajorVerNum; + args[2] = (int)tlibAttr.wMinorVerNum; + args[3] = tlibAttr.lcid; + + args[4] = ""; + object tlbRef = references.GetType().InvokeMember("AddActiveX", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, references, args, CultureInfo.InvariantCulture); + Debug.Assert(tlbRef != null, "Null reference returned by AddActiveX (tlbimp) by the project system for: " + clsid); + + args[4] = "aximp"; + object axRef = references.GetType().InvokeMember("AddActiveX", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, references, args, CultureInfo.InvariantCulture); + Debug.Assert(axRef != null, "Null reference returned by AddActiveX (aximp) by the project system for: " + clsid); + + axctlType = GetAxTypeFromReference(axRef, host); + } + catch (TargetInvocationException tie) + { + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Generating Ax References failed: " + tie.InnerException); + throw tie.InnerException; + } + catch (Exception e) + { + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Generating Ax References failed: " + e); + throw; + } + } + + if (axctlType == null) + { + IUIService uiSvc = (IUIService)host.GetService(typeof(IUIService)); + if (uiSvc == null) + { + RTLAwareMessageBox.Show(null, SR.AxImportFailed, null, MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, 0); + } + else + { + uiSvc.ShowError(SR.AxImportFailed); + } + + return Array.Empty(); + } + + var comps = new IComponent[1]; + try + { + comps[0] = host.CreateComponent(axctlType); + } + catch (Exception e) + { + Debug.Fail("Could not create type: " + e); + throw; + } + + Debug.Assert(comps[0] != null, "Could not create instance of ActiveX control wrappers!!!"); + return comps; + } + + /// + /// Loads the state of this 'AxToolboxItem' + /// from the stream. + /// + protected override void Deserialize(SerializationInfo info, StreamingContext context) + { + base.Deserialize(info, context); + clsid = info.GetString("Clsid"); + } + + /// + /// Gets hold of the DTE Reference object and from there, opens the assembly of the + /// ActiveX control we want to create. It then walks through all AxHost derived classes + /// in that assembly, and returns the type that matches our control's CLSID. + /// + private Type GetAxTypeFromReference(object reference, IDesignerHost host) + { + string path = (string)reference.GetType().InvokeMember("Path", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, reference, null, CultureInfo.InvariantCulture); + + // Missing reference will show up as an empty string. + // + if (path == null || path.Length <= 0) + { + return null; + } + + FileInfo file = new FileInfo(path); + string fullPath = file.FullName; + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Checking: " + fullPath); + + ITypeResolutionService trs = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); + Debug.Assert(trs != null, "No type resolution service found."); + + Assembly a = trs.GetAssembly(AssemblyName.GetAssemblyName(fullPath)); + Debug.Assert(a != null, "No assembly found at " + fullPath); + + return GetAxTypeFromAssembly(a); + } + + /// + /// Walks through all AxHost derived classes in the given assembly, + /// and returns the type that matches our control's CLSID. + /// + private Type GetAxTypeFromAssembly(Assembly a) + { + Type[] types = a.GetTypes(); + int len = types.Length; + for (int i = 0; i < len; ++i) + { + Type t = types[i]; + if (!(typeof(AxHost).IsAssignableFrom(t))) + { + continue; + } + + object[] attrs = t.GetCustomAttributes(typeof(AxHost.ClsidAttribute), false); + Debug.Assert(attrs != null && attrs.Length == 1, "Invalid number of GuidAttributes found on: " + t.FullName); + + AxHost.ClsidAttribute guid = (AxHost.ClsidAttribute)attrs[0]; + if (string.Equals(guid.Value, clsid, StringComparison.OrdinalIgnoreCase)) + { + return t; + } + } + + return null; + } + + /// + /// Gets the References collection object from the designer host. The steps are: + /// Get the ProjectItem from the IDesignerHost. + /// Get the Containing Project of the ProjectItem. + /// Get the VSProject of the Containing Project. + /// Get the References property of the VSProject. + /// + private object GetReferences(IDesignerHost host) + { + Debug.Assert(host != null, "Null Designer Host"); + + Type type; + type = Type.GetType("EnvDTE.ProjectItem, " + AssemblyRef.EnvDTE); + + if (type == null) + { + return null; + } + + object ext = host.GetService(type); + if (ext == null) + return null; + + string name = ext.GetType().InvokeMember("Name", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, ext, null, CultureInfo.InvariantCulture).ToString(); + + object project = ext.GetType().InvokeMember("ContainingProject", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, ext, null, CultureInfo.InvariantCulture); + Debug.Assert(project != null, "No DTE Project for the current project item: " + name); + + object vsproject = project.GetType().InvokeMember("Object", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, project, null, CultureInfo.InvariantCulture); + Debug.Assert(vsproject != null, "No VS Project for the current project item: " + name); + + object references = vsproject.GetType().InvokeMember("References", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, vsproject, null, CultureInfo.InvariantCulture); + Debug.Assert(references != null, "No References for the current project item: " + name); + + return references; + } + + /// + /// Gets the TypeLibAttr corresponding to the TLB containing our ActiveX control. + /// + private TYPELIBATTR GetTypeLibAttr() + { + string controlKey = "CLSID\\" + clsid; + RegistryKey key = Registry.ClassesRoot.OpenSubKey(controlKey); + if (key == null) + { + if (AxToolSwitch.TraceVerbose) + Debug.WriteLine("No registry key found for: " + controlKey); + throw new ArgumentException(string.Format(SR.AXNotRegistered, controlKey.ToString())); + } + + // Load the typelib into memory. + // + ITypeLib pTLB = null; + + // Open the key for the TypeLib + // + RegistryKey tlbKey = key.OpenSubKey("TypeLib"); + + if (tlbKey != null) + { + // Get the major and minor version numbers. + // + RegistryKey verKey = key.OpenSubKey("Version"); + Debug.Assert(verKey != null, "No version registry key found for: " + controlKey); + + string ver = (string)verKey.GetValue(""); + int dot = ver.IndexOf('.'); + + short majorVer; + + short minorVer; + if (dot == -1) + { + majorVer = short.Parse(ver, CultureInfo.InvariantCulture); + minorVer = 0; + } + else + { + majorVer = short.Parse(ver.Substring(0, dot), CultureInfo.InvariantCulture); + minorVer = short.Parse(ver.Substring(dot + 1, ver.Length - dot - 1), CultureInfo.InvariantCulture); + } + + Debug.Assert(majorVer > 0 && minorVer >= 0, "No Major version number found for: " + controlKey); + verKey.Close(); + + object o = tlbKey.GetValue(""); + + // Try to get the TypeLib's Guid. + // + var tlbGuid = new Guid((string)o); + Debug.Assert(!tlbGuid.Equals(Guid.Empty), "No valid Guid found for: " + controlKey); + tlbKey.Close(); + + try + { + pTLB = Oleaut32.LoadRegTypeLib(ref tlbGuid, majorVer, minorVer, Application.CurrentCulture.LCID); + } + catch (Exception e) + { + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + } + } + + // Try to load the TLB directly from the InprocServer32. + // + // If that fails, try to load the TLB based on the TypeLib guid key. + // + if (pTLB == null) + { + RegistryKey inprocServerKey = key.OpenSubKey("InprocServer32"); + if (inprocServerKey != null) + { + string inprocServer = (string)inprocServerKey.GetValue(""); + Debug.Assert(inprocServer != null, "No valid InprocServer32 found for: " + controlKey); + inprocServerKey.Close(); + + pTLB = Oleaut32.LoadTypeLib(inprocServer); + } + } + + key.Close(); + + if (pTLB != null) + { + try + { + IntPtr pTlibAttr = NativeMethods.InvalidIntPtr; + pTLB.GetLibAttr(out pTlibAttr); + if (pTlibAttr == NativeMethods.InvalidIntPtr) + throw new ArgumentException(string.Format(SR.AXNotRegistered, controlKey.ToString())); + else + { + // Marshal the returned int as a TLibAttr structure + // + TYPELIBATTR typeLibraryAttributes = (TYPELIBATTR)Marshal.PtrToStructure(pTlibAttr, typeof(TYPELIBATTR)); + pTLB.ReleaseTLibAttr(pTlibAttr); + + return typeLibraryAttributes; + } + } + finally + { + Marshal.ReleaseComObject(pTLB); + } + } + else + { + throw new ArgumentException(string.Format(SR.AXNotRegistered, controlKey.ToString())); + } + } + + /// + /// Saves the state of this 'AxToolboxItem' to + /// the specified serialization info. + /// + protected override void Serialize(SerializationInfo info, StreamingContext context) + { + if (AxToolSwitch.TraceVerbose) + Debug.WriteLine("Serializing AxToolboxItem:" + clsid); + base.Serialize(info, context); + info.AddValue("Clsid", clsid); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs new file mode 100644 index 00000000000..9a3f70bd1d9 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs @@ -0,0 +1,95 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.Reflection; + +namespace System.Windows.Forms.Design +{ + public partial class DocumentDesigner + { + /// + /// Document designer's version of the inheritance service. For UI + /// components, we will allow private controls if those controls are + /// children of our document, since they will be visible. + /// + private class DocumentInheritanceService : InheritanceService + { + private readonly DocumentDesigner designer; + + /// + /// Creates a new document inheritance service. + /// + public DocumentInheritanceService(DocumentDesigner designer) + { + this.designer = designer; + } + + /// + /// Indicates the inherited members to ignore. + /// + protected override bool IgnoreInheritedMember(MemberInfo member, IComponent component) + { + FieldInfo field = member as FieldInfo; + MethodInfo method = member as MethodInfo; + // We allow private members if they are controls on our design surface or + // derive from Menu. + // + bool privateMember; + Type memberType; + if (field != null) + { + privateMember = field.IsPrivate || field.IsAssembly; + memberType = field.FieldType; + } + else if (method != null) + { + privateMember = method.IsPrivate || method.IsAssembly; + memberType = method.ReturnType; + } + else + { + Debug.Fail("Unknown member type passed to IgnoreInheritedMember"); + return true; + } + + if (privateMember) + { + if (typeof(Control).IsAssignableFrom(memberType)) + { + // See if this member is a child of our document... + // + Control child = null; + if (field != null) + { + child = (Control)field.GetValue(component); + } + else if (method != null) + { + child = (Control)method.Invoke(component, null); + } + + Control parent = designer.Control; + + while (child != null && child != parent) + { + child = child.Parent; + } + + // If it is a child of our designer, we don't want to ignore this member. + // + if (child != null) + { + return false; + } + } + } + + return base.IgnoreInheritedMember(member, component); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs index 1957589e9ac..6d92727102e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs @@ -6,8 +6,14 @@ using System.ComponentModel; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; +using System.Diagnostics; +using System.Drawing; using System.Drawing.Design; +using System.IO; +using System.Runtime.InteropServices; using System.Windows.Forms.Design.Behavior; +using Microsoft.Win32; +using static Interop; namespace System.Windows.Forms.Design { @@ -16,39 +22,378 @@ namespace System.Windows.Forms.Design /// IRootDesigner. /// [ToolboxItemFilter("System.Windows.Forms")] - public class DocumentDesigner : ScrollableControlDesigner, IRootDesigner, IToolboxUser, IOleDragClient + public partial class DocumentDesigner : ScrollableControlDesigner, IRootDesigner, IToolboxUser, IOleDragClient { + private DesignerFrame frame; + private ControlCommandSet commandSet; + private InheritanceService inheritanceService; + private EventHandlerService eventHandlerService; + private DesignBindingValueUIHandler designBindingValueUIHandler; + private BehaviorService behaviorService; + private SelectionManager selectionManager; + private DesignerExtenders designerExtenders; + private InheritanceUI inheritanceUI; + private PbrsForward pbrsFwd; + private ArrayList suspendedComponents; + private UndoEngine undoEngine; + private bool initializing; // is the designer initializing? + + //used to keep the state of the tab order view + // + private bool queriedTabOrder; + private MenuCommand tabOrderCommand; + static internal IDesignerSerializationManager manager; + // The component tray + // + private ComponentTray componentTray; + + private int trayHeight = 80; + private bool trayLargeIcon; + private bool trayAutoArrange; + private bool trayLayoutSuspended; + + // ActiveX support + // + private static readonly Guid htmlDesignTime = new Guid("73CEF3DD-AE85-11CF-A406-00AA00C00940"); + + private Hashtable axTools; + private static readonly TraceSwitch AxToolSwitch = new TraceSwitch("AxTool", "ActiveX Toolbox Tracing"); + private const string AxClipFormat = "CLSID"; + private ToolboxItemCreatorCallback toolboxCreator; + + /// + /// Property shadow for ContainerControl's AutoScaleDimenions. We shadow here so it + /// always returns the CurrentAutoScaleDimensions for the control. This way the control's + /// state always adapts to the current font / monitor. + /// + private SizeF AutoScaleDimensions + { + get + { + ContainerControl c = Control as ContainerControl; + if (c != null) + { + return c.CurrentAutoScaleDimensions; + } + + Debug.Fail("AutoScaleDimensions should not be shadowed on non-ContainerControl objects."); + return SizeF.Empty; + } + set + { + ContainerControl c = Control as ContainerControl; + if (c != null) + { + c.AutoScaleDimensions = value; + } + } + } + + /// + /// Property shadow for ContainerControl's AutoScaleMode. We shadow here so it + /// never gets to the control; it can be very distracting if you change the font + /// and have the form you're designing suddenly move on you. + /// + private AutoScaleMode AutoScaleMode + { + get + { + ContainerControl c = Control as ContainerControl; + if (c != null) + { + return c.AutoScaleMode; + } + + Debug.Fail("AutoScaleMode should not be shadowed on non-ContainerControl objects."); + return AutoScaleMode.Inherit; + } + set + { + ShadowProperties[nameof(AutoScaleMode)] = value; + ContainerControl c = Control as ContainerControl; + if (c != null && c.AutoScaleMode != value) + { + c.AutoScaleMode = value; + + // If we're not loading and this changes update + // the current auto scale dimensions. + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host != null && !host.Loading) + { + c.AutoScaleDimensions = c.CurrentAutoScaleDimensions; + } + } + } + } + + /// + /// BackColor property on control. We shadow this property at design time. + /// + private Color BackColor + { + get + { + return Control.BackColor; + } + set + { + ShadowProperties[nameof(BackColor)] = value; + if (value.IsEmpty) + { + value = SystemColors.Control; + } + + Control.BackColor = value; + } + } + + /// + /// Location property on control. We shadow this property at design time. + /// + [DefaultValue(typeof(Point), "0, 0")] + private Point Location + { + get + { + return (Point)ShadowProperties[nameof(Location)]; + } + set + { + ShadowProperties[nameof(Location)] = value; + } + } + /// /// We override our selectino rules to make the document non-sizeable. /// - public override SelectionRules SelectionRules => throw new NotImplementedException(SR.NotImplementedByDesign); + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + rules &= ~(SelectionRules.Moveable | SelectionRules.TopSizeable | SelectionRules.LeftSizeable); - ViewTechnology[] IRootDesigner.SupportedTechnologies => throw new NotImplementedException(); + return rules; + } + } /// - /// Initializes the designer with the given component. The designer can - /// get the component's site and request services from it in this call. + /// Determines if the tab order UI is active. When tab order is active, we don't want to forward + /// any WndProc messages to the menu editor service (those are all non-selectable components) /// - public override void Initialize(IComponent component) + private bool TabOrderActive { - throw new NotImplementedException(SR.NotImplementedByDesign); + get + { + if (!queriedTabOrder) + { + queriedTabOrder = true; + IMenuCommandService menuCommandService = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (menuCommandService != null) + tabOrderCommand = menuCommandService.FindCommand(StandardCommands.TabOrder); + } + + if (tabOrderCommand != null) + { + return tabOrderCommand.Checked; + } + + return false; + } } - object IRootDesigner.GetView(ViewTechnology technology) + /// + /// + [DefaultValue(true)] + private bool TrayAutoArrange { - throw new NotImplementedException(); + get + { + return trayAutoArrange; + } + + set + { + trayAutoArrange = value; + if (componentTray != null) + { + componentTray.AutoArrange = trayAutoArrange; + } + } } - bool IToolboxUser.GetToolSupported(ToolboxItem tool) + /// + /// + [DefaultValue(false)] + private bool TrayLargeIcon { - throw new NotImplementedException(); + get + { + return trayLargeIcon; + } + + set + { + trayLargeIcon = value; + if (componentTray != null) + { + componentTray.ShowLargeIcons = trayLargeIcon; + } + } } - void IToolboxUser.ToolPicked(ToolboxItem tool) + /// + /// + [DefaultValue(80)] + private int TrayHeight { - throw new NotImplementedException(); + get + { + if (componentTray != null) + { + return componentTray.Height; + } + else + { + return trayHeight; + } + } + + set + { + trayHeight = value; + if (componentTray != null) + { + componentTray.Height = trayHeight; + } + } + } + + /// + /// + /// Retrieves the control view instance for the given component. + /// For Win32 designer, this will often be the component itself. + /// + Control IOleDragClient.GetControlForComponent(object component) + { + Control c = GetControl(component); + if (c != null) + return c; + + if (componentTray != null) + { + return ((IOleDragClient)componentTray).GetControlForComponent(component); + } + + return null; + } + + internal virtual bool CanDropComponents(DragEventArgs de) + { + // If there is no tray we bail. + if (componentTray == null) + return true; + + // Figure out if any of the components in the drag-drop are children + // of our own tray. If so, we should prevent this drag-drop from proceeding. + // + OleDragDropHandler ddh = GetOleDragHandler(); + object[] dragComps = ddh.GetDraggingObjects(de); + + if (dragComps != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + for (int i = 0; i < dragComps.Length; i++) + { + IComponent comp = dragComps[i] as IComponent; + if (host == null || dragComps[i] == null || comp == null) + { + continue; + } + + if (componentTray.IsTrayComponent(comp)) + { + return false; + } + } + } + + //ToolStripItems cannot be dropped on any ParentControlDesigners since they have custom DataObject Format. + if (de.Data is ToolStripItemDataObject) + { + return false; + } + + return true; + } + + private ToolboxItem CreateAxToolboxItem(IDataObject dataObject) + { + // Read the stream out of the dataobject and get hold of the CLSID of the Toolbox item. + // + MemoryStream stm = (MemoryStream)dataObject.GetData(AxClipFormat, true); + int len = (int)stm.Length; + byte[] bytes = new byte[len]; + stm.Read(bytes, 0, len); + + string clsid = Text.Encoding.Default.GetString(bytes); + int index = clsid.IndexOf("}"); + clsid = clsid.Substring(0, index + 1); + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "\tCLSID of the Toolbox item: " + clsid); + + // Look to see if we can find the Control key for this CLSID. If present, create a + // new AxToolboxItem and add it to the cache. + // + if (IsSupportedActiveXControl(clsid)) + { + AxToolboxItem tool; + // Look to see if we have already cached the ToolboxItem. + // + if (axTools != null) + { + tool = (AxToolboxItem)axTools[clsid]; + if (tool != null) + { + if (AxToolSwitch.TraceVerbose) + Debug.WriteLine("Found AxToolboxItem in tool cache"); + return tool; + } + } + + tool = new AxToolboxItem(clsid); + if (axTools == null) + { + axTools = new Hashtable(); + } + + axTools.Add(clsid, tool); + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "\tAdded AxToolboxItem"); + return tool; + } + else + { + return null; + } + } + + private ToolboxItem CreateCfCodeToolboxItem(IDataObject dataObject) + { + object serializationData = dataObject.GetData(OleDragDropHandler.NestedToolboxItemFormat, false); + if (serializationData != null) + { + return (ToolboxItem)serializationData; + } + + serializationData = dataObject.GetData(OleDragDropHandler.DataFormat, false); + if (serializationData != null) + { //backcompat + return new OleDragDropHandler.CfCodeToolboxItem(serializationData); + ; + } + + return null; } /// @@ -56,7 +401,175 @@ void IToolboxUser.ToolPicked(ToolboxItem tool) /// protected override void Dispose(bool disposing) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (disposing) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(host != null, "Must have a designer host on dispose"); + + if (host != null) + { + //Remove Adorner Window which hosts DropDowns. + ToolStripAdornerWindowService toolWindow = (ToolStripAdornerWindowService)GetService(typeof(ToolStripAdornerWindowService)); + if (toolWindow != null) + { + toolWindow.Dispose(); + host.RemoveService(typeof(ToolStripAdornerWindowService)); + } + + host.Activated -= new EventHandler(OnDesignerActivate); + host.Deactivated -= new EventHandler(OnDesignerDeactivate); + + // If the tray wasn't destroyed, then we got some sort of inbalance + // in our add/remove calls. Don't sweat it, but do remove the tray. + // + if (componentTray != null) + { + ISplitWindowService sws = (ISplitWindowService)GetService(typeof(ISplitWindowService)); + if (sws != null) + { + sws.RemoveSplitWindow(componentTray); + componentTray.Dispose(); + componentTray = null; + } + + host.RemoveService(typeof(ComponentTray)); + } + + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); + cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + } + + if (undoEngine != null) + { + undoEngine.Undoing -= new EventHandler(OnUndoing); + undoEngine.Undone -= new EventHandler(OnUndone); + } + + if (toolboxCreator != null) + { + IToolboxService toolbox = (IToolboxService)GetService(typeof(IToolboxService)); + Debug.Assert(toolbox != null, "No toolbox service available"); + if (toolbox != null) + { + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Removing DocumentDesigner as CLSID ToolboxItemCreator"); + toolbox.RemoveCreator(AxClipFormat, host); + + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Removing DocumentDesigner as CF_CODE ToolboxItemCreator"); + toolbox.RemoveCreator(OleDragDropHandler.DataFormat, host); + + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Removing DocumentDesigner as CF_TOOLBOXITEM ToolboxItemCreator"); + toolbox.RemoveCreator(OleDragDropHandler.NestedToolboxItemFormat, host); + } + + toolboxCreator = null; + } + } + + ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService)); + if (ss != null) + { + ss.SelectionChanged -= new EventHandler(OnSelectionChanged); + } + + if (behaviorService != null) + { + behaviorService.Dispose(); + behaviorService = null; + } + + if (selectionManager != null) + { + selectionManager.Dispose(); + selectionManager = null; + } + + if (componentTray != null) + { + if (host != null) + { + ISplitWindowService sws = (ISplitWindowService)GetService(typeof(ISplitWindowService)); + if (sws != null) + { + sws.RemoveSplitWindow(componentTray); + } + } + + componentTray.Dispose(); + componentTray = null; + } + + if (pbrsFwd != null) + { + pbrsFwd.Dispose(); + pbrsFwd = null; + } + + if (frame != null) + { + frame.Dispose(); + frame = null; + } + + if (commandSet != null) + { + commandSet.Dispose(); + commandSet = null; + } + + if (inheritanceService != null) + { + inheritanceService.Dispose(); + inheritanceService = null; + } + + if (inheritanceUI != null) + { + inheritanceUI.Dispose(); + inheritanceUI = null; + } + + if (designBindingValueUIHandler != null) + { + IPropertyValueUIService pvUISvc = (IPropertyValueUIService)GetService(typeof(IPropertyValueUIService)); + if (pvUISvc != null) + { + pvUISvc.RemovePropertyValueUIHandler(new PropertyValueUIHandler(designBindingValueUIHandler.OnGetUIValueItem)); + pvUISvc = null; + } + + designBindingValueUIHandler.Dispose(); + designBindingValueUIHandler = null; + } + + if (designerExtenders != null) + { + designerExtenders.Dispose(); + designerExtenders = null; + } + + if (axTools != null) + { + axTools.Clear(); + } + + if (host != null) + { + host.RemoveService(typeof(BehaviorService)); + host.RemoveService(typeof(ToolStripAdornerWindowService)); + host.RemoveService(typeof(SelectionManager)); + host.RemoveService(typeof(IInheritanceService)); + host.RemoveService(typeof(IEventHandlerService)); + host.RemoveService(typeof(IOverlayService)); + host.RemoveService(typeof(ISplitWindowService)); + host.RemoveService(typeof(InheritanceUI)); + } + } + + base.Dispose(disposing); } /// @@ -68,7 +581,149 @@ protected override void Dispose(bool disposing) /// public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) { - throw new NotImplementedException(SR.NotImplementedByDesign); + GlyphCollection glyphs = new GlyphCollection(); + + if (selectionType != GlyphSelectionType.NotSelected) + { + Point loc = BehaviorService.ControlToAdornerWindow((Control)Component); + Rectangle translatedBounds = new Rectangle(loc, ((Control)Component).Size); + bool primarySelection = (selectionType == GlyphSelectionType.SelectedPrimary); + + bool locked = false; + PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["Locked"]; + if (prop != null) + { + locked = (bool)prop.GetValue(Component); + } + + bool autoSize = false; + prop = TypeDescriptor.GetProperties(Component)["AutoSize"]; + if (prop != null) + { + autoSize = (bool)prop.GetValue(Component); + } + + AutoSizeMode mode = AutoSizeMode.GrowOnly; + prop = TypeDescriptor.GetProperties(Component)["AutoSizeMode"]; + if (prop != null) + { + mode = (AutoSizeMode)prop.GetValue(Component); + } + + SelectionRules rules = SelectionRules; + + if (locked) + { + // the lock glyph + glyphs.Add(new LockedHandleGlyph(translatedBounds, primarySelection)); + + //the four locked border glyphs + glyphs.Add(new LockedBorderGlyph(translatedBounds, SelectionBorderGlyphType.Top)); + glyphs.Add(new LockedBorderGlyph(translatedBounds, SelectionBorderGlyphType.Bottom)); + glyphs.Add(new LockedBorderGlyph(translatedBounds, SelectionBorderGlyphType.Left)); + glyphs.Add(new LockedBorderGlyph(translatedBounds, SelectionBorderGlyphType.Right)); + } + + // we check if the control is a form because we only want to disable resizing + // for components that are not Forms. + else if (autoSize && (mode == AutoSizeMode.GrowAndShrink) && !(Control is Form)) + { + //the non-resizeable grab handle + glyphs.Add(new NoResizeHandleGlyph(translatedBounds, rules, primarySelection, null)); + + //the four resizeable border glyphs + glyphs.Add(new NoResizeSelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Top, null)); + glyphs.Add(new NoResizeSelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Bottom, null)); + glyphs.Add(new NoResizeSelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Left, null)); + glyphs.Add(new NoResizeSelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Right, null)); + } + + else + { + glyphs.Add(new GrabHandleGlyph(translatedBounds, GrabHandleGlyphType.MiddleRight, StandardBehavior, primarySelection)); + glyphs.Add(new GrabHandleGlyph(translatedBounds, GrabHandleGlyphType.LowerRight, StandardBehavior, primarySelection)); + glyphs.Add(new GrabHandleGlyph(translatedBounds, GrabHandleGlyphType.MiddleBottom, StandardBehavior, primarySelection)); + glyphs.Add(new SelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Top, null)); + glyphs.Add(new SelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Bottom, StandardBehavior)); + glyphs.Add(new SelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Left, null)); + glyphs.Add(new SelectionBorderGlyph(translatedBounds, rules, SelectionBorderGlyphType.Right, StandardBehavior)); + } + } + + return glyphs; + } + + /// + /// Examines the current selection for a suitable frame designer. This + /// is used when we are creating a new component so we know what control + /// to parent the component to. This will always return a frame designer, + /// and may walk all the way up the control parent chain to this designer + /// if it needs to. + /// + private ParentControlDesigner GetSelectedParentControlDesigner() + { + ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); + ParentControlDesigner parentControlDesigner = null; + + if (s != null) + { + // We first try the primary selection. If that is null + // or isn't a Control, we then walk the set of selected + // objects. Failing all of this, we default to us. + // + object sel = s.PrimarySelection; + + if (sel == null || !(sel is Control)) + { + sel = null; + + ICollection sels = s.GetSelectedComponents(); + + foreach (object obj in sels) + { + if (obj is Control) + { + sel = obj; + break; + } + } + } + + if (sel != null) + { + // Now that we have our currently selected component + // we can walk up the parent chain looking for a frame + // designer. + // + Debug.Assert(sel is Control, "Our logic is flawed - sel should be a Control"); + Control c = (Control)sel; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + if (host != null) + { + while (c != null) + { + ParentControlDesigner designer = host.GetDesigner(c) as ParentControlDesigner; + + if (designer != null) + { + parentControlDesigner = designer; + break; + } + + c = c.Parent; + } + } + } + } + + if (parentControlDesigner == null) + { + parentControlDesigner = this; + } + + return parentControlDesigner; } /// @@ -78,10 +733,341 @@ public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) /// Once a tool is marked as enabled or disabled it may not be /// queried again. /// - [CLSCompliant(false)] protected virtual bool GetToolSupported(ToolboxItem tool) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return true; + } + + /// + /// Initializes the designer with the given component. The designer can + /// get the component's site and request services from it in this call. + /// + public override void Initialize(IComponent component) + { + initializing = true; + base.Initialize(component); + initializing = false; + + // If the back color of the control has not been established, force it to be + // "Control" so it doesn't walk up the parent chain and grab the document window's + // back color. + // + PropertyDescriptor backProp = TypeDescriptor.GetProperties(Component.GetType())["BackColor"]; + if (backProp != null && backProp.PropertyType == typeof(Color) && !backProp.ShouldSerializeValue(Component)) + { + Control.BackColor = SystemColors.Control; + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IExtenderProviderService exps = (IExtenderProviderService)GetService(typeof(IExtenderProviderService)); + if (exps != null) + { + designerExtenders = new DesignerExtenders(exps); + } + + if (host != null) + { + host.Activated += new EventHandler(OnDesignerActivate); + host.Deactivated += new EventHandler(OnDesignerDeactivate); + + ServiceCreatorCallback callback = new ServiceCreatorCallback(OnCreateService); + host.AddService(typeof(IEventHandlerService), callback); + + // M3.2 CONTROL ARRAY IS CUT + + // Create the view for this component. We first create the designer frame so we can provide + // the overlay and split window services, and then later on we initilaize the frame with + // the designer view. + // + frame = new DesignerFrame(component.Site); + + IOverlayService os = frame; + host.AddService(typeof(IOverlayService), os); + host.AddService(typeof(ISplitWindowService), frame); + + behaviorService = new BehaviorService(Component.Site, frame); + host.AddService(typeof(BehaviorService), behaviorService); + + selectionManager = new SelectionManager(host, behaviorService); + + host.AddService(typeof(SelectionManager), selectionManager); + host.AddService(typeof(ToolStripAdornerWindowService), callback); + + // And component add and remove events for our tray + // + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded += new ComponentEventHandler(OnComponentAdded); + cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + } + + // We must do the ineritance scan early, but not so early that we haven't hooked events + // to handle invisible components. We also use the variable "inheritanceService" + // as a check in OnCreateHandle -- we cannot call base.OnCreateHandle if we have + // not done an inheritance scan yet, because this will cause the base control + // class to hook all of the controls we may want to inherit. So, we do the + // scan, assign the variable, and then call OnCreateHandle if needed. + // + inheritanceUI = new InheritanceUI(); + host.AddService(typeof(InheritanceUI), inheritanceUI); + + InheritanceService isvc = new DocumentInheritanceService(this); + host.AddService(typeof(IInheritanceService), isvc); + + manager = host.GetService(typeof(IDesignerSerializationManager)) as IDesignerSerializationManager; + isvc.AddInheritedComponents(component, component.Site.Container); + manager = null; + + inheritanceService = isvc; + if (Control.IsHandleCreated) + { + OnCreateHandle(); + } + + IPropertyValueUIService pvUISvc = (IPropertyValueUIService)component.Site.GetService(typeof(IPropertyValueUIService)); + + if (pvUISvc != null) + { + designBindingValueUIHandler = new DesignBindingValueUIHandler(); + pvUISvc.AddPropertyValueUIHandler(new PropertyValueUIHandler(designBindingValueUIHandler.OnGetUIValueItem)); + } + + // Add the DocumentDesigner as a creator of CLSID toolbox items. + // + IToolboxService toolbox = (IToolboxService)host.GetService(typeof(IToolboxService)); + if (toolbox != null) + { + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Adding DocumentDesigner as CLSID ToolboxItemCreator"); + toolboxCreator = new ToolboxItemCreatorCallback(OnCreateToolboxItem); + toolbox.AddCreator(toolboxCreator, AxClipFormat, host); + toolbox.AddCreator(toolboxCreator, OleDragDropHandler.DataFormat, host); + toolbox.AddCreator(toolboxCreator, OleDragDropHandler.NestedToolboxItemFormat, host); + } + + // Listen for the completed load. When finished, we need to select the form. We don' + // want to do it before we're done, however, or else the dimensions of the selection rectangle + // could be off because during load, change events are not fired. + // + host.LoadComplete += new EventHandler(OnLoadComplete); + } + + // Setup our menu command structure. + // + Debug.Assert(component.Site != null, "Designer host should have given us a site by now."); + commandSet = new ControlCommandSet(component.Site); + + // Finally hook the designer view into the frame. We do this last because the frame may + // cause the control to be created, and if this happens before the inheritance scan we + // will subclass the inherited controls before we get a chance to attach designers. + // + frame.Initialize(Control); + pbrsFwd = new PbrsForward(frame, component.Site); + + // And force some shadow properties that we change in the course of + // initializing the form. + // + Location = new Point(0, 0); + } + + /// + /// Checks to see if the give CLSID is an ActiveX control + /// that we support. This ignores designtime controls. + /// + private bool IsSupportedActiveXControl(string clsid) + { + RegistryKey key = null; + RegistryKey designtimeKey = null; + + try + { + string controlKey = "CLSID\\" + clsid + "\\Control"; + key = Registry.ClassesRoot.OpenSubKey(controlKey); + if (key != null) + { + // ASURT 36817: + // We are not going to support design-time controls for this revision. We use the guids under + // HKCR\Component Categories to decide which categories to avoid. Currently the only one is + // the "HTML Design-time Control" category implemented by VID controls. + // + string category = "CLSID\\" + clsid + "\\Implemented Categories\\{" + htmlDesignTime.ToString() + "}"; + designtimeKey = Registry.ClassesRoot.OpenSubKey(category); + return (designtimeKey == null); + } + + return false; + } + finally + { + if (key != null) + key.Close(); + + if (designtimeKey != null) + designtimeKey.Close(); + } + } + + private void OnUndone(object source, EventArgs e) + { + //resume all suspended comps we found earlier + if (suspendedComponents != null) + { + foreach (Control c in suspendedComponents) + { + c.ResumeLayout(false/*performLayout*/); + c.PerformLayout(); + } + } + } + + private void OnUndoing(object source, EventArgs e) + { + // attempt to suspend all components within the icontainer + // plus the root component's parent. + // + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host != null) + { + IContainer container = host.Container; + if (container != null) + { + suspendedComponents = new ArrayList(container.Components.Count + 1); + + foreach (IComponent comp in container.Components) + { + Control control = comp as Control; + if (control != null) + { + control.SuspendLayout(); + //add this control to our suspended components list so we can resume + //later + suspendedComponents.Add(control); + } + } + + // Also suspend the rooot component's parent. + Control root = host.RootComponent as Control; + if (root != null) + { + Control rootParent = root.Parent; + if (rootParent != null) + { + rootParent.SuspendLayout(); + suspendedComponents.Add(rootParent); + } + } + } + } + } + + /// + /// Called when a component is added to the design container. + /// If the component isn't a control, this will demand create + /// the component tray and add the component to it. + /// + private void OnComponentAdded(object source, ComponentEventArgs ce) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + IComponent component = ce.Component; + + bool addControl = true; + + // This is the mirror to logic in ParentControlDesigner. The component should be + // added somewhere, and this logic decides where. + // + + // LETS SEE IF WE ARE TOOLSTRIP in which case we want to get added + // to the componentTray even though this is a control.. + // We should think of implementing an interface so that we can have many more + // controls behaving like this. + // + ToolStripDesigner td = host.GetDesigner(component) as ToolStripDesigner; + + if (td == null) + { + ControlDesigner cd = host.GetDesigner(component) as ControlDesigner; + if (cd != null) + { + Form form = cd.Control as Form; + if (form == null || !form.TopLevel) + { + addControl = false; + } + } + } + + if (addControl && + TypeDescriptor.GetAttributes(component).Contains(DesignTimeVisibleAttribute.Yes)) + { + if (componentTray == null) + { + ISplitWindowService sws = (ISplitWindowService)GetService(typeof(ISplitWindowService)); + if (sws != null) + { + componentTray = new ComponentTray(this, Component.Site); + sws.AddSplitWindow(componentTray); + + componentTray.Height = trayHeight; + componentTray.ShowLargeIcons = trayLargeIcon; + componentTray.AutoArrange = trayAutoArrange; + + host.AddService(typeof(ComponentTray), componentTray); + } + } + + if (componentTray != null) + { + // Suspend the layout of the tray through the loading + // process. This way, we won't continuosly try to layout + // components in auto arrange mode. We will instead let + // the controls restore themselves to their persisted state + // and then let auto-arrange kick in once. + // + if (host != null && host.Loading && !trayLayoutSuspended) + { + trayLayoutSuspended = true; + componentTray.SuspendLayout(); + } + + componentTray.AddComponent(component); + } + } + } + } + + /// + /// Called when a component is removed from the design container. + /// Here we check to see there are no more components on the tray + /// and if not, we will remove the tray. + /// + private void OnComponentRemoved(object source, ComponentEventArgs ce) + { + // ToolStrip is designableAsControl but has a ComponentTray Entry ... so special case it out. + bool designableAsControl = (ce.Component is Control && !(ce.Component is ToolStrip)) && !(ce.Component is Form && ((Form)ce.Component).TopLevel); + if (!designableAsControl && componentTray != null) + { + componentTray.RemoveComponent(ce.Component); + + if (componentTray.ComponentCount == 0) + { + ISplitWindowService sws = (ISplitWindowService)GetService(typeof(ISplitWindowService)); + if (sws != null) + { + sws.RemoveSplitWindow(componentTray); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + host.RemoveService(typeof(ComponentTray)); + } + + componentTray.Dispose(); + componentTray = null; + } + } + } } /// @@ -90,7 +1076,42 @@ protected virtual bool GetToolSupported(ToolboxItem tool) /// protected override void OnContextMenu(int x, int y) { - throw new NotImplementedException(SR.NotImplementedByDesign); + IMenuCommandService mcs = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (mcs != null) + { + ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService)); + if (selSvc != null) + { + // Here we check to see if we're the only component selected. If not, then + // we'll display the standard component menu. + // + if (selSvc.SelectionCount == 1 && selSvc.GetComponentSelected(Component)) + { + mcs.ShowContextMenu(MenuCommands.ContainerMenu, x, y); + } + + // Try to see if the component selected has a contextMenuStrip to show + else + { + Component selComp = selSvc.PrimarySelection as Component; + if (selComp != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + ComponentDesigner compDesigner = host.GetDesigner(selComp) as ComponentDesigner; + if (compDesigner != null) + { + compDesigner.ShowContextMenu(x, y); + return; + } + } + } + + mcs.ShowContextMenu(MenuCommands.SelectionMenu, x, y); + } + } + } } /// @@ -98,16 +1119,218 @@ protected override void OnContextMenu(int x, int y) /// protected override void OnCreateHandle() { - throw new NotImplementedException(SR.NotImplementedByDesign); + // Don't call base unless our inheritance serivce is already running. + if (inheritanceService != null) + { + base.OnCreateHandle(); + } } /// - /// Determines if a MenuEditorService has already been started. If not, - /// this method will create a new instance of the service. + /// Creates some of the more infrequently used services we offer. /// - protected virtual void EnsureMenuEditorService(IComponent c) + private object OnCreateService(IServiceContainer container, Type serviceType) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (serviceType == typeof(IEventHandlerService)) + { + if (eventHandlerService == null) + { + eventHandlerService = new EventHandlerService(frame); + } + + return eventHandlerService; + } + else if (serviceType == typeof(ToolStripAdornerWindowService)) + { + return new ToolStripAdornerWindowService(Component.Site, frame); + } + + Debug.Fail("Called back to create a service we don't know how to create: " + serviceType.Name); + return null; + } + + /// + /// Called when our document becomes active. We paint our form's + /// border the appropriate color here. + /// + private ToolboxItem OnCreateToolboxItem(object serializedData, string format) + { + Debug.WriteLineIf(AxToolSwitch.TraceVerbose, "Checking to see if: " + format + " is supported."); + + IDataObject dataObject = serializedData as IDataObject; + + if (dataObject == null) + { + Debug.Fail("Toolbox service didn't pass us a data object; that should never happen"); + return null; + } + + // CLSID format. + // + if (format.Equals(AxClipFormat)) + { + return CreateAxToolboxItem(dataObject); + } + + // CF_CODE format + // + if (format.Equals(OleDragDropHandler.DataFormat) || + format.Equals(OleDragDropHandler.NestedToolboxItemFormat)) + { + return CreateCfCodeToolboxItem(dataObject); + } + + return null; + } + + /// + /// Called when our document becomes active. Here we try to + /// select the appropriate toolbox tab. + /// + private void OnDesignerActivate(object source, EventArgs evevent) + { + if (undoEngine == null) + { + undoEngine = GetService(typeof(UndoEngine)) as UndoEngine; + if (undoEngine != null) + { + undoEngine.Undoing += new EventHandler(OnUndoing); + undoEngine.Undone += new EventHandler(OnUndone); + } + } + } + + /// + /// Called by the host when we become inactive. Here we update the + /// title bar of our form so it's the inactive color. + /// + private unsafe void OnDesignerDeactivate(object sender, EventArgs e) + { + Control control = Control; + if (control != null && control.IsHandleCreated) + { + User32.SendMessageW(control.Handle, User32.WM.NCACTIVATE); + User32.RedrawWindow(control.Handle, null, IntPtr.Zero, User32.RDW.FRAME); + } + } + + /// + /// Called when the designer is finished loading. Here we select the form. + /// + private void OnLoadComplete(object sender, EventArgs e) + { + // Remove the handler; we're done looking at this. + // + ((IDesignerHost)sender).LoadComplete -= new EventHandler(OnLoadComplete); + + // Restore the tray layout. + // + if (trayLayoutSuspended && componentTray != null) + componentTray.ResumeLayout(); + + // Select this component. + // + ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService)); + if (ss != null) + { + ss.SelectionChanged += new EventHandler(OnSelectionChanged); + ss.SetSelectedComponents(new object[] { Component }, SelectionTypes.Replace); + Debug.Assert(ss.PrimarySelection == Component, "Bug in selection service: form should have primary selection."); + } + } + + private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + { + Control ctrl = e.Component as Control; + if (ctrl != null && ctrl.IsHandleCreated) + { + User32.NotifyWinEvent((int)AccessibleEvents.LocationChange, new HandleRef(ctrl, ctrl.Handle), User32.OBJID.CLIENT, 0); + if (frame.Focused) + { + User32.NotifyWinEvent((int)AccessibleEvents.Focus, new HandleRef(ctrl, ctrl.Handle), User32.OBJID.CLIENT, 0); + } + } + } + + /// + /// Called by the selection service when the selection has changed. We do a number + /// of selection-related things here. + /// + private void OnSelectionChanged(object sender, EventArgs e) + { + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc != null) + { + ICollection selComponents = svc.GetSelectedComponents(); + + // Setup the correct active accessibility selection / focus data + // + Debug.WriteLineIf(CompModSwitches.MSAA.TraceInfo, "MSAA: SelectionChanged"); + foreach (object selObj in selComponents) + { + Control c = selObj as Control; + if (c != null) + { + Debug.WriteLineIf(CompModSwitches.MSAA.TraceInfo, "MSAA: SelectionAdd, control = " + c.ToString()); + User32.NotifyWinEvent((int)AccessibleEvents.SelectionAdd, new HandleRef(c, c.Handle), User32.OBJID.CLIENT, 0); + } + } + + Control primary = svc.PrimarySelection as Control; + if (primary != null) + { + Debug.WriteLineIf(CompModSwitches.MSAA.TraceInfo, "MSAA: Focus, control = " + primary.ToString()); + User32.NotifyWinEvent((int)AccessibleEvents.Focus, new HandleRef(primary, primary.Handle), User32.OBJID.CLIENT, 0); + } + + // see if there are visual controls selected. If so, we add a context attribute. + // Otherwise, we remove the attribute. We do not count the form. + // + IHelpService hs = (IHelpService)GetService(typeof(IHelpService)); + + if (hs != null) + { + ushort type = 0; + string[] types = new string[] + { + "VisualSelection", + "NonVisualSelection", + "MixedSelection" + }; + + foreach (object obj in selComponents) + { + if (obj is Control) + { + if (obj != Component) + { + type |= 1; + } + } + else + { + type |= 2; + } + + if (type == 3) + { + break; + } + } + + // Remove any prior attribute + // + for (int i = 0; i < types.Length; i++) + { + hs.RemoveContextAttribute("Keyword", types[i]); + } + + if (type != 0) + { + hs.AddContextAttribute("Keyword", types[type - 1], HelpKeywordType.GeneralKeyword); + } + } + } } /// @@ -121,7 +1344,126 @@ protected virtual void EnsureMenuEditorService(IComponent c) /// protected override void PreFilterProperties(IDictionary properties) { - throw new NotImplementedException(SR.NotImplementedByDesign); + PropertyDescriptor prop; + + base.PreFilterProperties(properties); + + // Add any properties that the Tray will persist. + properties["TrayHeight"] = TypeDescriptor.CreateProperty(typeof(DocumentDesigner), "TrayHeight", typeof(int), + BrowsableAttribute.No, + DesignOnlyAttribute.Yes, + new SRDescriptionAttribute("FormDocumentDesignerTraySizeDescr"), + CategoryAttribute.Design); + + properties["TrayLargeIcon"] = TypeDescriptor.CreateProperty(typeof(DocumentDesigner), "TrayLargeIcon", typeof(bool), + BrowsableAttribute.No, + DesignOnlyAttribute.Yes, + CategoryAttribute.Design); + + // Expose the doublebuffered property on control + properties["DoubleBuffered"] = TypeDescriptor.CreateProperty(typeof(Control), "DoubleBuffered", typeof(bool), + BrowsableAttribute.Yes, + DesignOnlyAttribute.No); + + // Handle shadowed properties + // + string[] shadowProps = new string[] + { + "Location", + "BackColor" + }; + + string[] noBrowseProps = new string[] + { + "Anchor", + "Dock", + "TabIndex", + "TabStop", + "Visible" + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + prop = (PropertyDescriptor)properties[shadowProps[i]]; + if (prop != null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(DocumentDesigner), prop, empty); + } + } + + prop = (PropertyDescriptor)properties["AutoScaleDimensions"]; + if (prop != null) + { + properties["AutoScaleDimensions"] = TypeDescriptor.CreateProperty(typeof(DocumentDesigner), prop, DesignerSerializationVisibilityAttribute.Visible); + } + + prop = (PropertyDescriptor)properties["AutoScaleMode"]; + if (prop != null) + { + properties["AutoScaleMode"] = TypeDescriptor.CreateProperty(typeof(DocumentDesigner), prop, DesignerSerializationVisibilityAttribute.Visible, BrowsableAttribute.Yes); + } + + for (int i = 0; i < noBrowseProps.Length; i++) + { + prop = (PropertyDescriptor)properties[noBrowseProps[i]]; + if (prop != null) + { + properties[noBrowseProps[i]] = TypeDescriptor.CreateProperty(prop.ComponentType, prop, BrowsableAttribute.No, DesignerSerializationVisibilityAttribute.Hidden); + } + } + } + + /// + /// Resets the back color to be based on the parent's back color. + /// + private void ResetBackColor() + { + BackColor = Color.Empty; + } + + private bool ShouldSerializeAutoScaleDimensions() + { + // Visual inheritance always adds default + // value attributes that adopt the current values. This + // isn't right for auto scale, however,because we always + // want to write out the auto scale values. So, we have + // to be a bit sleazy here and trick the inheritance engine + // to think that these properties currently have their + // default values. + return !initializing && AutoScaleMode != AutoScaleMode.None && AutoScaleMode != AutoScaleMode.Inherit; + } + + private bool ShouldSerializeAutoScaleMode() + { + // Visual inheritance always adds default + // value attributes that adopt the current values. This + // isn't right for auto scale, however,because we always + // want to write out the auto scale values. So, we have + // to be a bit sleazy here and trick the inheritance engine + // to think that these properties currently have their + // default values. + return !initializing && ShadowProperties.Contains(nameof(AutoScaleMode)); + } + + /// + /// Returns true if the BackColor property should be persisted in code gen. + /// + private bool ShouldSerializeBackColor() + { + // We push Color.Empty into our shadow cash during + // init and also whenever we are reset. We do this + // so we can push a real color into the controls + // back color to stop it from walking the parent chain. + // But, we want it to look like we didn't push a color + // so code gen won't write out "Color.Control" + if (!ShadowProperties.Contains(nameof(BackColor)) || ((Color)ShadowProperties[nameof(BackColor)]).IsEmpty) + { + return false; + } + + return true; } /// @@ -129,19 +1471,110 @@ protected override void PreFilterProperties(IDictionary properties) /// toolbox item. The document designer should create /// a component for the given tool. /// - [CLSCompliant(false)] protected virtual void ToolPicked(ToolboxItem tool) { - throw new NotImplementedException(SR.NotImplementedByDesign); + // If the tab order UI is showing, don't allow us to place a tool. + // + IMenuCommandService mcs = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (mcs != null) + { + MenuCommand cmd = mcs.FindCommand(StandardCommands.TabOrder); + if (cmd != null && cmd.Checked) + { + return; + } + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + host.Activate(); + } + + // Just find the currently selected frame designer and ask it to create the tool. + // + try + { + ParentControlDesigner designer = GetSelectedParentControlDesigner(); + if (!InvokeGetInheritanceAttribute(designer).Equals(InheritanceAttribute.InheritedReadOnly)) + { + InvokeCreateTool(designer, tool); + IToolboxService toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); + if (toolboxService != null) + { + toolboxService.SelectedToolboxItemUsed(); + } + } + } + catch (Exception e) + { + DisplayError(e); + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + } } + /// /// - /// Overrides our base class WndProc to provide support for - /// the menu editor service. + /// The list of technologies that this designer can support + /// for its view. Examples of different technologies are + /// WinForms and Web Forms. Other object models can be + /// supported at design time, but they most be able to + /// provide a view in one of the supported technologies. /// - protected override void WndProc(ref Message m) + ViewTechnology[] IRootDesigner.SupportedTechnologies + { + get + { + return new ViewTechnology[] { ViewTechnology.Default, (ViewTechnology)1 }; + } + } + + /// + /// + /// The view for this document. The designer + /// should assume that the view will be shown shortly + /// after this call is made and make any necessary + /// preparations. + /// + + //We can live with this one. We have obsoleted some of the enum values. This method + //only takes on argument, so it is pretty obvious what argument is bad. + [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")] + object IRootDesigner.GetView(ViewTechnology technology) + { + if (technology != ViewTechnology.Default && technology != (ViewTechnology)1) + { + throw new ArgumentException(); + } + + return frame; + } + + /// + /// Determines if the given tool is supported by this designer. + /// If a tool is supported then it will be enabled in the toolbox + /// when this designer regains focus. Otherwise, it will be disabled. + /// Once a tool is marked as enabled or disabled it may not be + /// queried again. + /// + bool IToolboxUser.GetToolSupported(ToolboxItem tool) + { + return GetToolSupported(tool); + } + + /// + /// + /// Selects the specified tool. + /// + void IToolboxUser.ToolPicked(ToolboxItem tool) { - throw new NotImplementedException(SR.NotImplementedByDesign); + using (DpiHelper.EnterDpiAwarenessScope(User32.DPI_AWARENESS_CONTEXT.SYSTEM_AWARE)) + { + ToolPicked(tool); + } } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs index d3dece13bec..51f0bd09b5a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs @@ -173,7 +173,7 @@ void IWindowsFormsEditorService.DropDownControl(Control control) return; } - System.Windows.Forms.DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) + DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) { IUIService uiSvc = (IUIService)((IServiceProvider)this).GetService(typeof(IUIService)); if (uiSvc != null) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs index 29fe6cca701..5a9ae87db96 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs @@ -19,7 +19,6 @@ namespace System.Windows.Forms.Design internal class FormDocumentDesigner : DocumentDesigner { private Size _autoScaleBaseSize = Size.Empty; - private bool _inAutoscale; private bool _initializing; private bool _autoSize; private ToolStripAdornerWindowService _toolStripAdornerWindowService; @@ -171,7 +170,7 @@ public override IList SnapLines get { ArrayList snapLines = null; - base.AddPaddingSnapLines(ref snapLines); + AddPaddingSnapLines(ref snapLines); if (snapLines is null) { Debug.Fail("why did base.AddPaddingSnapLines return null?"); @@ -262,17 +261,9 @@ private void ApplyAutoScaling(SizeF baseVar, Form form) return; } - float percY = ((float)newVar.Height) / ((float)baseVar.Height); - float percX = ((float)newVar.Width) / ((float)baseVar.Width); - try - { - _inAutoscale = true; - form.Scale(percX, percY); - } - finally - { - _inAutoscale = false; - } + float percY = newVar.Height / ((float)baseVar.Height); + float percX = newVar.Width / ((float)baseVar.Width); + form.Scale(percX, percY); } } @@ -285,6 +276,20 @@ protected override void Dispose(bool disposing) { IDesignerHost host = GetService(); Debug.Assert(host != null, "Must have a designer host on dispose"); + + if (host != null) + { + host.LoadComplete -= new EventHandler(OnLoadComplete); + host.Activated -= new EventHandler(OnDesignerActivate); + host.Deactivated -= new EventHandler(OnDesignerDeactivate); + } + + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); + cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + } } base.Dispose(disposing); @@ -311,12 +316,30 @@ public override void Initialize(IComponent component) base.Initialize(component); _initializing = false; AutoResizeHandles = true; + Debug.Assert(component is Form, "FormDocumentDesigner expects its component to be a form."); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + host.LoadComplete += new EventHandler(OnLoadComplete); + host.Activated += new EventHandler(OnDesignerActivate); + host.Deactivated += new EventHandler(OnDesignerDeactivate); + } + Form form = (Form)Control; form.WindowState = FormWindowState.Normal; ShadowProperties[nameof(AcceptButton)] = form.AcceptButton; ShadowProperties[nameof(CancelButton)] = form.CancelButton; + + // Monitor component/remove add events for our tray + // + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded += new ComponentEventHandler(OnComponentAdded); + cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + } } /// @@ -444,36 +467,5 @@ protected override void PreFilterProperties(IDictionary properties) properties["ClientSize"] = TypeDescriptor.CreateProperty(typeof(FormDocumentDesigner), prop, new DefaultValueAttribute(new Size(-1, -1))); } } - - /// - /// Handles the WM_WINDOWPOSCHANGING message - /// - private unsafe void WmWindowPosChanging(ref Message m) - { - User32.WINDOWPOS* wp = (User32.WINDOWPOS*)m.LParam; - bool updateSize = _inAutoscale; - if (!updateSize) - { - if (TryGetService(out IDesignerHost host)) - { - updateSize = host.Loading; - } - } - } - - /// - /// Overrides our base class WndProc to provide support for the menu editor service. - /// - protected override void WndProc(ref Message m) - { - switch ((User32.WM)m.Msg) - { - case User32.WM.WINDOWPOSCHANGING: - WmWindowPosChanging(ref m); - break; - } - - base.WndProc(ref m); - } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs index 7eb3abeb5ab..564ff71cef3 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs @@ -20,7 +20,7 @@ internal partial class FormatControl : UserControl // static because we want this value to be the same across a // VS session - private static DateTime s_dateTimeFormatValue = DateTime.Now; + private static readonly DateTime s_dateTimeFormatValue = DateTime.Now; private bool _loaded; public FormatControl() @@ -83,9 +83,9 @@ public string NullValue } set { - nullValueTextBox.TextChanged -= new System.EventHandler(nullValueTextBox_TextChanged); + nullValueTextBox.TextChanged -= new EventHandler(nullValueTextBox_TextChanged); nullValueTextBox.Text = value; - nullValueTextBox.TextChanged += new System.EventHandler(nullValueTextBox_TextChanged); + nullValueTextBox.TextChanged += new EventHandler(nullValueTextBox_TextChanged); } } @@ -104,7 +104,7 @@ void customStringTextBox_TextChanged(object sender, EventArgs e) Dirty = true; } - private void dateTimeFormatsListBox_SelectedIndexChanged(object sender, System.EventArgs e) + private void dateTimeFormatsListBox_SelectedIndexChanged(object sender, EventArgs e) { // recompute the SampleLabel FormatTypeClass item = formatTypeListBox.SelectedItem as FormatTypeClass; @@ -342,7 +342,7 @@ private void UpdateFormatTypeListBoxHeight() private void UpdateFormatTypeListBoxItems() { - dateTimeFormatsListBox.SelectedIndexChanged -= new System.EventHandler(dateTimeFormatsListBox_SelectedIndexChanged); + dateTimeFormatsListBox.SelectedIndexChanged -= new EventHandler(dateTimeFormatsListBox_SelectedIndexChanged); dateTimeFormatsListBox.Items.Clear(); dateTimeFormatsListBox.Items.Add(new DateTimeFormatsListBoxItem(s_dateTimeFormatValue, "d")); dateTimeFormatsListBox.Items.Add(new DateTimeFormatsListBoxItem(s_dateTimeFormatValue, "D")); @@ -354,7 +354,7 @@ private void UpdateFormatTypeListBoxItems() dateTimeFormatsListBox.Items.Add(new DateTimeFormatsListBoxItem(s_dateTimeFormatValue, "T")); dateTimeFormatsListBox.Items.Add(new DateTimeFormatsListBoxItem(s_dateTimeFormatValue, "M")); dateTimeFormatsListBox.SelectedIndex = 0; - dateTimeFormatsListBox.SelectedIndexChanged += new System.EventHandler(dateTimeFormatsListBox_SelectedIndexChanged); + dateTimeFormatsListBox.SelectedIndexChanged += new EventHandler(dateTimeFormatsListBox_SelectedIndexChanged); } private void UpdateTBLHeight() @@ -420,7 +420,7 @@ private void FormatControl_Load(object sender, EventArgs e) UpdateControlVisibility(formatTypeListBox.SelectedItem as FormatTypeClass); sampleLabel.Text = ((formatTypeListBox.SelectedItem) as FormatTypeClass).SampleString; - explanationLabel.Size = new System.Drawing.Size(formatGroupBox.Width - 10, 30); + explanationLabel.Size = new Drawing.Size(formatGroupBox.Width - 10, 30); explanationLabel.Text = ((formatTypeListBox.SelectedItem) as FormatTypeClass).TopLabelString; Dirty = false; @@ -456,8 +456,8 @@ private void FormatControlFinishedLoading() private class DateTimeFormatsListBoxItem { - DateTime value; - string formatString; + readonly DateTime value; + readonly string formatString; public DateTimeFormatsListBoxItem(DateTime value, string formatString) { this.value = value; @@ -567,7 +567,7 @@ public override string ToString() private class NumericFormatType : FormatTypeClass { - FormatControl _owner; + readonly FormatControl _owner; public NumericFormatType(FormatControl owner) { @@ -708,11 +708,11 @@ public override string ToString() private class CurrencyFormatType : FormatTypeClass { - FormatControl _owner; + readonly FormatControl _owner; public CurrencyFormatType(FormatControl owner) { - this._owner = owner; + _owner = owner; } public override string TopLabelString @@ -849,7 +849,7 @@ public override string ToString() private class DateTimeFormatType : FormatTypeClass { - FormatControl _owner; + readonly FormatControl _owner; public DateTimeFormatType(FormatControl owner) { @@ -991,7 +991,7 @@ public override string ToString() private class ScientificFormatType : FormatTypeClass { - FormatControl _owner; + readonly FormatControl _owner; public ScientificFormatType(FormatControl owner) { @@ -1132,7 +1132,7 @@ public override string ToString() private class CustomFormatType : FormatTypeClass { - FormatControl _owner; + readonly FormatControl _owner; public CustomFormatType(FormatControl owner) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs index fb0d04ad1be..67da486a3ee 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs @@ -11,7 +11,7 @@ namespace System.Windows.Forms.Design internal class FormatStringDialog : Form { // we need the context for the HELP service provider - private ITypeDescriptorContext _context; + private readonly ITypeDescriptorContext _context; private Button _cancelButton; private Button _okButton; private FormatControl _formatControl1; @@ -24,7 +24,7 @@ public FormatStringDialog(ITypeDescriptorContext context) _context = context; InitializeComponent(); - // Set right to left property according to SR.GetString(SR.RTL) value. + // Set right to left property according to SR.RTL value. string rtlString = SR.RTL; if (rtlString.Equals("RTL_False")) @@ -183,7 +183,7 @@ private void InitializeComponent() _cancelButton.Size = new Drawing.Size(87, 23); _cancelButton.TabIndex = 2; _cancelButton.Text = SR.DataGridView_Cancel; - _cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + _cancelButton.DialogResult = DialogResult.Cancel; _cancelButton.Click += new EventHandler(cancelButton_Click); // // okButton @@ -193,12 +193,12 @@ private void InitializeComponent() _okButton.Size = new Drawing.Size(87, 23); _okButton.TabIndex = 1; _okButton.Text = SR.DataGridView_OK; - _okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + _okButton.DialogResult = DialogResult.OK; _okButton.Click += new EventHandler(okButton_Click); // // Form1 // - AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + AutoScaleMode = AutoScaleMode.Font; AutoScaleDimensions = new Drawing.SizeF(6, 13); ClientSize = new Drawing.Size(396, 295); AutoSize = true; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs new file mode 100644 index 00000000000..1b669015dcb --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs @@ -0,0 +1,144 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// This class handles all design time behavior for the group box class. Group + /// boxes may contain sub-components and therefore use the frame designer. + /// + internal class GroupBoxDesigner : ParentControlDesigner + { + private InheritanceUI inheritanceUI; + + /// + /// Determines the default location for a control added to this designer. + /// it is usualy (0,0), but may be modified if the container has special borders, etc. + /// + protected override Point DefaultControlLocation + { + get + { + GroupBox gb = (GroupBox)Control; + return new Point(gb.DisplayRectangle.X, gb.DisplayRectangle.Y); + } + } + +#if TESTVALUEUI + /// + /// Initializes the designer with the given component. The designer can + /// get the component's site and request services from it in this call. + /// + public override void Initialize(IComponent component) { + base.Initialize(component); + + AutoResizeHandles = true; + + IPropertyValueUIService pvUISvc = (IPropertyValueUIService)component.Site.GetService(typeof(IPropertyValueUIService)); + + if (pvUISvc != null) { + pvUISvc.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnGetUIValueItem)); + } + } + + private void OnGetUIValueItem(object component, PropertyDescriptor propDesc, ArrayList valueUIItemList){ + + if (propDesc.PropertyType == typeof(string)) { + Bitmap bmp = new Bitmap(typeof(GroupBoxDesigner), "BoundProperty.bmp"); + bmp.MakeTransparent(); + valueUIItemList.Add(new LocalUIItem(bmp, new PropertyValueUIItemInvokeHandler(this.OnPropertyValueUIItemInvoke), "Data Can")); + + //bmp = new Bitmap("BoundProperty.bmp"); + valueUIItemList.Add(new LocalUIItem(bmp, new PropertyValueUIItemInvokeHandler(this.OnPropertyValueUIItemInvoke), "Little Button")); + } + + + } + + private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem) { + Debug.Fail("propertyuivalue '" + invokedItem.ToolTip + "' invoked"); + } + +#endif + + /// + /// We override this because even though we still want to + /// offset our grid for our display rectangle, we still want + /// to align to our parent's grid - so we don't look funny + /// + protected override void OnPaintAdornments(PaintEventArgs pe) + { + if (DrawGrid) + { + Control control = Control; + Rectangle rectangle = Control.DisplayRectangle; + + rectangle.Width++; // gpr: FillRectangle with a TextureBrush comes up one pixel short + rectangle.Height++; + ControlPaint.DrawGrid(pe.Graphics, rectangle, GridSize, control.BackColor); + } + + // If this control is being inherited, paint it + // + if (Inherited) + { + if (inheritanceUI == null) + { + inheritanceUI = (InheritanceUI)GetService(typeof(InheritanceUI)); + } + + if (inheritanceUI != null) + { + pe.Graphics.DrawImage(inheritanceUI.InheritanceGlyph, 0, 0); + } + } + } + + /// + /// We override our base class's WndProc here because + /// the group box always returns HTTRANSPARENT. This + /// causes the mouse to go "through" the group box, but + /// that's not what we want at design time. + /// + protected override void WndProc(ref Message m) + { + switch (m.Msg) + { + case (int)User32.WM.NCHITTEST: + // The group box always fires HTTRANSPARENT, which + // causes the message to go to our parent. We want + // the group box's designer to get these messages, however, + // so change this. + // + base.WndProc(ref m); + + if (unchecked((int)(long)m.Result) == (int)User32.HT.TRANSPARENT) + { + m.Result = (IntPtr)User32.HT.CLIENT; + } + + break; + + default: + base.WndProc(ref m); + break; + } + } + +#if TESTVALUEUI + + internal class LocalUIItem : PropertyValueUIItem { + private string itemName; + + public LocalUIItem(Image img, PropertyValueUIItemInvokeHandler handler, string itemName) : base(img, handler, itemName) { + this.itemName = itemName; + } + } +#endif + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs index a7e52890b0b..7e5abac1e87 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs @@ -23,7 +23,7 @@ internal class ImageIndexEditor : UITypeEditor protected string imageListPropertyName; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public ImageIndexEditor() { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs index 1719fcb94a8..20d431eb4e2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs @@ -55,7 +55,7 @@ public static ImageListImage ImageListImageFromStream(Stream stream, bool imageI return new ImageListImage((new Icon(stream)).ToBitmap()); } - return new ImageListImage((Bitmap)Bitmap.FromStream(stream)); + return new ImageListImage((Bitmap)Image.FromStream(stream)); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs index 226da16fde5..1360ad7f9c4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs @@ -48,7 +48,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide Type[] imageExtenders = GetImageExtenders(); for (int i = 0; i < imageExtenders.Length; i++) { - var myClass = this.GetType(); + var myClass = GetType(); var editor = (ImageEditor)Activator.CreateInstance(imageExtenders[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs new file mode 100644 index 00000000000..5131c6dbfc0 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs @@ -0,0 +1,162 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Reflection; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// Provides a designer that can design components + /// that extend TextBoxBase. + /// + internal class LabelDesigner : ControlDesigner + { + public LabelDesigner() + { + AutoResizeHandles = true; + } + + /// + /// Adds a baseline SnapLine to the list of SnapLines related + /// to this control. + /// + public override IList SnapLines + { + get + { + ArrayList snapLines = base.SnapLines as ArrayList; + ContentAlignment alignment = ContentAlignment.TopLeft; + + PropertyDescriptor prop; + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(Component); + + if ((prop = props["TextAlign"]) != null) + { + alignment = (ContentAlignment)prop.GetValue(Component); + } + + //a single text-baseline for the label (and linklabel) control + int baseline = DesignerUtils.GetTextBaseline(Control, alignment); + + if ((prop = props["AutoSize"]) != null) + { + if ((bool)prop.GetValue(Component) == false) + { + //Only adjust if AutoSize is false + BorderStyle borderStyle = BorderStyle.None; + if ((prop = props["BorderStyle"]) != null) + { + borderStyle = (BorderStyle)prop.GetValue(Component); + } + + baseline += LabelBaselineOffset(alignment, borderStyle); + } + } + + snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium)); + + // VSWhidbey# 414468 + Label label = Control as Label; + if (label != null && label.BorderStyle == BorderStyle.None) + { + Type type = Type.GetType("System.Windows.Forms.Label"); + if (type != null) + { + MethodInfo info = type.GetMethod("GetLeadingTextPaddingFromTextFormatFlags", BindingFlags.Instance | BindingFlags.NonPublic); + if (info != null) + { + int offset = (int)info.Invoke(Component, null); + bool rtl = (label.RightToLeft == RightToLeft.Yes); + + for (int i = 0; i < snapLines.Count; i++) + { + // remove previous padding snaplines + SnapLine snapLine = snapLines[i] as SnapLine; + if (snapLine != null && snapLine.SnapLineType == (rtl ? SnapLineType.Right : SnapLineType.Left)) + { + snapLine.AdjustOffset(rtl ? -offset : offset); + break; + } + } + } + else + { + Debug.Fail("Who removed GetLeadingTextPaddingFromTextFormatFlags from Label?"); + } + } + } + + return snapLines; + } + } + + private int LabelBaselineOffset(ContentAlignment alignment, BorderStyle borderStyle) + { + if (((alignment & DesignerUtils.AnyMiddleAlignment) != 0) || + ((alignment & DesignerUtils.AnyTopAlignment) != 0)) + { + if (borderStyle == BorderStyle.None) + { + return 0; + } + else if ((borderStyle == BorderStyle.FixedSingle) || (borderStyle == BorderStyle.Fixed3D)) + { + return 1; + } + else + { + Debug.Fail("Unknown BorderStyle"); + return 0; + } + } + else + {//bottom alignment + if (borderStyle == BorderStyle.None) + { + return -1; + } + else if ((borderStyle == BorderStyle.FixedSingle) || (borderStyle == BorderStyle.Fixed3D)) + { + return 0; + } + else + { + Debug.Fail("Unknown BorderStyle"); + return 0; + } + } + } + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + object component = Component; + + PropertyDescriptor propAutoSize = TypeDescriptor.GetProperties(component)["AutoSize"]; + if (propAutoSize != null) + { + bool autoSize = (bool)propAutoSize.GetValue(component); + + if (autoSize) + rules &= ~SelectionRules.AllSizeable; + } + + return rules; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs index 989a3f663c5..5ea4ebb65d6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs @@ -76,7 +76,7 @@ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext contex => UITypeEditorEditStyle.Modal; /// - /// Dialog box for the link area. + /// Dialog box for the link area. /// internal class LinkAreaUI : Form { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs new file mode 100644 index 00000000000..eb951dd44b3 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs @@ -0,0 +1,234 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Collections; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// This class handles all design time behavior for the list box class. + /// It adds a sample item to the list box at design time. + /// + internal class ListBoxDesigner : ControlDesigner + { + private DesignerActionListCollection _actionLists; + + public bool IntegralHeight + { + get + { + return (bool)ShadowProperties[nameof(IntegralHeight)]; + } + set + { + ShadowProperties[nameof(IntegralHeight)] = value; + + ListBox listBox = (ListBox)Component; + if ((listBox.Dock != DockStyle.Fill) && + (listBox.Dock != DockStyle.Left) && + (listBox.Dock != DockStyle.Right)) + { + listBox.IntegralHeight = value; + } + } + } + + public DockStyle Dock + { + get + { + return ((ListBox)Component).Dock; + } + set + { + ListBox listBox = (ListBox)Component; + if ((value == DockStyle.Fill) || (value == DockStyle.Left) || (value == DockStyle.Right)) + { + // VSO 159543 + // Allow partial listbox item displays so that we don't try to resize the listbox after we dock. + listBox.IntegralHeight = false; + listBox.Dock = value; + } + else + { + listBox.Dock = value; + // VSO 159543 + // Restore the IntegralHeight after we dock. Order is necessary here. Setting IntegralHeight will + // potentially resize the control height, but we don't want to base the height on the dock. + // Instead, undock the control first, so the IntegralHeight is based on the restored size. + listBox.IntegralHeight = (bool)ShadowProperties[nameof(IntegralHeight)]; + } + } + } + + protected override void PreFilterProperties(IDictionary properties) + { + PropertyDescriptor integralHeightProp = (PropertyDescriptor)properties["IntegralHeight"]; + if (integralHeightProp != null) + { + properties["IntegralHeight"] = TypeDescriptor.CreateProperty(typeof(ListBoxDesigner), integralHeightProp, Array.Empty()); + } + + PropertyDescriptor dockProp = (PropertyDescriptor)properties["Dock"]; + if (dockProp != null) + { + properties["Dock"] = TypeDescriptor.CreateProperty(typeof(ListBoxDesigner), dockProp, Array.Empty()); + } + + base.PreFilterProperties(properties); + } + + /// + /// Destroys this designer. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + // Now, hook the component rename event so we can update the text in the + // list box. + // + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); + cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + } + } + + base.Dispose(disposing); + } + + /// + /// Called by the host when we're first initialized. + /// + public override void Initialize(IComponent component) + { + base.Initialize(component); + + ListBox listBox = component as ListBox; + if (null != listBox) + IntegralHeight = listBox.IntegralHeight; + + AutoResizeHandles = true; + + // Now, hook the component rename event so we can update the text in the + // list box. + // + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); + cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + } + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + // in Whidbey, formattingEnabled is true + ((ListBox)Component).FormattingEnabled = true; + + // VSWhidbey 497239 - Setting FormattingEnabled clears the text we set in + // OnCreateHandle so let's set it here again. We need to keep setting the text in + // OnCreateHandle, otherwise we introduce VSWhidbey 498162. + PropertyDescriptor nameProp = TypeDescriptor.GetProperties(Component)["Name"]; + if (nameProp != null) + { + UpdateControlName(nameProp.GetValue(Component).ToString()); + } + } + + /// + /// Raised when a component's name changes. Here we update the contents of the list box + /// if we are displaying the component's name in it. + /// + private void OnComponentRename(object sender, ComponentRenameEventArgs e) + { + if (e.Component == Component) + { + UpdateControlName(e.NewName); + } + } + + /// + /// Raised when ComponentChanges. We listen to this to check if the "Items" propertychanged. + /// and if so .. then update the Text within the ListBox. + /// + private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + { + if (e.Component == Component && e.Member != null && e.Member.Name == "Items") + { + PropertyDescriptor nameProp = TypeDescriptor.GetProperties(Component)["Name"]; + if (nameProp != null) + { + UpdateControlName(nameProp.GetValue(Component).ToString()); + } + } + } + + /// + /// This is called immediately after the control handle has been created. + /// + protected override void OnCreateHandle() + { + base.OnCreateHandle(); + PropertyDescriptor nameProp = TypeDescriptor.GetProperties(Component)["Name"]; + if (nameProp != null) + { + UpdateControlName(nameProp.GetValue(Component).ToString()); + } + } + + /// + /// Updates the name being displayed on this control. This will do nothing if + /// the control has items in it. + /// + private void UpdateControlName(string name) + { + ListBox lb = (ListBox)Control; + if (lb.IsHandleCreated && lb.Items.Count == 0) + { + User32.SendMessageW(lb, (User32.WM)User32.LB.RESETCONTENT); + User32.SendMessageW(lb, (User32.WM)User32.LB.ADDSTRING, IntPtr.Zero, name); + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + if (Component is CheckedListBox) + { + _actionLists.Add(new ListControlUnboundActionList(this)); + } + else + { + // TODO: investigate necessity and possibility of porting databinding infra +#if DESIGNER_DATABINDING + // Requires: + // - System.Windows.Forms.Design.DataMemberFieldEditor + // - System.Windows.Forms.Design.DesignBindingConverter + // - System.Windows.Forms.Design.DesignBindingEditor + // + _actionLists.Add(new ListControlBoundActionList(this)); +#else + _actionLists.Add(new ListControlUnboundActionList(this)); +#endif + } + } + + return _actionLists; + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs new file mode 100644 index 00000000000..dd4e71ae309 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal class ListControlUnboundActionList : DesignerActionList + { + private readonly ComponentDesigner _designer; + + public ListControlUnboundActionList(ComponentDesigner designer) : base(designer.Component) + { + _designer = designer; + } + + public void InvokeItemsDialog() + { + EditorServiceContext.EditValue(_designer, Component, "Items"); + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection returnItems = new DesignerActionItemCollection(); + returnItems.Add(new DesignerActionMethodItem(this, "InvokeItemsDialog", + SR.ListControlUnboundActionListEditItemsDisplayName, + SR.ItemsCategoryName, + SR.ListControlUnboundActionListEditItemsDescription, true)); + return returnItems; + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs new file mode 100644 index 00000000000..0511b28ecf4 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; + +namespace System.Windows.Forms.Design +{ + internal class ListViewActionList : DesignerActionList + { + private readonly ComponentDesigner _designer; + public ListViewActionList(ComponentDesigner designer) : base(designer.Component) + { + _designer = designer; + } + + public void InvokeItemsDialog() + { + EditorServiceContext.EditValue(_designer, Component, "Items"); + } + + public void InvokeColumnsDialog() + { + EditorServiceContext.EditValue(_designer, Component, "Columns"); + } + + public void InvokeGroupsDialog() + { + EditorServiceContext.EditValue(_designer, Component, "Groups"); + } + + public View View + { + get + { + return ((ListView)Component).View; + } + set + { + TypeDescriptor.GetProperties(Component)["View"].SetValue(Component, value); + } + } + + public ImageList LargeImageList + { + get + { + return ((ListView)Component).LargeImageList; + } + set + { + TypeDescriptor.GetProperties(Component)["LargeImageList"].SetValue(Component, value); + } + } + + public ImageList SmallImageList + { + get + { + return ((ListView)Component).SmallImageList; + } + set + { + TypeDescriptor.GetProperties(Component)["SmallImageList"].SetValue(Component, value); + } + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionMethodItem(this, "InvokeItemsDialog", + SR.ListViewActionListEditItemsDisplayName, + SR.PropertiesCategoryName, + SR.ListViewActionListEditItemsDescription, true)); + items.Add(new DesignerActionMethodItem(this, "InvokeColumnsDialog", + SR.ListViewActionListEditColumnsDisplayName, + SR.PropertiesCategoryName, + SR.ListViewActionListEditColumnsDescription, true)); + items.Add(new DesignerActionMethodItem(this, "InvokeGroupsDialog", + SR.ListViewActionListEditGroupsDisplayName, + SR.PropertiesCategoryName, + SR.ListViewActionListEditGroupsDescription, true)); + items.Add(new DesignerActionPropertyItem("View", + SR.ListViewActionListViewDisplayName, + SR.PropertiesCategoryName, + SR.ListViewActionListViewDescription)); + items.Add(new DesignerActionPropertyItem("SmallImageList", + SR.ListViewActionListSmallImagesDisplayName, + SR.PropertiesCategoryName, + SR.ListViewActionListSmallImagesDescription)); + items.Add(new DesignerActionPropertyItem("LargeImageList", + SR.ListViewActionListLargeImagesDisplayName, + SR.PropertiesCategoryName, + SR.ListViewActionListLargeImagesDescription)); + return items; + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs new file mode 100644 index 00000000000..3d2a898387a --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs @@ -0,0 +1,213 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Collections; +using System.Drawing; +using System.Runtime.InteropServices; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// This is the designer for the list view control. It implements hit testing for + /// the items in the list view. + /// + internal class ListViewDesigner : ControlDesigner + { + private DesignerActionListCollection _actionLists; + private ComCtl32.HDHITTESTINFO _hdrhit; + private bool _inShowErrorDialog; + + /// + /// + /// Retrieves a list of associated components. These are components that should be incluced in a cut or copy operation on this component. + /// + /// + public override ICollection AssociatedComponents + { + get + { + ListView lv = Control as ListView; + if (lv != null) + { + return lv.Columns; + } + + return base.AssociatedComponents; + } + } + + private bool OwnerDraw + { + get + { + return (bool)ShadowProperties[nameof(OwnerDraw)]; + } + set + { + ShadowProperties[nameof(OwnerDraw)] = value; + } + } + + private View View + { + get + { + return ((ListView)Component).View; + } + set + { + ((ListView)Component).View = value; + if (value == View.Details) + { + HookChildHandles(Control.Handle); + } + } + } + + /// + /// We override GetHitTest to make the header in report view UI-active. + /// + protected override bool GetHitTest(Point point) + { + ListView lv = (ListView)Component; + if (lv.View == View.Details) + { + Point lvPoint = Control.PointToClient(point); + IntPtr hwndList = lv.Handle; + IntPtr hwndHit = User32.ChildWindowFromPointEx(hwndList, lvPoint, User32.CWP.SKIPINVISIBLE); + + if (hwndHit != IntPtr.Zero && hwndHit != hwndList) + { + IntPtr hwndHdr = User32.SendMessageW(hwndList, (User32.WM)ComCtl32.LVM.GETHEADER); + if (hwndHit == hwndHdr) + { + User32.MapWindowPoints(IntPtr.Zero, hwndHdr, ref point, 1); + _hdrhit.pt = point; + User32.SendMessageW(hwndHdr, (User32.WM)ComCtl32.HDM.HITTEST, IntPtr.Zero, ref _hdrhit); + if (_hdrhit.flags == ComCtl32.HHT.ONDIVIDER) + return true; + } + } + } + + return false; + } + + public override void Initialize(IComponent component) + { + ListView lv = (ListView)component; + OwnerDraw = lv.OwnerDraw; + lv.OwnerDraw = false; + lv.UseCompatibleStateImageBehavior = false; + + AutoResizeHandles = true; + + base.Initialize(component); + if (lv.View == View.Details) + { + HookChildHandles(Control.Handle); + } + } + + protected override void PreFilterProperties(IDictionary properties) + { + PropertyDescriptor ownerDrawProp = (PropertyDescriptor)properties["OwnerDraw"]; + + if (ownerDrawProp != null) + { + properties["OwnerDraw"] = TypeDescriptor.CreateProperty(typeof(ListViewDesigner), ownerDrawProp, Array.Empty()); + } + + PropertyDescriptor viewProp = (PropertyDescriptor)properties["View"]; + + if (viewProp != null) + { + properties["View"] = TypeDescriptor.CreateProperty(typeof(ListViewDesigner), viewProp, Array.Empty()); + } + + base.PreFilterProperties(properties); + } + + protected unsafe override void WndProc(ref Message m) + { + switch (m.Msg) + { + case (int)User32.WM.NOTIFY: + case (int)User32.WM.REFLECT_NOTIFY: + User32.NMHDR* nmhdr = (User32.NMHDR*)m.LParam; + if (nmhdr->code == (int)ComCtl32.HDN.ENDTRACKW) + { + // Re-codegen if the columns have been resized + // + try + { + IComponentChangeService componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + componentChangeService.OnComponentChanged(Component, null, null, null); + } + catch (InvalidOperationException ex) + { + if (_inShowErrorDialog) + { + return; + } + + IUIService uiService = (IUIService)Component.Site.GetService(typeof(IUIService)); + _inShowErrorDialog = true; + try + { + ShowErrorDialog(uiService, ex, (ListView)Component); + } + finally + { + _inShowErrorDialog = false; + } + + return; + } + } + + break; + } + + base.WndProc(ref m); + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + _actionLists.Add(new ListViewActionList(this)); + } + + return _actionLists; + } + } + + private static void ShowErrorDialog(IUIService uiService, Exception ex, Control control) + { + if (uiService != null) + { + uiService.ShowError(ex); + } + else + { + string message = ex.Message; + if (message == null || message.Length == 0) + { + message = ex.ToString(); + } + + RTLAwareMessageBox.Show(control, message, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, + MessageBoxDefaultButton.Button1, 0); + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs index db082f459eb..f84d092a426 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs @@ -50,12 +50,12 @@ private string CreateListViewGroupName(ListViewGroupCollection lvgCollection) } int i = 1; - resultName = lvgName + i.ToString(System.Globalization.CultureInfo.CurrentCulture); + resultName = lvgName + i.ToString(Globalization.CultureInfo.CurrentCulture); while (lvgCollection[resultName] != null) { i++; - resultName = lvgName + i.ToString(System.Globalization.CultureInfo.CurrentCulture); + resultName = lvgName + i.ToString(Globalization.CultureInfo.CurrentCulture); } return resultName; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs index 8d97884c722..ef8301e31d4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs @@ -13,7 +13,7 @@ namespace System.Windows.Forms.Design internal class ListViewItemCollectionEditor : CollectionEditor { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public ListViewItemCollectionEditor(Type type) : base(type) { } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs index 8aa164016ee..1e81860c098 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs @@ -17,7 +17,7 @@ internal class ListViewSubItemCollectionEditor : CollectionEditor private ListViewItem.ListViewSubItem _firstSubItem; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public ListViewSubItemCollectionEditor(Type type) : base(type) { } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs index 1298be80fd4..fe6e5abf680 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs @@ -13,8 +13,8 @@ namespace System.Windows.Forms.Design /// internal class MaskDescriptorComparer : IComparer { - private SortOrder _sortOrder; - private SortType _sortType; + private readonly SortOrder _sortOrder; + private readonly SortType _sortType; public enum SortType { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs index 395156ff4ac..ccb90f10af7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs @@ -38,7 +38,7 @@ public MaskDescriptorTemplate(string mask, string name, string sample, Type vali string msg; - if (!MaskDescriptor.IsValidMaskDescriptor(this, out msg)) + if (!IsValidMaskDescriptor(this, out msg)) { // Don't throw here, callers should check the Mask property for validity. See the ValidMaskDescriptorList below. _mask = null; @@ -74,7 +74,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu //case "en-US": // English US. case "en": // English. // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("00000", "Numeric (5-digits)", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("00000", "Numeric (5-digits)", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("(999) 000-0000", "Phone number", "5745550123", null, culture)); // Phone Number No Area Code. @@ -128,7 +128,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu // Special-case date sample format for French-Canada. string dateSample = culture.Name == "fr-CA" ? "11282005" : "28112005"; // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("99999", "Numérique (5 chiffres)", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("99999", "Numérique (5 chiffres)", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("00 00 00 00 00 00", "Numéro de téléphone (France)", "0123456789", null, culture)); // Short Date. @@ -146,7 +146,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu //case "it-IT": // Italian Italy. case "it": // Italian. // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("99999", "Numerico (5 Cifre)", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("99999", "Numerico (5 Cifre)", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("0000 00000", "Numero di telefono", "012345678", null, culture)); // Mobile Phone Number. @@ -164,7 +164,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu //case "es-ES": // Spanish Spain. case "es": // Spanish. // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("99999", "Numérico", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("99999", "Numérico", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("(999)000-0000", "Número de teléfono", "0123456789", null, culture)); // Mobile Phone Number. @@ -186,7 +186,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu //case "ja-JP": // Japanese. case "ja": // Japanese. // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("99999", "数値(5桁)", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("99999", "数値(5桁)", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("99900-9990-0000", "電話番号", " 012- 345-6789", null, culture)); // Mobile Phone Number. @@ -219,7 +219,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu case "zh-CHS": // Simplified Chinese. case "zh-Hans": // New name of Simplified Chinese. // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("99999", "数字(最长5位)", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("99999", "数字(最长5位)", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("(900)9000-0000", "(区号)电话号码", " 1234567890", null, culture)); // Phone Number No Area Code. @@ -274,7 +274,7 @@ public static List GetLocalizedMaskDescriptors(CultureInfo cultu //case "ko-KR": // Korean. case "ko": // Korean. // Numeric. - maskDescriptors.Add(new MaskDescriptorTemplate("99999", "숫자(5자리)", "12345", typeof(Int32), culture)); + maskDescriptors.Add(new MaskDescriptorTemplate("99999", "숫자(5자리)", "12345", typeof(int), culture)); // Phone Number. maskDescriptors.Add(new MaskDescriptorTemplate("(999)9000-0000", "전화 번호", "01234567890", null, culture)); // Mobile Phone Number. diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs index e684338ed2b..76ee3ef6275 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs @@ -607,7 +607,7 @@ private void listViewCannedMasks_SelectedIndexChanged(object sender, EventArgs e } int selectedIndex = _listViewCannedMasks.SelectedIndices[0]; - MaskDescriptor maskDescriptor = (MaskDescriptor)_maskDescriptors[selectedIndex]; + MaskDescriptor maskDescriptor = _maskDescriptors[selectedIndex]; // If one of the canned mask descriptors chosen, update test control. if (maskDescriptor != _customMaskDescriptor) @@ -643,9 +643,9 @@ private string HelpTopic } /// - /// - /// Called when the help button is clicked. - /// + /// + /// Called when the help button is clicked. + /// /// private void ShowHelp() { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs index 4cb97e98a33..c93c25680fc 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs @@ -64,7 +64,7 @@ public override object EditValue(System.ComponentModel.ITypeDescriptorContext co ITypeDiscoveryService discoverySvc = (ITypeDiscoveryService)provider.GetService(typeof(ITypeDiscoveryService)); // fine if service is not found. IUIService uiSvc = (IUIService)provider.GetService(typeof(IUIService)); IHelpService helpService = (IHelpService)provider.GetService(typeof(IHelpService)); - string mask = MaskPropertyEditor.EditMask(discoverySvc, uiSvc, context.Instance as MaskedTextBox, helpService); + string mask = EditMask(discoverySvc, uiSvc, context.Instance as MaskedTextBox, helpService); if (mask != null) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs index fe80dd67414..446f98b4c6e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs @@ -146,13 +146,13 @@ private void OnVerbSetMask(object sender, EventArgs e) } /// - /// Allows a designer to filter the set of properties - /// the component it is designing will expose through the - /// TypeDescriptor object. This method is called - /// immediately before its corresponding "Post" method. - /// If you are overriding this method you should call - /// the base implementation before you perform your own - /// filtering. + /// Allows a designer to filter the set of properties + /// the component it is designing will expose through the + /// TypeDescriptor object. This method is called + /// immediately before its corresponding "Post" method. + /// If you are overriding this method you should call + /// the base implementation before you perform your own + /// filtering. /// protected override void PreFilterProperties(IDictionary properties) { @@ -230,10 +230,10 @@ private char PasswordChar /// /// Shadow the Text property to do two things: - /// 1. Always show the text without prompt or literals. - /// 2. The text from the UITypeEditor is assigned escaping literals, prompt and spaces, this is to allow for partial inputs. - /// Observe that if the MTB is hooked to a PropertyBrowser at design time, shadowing of the property won't work unless the - /// application is a well written control designer (implements corresponding interfaces). + /// 1. Always show the text without prompt or literals. + /// 2. The text from the UITypeEditor is assigned escaping literals, prompt and spaces, this is to allow for partial inputs. + /// Observe that if the MTB is hooked to a PropertyBrowser at design time, shadowing of the property won't work unless the + /// application is a well written control designer (implements corresponding interfaces). /// private string Text { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs index d5ebc1dd1d1..80575485d25 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs @@ -46,11 +46,11 @@ public MaskedTextBoxTextEditorDropDown(MaskedTextBox maskedTextBox) // Controls.Add(_cloneMtb); - BackColor = System.Drawing.SystemColors.Control; + BackColor = Drawing.SystemColors.Control; BorderStyle = BorderStyle.FixedSingle; Name = "MaskedTextBoxTextEditorDropDown"; Padding = new Padding(16); - Size = new System.Drawing.Size(100, 52); + Size = new Drawing.Size(100, 52); ((System.ComponentModel.ISupportInitialize)(_errorProvider)).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs index c428978f54b..6c823053a47 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs @@ -64,7 +64,7 @@ protected override void OnOpening(CancelEventArgs e) // We dont want the runtime behavior for this Design Time only DropDown and hence we overide the ProcessDialogKey and just close the DropDown instead of running through the runtime implementation for RIGHT/LEFT Keys which ends up setting ModalMenuFilter. protected override bool ProcessDialogKey(Keys keyData) { - Keys keyCode = (Keys)keyData & Keys.KeyCode; + Keys keyCode = keyData & Keys.KeyCode; switch (keyCode) { case Keys.Left: diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs new file mode 100644 index 00000000000..8b2967cdf7d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs @@ -0,0 +1,188 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Design; +using System.Globalization; +using System.Runtime.Serialization; + +namespace System.Windows.Forms.Design +{ + internal partial class OleDragDropHandler + { + [Serializable] // designer related + internal class CfCodeToolboxItem : ToolboxItem + { + private object _serializationData; + private static int s_template; + private bool _displayNameSet; + + public CfCodeToolboxItem(object serializationData) : base() + { + this._serializationData = serializationData; + } + + private CfCodeToolboxItem(SerializationInfo info, StreamingContext context) + { + Deserialize(info, context); + } + + /// + /// + public void SetDisplayName() + { + if (!_displayNameSet) + { + _displayNameSet = true; + DisplayName = "Template" + (++s_template).ToString(CultureInfo.CurrentCulture); + } + } + + /// + /// Saves the state of this to + /// the specified serialization info. + /// + protected override void Serialize(SerializationInfo info, StreamingContext context) + { + base.Serialize(info, context); + if (_serializationData != null) + { + info.AddValue("CfCodeToolboxItem.serializationData", _serializationData); + } + } + + /// + /// Loads the state of this + /// from the stream. + /// + protected override void Deserialize(SerializationInfo info, StreamingContext context) + { + base.Deserialize(info, context); + + foreach (SerializationEntry entry in info) + { + if (entry.Name == "CfCodeToolboxItem.serializationData") + { + _serializationData = entry.Value; + break; + } + } + } + + protected override IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues) + { + IDesignerSerializationService ds = (IDesignerSerializationService)host.GetService(typeof(IDesignerSerializationService)); + if (ds == null) + { + return null; + } + + // Deserialize to components collection + // + ICollection objects = ds.Deserialize(_serializationData); + ArrayList components = new ArrayList(); + foreach (object obj in objects) + { + if (obj != null && obj is IComponent) + { + components.Add(obj); + } + } + + IComponent[] componentsArray = new IComponent[components.Count]; + components.CopyTo(componentsArray, 0); + + ArrayList trayComponents = null; + + // Parent and locate each Control + // + if (defaultValues == null) + defaultValues = new Hashtable(); + Control parentControl = defaultValues["Parent"] as Control; + if (parentControl != null) + { + ParentControlDesigner parentControlDesigner = host.GetDesigner(parentControl) as ParentControlDesigner; + if (parentControlDesigner != null) + { + // Determine bounds of all controls + // + Rectangle bounds = Rectangle.Empty; + + foreach (IComponent component in componentsArray) + { + Control childControl = component as Control; + + if (childControl != null && childControl != parentControl && childControl.Parent == null) + { + if (bounds.IsEmpty) + { + bounds = childControl.Bounds; + } + else + { + bounds = Rectangle.Union(bounds, childControl.Bounds); + } + } + } + + defaultValues.Remove("Size"); // don't care about the drag size + foreach (IComponent component in componentsArray) + { + Control childControl = component as Control; + Form form = childControl as Form; + if (childControl != null + && !(form != null && form.TopLevel) // Don't add top-level forms + && childControl.Parent == null) + { + defaultValues["Offset"] = new Size(childControl.Bounds.X - bounds.X, childControl.Bounds.Y - bounds.Y); + parentControlDesigner.AddControl(childControl, defaultValues); + } + } + } + } + + // VSWhidbey 516338 - When creating an item for the tray, template items will have + // an old location stored in them, so they may show up on top of other items. + // So we need to call UpdatePastePositions for each one to get the tray to + // arrange them properly. + // + ComponentTray tray = (ComponentTray)host.GetService(typeof(ComponentTray)); + + if (tray != null) + { + foreach (IComponent component in componentsArray) + { + ComponentTray.TrayControl c = tray.GetTrayControlFromComponent(component); + + if (c != null) + { + if (trayComponents == null) + { + trayComponents = new ArrayList(); + } + + trayComponents.Add(c); + } + } + + if (trayComponents != null) + { + tray.UpdatePastePositions(trayComponents); + } + } + + return componentsArray; + } + + protected override IComponent[] CreateComponentsCore(IDesignerHost host) + { + return CreateComponentsCore(host, null); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs new file mode 100644 index 00000000000..e173217e08c --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs @@ -0,0 +1,359 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel.Design.Serialization; +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; + +namespace System.Windows.Forms.Design +{ + internal partial class OleDragDropHandler + { + protected class ComponentDataObject : IDataObject + { + private readonly IServiceProvider serviceProvider; + private object[] components; + + private Stream serializationStream; + private object serializationData; + private readonly int initialX; + private readonly int initialY; + private readonly IOleDragClient dragClient; + private CfCodeToolboxItem toolboxitemdata; + + public ComponentDataObject(IOleDragClient dragClient, IServiceProvider sp, object[] comps, int x, int y) + { + serviceProvider = sp; + components = GetComponentList(comps, null, -1); + initialX = x; + initialY = y; + this.dragClient = dragClient; + } + + public ComponentDataObject(IOleDragClient dragClient, IServiceProvider sp, object serializationData) + { + serviceProvider = sp; + this.serializationData = serializationData; + this.dragClient = dragClient; + } + + private Stream SerializationStream + { + get + { + if (serializationStream == null && Components != null) + { + IDesignerSerializationService ds = (IDesignerSerializationService)serviceProvider.GetService(typeof(IDesignerSerializationService)); + if (ds != null) + { + object[] comps = new object[components.Length]; + for (int i = 0; i < components.Length; i++) + { + Debug.Assert(components[i] is IComponent, "Item " + components[i].GetType().Name + " is not an IComponent"); + comps[i] = (IComponent)components[i]; + } + + object sd = ds.Serialize(comps); + serializationStream = new MemoryStream(); + BinaryFormatter formatter = new BinaryFormatter(); +#pragma warning disable SYSLIB0011 // Type or member is obsolete + formatter.Serialize(serializationStream, sd); +#pragma warning restore SYSLIB0011 // Type or member is obsolete + serializationStream.Seek(0, SeekOrigin.Begin); + } + } + + return serializationStream; + } + } + + public object[] Components + { + get + { + if (components == null && (serializationStream != null || serializationData != null)) + { + Deserialize(null, false); + if (components == null) + { + return Array.Empty(); + } + } + + return (object[])components.Clone(); + } + } + + /// + /// computes the IDataObject which constitutes this whole toolboxitem for storage in the toolbox. + /// + private CfCodeToolboxItem NestedToolboxItem + { + get + { + if (toolboxitemdata == null) + { + toolboxitemdata = new CfCodeToolboxItem(GetData(DataFormat)); + } + + return toolboxitemdata; + } + } + + /// + /// Used to retrieve the selection for a copy. The default implementation + /// retrieves the current selection. + /// + private object[] GetComponentList(object[] components, ArrayList list, int index) + { + if (serviceProvider == null) + { + return components; + } + + ISelectionService selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService)); + + if (selSvc == null) + { + return components; + } + + ICollection selectedComponents; + if (components == null) + selectedComponents = selSvc.GetSelectedComponents(); + else + selectedComponents = new ArrayList(components); + + IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); + if (host != null) + { + ArrayList copySelection = new ArrayList(); + foreach (IComponent comp in selectedComponents) + { + copySelection.Add(comp); + GetAssociatedComponents(comp, host, copySelection); + } + + selectedComponents = copySelection; + } + + object[] comps = new object[selectedComponents.Count]; + selectedComponents.CopyTo(comps, 0); + return comps; + } + + private void GetAssociatedComponents(IComponent component, IDesignerHost host, ArrayList list) + { + ComponentDesigner designer = host.GetDesigner(component) as ComponentDesigner; + if (designer == null) + { + return; + } + + foreach (IComponent childComp in designer.AssociatedComponents) + { + list.Add(childComp); + GetAssociatedComponents(childComp, host, list); + } + } + + public virtual object GetData(string format) + { + return GetData(format, false); + } + + public virtual object GetData(string format, bool autoConvert) + { + if (format.Equals(DataFormat)) + { + BinaryFormatter formatter = new BinaryFormatter(); + SerializationStream.Seek(0, SeekOrigin.Begin); +#pragma warning disable SYSLIB0011 // Type or member is obsolete + return formatter.Deserialize(SerializationStream); +#pragma warning restore SYSLIB0011 // Type or member is obsolete + } + else if (format.Equals(NestedToolboxItemFormat)) + { + NestedToolboxItem.SetDisplayName(); + return NestedToolboxItem; + } + + return null; + } + + public virtual object GetData(Type t) + { + return GetData(t.FullName); + } + + /// + /// If the there is data store in the data object associated with + /// format this will return true. + /// + public bool GetDataPresent(string format, bool autoConvert) + { + return Array.IndexOf(GetFormats(), format) != -1; + } + + /// + /// If the there is data store in the data object associated with + /// format this will return true. + /// + public bool GetDataPresent(string format) + { + return GetDataPresent(format, false); + } + + /// + /// If the there is data store in the data object associated with + /// format this will return true. + /// + public bool GetDataPresent(Type format) + { + return GetDataPresent(format.FullName, false); + } + + /// + /// Retrieves a list of all formats stored in this data object. + /// + public string[] GetFormats(bool autoConvert) + { + return GetFormats(); + } + + /// + /// Retrieves a list of all formats stored in this data object. + /// + public string[] GetFormats() + { + return new string[] { NestedToolboxItemFormat, DataFormat, DataFormats.Serializable, ExtraInfoFormat }; + } + + public void Deserialize(IServiceProvider serviceProvider, bool removeCurrentComponents) + { + if (serviceProvider == null) + { + serviceProvider = this.serviceProvider; + } + + IDesignerSerializationService ds = (IDesignerSerializationService)serviceProvider.GetService(typeof(IDesignerSerializationService)); + IDesignerHost host = null; + DesignerTransaction trans = null; + + try + { + if (serializationData == null) + { + BinaryFormatter formatter = new BinaryFormatter(); +#pragma warning disable SYSLIB0011 // Type or member is obsolete + serializationData = formatter.Deserialize(SerializationStream); +#pragma warning restore SYSLIB0011 // Type or member is obsolete + } + + if (removeCurrentComponents && components != null) + { + foreach (IComponent removeComp in components) + { + if (host == null && removeComp.Site != null) + { + host = (IDesignerHost)removeComp.Site.GetService(typeof(IDesignerHost)); + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.DragDropMoveComponents, components.Length)); + } + } + + if (host != null) + { + host.DestroyComponent(removeComp); + } + } + + components = null; + } + + ICollection objects = ds.Deserialize(serializationData); + components = new IComponent[objects.Count]; + IEnumerator e = objects.GetEnumerator(); + int idx = 0; + + while (e.MoveNext()) + { + components[idx++] = (IComponent)e.Current; + } + + // only do top-level components here, + // because other are already parented. + // otherwise, when we process these + // components it's too hard to know what we + // should be reparenting. + ArrayList topComps = new ArrayList(); + for (int i = 0; i < components.Length; i++) + { + if (components[i] is Control) + { + Control c = (Control)components[i]; + if (c.Parent == null) + { + topComps.Add(components[i]); + } + } + else + { + topComps.Add(components[i]); + } + } + + components = topComps.ToArray(); + } + finally + { + if (trans != null) + { + trans.Commit(); + } + } + } + + /// + /// Sets the data to be associated with the specific data format. For + /// a listing of predefined formats see System.Windows.Forms.DataFormats. + /// + public void SetData(string format, bool autoConvert, object data) + { + SetData(format, data); + } + + /// + /// Sets the data to be associated with the specific data format. For + /// a listing of predefined formats see System.Windows.Forms.DataFormats. + /// + public void SetData(string format, object data) + { + throw new Exception(SR.DragDropSetDataError); + } + + /// + /// Sets the data to be associated with the specific data format. + /// + public void SetData(Type format, object data) + { + SetData(format.FullName, data); + } + + /// + /// Stores data in the data object. The format assumed is the + /// class of data + /// + public void SetData(object data) + { + SetData(data.GetType(), data); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs new file mode 100644 index 00000000000..f9b31c2b717 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Windows.Forms.Design +{ + internal partial class OleDragDropHandler + { + // just so we can recognize the ones we create + protected class ComponentDataObjectWrapper : DataObject + { + readonly ComponentDataObject innerData; + + public ComponentDataObjectWrapper(ComponentDataObject dataObject) : base(dataObject) + { + innerData = dataObject; + } + + public ComponentDataObject InnerData + { + get + { + return innerData; + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs index c86fa20ded9..4c45b498660 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs @@ -2,240 +2,1257 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections; using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.Drawing; using System.Drawing.Design; using System.Windows.Forms.Design.Behavior; +using static Interop; namespace System.Windows.Forms.Design { - internal class OleDragDropHandler + internal partial class OleDragDropHandler { - // NOTE: This is only a stub of the .NET Framework OleDragDropHandler. Disabled code that interacted with - // this class is behind #if FEATURE_OLEDRAGDROPHANDLER + // This is a bit that we stuff into the DoDragDrop + // to indicate that the thing that is being dragged should only + // be allowed to be moved in the current DropTarget (e.g. parent designer). + // We use this for interited components that can be modified (e.g. location/size) changed + // but not removed from their parent. + // + protected const int AllowLocalMoveOnly = 0x04000000; - // This is a bit that we stuff into the DoDragDrop to indicate that the thing that is being dragged should - // only be allowed to be moved in the current DropTarget (e.g. parent designer). We use this for interited - // components that can be modified (e.g. location/size) changed but not removed from their parent. + private readonly SelectionUIHandler selectionHandler; + private readonly IServiceProvider serviceProvider; + private readonly IOleDragClient client; + + private bool dragOk; + private bool forceDrawFrames; + private bool localDrag; + private bool localDragInside; + private Point localDragOffset = Point.Empty; + private DragDropEffects localDragEffect; + private object[] dragComps; + private Point dragBase = Point.Empty; + private static bool freezePainting; + private static Hashtable currentDrags; + + private static readonly CodeMarkers codemarkers = CodeMarkers.Instance; - protected const int AllowLocalMoveOnly = 0x04000000; public const string CF_CODE = "CF_XMLCODE"; public const string CF_COMPONENTTYPES = "CF_COMPONENTTYPES"; public const string CF_TOOLBOXITEM = "CF_NESTEDTOOLBOXITEM"; - public OleDragDropHandler(SelectionUIHandler selectionHandler, IServiceProvider serviceProvider, - IOleDragClient client) + public OleDragDropHandler(SelectionUIHandler selectionHandler, IServiceProvider serviceProvider, IOleDragClient client) { - throw new NotImplementedException(SR.NotImplementedByDesign); + this.serviceProvider = serviceProvider; + this.selectionHandler = selectionHandler; + this.client = client; } - public static string DataFormat => throw new NotImplementedException(SR.NotImplementedByDesign); + public static string DataFormat + { + get + { + return CF_CODE; + } + } - public static string ExtraInfoFormat => throw new NotImplementedException(SR.NotImplementedByDesign); + public static string ExtraInfoFormat + { + get + { + return CF_COMPONENTTYPES; + } + } - public static string NestedToolboxItemFormat => throw new NotImplementedException(SR.NotImplementedByDesign); + public static string NestedToolboxItemFormat + { + get + { + return CF_TOOLBOXITEM; + } + } - public bool Dragging => throw new NotImplementedException(SR.NotImplementedByDesign); + private IComponent GetDragOwnerComponent(IDataObject data) + { + if (currentDrags == null || !currentDrags.Contains(data)) + { + return null; + } - public static bool FreezePainting => throw new NotImplementedException(SR.NotImplementedByDesign); + return currentDrags[data] as IComponent; + } - protected virtual bool CanDropDataObject(IDataObject dataObj) + private static void AddCurrentDrag(IDataObject data, IComponent component) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (currentDrags == null) + { + currentDrags = new Hashtable(); + } + + currentDrags[data] = component; } - /// - /// This is the worker method of all CreateTool methods. It is the only one - /// that can be overridden. - /// - public IComponent[] CreateTool(ToolboxItem tool, Control parent, int x, int y, int width, int height, - bool hasLocation, bool hasSize) + private static void RemoveCurrentDrag(IDataObject data) { - throw new NotImplementedException(SR.NotImplementedByDesign); + currentDrags.Remove(data); } - public IComponent[] CreateTool(ToolboxItem tool, Control parent, int x, int y, int width, int height, - bool hasLocation, bool hasSize, ToolboxSnapDragDropEventArgs e) + internal IOleDragClient Destination { - throw new NotImplementedException(SR.NotImplementedByDesign); + get + { + return client; + } } - public bool DoBeginDrag(object[] components, SelectionRules rules, int initialX, int initialY) + protected virtual bool CanDropDataObject(IDataObject dataObj) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (dataObj != null) + { + if (dataObj is ComponentDataObjectWrapper) + { + object[] dragObjs = GetDraggingObjects(dataObj, true); + if (dragObjs == null) + { + return false; + } + + bool dropOk = true; + for (int i = 0; dropOk && i < dragObjs.Length; i++) + { + dropOk = dropOk && (dragObjs[i] is IComponent) && client.IsDropOk((IComponent)dragObjs[i]); + } + + return dropOk; + } + + try + { + object serializationData = dataObj.GetData(DataFormat, false); + + if (serializationData == null) + { + return false; + } + + IDesignerSerializationService ds = (IDesignerSerializationService)GetService(typeof(IDesignerSerializationService)); + if (ds == null) + { + return false; + } + + ICollection objects = ds.Deserialize(serializationData); + if (objects.Count > 0) + { + bool dropOk = true; + + foreach (object o in objects) + { + if (!(o is IComponent)) + { + continue; + } + + dropOk = dropOk && client.IsDropOk((IComponent)o); + if (!dropOk) + break; + } + + return dropOk; + } + } + catch (Exception ex) + { + // we return false on any exception + if (ClientUtils.IsCriticalException(ex)) + { + throw; + } + } + } + + return false; } - public void DoEndDrag(object[] components, bool cancel) + public bool Dragging { - throw new NotImplementedException(SR.NotImplementedByDesign); + get + { + return localDrag; + } } - public void DoOleDragDrop(DragEventArgs de) + public static bool FreezePainting { - throw new NotImplementedException(SR.NotImplementedByDesign); + get + { + return freezePainting; + } } - public void DoOleDragEnter(DragEventArgs de) + /// + /// This is the worker method of all CreateTool methods. It is the only one + /// that can be overridden. + /// + public IComponent[] CreateTool(ToolboxItem tool, Control parent, int x, int y, int width, int height, bool hasLocation, bool hasSize) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return CreateTool(tool, parent, x, y, width, height, hasLocation, hasSize, null); } - public void DoOleDragLeave() + public IComponent[] CreateTool(ToolboxItem tool, Control parent, int x, int y, int width, int height, bool hasLocation, bool hasSize, ToolboxSnapDragDropEventArgs e) { - throw new NotImplementedException(SR.NotImplementedByDesign); + // Services we will need + // + IToolboxService toolboxSvc = (IToolboxService)GetService(typeof(IToolboxService)); + ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService)); + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IComponent[] comps = Array.Empty(); + + Cursor oldCursor = Cursor.Current; + Cursor.Current = Cursors.WaitCursor; + DesignerTransaction trans = null; + + try + { + try + { + if (host != null) + trans = host.CreateTransaction(string.Format(SR.DesignerBatchCreateTool, tool.ToString())); + } + catch (CheckoutException cxe) + { + if (cxe == CheckoutException.Canceled) + return comps; + + throw; + } + + try + { + try + { + // First check if we are currently in localization mode (i.e., language is non-default). + // If so, we should not permit addition of new components. This is an intentional + // change from Everett - see VSWhidbey #292249. + if (host != null && CurrentlyLocalizing(host.RootComponent)) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + if (uiService != null) + { + uiService.ShowMessage(SR.LocalizingCannotAdd); + } + + comps = Array.Empty(); + return comps; + } + + // Create a dictionary of default values that the designer can + // use to initialize a control with. + Hashtable defaultValues = new Hashtable(); + if (parent != null) + defaultValues["Parent"] = parent; + + // adjust the location if we are in a mirrored parent. That is because the origin + // will then be in the upper right rather than upper left. + if (parent != null && parent.IsMirrored) + { + x += width; + } + + if (hasLocation) + defaultValues["Location"] = new Point(x, y); + if (hasSize) + defaultValues["Size"] = new Size(width, height); + //store off extra behavior drag/drop information + if (e != null) + defaultValues["ToolboxSnapDragDropEventArgs"] = e; + + comps = tool.CreateComponents(host, defaultValues); + } + catch (CheckoutException checkoutEx) + { + if (checkoutEx == CheckoutException.Canceled) + { + comps = Array.Empty(); + } + else + { + throw; + } + } + catch (ArgumentException argumentEx) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + if (uiService != null) + { + uiService.ShowError(argumentEx); + } + } + catch (Exception ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + + string exceptionMessage = string.Empty; + if (ex.InnerException != null) + { + exceptionMessage = ex.InnerException.ToString(); + } + + if (string.IsNullOrEmpty(exceptionMessage)) + { + exceptionMessage = ex.ToString(); + } + + if (ex is InvalidOperationException) + { + exceptionMessage = ex.Message; + } + + if (uiService != null) + { + uiService.ShowError(ex, string.Format(SR.FailedToCreateComponent, tool.DisplayName, exceptionMessage)); + } + else + { + throw; + } + } + + if (comps == null) + { + comps = Array.Empty(); + } + } + finally + { + if (toolboxSvc != null && tool.Equals(toolboxSvc.GetSelectedToolboxItem(host))) + { + toolboxSvc.SelectedToolboxItemUsed(); + } + } + } + finally + { + if (trans != null) + { + trans.Commit(); + } + + Cursor.Current = oldCursor; + } + + // Finally, select the newly created components. + // + if (selSvc != null && comps.Length > 0) + { + if (host != null) + { + host.Activate(); + } + + ArrayList selectComps = new ArrayList(comps); + + for (int i = 0; i < comps.Length; i++) + { + if (!TypeDescriptor.GetAttributes(comps[i]).Contains(DesignTimeVisibleAttribute.Yes)) + { + selectComps.Remove(comps[i]); + } + } + + selSvc.SetSelectedComponents(selectComps.ToArray(), SelectionTypes.Replace); + } + + codemarkers.CodeMarker((int)CodeMarkerEvent.perfFXDesignCreateComponentEnd); + return comps; } - public void DoOleDragOver(DragEventArgs de) + /// + /// Determines whether we are currently in localization mode - i.e., language is not (Default). + /// + private bool CurrentlyLocalizing(IComponent rootComponent) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (rootComponent != null) + { + PropertyDescriptor prop = TypeDescriptor.GetProperties(rootComponent)["Language"]; + + if (prop != null && prop.PropertyType == typeof(Globalization.CultureInfo)) + { + Globalization.CultureInfo ci = (Globalization.CultureInfo)prop.GetValue(rootComponent); + if (!ci.Equals(Globalization.CultureInfo.InvariantCulture)) + { + return true; + } + } + } + + return false; } - public void DoOleGiveFeedback(GiveFeedbackEventArgs e) + private void DisableDragDropChildren(ICollection controls, ArrayList allowDropCache) { - throw new NotImplementedException(SR.NotImplementedByDesign); + foreach (Control c in controls) + { + if (c != null) + { + if (c.AllowDrop) + { + allowDropCache.Add(c); + c.AllowDrop = false; + } + + if (c.HasChildren) + { + DisableDragDropChildren(c.Controls, allowDropCache); + } + } + } } - public object[] GetDraggingObjects(IDataObject dataObj) + private Point DrawDragFrames(object[] comps, + Point oldOffset, DragDropEffects oldEffect, + Point newOffset, DragDropEffects newEffect, + bool drawAtNewOffset) { - throw new NotImplementedException(SR.NotImplementedByDesign); + Control comp; + Control parentControl = client.GetDesignerControl(); + + if (selectionHandler == null) + { + Debug.Fail("selectionHandler should not be null"); + return Point.Empty; + } + + if (comps == null) + { + return Point.Empty; + } + + for (int i = 0; i < comps.Length; i++) + { + comp = client.GetControlForComponent(comps[i]); + + Color backColor = SystemColors.Control; + try + { + backColor = comp.BackColor; + } + catch (Exception ex) + { + if (ClientUtils.IsCriticalException(ex)) + { + throw; + } + } + + // If we are moving, we must make sure that the location property of the component + // is not read only. Otherwise, we can't move the thing. + // + bool readOnlyLocation = true; + + PropertyDescriptor loc = TypeDescriptor.GetProperties(comps[i])["Location"]; + if (loc != null) + { + readOnlyLocation = loc.IsReadOnly; + } + + Rectangle newRect; + // first, undraw the old rect + if (!oldOffset.IsEmpty) + { + if ((oldEffect & DragDropEffects.Move) == 0 || + !readOnlyLocation) + { + newRect = comp.Bounds; + + if (drawAtNewOffset) + { + newRect.X = oldOffset.X; + newRect.Y = oldOffset.Y; + } + else + { + newRect.Offset(oldOffset.X, oldOffset.Y); + } + + newRect = selectionHandler.GetUpdatedRect(comp.Bounds, newRect, false); + DrawReversibleFrame(parentControl.Handle, newRect, backColor); + } + } + + if (!newOffset.IsEmpty) + { + if ((oldEffect & DragDropEffects.Move) == 0 || + !readOnlyLocation) + { + newRect = comp.Bounds; + if (drawAtNewOffset) + { + newRect.X = newOffset.X; + newRect.Y = newOffset.Y; + } + else + { + newRect.Offset(newOffset.X, newOffset.Y); + } + + newRect = selectionHandler.GetUpdatedRect(comp.Bounds, newRect, false); + DrawReversibleFrame(parentControl.Handle, newRect, backColor); + } + } + } + + return newOffset; } - public object[] GetDraggingObjects(DragEventArgs de) + private void DrawReversibleFrame(IntPtr handle, Rectangle rectangle, Color backColor) { - throw new NotImplementedException(SR.NotImplementedByDesign); + //Bug # 71547 to make drag rect visible if any the dimensions of the control are 0 + if (rectangle.Width == 0) + rectangle.Width = 5; + if (rectangle.Height == 0) + rectangle.Height = 5; + + // Copy of ControlPaint.DrawReversibleFrame, see VSWhidbey 581670 + // If ControlPaint ever gets overrloaded, we should replace the code below by calling it: + // ControlPaint.DrawReversibleFrame(handle, rectangle, backColor, FrameStyle.Thick); + + // ------ Duplicate code---------------------------------------------------------- + Gdi32.R2 rop2; + Color graphicsColor; + + if (backColor.GetBrightness() < .5) + { + rop2 = Gdi32.R2.NOTXORPEN; + graphicsColor = Color.White; + } + else + { + rop2 = Gdi32.R2.XORPEN; + graphicsColor = Color.Black; + } + + using var dc = new User32.GetDcScope(handle); + using var pen = new Gdi32.ObjectScope(Gdi32.CreatePen(Gdi32.PS.SOLID, 2, ColorTranslator.ToWin32(backColor))); + + using var rop2Scope = new Gdi32.SetRop2Scope(dc, rop2); + using var brushSelection = new Gdi32.SelectObjectScope(dc, Gdi32.GetStockObject(Gdi32.StockObject.NULL_BRUSH)); + using var penSelection = new Gdi32.SelectObjectScope(dc, pen); + + Gdi32.SetBkColor(dc, ColorTranslator.ToWin32(graphicsColor)); + Gdi32.Rectangle(dc, rectangle.X, rectangle.Y, rectangle.Right, rectangle.Bottom); + // ------ Duplicate code---------------------------------------------------------- } - protected object GetService(Type t) + public bool DoBeginDrag(object[] components, SelectionRules rules, int initialX, int initialY) { - throw new NotImplementedException(SR.NotImplementedByDesign); + // if we're in a sizing operation, or the mouse isn't down, don't do this! + if ((rules & SelectionRules.AllSizeable) != SelectionRules.None || Control.MouseButtons == MouseButtons.None) + { + return true; + } + + Control c = client.GetDesignerControl(); + + localDrag = true; + localDragInside = false; + + dragComps = components; + dragBase = new Point(initialX, initialY); + localDragOffset = Point.Empty; + c.PointToClient(new Point(initialX, initialY)); + + DragDropEffects allowedEffects = DragDropEffects.Copy | DragDropEffects.None | DragDropEffects.Move; + + // check to see if any of the components are inherhited. if so, don't allow them to be moved. + // We replace DragDropEffects.Move with a local bit called AllowLocalMoveOnly which means it + // can be moved around on the current dropsource/target, but not to another target. Since only + // we understand this bit, other drop targets will not allow the move to occur + // + for (int i = 0; i < components.Length; i++) + { + InheritanceAttribute attr = (InheritanceAttribute)TypeDescriptor.GetAttributes(components[i])[typeof(InheritanceAttribute)]; + + if (!attr.Equals(InheritanceAttribute.NotInherited) && !attr.Equals(InheritanceAttribute.InheritedReadOnly)) + { + allowedEffects &= ~DragDropEffects.Move; + allowedEffects |= (DragDropEffects)AllowLocalMoveOnly; + } + } + + DataObject data = new ComponentDataObjectWrapper(new ComponentDataObject(client, serviceProvider, components, initialX, initialY)); + + // We make sure we're painted before we start the drag. Then, we disable window painting to + // ensure that the drag can proceed without leaving artifacts lying around. We should be caling LockWindowUpdate, + // but that causes a horrible flashing because GDI+ uses direct draw. + // + User32.MSG msg = default; + while (User32.PeekMessageW(ref msg, IntPtr.Zero, User32.WM.PAINT, User32.WM.PAINT, User32.PM.REMOVE).IsTrue()) + { + User32.TranslateMessage(ref msg); + User32.DispatchMessageW(ref msg); + } + + // don't do any new painting... + bool oldFreezePainting = freezePainting; + + // asurt 90345 -- this causes some subtle bugs, so i'm turning it off to see if we really need it, and if we do + // if we can find a better way. + // + //freezePainting = true; + + AddCurrentDrag(data, client.Component); + + // Walk through all the children recursively and disable drag-drop + // for each of them. This way, we will not accidentally try to drop + // ourselves into our own children. + // + ArrayList allowDropChanged = new ArrayList(); + foreach (object comp in components) + { + Control ctl = comp as Control; + if (ctl != null && ctl.HasChildren) + { + DisableDragDropChildren(ctl.Controls, allowDropChanged); + } + } + + DragDropEffects effect = DragDropEffects.None; + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + DesignerTransaction trans = null; + if (host != null) + { + trans = host.CreateTransaction(string.Format(SR.DragDropDragComponents, components.Length)); + } + + try + { + effect = c.DoDragDrop(data, allowedEffects); + if (trans != null) + { + trans.Commit(); + } + } + finally + { + RemoveCurrentDrag(data); + + // Reset the AllowDrop for the components being dragged. + // + foreach (Control ctl in allowDropChanged) + { + ctl.AllowDrop = true; + } + + freezePainting = oldFreezePainting; + + if (trans != null) + { + ((IDisposable)trans).Dispose(); + } + } + + bool isMove = (effect & DragDropEffects.Move) != 0 || ((int)effect & AllowLocalMoveOnly) != 0; + + // since the EndDrag will clear this + bool isLocalMove = isMove && localDragInside; + + ISelectionUIService selectionUISvc = (ISelectionUIService)GetService(typeof(ISelectionUIService)); + Debug.Assert(selectionUISvc != null, "Unable to get selection ui service when adding child control"); + + if (selectionUISvc != null) + { + // We must check to ensure that UI service is still in drag mode. It is + // possible that the user hit escape, which will cancel drag mode. + // + if (selectionUISvc.Dragging) + { + // cancel the drag if we aren't doing a local move + selectionUISvc.EndDrag(!isLocalMove); + } + } + + if (!localDragOffset.IsEmpty && effect != DragDropEffects.None) + { + DrawDragFrames(dragComps, localDragOffset, localDragEffect, + Point.Empty, DragDropEffects.None, false); + } + + localDragOffset = Point.Empty; + dragComps = null; + localDrag = localDragInside = false; + dragBase = Point.Empty; + + /*if (!isLocalMove && isMove){ + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IUndoService undoService = (IUndoService)GetService(typeof(IUndoService)); + IActionUnit unit = null; + + if (host != null) { + DesignerTransaction trans = host.CreateTransaction("Drag/drop"); + try{ + // delete the components + try{ + for (int i = 0; i < components.Length; i++){ + if (components[i] is IComponent){ + if (undoService != null){ + unit = new CreateControlActionUnit(host, (IComponent)components[i], true); + } + host.DestroyComponent((IComponent)components[i]); + if (undoService != null){ + undoService.AddAction(unit, false); + } + } + } + }catch(CheckoutException ex){ + if (ex != CheckoutException.Canceled){ + throw ex; + } + } + } + finally{ + trans.Commit(); + } + } + }*/ + + return false; } - protected virtual void OnInitializeComponent(IComponent comp, int x, int y, int width, int height, - bool hasLocation, bool hasSize) + public void DoEndDrag(object[] components, bool cancel) { + dragComps = null; + localDrag = false; + localDragInside = false; } - // just so we can recognize the ones we create - protected class ComponentDataObjectWrapper : DataObject + public void DoOleDragDrop(DragEventArgs de) { - public ComponentDataObjectWrapper(ComponentDataObject dataObject) : base(dataObject) + // ASURT 43757: By the time we come here, it means that the user completed the drag-drop and + // we compute the new location/size of the controls if needed and set the property values. + // We have to stop freezePainting right here, so that controls can get a chance to validate + // their new rects. + // + freezePainting = false; + + if (selectionHandler == null) { - throw new NotImplementedException(SR.NotImplementedByDesign); + Debug.Fail("selectionHandler should not be null"); + de.Effect = DragDropEffects.None; + return; } - public ComponentDataObject InnerData => throw new NotImplementedException(SR.NotImplementedByDesign); - } + // make sure we've actually moved + if ((localDrag && de.X == dragBase.X && de.Y == dragBase.Y) || + de.AllowedEffect == DragDropEffects.None || + (!localDrag && !dragOk)) + { + de.Effect = DragDropEffects.None; + return; + } - protected class ComponentDataObject : IDataObject - { - public ComponentDataObject(IOleDragClient dragClient, IServiceProvider sp, object[] comps, int x, int y) + bool localMoveOnly = ((int)de.AllowedEffect & AllowLocalMoveOnly) != 0 && localDragInside; + + // if we are dragging inside the local dropsource/target, and and AllowLocalMoveOnly flag is set, + // we just consider this a normal move. + // + bool moveAllowed = (de.AllowedEffect & DragDropEffects.Move) != DragDropEffects.None || localMoveOnly; + bool copyAllowed = (de.AllowedEffect & DragDropEffects.Copy) != DragDropEffects.None; + + if ((de.Effect & DragDropEffects.Move) != 0 && !moveAllowed) { - throw new NotImplementedException(SR.NotImplementedByDesign); + // Try copy instead? + de.Effect = DragDropEffects.Copy; } - public ComponentDataObject(IOleDragClient dragClient, IServiceProvider sp, object serializationData) + // make sure the copy is allowed + if ((de.Effect & DragDropEffects.Copy) != 0 && !copyAllowed) { - throw new NotImplementedException(SR.NotImplementedByDesign); + // if copy isn't allowed, don't do anything + + de.Effect = DragDropEffects.None; + return; } - public object[] Components => throw new NotImplementedException(SR.NotImplementedByDesign); + if (localMoveOnly && (de.Effect & DragDropEffects.Move) != 0) + { + de.Effect |= (DragDropEffects)AllowLocalMoveOnly | DragDropEffects.Move; + } + else if ((de.Effect & DragDropEffects.Copy) != 0) + { + de.Effect = DragDropEffects.Copy; + } - public virtual object GetData(string format) + if (forceDrawFrames || localDragInside) { - throw new NotImplementedException(SR.NotImplementedByDesign); + // undraw the drag rect + localDragOffset = DrawDragFrames(dragComps, localDragOffset, localDragEffect, + Point.Empty, DragDropEffects.None, forceDrawFrames); + forceDrawFrames = false; } - public virtual object GetData(string format, bool autoConvert) + Cursor oldCursor = Cursor.Current; + + try { - throw new NotImplementedException(SR.NotImplementedByDesign); + Cursor.Current = Cursors.WaitCursor; + + if (dragOk || (localDragInside && de.Effect == DragDropEffects.Copy)) + { + // add em to this parent. + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IContainer container = host.RootComponent.Site.Container; + + object[] components; + IDataObject dataObj = de.Data; + bool updateLocation = false; + + if (dataObj is ComponentDataObjectWrapper) + { + dataObj = ((ComponentDataObjectWrapper)dataObj).InnerData; + ComponentDataObject cdo = (ComponentDataObject)dataObj; + + // if we're moving ot a different container, do a full serialization + // to make sure we pick up design time props, etc. + // + IComponent dragOwner = GetDragOwnerComponent(de.Data); + bool newContainer = dragOwner == null || client.Component == null || dragOwner.Site.Container != client.Component.Site.Container; + bool collapseChildren = false; + if (de.Effect == DragDropEffects.Copy || newContainer) + { + // this causes new elements to be created + // + cdo.Deserialize(serviceProvider, (de.Effect & DragDropEffects.Copy) == 0); + } + else + { + collapseChildren = true; + } + + updateLocation = true; + components = cdo.Components; + + if (collapseChildren) + { + components = GetTopLevelComponents(components); + } + } + else + { + object serializationData = dataObj.GetData(DataFormat, true); + + if (serializationData == null) + { + Debug.Fail("data object didn't return any data, so how did we allow the drop?"); + components = Array.Empty(); + } + else + { + dataObj = new ComponentDataObject(client, serviceProvider, serializationData); + components = ((ComponentDataObject)dataObj).Components; + updateLocation = true; + } + } + + // now we need to offset the components locations from the drop mouse + // point to the parent, since their current locations are relative + // the the mouse pointer + if (components != null && components.Length > 0) + { + Debug.Assert(container != null, "Didn't get a container from the site!"); + string name; + IComponent comp = null; + + DesignerTransaction trans = null; + + try + { + trans = host.CreateTransaction(SR.DragDropDropComponents); + if (!localDrag) + { + host.Activate(); + } + + ArrayList selectComps = new ArrayList(); + + for (int i = 0; i < components.Length; i++) + { + comp = components[i] as IComponent; + + if (comp == null) + { + comp = null; + continue; + } + + try + { + name = null; + if (comp.Site != null) + { + name = comp.Site.Name; + } + + Control oldDesignerControl = null; + if (updateLocation) + { + oldDesignerControl = client.GetDesignerControl(); + User32.SendMessageW(oldDesignerControl.Handle, User32.WM.SETREDRAW); + } + + Point dropPt = client.GetDesignerControl().PointToClient(new Point(de.X, de.Y)); + + // First check if the component we are dropping have a TrayLocation, and if so, use it + PropertyDescriptor loc = TypeDescriptor.GetProperties(comp)["TrayLocation"]; + if (loc == null) + { + // it didn't, so let's check for the regular Location + loc = TypeDescriptor.GetProperties(comp)["Location"]; + } + + if (loc != null && !loc.IsReadOnly) + { + Rectangle bounds = new Rectangle(); + Point pt = (Point)loc.GetValue(comp); + bounds.X = dropPt.X + pt.X; + bounds.Y = dropPt.Y + pt.Y; + bounds = selectionHandler.GetUpdatedRect(Rectangle.Empty, bounds, false); + } + + if (!client.AddComponent(comp, name, false)) + { + // this means that we just moved the control + // around in the same designer. + + de.Effect = DragDropEffects.None; + } + else + { + // make sure the component was added to this client + if (client.GetControlForComponent(comp) == null) + { + updateLocation = false; + } + } + + if (updateLocation) + { + ParentControlDesigner parentDesigner = client as ParentControlDesigner; + if (parentDesigner != null) + { + Control c = client.GetControlForComponent(comp); + dropPt = parentDesigner.GetSnappedPoint(c.Location); + c.Location = dropPt; + } + } + + if (oldDesignerControl != null) + { + //((ComponentDataObject)dataObj).ShowControls(); + User32.SendMessageW(oldDesignerControl.Handle, User32.WM.SETREDRAW, (IntPtr)1); + oldDesignerControl.Invalidate(true); + } + + if (TypeDescriptor.GetAttributes(comp).Contains(DesignTimeVisibleAttribute.Yes)) + { + selectComps.Add(comp); + } + } + catch (CheckoutException ceex) + { + if (ceex == CheckoutException.Canceled) + { + break; + } + + throw; + } + } + + if (host != null) + { + host.Activate(); + } + + // select the newly added components + ISelectionService selService = (ISelectionService)GetService(typeof(ISelectionService)); + + selService.SetSelectedComponents((object[])selectComps.ToArray(typeof(IComponent)), SelectionTypes.Replace); + localDragInside = false; + } + finally + { + if (trans != null) + trans.Commit(); + } + } + } + + if (localDragInside) + { + ISelectionUIService selectionUISvc = (ISelectionUIService)GetService(typeof(ISelectionUIService)); + Debug.Assert(selectionUISvc != null, "Unable to get selection ui service when adding child control"); + + if (selectionUISvc != null) + { + // We must check to ensure that UI service is still in drag mode. It is + // possible that the user hit escape, which will cancel drag mode. + // + if (selectionUISvc.Dragging && moveAllowed) + { + Rectangle offset = new Rectangle(de.X - dragBase.X, de.Y - dragBase.Y, 0, 0); + selectionUISvc.DragMoved(offset); + } + } + } + + dragOk = false; } + finally + { + Cursor.Current = oldCursor; + } + } + + public void DoOleDragEnter(DragEventArgs de) + { + /* + this causes focus rects to be drawn, which we don't want to happen. + + Control dragHost = client.GetDesignerControl(); - public virtual object GetData(Type t) + if (dragHost != null && dragHost.CanSelect) { + dragHost.Focus(); + }*/ + + if (!localDrag && CanDropDataObject(de.Data) && de.AllowedEffect != DragDropEffects.None) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (!client.CanModifyComponents) + { + return; + } + + dragOk = true; + + // this means it's not us doing the drag + if ((de.KeyState & (int)User32.MK.CONTROL) != 0 && (de.AllowedEffect & DragDropEffects.Copy) != 0) + { + de.Effect = DragDropEffects.Copy; + } + else if ((de.AllowedEffect & DragDropEffects.Move) != 0) + { + de.Effect = DragDropEffects.Move; + } + else + { + de.Effect = DragDropEffects.None; + return; + } } + else if (localDrag && de.AllowedEffect != DragDropEffects.None) + { + localDragInside = true; + if ((de.KeyState & (int)User32.MK.CONTROL) != 0 + && (de.AllowedEffect & DragDropEffects.Copy) != 0 + && client.CanModifyComponents) + { + de.Effect = DragDropEffects.Copy; + } + + bool localMoveOnly = ((int)de.AllowedEffect & AllowLocalMoveOnly) != 0 && localDragInside; + + if (localMoveOnly) + { + de.Effect |= (DragDropEffects)AllowLocalMoveOnly; + } - /// - /// If the there is data store in the data object associated with - /// format this will return true. - /// - public bool GetDataPresent(string format, bool autoConvert) + if ((de.AllowedEffect & DragDropEffects.Move) != 0) + { + de.Effect |= DragDropEffects.Move; + } + } + else { - throw new NotImplementedException(SR.NotImplementedByDesign); + de.Effect = DragDropEffects.None; } + } - /// - /// If the there is data store in the data object associated with - /// format this will return true. - /// - public bool GetDataPresent(string format) + public void DoOleDragLeave() + { + if (localDrag || forceDrawFrames) { - return GetDataPresent(format, false); + localDragInside = false; + localDragOffset = DrawDragFrames(dragComps, localDragOffset, localDragEffect, + Point.Empty, DragDropEffects.None, forceDrawFrames); + + if (forceDrawFrames && dragOk) + { + dragBase = Point.Empty; + dragComps = null; + } + + forceDrawFrames = false; } - /// - /// If the there is data store in the data object associated with - /// format this will return true. - /// - public bool GetDataPresent(Type format) + dragOk = false; + } + + public void DoOleDragOver(DragEventArgs de) + { + Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\tOleDragDropHandler.OnDragOver: " + de.ToString()); + if (!localDrag && !dragOk) { - throw new NotImplementedException(SR.NotImplementedByDesign); + de.Effect = DragDropEffects.None; + return; } - /// - /// Retrieves a list of all formats stored in this data object. - /// - public string[] GetFormats(bool autoConvert) + bool copy = (de.KeyState & (int)User32.MK.CONTROL) != 0 + && (de.AllowedEffect & DragDropEffects.Copy) != 0 + && client.CanModifyComponents; + + // we pretend AllowLocalMoveOnly is a normal move when we are over the originating container. + // + bool localMoveOnly = ((int)de.AllowedEffect & AllowLocalMoveOnly) != 0 && localDragInside; + bool move = (de.AllowedEffect & DragDropEffects.Move) != 0 || localMoveOnly; + + if ((copy || move) && (localDrag || forceDrawFrames)) { - throw new NotImplementedException(SR.NotImplementedByDesign); + Point convertedPoint = client.GetDesignerControl().PointToClient(new Point(de.X, de.Y)); + + // draw the shadow rects. + Point newOffset; + if (forceDrawFrames) + { + newOffset = convertedPoint; + } + else + { + newOffset = new Point(de.X - dragBase.X, de.Y - dragBase.Y); + } + + // 96845 -- only allow drops on the client area + // + if (!client.GetDesignerControl().ClientRectangle.Contains(convertedPoint)) + { + copy = false; + move = false; + newOffset = localDragOffset; + } + + if (newOffset != localDragOffset) + { + Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\tParentControlDesigner.OnDragOver: " + de.ToString()); + DrawDragFrames(dragComps, localDragOffset, localDragEffect, + newOffset, de.Effect, forceDrawFrames); + localDragOffset = newOffset; + localDragEffect = de.Effect; + } } - /// - /// Retrieves a list of all formats stored in this data object. - /// - public string[] GetFormats() + if (copy) + { + de.Effect = DragDropEffects.Copy; + } + else if (move) { - throw new NotImplementedException(SR.NotImplementedByDesign); + de.Effect = DragDropEffects.Move; + } + else + { + de.Effect = DragDropEffects.None; } - /// - /// Sets the data to be associated with the specific data format. For - /// a listing of predefined formats see System.Windows.Forms.DataFormats. - /// - public void SetData(string format, bool autoConvert, object data) + if (localMoveOnly) { - throw new NotImplementedException(SR.NotImplementedByDesign); + de.Effect |= (DragDropEffects)AllowLocalMoveOnly; } + } - /// - /// Sets the data to be associated with the specific data format. For - /// a listing of predefined formats see System.Windows.Forms.DataFormats. - /// - public void SetData(string format, object data) + public void DoOleGiveFeedback(GiveFeedbackEventArgs e) + { + if (selectionHandler == null) { - throw new Exception(SR.DragDropSetDataError); + Debug.Fail("selectionHandler should not be null"); } - /// - /// Sets the data to be associated with the specific data format. - /// - public void SetData(Type format, object data) + e.UseDefaultCursors = ((!localDragInside && !forceDrawFrames) || ((e.Effect & (DragDropEffects.Copy)) != 0)) || e.Effect == DragDropEffects.None; + if (!e.UseDefaultCursors && selectionHandler != null) { - throw new NotImplementedException(SR.NotImplementedByDesign); + selectionHandler.SetCursor(); } + } + + private object[] GetDraggingObjects(IDataObject dataObj, bool topLevelOnly) + { + object[] components = null; + + if (dataObj is ComponentDataObjectWrapper) + { + dataObj = ((ComponentDataObjectWrapper)dataObj).InnerData; + ComponentDataObject cdo = (ComponentDataObject)dataObj; + + components = cdo.Components; + } + + if (!topLevelOnly || components == null) + { + return components; + } + + return GetTopLevelComponents(components); + } - /// - /// Stores data in the data object. The format assumed is the - /// class of data - /// - public void SetData(object data) + public object[] GetDraggingObjects(IDataObject dataObj) + { + return GetDraggingObjects(dataObj, false); + } + + public object[] GetDraggingObjects(DragEventArgs de) + { + return GetDraggingObjects(de.Data); + } + + private object[] GetTopLevelComponents(ICollection comps) + { + // Filter the top-level components. + // + if (!(comps is IList)) { - throw new NotImplementedException(SR.NotImplementedByDesign); + comps = new ArrayList(comps); } - public void Deserialize(IServiceProvider serviceProvider, bool removeCurrentComponents) + IList compList = (IList)comps; + ArrayList topLevel = new ArrayList(); + foreach (object comp in compList) { - throw new NotImplementedException(SR.NotImplementedByDesign); + Control c = comp as Control; + if (c == null && comp != null) + { + topLevel.Add(comp); + } + else if (c != null) + { + if (c.Parent == null || !compList.Contains(c.Parent)) + { + topLevel.Add(comp); + } + } } + + return topLevel.ToArray(); + } + + protected object GetService(Type t) + { + return serviceProvider.GetService(t); + } + + protected virtual void OnInitializeComponent(IComponent comp, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs new file mode 100644 index 00000000000..8f8adf8c036 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Runtime.Versioning; + +namespace System.Windows.Forms.Design +{ + /// + /// This class handles all design time behavior for the panel class. This + /// draws a visible border on the panel if it doesn't have a border so the + /// user knows where the boundaries of the panel lie. + /// + internal class PanelDesigner : ScrollableControlDesigner + { + public PanelDesigner() + { + AutoResizeHandles = true; + } + + /// + /// This draws a nice border around our panel. We need + /// this because the panel can have no border and you can't + /// tell where it is. + /// + /// + protected virtual void DrawBorder(Graphics graphics) + { + Panel panel = (Panel)Component; // if the panel is invisible, bail now + if (panel == null || !panel.Visible) + { + return; + } + + Pen pen = BorderPen; + Rectangle rc = Control.ClientRectangle; + + rc.Width--; + rc.Height--; + + graphics.DrawRectangle(pen, rc); + pen.Dispose(); + } + + /// + /// Overrides our base class. Here we check to see if there + /// is no border on the panel. If not, we draw one so that + /// the panel shape is visible at design time. + /// + protected override void OnPaintAdornments(PaintEventArgs pe) + { + Panel panel = (Panel)Component; + + if (panel.BorderStyle == BorderStyle.None) + { + DrawBorder(pe.Graphics); + } + + base.OnPaintAdornments(pe); + } + + /// + /// Creates a Dashed-Pen of appropriate color. + /// + protected Pen BorderPen + { + [ResourceExposure(ResourceScope.Process)] + [ResourceConsumption(ResourceScope.Process)] + get + { + Color penColor = Control.BackColor.GetBrightness() < .5 ? + ControlPaint.Light(Control.BackColor) : + ControlPaint.Dark(Control.BackColor); + + Pen pen = new Pen(penColor); + pen.DashStyle = DashStyle.Dash; + + return pen; + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs new file mode 100644 index 00000000000..5a2e44e20ba --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + public partial class ParentControlDesigner + { + /// + /// This class overrides the escape command so that we can escape + /// out of our private drags. + /// + private class EscapeHandler : IMenuStatusHandler + { + private readonly ParentControlDesigner designer; + + /// + /// Creates a new escape handler. + /// + public EscapeHandler(ParentControlDesigner designer) + { + this.designer = designer; + } + + /// + /// CommandSet will check with this handler on each status update + /// to see if the handler wants to override the availability of + /// this command. + /// + public bool OverrideInvoke(MenuCommand cmd) + { + if (cmd.CommandID.Equals(MenuCommands.KeyCancel)) + { + designer.OnMouseDragEnd(true); + return true; + } + + return false; + } + + /// + /// CommandSet will check with this handler on each status update + /// to see if the handler wants to override the availability of + /// this command. + /// + public bool OverrideStatus(MenuCommand cmd) + { + if (cmd.CommandID.Equals(MenuCommands.KeyCancel)) + { + cmd.Enabled = true; + } + else + { + cmd.Enabled = false; + } + + return true; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs index df5bfb3ff14..50c96d34779 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs @@ -9,6 +9,7 @@ using System.Drawing; using System.Drawing.Design; using System.Windows.Forms.Design.Behavior; +using static Interop; namespace System.Windows.Forms.Design { @@ -17,15 +18,51 @@ namespace System.Windows.Forms.Design /// to manipulate child components, and provides a selection UI handler for all /// components it contains. /// - public class ParentControlDesigner : ControlDesigner, IOleDragClient + public partial class ParentControlDesigner : ControlDesigner, IOleDragClient { - private Control pendingRemoveControl; // we've gotten an OnComponentRemoving, and are waiting for OnComponentRemove - - private OleDragDropHandler _oleDragDropHandler; // handler for ole drag drop operations - private IComponentChangeService _componentChangeService; - private StatusCommandUI statusCommandUI; // UI for setting the StatusBar Information.. - - private int suspendChanging; + private Point _mouseDragBase = InvalidPoint; // the base point of the drag + private Rectangle _mouseDragOffset = Rectangle.Empty; // always keeps the current rectangle + private ToolboxItem _mouseDragTool; // the tool that's being dragged, if we're creating a component + private FrameStyle _mouseDragFrame; // the frame style of this mouse drag + + private OleDragDropHandler _oleDragDropHandler; // handler for ole drag drop operations + private EscapeHandler _escapeHandler; // active during drags to override escape. + private Control _pendingRemoveControl; // we've gotten an OnComponentRemoving, and are waiting for OnComponentRemove + private IComponentChangeService _componentChangeSvc; + private DragAssistanceManager _dragManager; //used to apply snaplines when dragging a new tool rect on the designer's surface + private ToolboxSnapDragDropEventArgs _toolboxSnapDragDropEventArgs; //used to store extra info about a beh. svc. dragdrop from the toolbx + private ToolboxItemSnapLineBehavior _toolboxItemSnapLineBehavior; //this is our generic snapline box for dragging comps from the toolbx + private Graphics _graphics; //graphics object of the adornerwindow (via BehaviorService) + + // Services that we keep around for the duration of a drag. you should always check + // to see if you need to get this service. We cache it, but demand create it. + // + private IToolboxService _toolboxService; + + private const int MinGridSize = 2; + private const int MaxGridSize = 200; + + // designer options... + // + private Point _adornerWindowToScreenOffset; //quick lookup for offsetting snaplines for new tools + + private bool _checkSnapLineSetting = true; // Since layout options is global for the duration of the designer, we should only query it once. + private bool _defaultUseSnapLines; + + private bool _gridSnap = true; + private Size _gridSize = Size.Empty; + private bool _drawGrid = true; + + private bool _parentCanSetDrawGrid = true; //since we can inherit the grid/snap setting of our parent, + private bool _parentCanSetGridSize = true; // these 3 properties let us know if these values have + private bool _parentCanSetGridSnap = true; // been set explicitly by a user - so to ignore the parent's setting + + private bool _getDefaultDrawGrid = true; + private bool _getDefaultGridSize = true; + private bool _getDefaultGridSnap = true; + private StatusCommandUI _statusCommandUI; // UI for setting the StatusBar Information.. + + private int _suspendChanging; /// /// This is called after the user selects a toolbox item (that has a ParentControlDesigner @@ -33,13 +70,25 @@ public class ParentControlDesigner : ControlDesigner, IOleDragClient /// this property returns true, it is indicating that the Controls that were lasso'd on the /// designer's surface will be re-parented to this designer's control. /// - protected virtual bool AllowControlLasso => throw new NotImplementedException(SR.NotImplementedByDesign); + protected virtual bool AllowControlLasso + { + get + { + return true; + } + } /// /// This is called to check whether a generic dragbox should be drawn when dragging a toolbox item /// over the designer's surface. /// - protected virtual bool AllowGenericDragBox => throw new NotImplementedException(SR.NotImplementedByDesign); + protected virtual bool AllowGenericDragBox + { + get + { + return true; + } + } /// /// This is called to check whether the z-order of dragged controls should be maintained when dropped on a @@ -52,218 +101,405 @@ public class ParentControlDesigner : ControlDesigner, IOleDragClient /// OnChildControlAdded to set the right child index, since in this case, the control(s) being dragged /// will be removed from the dragSource and then added to the dragTarget. /// - protected internal virtual bool AllowSetChildIndexOnDrop => - throw new NotImplementedException(SR.NotImplementedByDesign); - - /// - /// Determines the default location for a control added to this designer. - /// it is usualy (0,0), but may be modified if the container has special borders, etc. - /// - protected virtual Point DefaultControlLocation => new Point(0, 0); + protected internal virtual bool AllowSetChildIndexOnDrop + { + get + { + return true; + } + } /// - /// Accessor method for the DrawGrid property. This property determines - /// if the grid should be drawn on a control. + /// This is called when the component is added to the parent container. + /// Theoretically it performs the same function as IsDropOK does, but + /// unfortunately IsDropOK is not robust enough and does not allow for specific error messages. + /// This method is a chance to display the same error as is displayed at runtime. /// - protected virtual bool DrawGrid + protected internal virtual bool CanAddComponent(IComponent component) { - get => throw new NotImplementedException(SR.NotImplementedByDesign); - set => throw new NotImplementedException(SR.NotImplementedByDesign); + return true; } /// - /// Determines whether drag rects can be drawn on this designer. + /// This can be called to determine the current grid spacing and mode. + /// It is sensitive to what modifier keys the user currently has down and + /// will either return the current grid snap dimensons, or a 1x1 point + /// indicating no snap. /// - protected override bool EnableDragRect => throw new NotImplementedException(SR.NotImplementedByDesign); + private Size CurrentGridSize + { + get + { + return GridSize; + } + } /// - /// Gets/Sets the GridSize property for a form or user control. + /// Determines the default location for a control added to this designer. + /// it is usualy (0,0), but may be modified if the container has special borders, etc. /// - protected Size GridSize + protected virtual Point DefaultControlLocation { - get => throw new NotImplementedException(SR.NotImplementedByDesign); - set => throw new NotImplementedException(SR.NotImplementedByDesign); + get + { + return new Point(0, 0); + } } - /// - /// This property is used by deriving classes to determine if the designer is - /// in a state where it has a valid MouseDragTool. - /// - [CLSCompliant(false)] - protected ToolboxItem MouseDragTool => throw new NotImplementedException(SR.NotImplementedByDesign); + private bool DefaultUseSnapLines + { + get + { + if (_checkSnapLineSetting) + { + _checkSnapLineSetting = false; + _defaultUseSnapLines = DesignerUtils.UseSnapLines(Component.Site); + } + + return _defaultUseSnapLines; + } + } /// - /// Returns a list of SnapLine objects representing interesting - /// alignment points for this control. These SnapLines are used - /// to assist in the positioning of the control on a parent's - /// surface. + /// Accessor method for the DrawGrid property. This property determines + /// if the grid should be drawn on a control. /// - public override IList SnapLines => throw new NotImplementedException(SR.NotImplementedByDesign); - - internal Size ParentGridSize + protected virtual bool DrawGrid { - get => GridSize; - } - - internal OleDragDropHandler GetOleDragHandler() - => _oleDragDropHandler ??= new OleDragDropHandler(null, GetService(), this); + get + { + // If snaplines are on, the we never want to draw the grid - internal void AddControl(Control newChild, IDictionary defaultValues) - { - Point location = Point.Empty; - Size size = Size.Empty; - Size offset = new Size(0, 0); - bool hasLocation = (defaultValues != null && defaultValues.Contains("Location")); - bool hasSize = (defaultValues != null && defaultValues.Contains("Size")); + if (DefaultUseSnapLines) + { + return false; + } + else if (_getDefaultDrawGrid) + { + _drawGrid = true; + + //Before we check our options page, we need to see if our parent + //is a ParentControlDesigner, is so, then we will want to inherit all + //our grid/snap setting from it - instead of our options page + // + ParentControlDesigner parent = GetParentControlDesignerOfParent(); + if (parent != null) + { + _drawGrid = parent.DrawGrid; + } + else + { + object value = DesignerUtils.GetOptionValue(ServiceProvider, "ShowGrid"); + if (value is bool) + { + _drawGrid = (bool)value; + } + } + } - if (hasLocation) - { - location = (Point)defaultValues["Location"]; + return _drawGrid; } - if (hasSize) + set { - size = (Size)defaultValues["Size"]; + if (value != _drawGrid) + { + if (_parentCanSetDrawGrid) + { + _parentCanSetDrawGrid = false; + } + + if (_getDefaultDrawGrid) + { + _getDefaultDrawGrid = false; + } + + _drawGrid = value; + + //invalidate the cotnrol to remove or draw the grid based on the new value + Control control = Control; + if (control != null) + { + control.Invalidate(true); + } + + //now, notify all child parent control designers that we have changed our setting + // 'cause they might to change along with us, unless the user has explicitly set + // those values... + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + // for (int i = 0; i < children.Length; i++) { + foreach (Control child in Control.Controls) + { + ParentControlDesigner designer = host.GetDesigner(child) as ParentControlDesigner; + if (designer != null) + { + designer.DrawGridOfParentChanged(_drawGrid); + } + } + } + } } + } - if (defaultValues != null && defaultValues.Contains("Offset")) + /// + /// Determines whether drag rects can be drawn on this designer. + /// + protected override bool EnableDragRect + { + get { - offset = (Size)defaultValues["Offset"]; + return true; } + } - // If this component doesn't have a control designer, or if this control is top level, then ignore it. - // We have the reverse logic in OnComponentAdded in the document designer so that we will add those guys - // to the tray. Also, if the child-control has already been parented, we assume it's also been located - // and return immediately. Otherwise, proceed with the parenting and locating. - if (!TryGetService(out IDesignerHost host) - || newChild == null - || Control.Contains(newChild) - || (host.GetDesigner(newChild) as ControlDesigner) == null - || (newChild is Form form && form.TopLevel)) + internal Size ParentGridSize + { + get { - return; + return GridSize; } + } - Rectangle bounds = new Rectangle(); - - // If we were provided with a location, convert it to parent control coordinates. Otherwise, get the control's size and put the location in the middle of it - if (hasLocation) + /// + /// Gets/Sets the GridSize property for a form or user control. + /// + protected Size GridSize + { + get { - location = Control.PointToClient(location); - bounds.X = location.X; - bounds.Y = location.Y; + if (_getDefaultGridSize) + { + _gridSize = new Size(8, 8); + + //Before we check our options page, we need to see if our parent + //is a ParentControlDesigner, is so, then we will want to inherit all + //our grid/snap setting from it - instead of our options page + // + ParentControlDesigner parent = GetParentControlDesignerOfParent(); + if (parent != null) + { + _gridSize = parent.GridSize; + } + else + { + object value = DesignerUtils.GetOptionValue(ServiceProvider, "GridSize"); + if (value is Size) + { + _gridSize = (Size)value; + } + } + } + + return _gridSize; } - else + set { - // is the currently selected control this container? - object primarySelection = GetService().PrimarySelection; - Control selectedControl = null; - if (primarySelection != null) + if (_parentCanSetGridSize) { - selectedControl = ((IOleDragClient)this).GetControlForComponent(primarySelection); + _parentCanSetGridSize = false; } - // If the resulting control that came back isn't sited, it's not part of the design surface and should not be used as a marker. - if (selectedControl != null && selectedControl.Site is null) + if (_getDefaultGridSize) { - selectedControl = null; + _getDefaultGridSize = false; } - // if the currently selected container is this parent control, default to 0,0 - if (primarySelection == Component || selectedControl is null) + //do some validation checking here, against min & max GridSize + // + if (value.Width < MinGridSize || value.Height < MinGridSize || + value.Width > MaxGridSize || value.Height > MaxGridSize) + throw new ArgumentException(string.Format(SR.InvalidArgument, + "GridSize", + value.ToString())); + _gridSize = value; + + //invalidate the control + Control control = Control; + if (control != null) { - bounds.X = DefaultControlLocation.X; - bounds.Y = DefaultControlLocation.Y; + control.Invalidate(true); } - else + + //now, notify all child parent control designers that we have changed our setting + // 'cause they might to change along with us, unless the user has explicitly set + // those values... + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) { - // otherwise offset from selected control. - bounds.X = selectedControl.Location.X + GridSize.Width; - bounds.Y = selectedControl.Location.Y + GridSize.Height; + foreach (Control child in Control.Controls) + { + ParentControlDesigner designer = host.GetDesigner(child) as ParentControlDesigner; + if (designer != null) + { + designer.GridSizeOfParentChanged(_gridSize); + } + } } } + } - // If we were not given a size, ask the control for its default. We also update the location here so the control is in the middle of the user's point, rather than at the edge. - if (hasSize) - { - bounds.Width = size.Width; - bounds.Height = size.Height; - } - else + /// + /// This property is used by deriving classes to determine if the designer is + /// in a state where it has a valid MouseDragTool. + /// + [CLSCompliant(false)] + protected ToolboxItem MouseDragTool + { + get { - bounds.Size = GetDefaultSize(newChild); + return _mouseDragTool; } + } - // If we were given neither, center the control - if (!hasSize && !hasLocation) - { - // get the adjusted location, then inflate the rect so we can find a nice spot for this control to live. - Rectangle tempBounds = GetAdjustedSnapLocation(Rectangle.Empty, bounds); - // compute the stacking location - tempBounds = GetControlStackLocation(tempBounds); - bounds = tempBounds; - } - else + /// + /// This property is used by deriving classes to determine if it returns the control being designed or some other + /// Container ... + /// while adding a component to it. + /// e.g: When SplitContainer is selected and a component is being added ... the SplitContainer designer would return a + /// SelectedPanel as the ParentControl for all the items being added rather than itself. + /// + protected virtual Control GetParentForComponent(IComponent component) + { + return Control; + } + + // We need to allocation new ArrayList and pass it to the caller.. + // So its ok to Suppress this. + protected void AddPaddingSnapLines(ref ArrayList snapLines) + { + if (snapLines == null) { - // Finally, convert the bounds to the appropriate grid snaps - bounds = GetAdjustedSnapLocation(Rectangle.Empty, bounds); + snapLines = new ArrayList(4); } - // Adjust for the offset, if any - bounds.X += offset.Width; - bounds.Y += offset.Height; - // check to see if we have additional information for bounds from the behaviorservice dragdrop logic - if (defaultValues != null && defaultValues.Contains("ToolboxSnapDragDropEventArgs")) + //In order to add padding, we need to get the offset from the usable client area of our control + //and the actual origin of our control. In other words: how big is the non-client area here? + // Ex: we want to add padding on a form to the insides of the borders and below the titlebar. + Point offset = GetOffsetToClientArea(); + + //the desplay rectangle should be the client area combined with the padding value + Rectangle displayRectangle = Control.DisplayRectangle; + displayRectangle.X += offset.X;//offset for non-client area + displayRectangle.Y += offset.Y;//offset for non-client area + + //add the four paddings of our control + + // Even if a control does not have padding, we still want to add Padding snaplines. + // This is because we only try to match to matching snaplines. Makes the code a little easier... + snapLines.Add(new SnapLine(SnapLineType.Vertical, displayRectangle.Left, SnapLine.PaddingLeft, SnapLinePriority.Always)); + snapLines.Add(new SnapLine(SnapLineType.Vertical, displayRectangle.Right, SnapLine.PaddingRight, SnapLinePriority.Always)); + snapLines.Add(new SnapLine(SnapLineType.Horizontal, displayRectangle.Top, SnapLine.PaddingTop, SnapLinePriority.Always)); + snapLines.Add(new SnapLine(SnapLineType.Horizontal, displayRectangle.Bottom, SnapLine.PaddingBottom, SnapLinePriority.Always)); + } + + /// + /// Returns a list of SnapLine objects representing interesting + /// alignment points for this control. These SnapLines are used + /// to assist in the positioning of the control on a parent's + /// surface. + /// + public override IList SnapLines + { + get { - ToolboxSnapDragDropEventArgs e = defaultValues["ToolboxSnapDragDropEventArgs"] as ToolboxSnapDragDropEventArgs; - Debug.Assert(e != null, "Why can't we get a ToolboxSnapDragDropEventArgs object out of our default values?"); - Rectangle snappedBounds = DesignerUtils.GetBoundsFromToolboxSnapDragDropInfo(e, bounds, Control.IsMirrored); - //Make sure the snapped bounds intersects with the bounds of the root control before we go adjusting the drag offset. A race condition exists where the user can drag a tbx item so fast that the adorner window will never receive the proper drag/mouse move messages and never properly adjust the snap drag info. This cause the control to be added @ 0,0 w.r.t. the adorner window. - if (host.RootComponent is Control rootControl && snappedBounds.IntersectsWith(rootControl.ClientRectangle)) + ArrayList snapLines = base.SnapLines as ArrayList; + + if (snapLines == null) { - bounds = snappedBounds; + Debug.Fail("why did base.SnapLines return null?"); + snapLines = new ArrayList(4); } - } - // Parent the control to the designer and set it to the front. - PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Control)["Controls"]; - if (_componentChangeService != null) - { - _componentChangeService.OnComponentChanging(Control, controlsProp); + AddPaddingSnapLines(ref snapLines); + return snapLines; } + } - AddChildControl(newChild); - // Now see if the control has size and location properties. Update these values if it does. - PropertyDescriptorCollection props = TypeDescriptor.GetProperties(newChild); - if (props != null) + private IServiceProvider ServiceProvider + { + get { - PropertyDescriptor prop = props["Size"]; - if (prop != null) + if (Component != null) { - prop.SetValue(newChild, new Size(bounds.Width, bounds.Height)); + return Component.Site; } - // ControlDesigner shadows the Location property. If the control is parented and the parent is a scrollable control, then it expects the Location to be in displayrectangle coordinates. At this point bounds are in clientrectangle coordinates, so we need to check if we need to adjust the coordinates. The reason this worked in Everett was that the AddChildControl was done AFTER this. The AddChildControl was moved above a while back. Not sure what will break if AddChildControl is moved down below, so let's just fix up things here. - Point pt = new Point(bounds.X, bounds.Y); - if (newChild.Parent is ScrollableControl p) + return null; + } + } + + /// + /// Determines if we should snap to grid or not. + /// + private bool SnapToGrid + { + get + { + // If snaplines are on, the we never want to snap to grid + if (DefaultUseSnapLines) { - Point ptScroll = p.AutoScrollPosition; - pt.Offset(-ptScroll.X, -ptScroll.Y); //always want to add the control below/right of the AutoScrollPosition + return false; } - - prop = props["Location"]; - if (prop != null) + else if (_getDefaultGridSnap) { - prop.SetValue(newChild, pt); + _gridSnap = true; + + //Before we check our options page, we need to see if our parent + //is a ParentControlDesigner, is so, then we will want to inherit all + //our grid/snap setting from it - instead of our options page + // + ParentControlDesigner parent = GetParentControlDesignerOfParent(); + if (parent != null) + { + _gridSnap = parent.SnapToGrid; + } + else + { + object optionValue = DesignerUtils.GetOptionValue(ServiceProvider, "SnapToGrid"); + if (optionValue != null && optionValue is bool) + { + _gridSnap = (bool)optionValue; + } + } } - } - if (_componentChangeService != null) - { - _componentChangeService.OnComponentChanged(Control, controlsProp, Control.Controls, Control.Controls); + return _gridSnap; } + set + { + if (_gridSnap != value) + { + if (_parentCanSetGridSnap) + { + _parentCanSetGridSnap = false; + } + + if (_getDefaultGridSnap) + { + _getDefaultGridSnap = false; + } - newChild.Update(); + _gridSnap = value; + + //now, notify all child parent control designers that we have changed our setting + // 'cause they might to change along with us, unless the user has explicitly set + // those values... + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + foreach (Control child in Control.Controls) + { + ParentControlDesigner designer = host.GetDesigner(child) as ParentControlDesigner; + if (designer != null) + { + designer.GridSnapOfParentChanged(_gridSnap); + } + } + } + } + } } internal virtual void AddChildControl(Control newChild) @@ -271,6 +507,7 @@ internal virtual void AddChildControl(Control newChild) if (newChild.Left == 0 && newChild.Top == 0 && newChild.Width >= Control.Width && newChild.Height >= Control.Height) { // bump the control down one gridsize just so it's selectable... + // Point loc = newChild.Location; loc.Offset(GridSize.Width, GridSize.Height); newChild.Location = loc; @@ -280,155 +517,382 @@ internal virtual void AddChildControl(Control newChild) Control.Controls.SetChildIndex(newChild, 0); } - private Rectangle GetControlStackLocation(Rectangle centeredLocation) + internal void AddControl(Control newChild, IDictionary defaultValues) { - Control parent = Control; - int parentHeight = parent.ClientSize.Height; - int parentWidth = parent.ClientSize.Width; - if (centeredLocation.Bottom >= parentHeight || centeredLocation.Right >= parentWidth) + Point location = Point.Empty; + Size size = Size.Empty; + Size offset = new Size(0, 0); + bool hasLocation = (defaultValues != null && defaultValues.Contains("Location")); + bool hasSize = (defaultValues != null && defaultValues.Contains("Size")); + + if (hasLocation) + location = (Point)defaultValues["Location"]; + if (hasSize) + size = (Size)defaultValues["Size"]; + if (defaultValues != null && defaultValues.Contains("Offset")) { - centeredLocation.X = DefaultControlLocation.X; - centeredLocation.Y = DefaultControlLocation.Y; + offset = (Size)defaultValues["Offset"]; } - return centeredLocation; - } - - private Size GetDefaultSize(IComponent component) - { - //Check to see if the control is AutoSized. VSWhidbey #416721 - PropertyDescriptor prop = TypeDescriptor.GetProperties(component)["AutoSize"]; - Size size; - if (prop != null && - !(prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden) || - prop.Attributes.Contains(BrowsableAttribute.No))) + // If this component doesn't have a control designer, or if this control + // is top level, then ignore it. We have the reverse logic in OnComponentAdded + // in the document designer so that we will add those guys to the tray. + // Also, if the child-control has already been parented, we assume it's also been located and return immediately. + // Otherwise, proceed with the parenting and locating. + // + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null + && newChild != null + && !Control.Contains(newChild) + && (host.GetDesigner(newChild) as ControlDesigner) != null + && !(newChild is Form && ((Form)newChild).TopLevel)) { - bool autoSize = (bool)prop.GetValue(component); - if (autoSize) + Rectangle bounds = new Rectangle(); + + // If we were provided with a location, convert it to parent control coordinates. + // Otherwise, get the control's size and put the location in the middle of it + // + if (hasLocation) { - prop = TypeDescriptor.GetProperties(component)["PreferredSize"]; - if (prop != null) + location = Control.PointToClient(location); + bounds.X = location.X; + bounds.Y = location.Y; + } + else + { + // is the currently selected control this container? + // + ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService)); + object primarySelection = selSvc.PrimarySelection; + Control selectedControl = null; + if (primarySelection != null) { - size = (Size)prop.GetValue(component); - if (size != Size.Empty) - { - return size; - } + selectedControl = ((IOleDragClient)this).GetControlForComponent(primarySelection); + } + + // If the resulting control that came back isn't sited, it's not part of the + // design surface and should not be used as a marker. + // + if (selectedControl != null && selectedControl.Site == null) + { + selectedControl = null; + } + + // if the currently selected container is this parent + // control, default to 0,0 + // + if (primarySelection == Component || selectedControl == null) + { + bounds.X = DefaultControlLocation.X; + bounds.Y = DefaultControlLocation.Y; + } + else + { + // otherwise offset from selected control. + // + bounds.X = selectedControl.Location.X + GridSize.Width; + bounds.Y = selectedControl.Location.Y + GridSize.Height; } } - } - // attempt to get the size property of our component - prop = TypeDescriptor.GetProperties(component)["Size"]; - if (prop != null) - { - // first, let's see if we can get a valid size... - size = (Size)prop.GetValue(component); - // ...if not, we'll see if there's a default size attribute... - if (size.Width <= 0 || size.Height <= 0) + // If we were not given a size, ask the control for its default. We + // also update the location here so the control is in the middle of + // the user's point, rather than at the edge. + // + if (hasSize) { - DefaultValueAttribute sizeAttr = (DefaultValueAttribute)prop.Attributes[typeof(DefaultValueAttribute)]; - if (sizeAttr != null) + bounds.Width = size.Width; + bounds.Height = size.Height; + } + else + { + bounds.Size = GetDefaultSize(newChild); + } + + // If we were given neither, center the control + // + if (!hasSize && !hasLocation) + { + // get the adjusted location, then inflate + // the rect so we can find a nice spot + // for this control to live. + // + Rectangle tempBounds = GetAdjustedSnapLocation(Rectangle.Empty, bounds); + + // compute the stacking location + // + tempBounds = GetControlStackLocation(tempBounds); + bounds = tempBounds; + } + else + { + // Finally, convert the bounds to the appropriate grid snaps + // + bounds = GetAdjustedSnapLocation(Rectangle.Empty, bounds); + } + + // Adjust for the offset, if any + // + bounds.X += offset.Width; + bounds.Y += offset.Height; + + //check to see if we have additional information for bounds from + //the behaviorservice dragdrop logic + if (defaultValues != null && defaultValues.Contains("ToolboxSnapDragDropEventArgs")) + { + ToolboxSnapDragDropEventArgs e = defaultValues["ToolboxSnapDragDropEventArgs"] as ToolboxSnapDragDropEventArgs; + Debug.Assert(e != null, "Why can't we get a ToolboxSnapDragDropEventArgs object out of our default values?"); + + Rectangle snappedBounds = DesignerUtils.GetBoundsFromToolboxSnapDragDropInfo(e, bounds, Control.IsMirrored); + + //Make sure the snapped bounds intersects with the bounds of the root control before we go + //adjusting the drag offset. A race condition exists where the user can drag a tbx item so fast + //that the adorner window will never receive the proper drag/mouse move messages and + //never properly adjust the snap drag info. This cause the control to be added @ 0,0 w.r.t. + //the adorner window. + Control rootControl = host.RootComponent as Control; + if (rootControl != null && snappedBounds.IntersectsWith(rootControl.ClientRectangle)) { - return ((Size)sizeAttr.Value); + bounds = snappedBounds; } } - else + + // Parent the control to the designer and set it to the front. + // + // + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Control)["Controls"]; + if (_componentChangeSvc != null) { - return size; + _componentChangeSvc.OnComponentChanging(Control, controlsProp); } - } - // Couldn't get the size or a def size attrib, returning 75,23... - return (new Size(75, 23)); + AddChildControl(newChild); + + // Now see if the control has size and location properties. Update + // these values if it does. + // + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(newChild); + if (props != null) + { + PropertyDescriptor prop = props["Size"]; + if (prop != null) + { + prop.SetValue(newChild, new Size(bounds.Width, bounds.Height)); + } + + //VSWhidbey# 364133 - ControlDesigner shadows the Location property. If the control is parented + //and the parent is a scrollable control, then it expects the Location to be in displayrectangle coordinates. + //At this point bounds are in clientrectangle coordinates, so we need to check if we need to adjust the coordinates. + //The reason this worked in Everett was that the AddChildControl was done AFTER this. The AddChildControl was moved + //above a while back. Not sure what will break if AddChildControl is moved down below, so let's just fix up things + //here. + + Point pt = new Point(bounds.X, bounds.Y); + ScrollableControl p = newChild.Parent as ScrollableControl; + if (p != null) + { + Point ptScroll = p.AutoScrollPosition; + pt.Offset(-ptScroll.X, -ptScroll.Y); //always want to add the control below/right of the AutoScrollPosition + } + + prop = props["Location"]; + if (prop != null) + { + prop.SetValue(newChild, pt); + } + } + + if (_componentChangeSvc != null) + { + _componentChangeSvc.OnComponentChanged(Control, controlsProp, Control.Controls, Control.Controls); + } + + newChild.Update(); + } } - private Rectangle GetAdjustedSnapLocation(Rectangle originalRect, Rectangle dragRect) + /// + /// Adds all the child components of a component + /// to the given container + /// + private void AddChildComponents(IComponent component, IContainer container, IDesignerHost host) { - Rectangle adjustedRect = GetUpdatedRect(originalRect, dragRect, true); - //now, preserve the width and height that was originally passed in - adjustedRect.Width = dragRect.Width; - adjustedRect.Height = dragRect.Height; - // we need to keep in mind that if we adjust to the snap, that we could have possibly moved the control's position outside of the display rect. ex: groupbox's display rect.x = 3, but we might snap to 0. so we need to check with the control's designer to make sure this doesn't happen - Point minimumLocation = DefaultControlLocation; - if (adjustedRect.X < minimumLocation.X) - { - adjustedRect.X = minimumLocation.X; - } + Control control = GetControl(component); - if (adjustedRect.Y < minimumLocation.Y) + if (control != null) { - adjustedRect.Y = minimumLocation.Y; - } + Control parent = control; - // here's our rect that has been snapped to grid - return adjustedRect; - } + Control[] children = new Control[parent.Controls.Count]; + parent.Controls.CopyTo(children, 0); - bool IOleDragClient.CanModifyComponents => throw new NotImplementedException(); + string name; + ISite childSite; - bool IOleDragClient.AddComponent(IComponent component, string name, bool firstAdd) - { - throw new NotImplementedException(); - } + for (int i = 0; i < children.Length; i++) + { + childSite = ((IComponent)children[i]).Site; - bool IOleDragClient.IsDropOk(IComponent component) - { - throw new NotImplementedException(); - } + IContainer childContainer; + if (childSite != null) + { + name = childSite.Name; + if (container.Components[name] != null) + { + name = null; + } - Control IOleDragClient.GetDesignerControl() - { - throw new NotImplementedException(); - } + childContainer = childSite.Container; + } + else + { + //name = null; + // we don't want to add unsited child controls because + // these may be items from a composite control. if they + // are legitamite children, the ComponentModelPersister would have + // sited them already. + // + continue; + } - Control IOleDragClient.GetControlForComponent(object component) - { - throw new NotImplementedException(); + if (childContainer != null) + { + childContainer.Remove(children[i]); + } + + if (name != null) + { + container.Add(children[i], name); + } + else + { + container.Add(children[i]); + } + + if (children[i].Parent != parent) + { + parent.Controls.Add(children[i]); + } + else + { + // ugh, last resort + int childIndex = parent.Controls.GetChildIndex(children[i]); + parent.Controls.Remove(children[i]); + parent.Controls.Add(children[i]); + parent.Controls.SetChildIndex(children[i], childIndex); + } + + IComponentInitializer init = host.GetDesigner(component) as IComponentInitializer; + if (init != null) + { + init.InitializeExistingComponent(null); + } + + // recurse; + AddChildComponents(children[i], container, host); + } + } } /// - /// This is called when the component is added to the parent container. - /// Theoretically it performs the same function as IsDropOK does, but - /// unfortunately IsDropOK is not robust enough and does not allow for specific error messages. - /// This method is a chance to display the same error as is displayed at runtime. + /// Disposes this component. /// - protected internal virtual bool CanAddComponent(IComponent component) + protected override void Dispose(bool disposing) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (disposing) + { + // Stop any drag that we are currently processing. + + // HACK HACK HACK + // + // See VSWhidbey #575663. + // + // If we are not in a mousedrag, then pretend we are cancelling. + // This is such that the base will not set the primaryselection to be + // the associated Component. Doing so can cause a crash in hosted designers. + // It doesn't make sense to do so anyway, since the designer (and thus + // the component) is being disposed. + OnMouseDragEnd((_mouseDragBase == InvalidPoint) ? true : false); + + EnableDragDrop(false); + + if (Control is ScrollableControl) + { + ((ScrollableControl)Control).Scroll -= new ScrollEventHandler(OnScroll); + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + _componentChangeSvc.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); + _componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + _componentChangeSvc = null; + } + } + + base.Dispose(disposing); } /// - /// This property is used by deriving classes to determine if it returns the control being designed or some other - /// Container ... - /// while adding a component to it. - /// e.g: When SplitContainer is selected and a component is being added ... the SplitContainer designer would return a - /// SelectedPanel as the ParentControl for all the items being added rather than itself. + /// This is called by the parent when the ParentControlDesigner's + /// grid/snap settings have changed. Unless the user has explicitly + /// set these values, this designer will just inherit the new ones + /// from the parent. /// - protected virtual Control GetParentForComponent(IComponent component) + private void DrawGridOfParentChanged(bool drawGrid) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (_parentCanSetDrawGrid) + { + // If the parent sets us, then treat this as if no one set us + bool getDefaultDrawGridTemp = _getDefaultDrawGrid; + DrawGrid = drawGrid; + _parentCanSetDrawGrid = true; + _getDefaultDrawGrid = getDefaultDrawGridTemp; + } } - // We need to allocation new ArrayList and pass it to the caller.. - // So its ok to Suppress this. - protected void AddPaddingSnapLines(ref ArrayList snapLines) + /// + /// This is called by the parent when the ParentControlDesigner's + /// grid/snap settings have changed. Unless the user has explicitly + /// set these values, this designer will just inherit the new ones + /// from the parent. + /// + private void GridSizeOfParentChanged(Size gridSize) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (_parentCanSetGridSize) + { + // If the parent sets us, then treat this as if no one set us + bool getDefaultGridSizeTemp = _getDefaultGridSize; + GridSize = gridSize; + _parentCanSetGridSize = true; + _getDefaultGridSize = getDefaultGridSizeTemp; + } } /// - /// Disposes this component. + /// This is called by the parent when the ParentControlDesigner's + /// grid/snap settings have changed. Unless the user has explicitly + /// set these values, this designer will just inherit the new ones + /// from the parent. /// - protected override void Dispose(bool disposing) + private void GridSnapOfParentChanged(bool gridSnap) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (_parentCanSetGridSnap) + { + // If the parent sets us, then treat this as if no one set us + bool getDefaultGridSnapTemp = _getDefaultGridSnap; + SnapToGrid = gridSnap; + _parentCanSetGridSnap = true; + _getDefaultGridSnap = getDefaultGridSnapTemp; + } } - [CLSCompliant(false)] + /// + /// [To be supplied.] + /// protected static void InvokeCreateTool(ParentControlDesigner toInvoke, ToolboxItem tool) { - throw new NotImplementedException(SR.NotImplementedByDesign); + toInvoke.CreateTool(tool); } /// @@ -438,7 +902,7 @@ protected static void InvokeCreateTool(ParentControlDesigner toInvoke, ToolboxIt /// public virtual bool CanParent(ControlDesigner controlDesigner) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return CanParent(controlDesigner.Control); } /// @@ -448,17 +912,16 @@ public virtual bool CanParent(ControlDesigner controlDesigner) /// public virtual bool CanParent(Control control) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return !control.Contains(Control); } /// /// Creates the given tool in the center of the currently selected /// control. The default size for the tool is used. /// - [CLSCompliant(false)] protected void CreateTool(ToolboxItem tool) { - throw new NotImplementedException(SR.NotImplementedByDesign); + CreateToolCore(tool, 0, 0, 0, 0, false, false); } /// @@ -468,7 +931,7 @@ protected void CreateTool(ToolboxItem tool) [CLSCompliant(false)] protected void CreateTool(ToolboxItem tool, Point location) { - throw new NotImplementedException(SR.NotImplementedByDesign); + CreateToolCore(tool, location.X, location.Y, 0, 0, true, false); } /// @@ -478,7 +941,7 @@ protected void CreateTool(ToolboxItem tool, Point location) [CLSCompliant(false)] protected void CreateTool(ToolboxItem tool, Rectangle bounds) { - throw new NotImplementedException(SR.NotImplementedByDesign); + CreateToolCore(tool, bounds.X, bounds.Y, bounds.Width, bounds.Height, true, true); } /// @@ -486,182 +949,1337 @@ protected void CreateTool(ToolboxItem tool, Rectangle bounds) /// that can be overridden. /// [CLSCompliant(false)] - protected virtual IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, - bool hasLocation, bool hasSize) + protected virtual IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + IComponent[] comp = null; - /// - /// Returns the control that represents the UI for the given component. - /// - protected Control GetControl(object component) - { - throw new NotImplementedException(SR.NotImplementedByDesign); + try + { + // We invoke the drag drop handler for this. This implementation is shared between all designers that + // create components. + // + comp = GetOleDragHandler().CreateTool(tool, Control, x, y, width, height, hasLocation, hasSize, _toolboxSnapDragDropEventArgs); + } + finally + { + //clear the toolboxSnap drag args so we won't provide bad information the next time around + _toolboxSnapDragDropEventArgs = null; + } + + return comp; } /// - /// Returns a 'BodyGlyph' representing the bounds of this control. - /// The BodyGlyph is responsible for hit testing the related CtrlDes - /// and forwarding messages directly to the designer. + /// Used when draggin a new tool rect on the designer's surface - + /// this will return some generic snaplines Allowing the rect to + /// snap to existing control edges on the surface. /// - protected override ControlBodyGlyph GetControlGlyph(GlyphSelectionType selectionType) + private SnapLine[] GenerateNewToolSnapLines(Rectangle r) { - throw new NotImplementedException(SR.NotImplementedByDesign); + return new SnapLine[] + { + new SnapLine(SnapLineType.Left, r.Right), + new SnapLine(SnapLineType.Right, r.Right), + new SnapLine(SnapLineType.Bottom, r.Bottom), + new SnapLine(SnapLineType.Top, r.Bottom) + }; } /// - /// Adds our ContainerSelectorGlyph to the selection glyphs. + /// Finds the array of components within the given rectangle. This uses the rectangle to + /// find controls within our control, and then uses those controls to find the actual + /// components. It returns an object array so the output can be directly fed into + /// the selection service. /// - public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) + internal object[] GetComponentsInRect(Rectangle value, bool screenCoords, bool containRect) { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + ArrayList list = new ArrayList(); + Rectangle rect = screenCoords ? Control.RectangleToClient(value) : value; - internal Point GetSnappedPoint(Point pt) - { - Rectangle r = GetUpdatedRect(Rectangle.Empty, new Rectangle(pt.X, pt.Y, 0, 0), false); - return new Point(r.X, r.Y); - } + IContainer container = Component.Site.Container; - /// - /// Updates the given rectangle, adjusting it for grid snaps as - /// needed. - /// - protected Rectangle GetUpdatedRect(Rectangle originalRect, Rectangle dragRect, bool updateSize) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + Control control = Control; + int controlCount = control.Controls.Count; - /// - /// Initializes the designer with the given component. The designer can - /// get the component's site and request services from it in this call. - /// - public override void Initialize(IComponent component) - { - base.Initialize(component); - if (Control is ScrollableControl control) + for (int i = 0; i < controlCount; i++) { - control.Scroll += new ScrollEventHandler(OnScroll); - } - - EnableDragDrop(true); - _componentChangeService = GetService()?.GetService(); + Control child = control.Controls[i]; + Rectangle bounds = child.Bounds; - // update the Status Command - statusCommandUI = new StatusCommandUI(component.Site); - } + container = DesignerUtils.CheckForNestedContainer(container); // ...necessary to support SplitterPanel components - private void OnComponentRemoved(object sender, ComponentEventArgs e) - { - if (e.Component == pendingRemoveControl) - { - pendingRemoveControl = null; - _componentChangeService.OnComponentChanged(Control, TypeDescriptor.GetProperties(Control)["Controls"], null, null); + if (child.Visible && ((containRect && rect.Contains(bounds)) || (!containRect && bounds.IntersectsWith(rect))) && + child.Site != null && child.Site.Container == container) + { + list.Add(child); + } } + + return list.ToArray(); } - private void OnComponentRemoving(object sender, ComponentEventArgs e) + /// + /// Returns the control that represents the UI for the given component. + /// + protected Control GetControl(object component) { - if (e.Component is Control comp && comp.Parent != null && comp.Parent == Control) + IComponent comp = component as IComponent; + if (comp != null) { - pendingRemoveControl = (Control)comp; - //We suspend Component Changing Events for bulk operations to avoid unnecessary serialization\deserialization for undo - if (suspendChanging == 0) + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) { - _componentChangeService.OnComponentChanging(Control, TypeDescriptor.GetProperties(Control)["Controls"]); + ControlDesigner cd = host.GetDesigner(comp) as ControlDesigner; + if (cd != null) + { + return cd.Control; + } } } - } - - internal void SuspendChangingEvents() - { - suspendChanging++; - Debug.Assert(suspendChanging > 0, "Unbalanced SuspendChangingEvents\\ResumeChangingEvents"); - } - - internal void ForceComponentChanging() - { - _componentChangeService.OnComponentChanging(Control, TypeDescriptor.GetProperties(Control)["Controls"]); - } - - internal void ResumeChangingEvents() - { - suspendChanging--; - Debug.Assert(suspendChanging >= 0, "Unbalanced SuspendChangingEvents\\ResumeChangingEvents"); - } - public override void InitializeNewComponent(IDictionary defaultValues) - { - throw new NotImplementedException(SR.NotImplementedByDesign); + return null; } /// - /// Called in order to cleanup a drag and drop operation. Here we - /// cleanup any operations that were performed at the beginning of a drag. + /// Computes the next default location for a control. It tries to find a spot + /// where no other controls are being obscured and the new control has 2 corners + /// that don't have other controls under them. /// - protected override void OnDragComplete(DragEventArgs de) + private Rectangle GetControlStackLocation(Rectangle centeredLocation) { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + Control parent = Control; - /// - /// Called in response to a drag drop for OLE drag and drop. Here we - /// drop a toolbox component on our parent control. - /// - // Standard 'catch all - rethrow critical' exception pattern - protected override void OnDragDrop(DragEventArgs de) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + int parentHeight = parent.ClientSize.Height; + int parentWidth = parent.ClientSize.Width; - /// - /// Called in response to a drag enter for OLE drag and drop. - /// - protected override void OnDragEnter(DragEventArgs de) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + if (centeredLocation.Bottom >= parentHeight || + centeredLocation.Right >= parentWidth) + { + centeredLocation.X = DefaultControlLocation.X; + centeredLocation.Y = DefaultControlLocation.Y; + } - /// - /// Called when a drag-drop operation leaves the control designer view - /// - protected override void OnDragLeave(EventArgs e) - { - throw new NotImplementedException(SR.NotImplementedByDesign); + return centeredLocation; } /// - /// Called when a drag drop object is dragged over the control designer view + /// Retrieves the default dimensions for the given component class. /// - protected override void OnDragOver(DragEventArgs de) + private Size GetDefaultSize(IComponent component) { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + //Check to see if the control is AutoSized. VSWhidbey #416721 + PropertyDescriptor prop = TypeDescriptor.GetProperties(component)["AutoSize"]; + + Size size; + if (prop != null && + !(prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden) || + prop.Attributes.Contains(BrowsableAttribute.No))) + { + bool autoSize = (bool)prop.GetValue(component); + if (autoSize) + { + prop = TypeDescriptor.GetProperties(component)["PreferredSize"]; + if (prop != null) + { + size = (Size)prop.GetValue(component); + if (size != Size.Empty) + { + return size; + } + } + } + } + + // attempt to get the size property of our component + // + prop = TypeDescriptor.GetProperties(component)["Size"]; + + if (prop != null) + { + // first, let's see if we can get a valid size... + size = (Size)prop.GetValue(component); + + // ...if not, we'll see if there's a default size attribute... + if (size.Width <= 0 || size.Height <= 0) + { + var sizeAttr = (DefaultValueAttribute)prop.Attributes[typeof(DefaultValueAttribute)]; + if (sizeAttr != null) + { + return ((Size)sizeAttr.Value); + } + } + else + { + return size; + } + } + + // Couldn't get the size or a def size attrib, returning 75,23... + // + return (new Size(75, 23)); + } + + /// + /// Returns a 'BodyGlyph' representing the bounds of this control. + /// The BodyGlyph is responsible for hit testing the related CtrlDes + /// and forwarding messages directly to the designer. + /// + protected override ControlBodyGlyph GetControlGlyph(GlyphSelectionType selectionType) + { + OnSetCursor(); + + Rectangle controlRect = BehaviorService.ControlRectInAdornerWindow(Control); + + Control parent = Control.Parent; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + if (parent != null && host != null && host.RootComponent != Component) + { + Rectangle parentRect = BehaviorService.ControlRectInAdornerWindow(parent); + Rectangle nonClipRect = Rectangle.Intersect(parentRect, controlRect); + + // If we are not selected... + + if (selectionType == GlyphSelectionType.NotSelected) + { + // If we are partially clipped (not fully clipped or wholly contained) by + // our parent,then adjust the bounds of the glyph to be the "visible" rect. VSWhidbey 530929 + if (!nonClipRect.IsEmpty && !parentRect.Contains(controlRect)) + { + return new ControlBodyGlyph(nonClipRect, Cursor.Current, Control, this); + } + + // If we are completely clipped, then we do not want to be a drop target at all + else if (nonClipRect.IsEmpty) + { + return null; + } + } + } + + return new ControlBodyGlyph(controlRect, Cursor.Current, Control, this); + } + + /// + /// Adds our ContainerSelectorGlyph to the selection glyphs. + /// + public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) + { + GlyphCollection glyphs = base.GetGlyphs(selectionType); + + //only add this glyph if our container is 1) moveable 2) not read-only + //AND 3) it is selected . + if ((SelectionRules & SelectionRules.Moveable) != 0 && + InheritanceAttribute != InheritanceAttribute.InheritedReadOnly && selectionType != GlyphSelectionType.NotSelected) + { + //get the adornerwindow-relative coords for the container control + Point loc = BehaviorService.ControlToAdornerWindow((Control)Component); + Rectangle translatedBounds = new Rectangle(loc, ((Control)Component).Size); + + int glyphOffset = (int)(DesignerUtils.CONTAINERGRABHANDLESIZE * .5); + + //if the control is too small for our ideal position... + if (translatedBounds.Width < 2 * DesignerUtils.CONTAINERGRABHANDLESIZE) + { + glyphOffset = -1 * glyphOffset; + } + + ContainerSelectorBehavior behavior = new ContainerSelectorBehavior((Control)Component, Component.Site, true); + ContainerSelectorGlyph containerSelectorGlyph = new ContainerSelectorGlyph(translatedBounds, DesignerUtils.CONTAINERGRABHANDLESIZE, glyphOffset, behavior); + + glyphs.Insert(0, containerSelectorGlyph); + } + + return glyphs; + } + + internal OleDragDropHandler GetOleDragHandler() + { + if (_oleDragDropHandler == null) + { + _oleDragDropHandler = new OleDragDropHandler(null, (IServiceProvider)GetService(typeof(IDesignerHost)), this); + } + + return _oleDragDropHandler; + } + + /// + /// This method return the ParentControlDesigner of the parenting control, + /// it is used for inheriting the grid size, snap to grid, and draw grid + /// of parenting controls. + /// + private ParentControlDesigner GetParentControlDesignerOfParent() + { + Control parent = Control.Parent; + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (parent != null && host != null) + { + return (host.GetDesigner(parent) as ParentControlDesigner); + } + + return null; + } + + /// + /// Updates the location of the control according to the GridSnap and Size. + /// This method simply calls GetUpdatedRect(), then ignores the width and + /// height + /// + private Rectangle GetAdjustedSnapLocation(Rectangle originalRect, Rectangle dragRect) + { + Rectangle adjustedRect = GetUpdatedRect(originalRect, dragRect, true); + + //now, preserve the width and height that was originally passed in + adjustedRect.Width = dragRect.Width; + adjustedRect.Height = dragRect.Height; + + //we need to keep in mind that if we adjust to the snap, that we could + //have possibly moved the control's position outside of the display rect. + //ex: groupbox's display rect.x = 3, but we might snap to 0. + //so we need to check with the control's designer to make sure this + //doesn't happen + // + Point minimumLocation = DefaultControlLocation; + if (adjustedRect.X < minimumLocation.X) + { + adjustedRect.X = minimumLocation.X; + } + + if (adjustedRect.Y < minimumLocation.Y) + { + adjustedRect.Y = minimumLocation.Y; + } + + //here's our rect that has been snapped to grid + return adjustedRect; + } + + internal Point GetSnappedPoint(Point pt) + { + Rectangle r = GetUpdatedRect(Rectangle.Empty, new Rectangle(pt.X, pt.Y, 0, 0), false); + return new Point(r.X, r.Y); + } + + internal Rectangle GetSnappedRect(Rectangle originalRect, Rectangle dragRect, bool updateSize) + { + return GetUpdatedRect(originalRect, dragRect, updateSize); + } + + /// + /// Updates the given rectangle, adjusting it for grid snaps as + /// needed. + /// + protected Rectangle GetUpdatedRect(Rectangle originalRect, Rectangle dragRect, bool updateSize) + { + Rectangle updatedRect; + if (SnapToGrid) + { + Size gridSize = GridSize; + Point halfGrid = new Point(gridSize.Width / 2, gridSize.Height / 2); + + updatedRect = dragRect; + updatedRect.X = originalRect.X; + updatedRect.Y = originalRect.Y; + + // decide to snap the start location to grid ... + // + if (dragRect.X != originalRect.X) + { + updatedRect.X = (dragRect.X / gridSize.Width) * gridSize.Width; + + // Snap the location to the grid point closest to the dragRect location + // + if (dragRect.X - updatedRect.X > halfGrid.X) + { + updatedRect.X += gridSize.Width; + } + } + + if (dragRect.Y != originalRect.Y) + { + updatedRect.Y = (dragRect.Y / gridSize.Height) * gridSize.Height; + + // Snap the location to the grid point closest to the dragRect location + // + if (dragRect.Y - updatedRect.Y > halfGrid.Y) + { + updatedRect.Y += gridSize.Height; + } + } + + // here, we need to calculate the new size depending on how we snap to the grid ... + // + if (updateSize) + { + // update the width and the height + // + updatedRect.Width = ((dragRect.X + dragRect.Width) / gridSize.Width) * gridSize.Width - updatedRect.X; + updatedRect.Height = ((dragRect.Y + dragRect.Height) / gridSize.Height) * gridSize.Height - updatedRect.Y; + + // ASURT 71552 Added so that if the updated dimnesion is smaller than grid dimension then snap that dimension to + // the grid dimension + // + if (updatedRect.Width < gridSize.Width) + updatedRect.Width = gridSize.Width; + if (updatedRect.Height < gridSize.Height) + updatedRect.Height = gridSize.Height; + } + } + else + { + updatedRect = dragRect; + } + + return updatedRect; + } + + /// + /// Initializes the designer with the given component. The designer can + /// get the component's site and request services from it in this call. + /// + public override void Initialize(IComponent component) + { + base.Initialize(component); + + if (Control is ScrollableControl) + { + ((ScrollableControl)Control).Scroll += new ScrollEventHandler(OnScroll); + } + + EnableDragDrop(true); + + // Hook load events. At the end of load, we need to do a scan through all + // of our child controls to see which ones are being inherited. We + // connect these up. + // + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + _componentChangeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); + if (_componentChangeSvc != null) + { + _componentChangeSvc.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); + _componentChangeSvc.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + } + } + + // update the Status Command + _statusCommandUI = new StatusCommandUI(component.Site); + } + + /// + /// + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + if (!AllowControlLasso) + { + return; + } + + if (defaultValues != null && defaultValues["Size"] != null && defaultValues["Location"] != null && defaultValues["Parent"] != null) + { + //build our rect that may have covered some child controls + Rectangle bounds = new Rectangle((Point)defaultValues["Location"], (Size)defaultValues["Size"]); + + //ask the parent to give us the comps within this rect + IComponent parent = defaultValues["Parent"] as IComponent; + if (parent == null) + { + Debug.Fail("Couldn't get the parent instance from 'defaultValues'"); + return; + } + + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host == null) + { + Debug.Fail("Failed to IDesignerHost"); + return; + } + + ParentControlDesigner parentDesigner = host.GetDesigner(parent) as ParentControlDesigner; + if (parentDesigner == null) + { + Debug.Fail("Could not get ParentControlDesigner for " + parent); + return; + } + + object[] comps = parentDesigner.GetComponentsInRect(bounds, true, true /* component should be fully contained*/); + + if (comps == null || comps.Length == 0) + { + //no comps to re-parent + return; + } + + ArrayList selectedControls = new ArrayList(comps); + + //remove this + if (selectedControls.Contains(Control)) + { + selectedControls.Remove(Control); + } + + //Finally, we have identified that we need to re-parent the lasso'd controls. + //We will start a designer transaction, send some changing notifications + //and swap parents... + // + ReParentControls(Control, selectedControls, string.Format(SR.ParentControlDesignerLassoShortcutRedo, Control.Site.Name), host); + } + } + + /// + /// Checks if an option has the default value + /// + private bool IsOptionDefault(string optionName, object value) + { + IDesignerOptionService optSvc = (IDesignerOptionService)GetService(typeof(IDesignerOptionService)); + + object defaultValue = null; + + if (optSvc == null) + { + if (optionName.Equals("ShowGrid")) + { + defaultValue = true; + } + else if (optionName.Equals("SnapToGrid")) + { + defaultValue = true; + } + else if (optionName.Equals("GridSize")) + { + defaultValue = new Size(8, 8); + } + } + else + { + defaultValue = DesignerUtils.GetOptionValue(ServiceProvider, optionName); + } + + if (defaultValue != null) + { + return defaultValue.Equals(value); + } + else + { + return value == null; + } + } + + /// + /// + private void OnComponentRemoving(object sender, ComponentEventArgs e) + { + Control comp = e.Component as Control; + if (comp != null && comp.Parent != null && comp.Parent == Control) + { + _pendingRemoveControl = comp; + //We suspend Component Changing Events for bulk operations to avoid unnecessary serialization\deserialization for undo + // see bug 488115 + if (_suspendChanging == 0) + { + _componentChangeSvc.OnComponentChanging(Control, TypeDescriptor.GetProperties(Control)["Controls"]); + } + } + } + + /// + /// + private void OnComponentRemoved(object sender, ComponentEventArgs e) + { + if (e.Component == _pendingRemoveControl) + { + _pendingRemoveControl = null; + _componentChangeSvc.OnComponentChanged(Control, TypeDescriptor.GetProperties(Control)["Controls"], null, null); + } + } + + internal void SuspendChangingEvents() + { + _suspendChanging++; + Debug.Assert(_suspendChanging > 0, "Unbalanced SuspendChangingEvents\\ResumeChangingEvents"); + } + + internal void ResumeChangingEvents() + { + _suspendChanging--; + Debug.Assert(_suspendChanging >= 0, "Unbalanced SuspendChangingEvents\\ResumeChangingEvents"); + } + + internal void ForceComponentChanging() + { + _componentChangeSvc.OnComponentChanging(Control, TypeDescriptor.GetProperties(Control)["Controls"]); + } + + /// + /// Called in order to cleanup a drag and drop operation. Here we + /// cleanup any operations that were performed at the beginning of a drag. + /// + protected override void OnDragComplete(DragEventArgs de) + { + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data != null) + { + data.CleanupDrag(); + } + } + + /// + /// Called in response to a drag drop for OLE drag and drop. Here we + /// drop a toolbox component on our parent control. + /// + // Standard 'catch all - rethrow critical' exception pattern + protected override void OnDragDrop(DragEventArgs de) + { + //if needed, cache extra info about the behavior dragdrop event + //ex: snapline and offset info + if (de is ToolboxSnapDragDropEventArgs) + { + _toolboxSnapDragDropEventArgs = de as ToolboxSnapDragDropEventArgs; + } + + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data != null) + { + data.Target = Component; + data.EndDragDrop(AllowSetChildIndexOnDrop); + + OnDragComplete(de); + } + + // this should only occur when D&Ding between component trays on two separate forms. + else if (_mouseDragTool == null && data == null) + { + OleDragDropHandler ddh = GetOleDragHandler(); + if (ddh != null) + { + IOleDragClient target = ddh.Destination; + if (target != null && target.Component != null && target.Component.Site != null) + { + IContainer container = target.Component.Site.Container; + if (container != null) + { + object[] dragComps = ddh.GetDraggingObjects(de); + for (int i = 0; i < dragComps.Length; i++) + { + IComponent comp = dragComps[i] as IComponent; + container.Add(comp); + } + } + } + } + } + + if (_mouseDragTool != null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + host.Activate(); + } + + try + { + //There may be a wizard displaying as a result of CreateTool. + //we do not want the behavior service thinking there he is dragging while this wizard is up + //it causes the cursor to constantly flicker to the toolbox cursor. + if (BehaviorService != null) + { + //this will cause the BehSvc to return from 'drag mode' + // + BehaviorService.EndDragNotification(); + } + + CreateTool(_mouseDragTool, new Point(de.X, de.Y)); + } + catch (Exception e) + { + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + else + { + DisplayError(e); + } + } + + _mouseDragTool = null; + return; + } + } + + /// + /// Called in response to a drag enter for OLE drag and drop. + /// + protected override void OnDragEnter(DragEventArgs de) + { + // Are we are new target, meaning is the drop target different than the drag source + bool newTarget = false; + + DropSourceBehavior.BehaviorDataObject behDataObject = null; + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data != null) + { + behDataObject = data; + behDataObject.Target = Component; + de.Effect = (Control.ModifierKeys == Keys.Control) ? DragDropEffects.Copy : DragDropEffects.Move; + newTarget = !(data.Source.Equals(Component)); //Check if we are moving to a new target + } + + // If tab order UI is being shown, then don't allow anything to be + // dropped here. + // + IMenuCommandService ms = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (ms != null) + { + MenuCommand tabCommand = ms.FindCommand(StandardCommands.TabOrder); + if (tabCommand != null && tabCommand.Checked) + { + de.Effect = DragDropEffects.None; + return; + } + } + + // Get the objects that are being dragged + // + object[] dragComps; + if (behDataObject != null && behDataObject.DragComponents != null) + { + dragComps = new object[behDataObject.DragComponents.Count]; + behDataObject.DragComponents.CopyTo(dragComps, 0); + } + else + { + OleDragDropHandler ddh = GetOleDragHandler(); + dragComps = ddh.GetDraggingObjects(de); + } + + Control draggedControl = null; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + DocumentDesigner parentDesigner = host.GetDesigner(host.RootComponent) as DocumentDesigner; + if (parentDesigner != null) + { + if (!parentDesigner.CanDropComponents(de)) + { + de.Effect = DragDropEffects.None; + return; + } + } + } + + if (dragComps != null) + { + if (data == null) + { + // This should only be true, when moving a component from the Tray, + // to a new form. In this case, we are moving targets. + newTarget = true; + } + + for (int i = 0; i < dragComps.Length; i++) + { + IComponent comp = dragComps[i] as IComponent; + if (host == null || comp == null) + { + continue; + } + + if (newTarget) + { + // If we are dropping on a new target, then check to see if any of the components + // are inherited. If so, don't allow them to be moved. + InheritanceAttribute attr = (InheritanceAttribute)TypeDescriptor.GetAttributes(comp)[typeof(InheritanceAttribute)]; + if (attr != null && !attr.Equals(InheritanceAttribute.NotInherited) && !attr.Equals(InheritanceAttribute.InheritedReadOnly)) + { + de.Effect = DragDropEffects.None; + return; + } + } + + // try go get the control for the thing that's being dragged + // + object draggedDesigner = host.GetDesigner(comp); + if (draggedDesigner is IOleDragClient) + { + draggedControl = ((IOleDragClient)this).GetControlForComponent(dragComps[i]); + } + + Control ctrl = dragComps[i] as Control; + if (draggedControl == null && ctrl != null) + { + draggedControl = ctrl; + } + + // oh well, it's not a control so it doesn't matter + // + if (draggedControl == null) + { + continue; + } + + // If we're inheriting from a private container, we can't modify the controls collection. + // So drag-drop is only allowed within the container i.e. the dragged controls must already + // be parented to this container. + // + if (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly && draggedControl.Parent != Control) + { + de.Effect = DragDropEffects.None; + return; + } + + //Can the component be dropped on this parent? I.e. you can only + //drop a tab page on a tab control, not say a panel + if (!((IOleDragClient)this).IsDropOk(comp)) + { + de.Effect = DragDropEffects.None; + return; + } + } + + // should only occur when dragging and dropping + // from the component tray. + if (data == null) + { + PerformDragEnter(de, host); + } + } + + if (_toolboxService == null) + { + _toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); + } + + // Only assume the items came from the ToolBox if dragComps == null + // + if (_toolboxService != null && dragComps == null) + { + _mouseDragTool = _toolboxService.DeserializeToolboxItem(de.Data, host); + + //If we have a valid toolbox item to drag and + //we haven't pushed our behaivor, then do so now... + if ((_mouseDragTool != null) && BehaviorService != null && BehaviorService.UseSnapLines) + { + //demand create + if (_toolboxItemSnapLineBehavior == null) + { + _toolboxItemSnapLineBehavior = new ToolboxItemSnapLineBehavior(Component.Site, BehaviorService, this, AllowGenericDragBox); + } + + if (!_toolboxItemSnapLineBehavior.IsPushed) + { + BehaviorService.PushBehavior(_toolboxItemSnapLineBehavior); + _toolboxItemSnapLineBehavior.IsPushed = true; + } + } + + if (_mouseDragTool != null) + { + PerformDragEnter(de, host); + } + + // This must be called last. Tell the behavior that we are beginning a drag. + // Yeah, this is OnDragEnter, but to the behavior this is as if we are starting a drag. + // VSWhidbey 487816 + if (_toolboxItemSnapLineBehavior != null) + { + _toolboxItemSnapLineBehavior.OnBeginDrag(); + } + } + } + + private void PerformDragEnter(DragEventArgs de, IDesignerHost host) + { + if (host != null) + { + host.Activate(); + } + + Debug.Assert(0 != (de.AllowedEffect & (DragDropEffects.Move | DragDropEffects.Copy)), "DragDropEffect.Move | .Copy isn't allowed?"); + if ((de.AllowedEffect & DragDropEffects.Move) != 0) + { + de.Effect = DragDropEffects.Move; + } + else + { + de.Effect = DragDropEffects.Copy; + } + + // If we're inheriting from a private container, we can't modify the controls collection. + if (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly) + { + de.Effect = DragDropEffects.None; + return; + } + + // Also, select this parent control to indicate it will be the drop target. + // + ISelectionService sel = (ISelectionService)GetService(typeof(ISelectionService)); + if (sel != null) + { + sel.SetSelectedComponents(new object[] { Component }, SelectionTypes.Replace); + } + } + + /// + /// Called when a drag-drop operation leaves the control designer view + /// + protected override void OnDragLeave(EventArgs e) + { + //if we're dragging around our generic snapline box - let's remove it here + if (_toolboxItemSnapLineBehavior != null && _toolboxItemSnapLineBehavior.IsPushed) + { + BehaviorService.PopBehavior(_toolboxItemSnapLineBehavior); + _toolboxItemSnapLineBehavior.IsPushed = false; + } + + _mouseDragTool = null; + } + + /// + /// Called when a drag drop object is dragged over the control designer view + /// + protected override void OnDragOver(DragEventArgs de) + { + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data != null) + { + data.Target = Component; + de.Effect = (Control.ModifierKeys == Keys.Control) ? DragDropEffects.Copy : DragDropEffects.Move; + } + + Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\tParentControlDesigner.OnDragOver: " + de.ToString()); + + // If tab order UI is being shown, then don't allow anything to be + // dropped here. + // + IMenuCommandService ms = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (ms != null) + { + MenuCommand tabCommand = ms.FindCommand(StandardCommands.TabOrder); + Debug.Assert(tabCommand != null, "Missing tab order command"); + if (tabCommand != null && tabCommand.Checked) + { + de.Effect = DragDropEffects.None; + return; + } + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host != null) + { + DocumentDesigner parentDesigner = host.GetDesigner(host.RootComponent) as DocumentDesigner; + if (parentDesigner != null) + { + if (!parentDesigner.CanDropComponents(de)) + { + de.Effect = DragDropEffects.None; + return; + } + } + } + + if (_mouseDragTool != null) + { + Debug.Assert(0 != (de.AllowedEffect & DragDropEffects.Copy), "DragDropEffect.Move isn't allowed?"); + de.Effect = DragDropEffects.Copy; + return; + } + + Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\tParentControlDesigner.OnDragOver: " + de.ToString()); + } + + /// + /// Called in response to the left mouse button being pressed on a + /// component. The designer overrides this to provide a + /// "lasso" selection for components within the control. + /// + + private static int FrameWidth(FrameStyle style) + { + return (style == FrameStyle.Dashed ? 1 : 2); + } + + protected override void OnMouseDragBegin(int x, int y) + { + Control control = Control; + + // Figure out the drag frame style. We use a dotted line for selecting + // a component group, and a thick line for creating a new component. + // If we are a privately inherited component, then we always use the + // selection frame because we can't add components. + // + if (!InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly)) + { + if (_toolboxService == null) + { + _toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); + } + + if (_toolboxService != null) + { + _mouseDragTool = _toolboxService.GetSelectedToolboxItem((IDesignerHost)GetService(typeof(IDesignerHost))); + } + } + + // Set the mouse capture and clipping to this control. + // + control.Capture = true; + + RECT winRect = default; + User32.GetWindowRect(control.Handle, ref winRect); + Rectangle.FromLTRB(winRect.left, winRect.top, winRect.right, winRect.bottom); + + _mouseDragFrame = (_mouseDragTool == null) ? FrameStyle.Dashed : FrameStyle.Thick; + + // Setting this non-null signifies that we are dragging with the + // mouse. + // + _mouseDragBase = new Point(x, y); + + // Select the given object. + // + ISelectionService selsvc = (ISelectionService)GetService(typeof(ISelectionService)); + + if (selsvc != null) + { + selsvc.SetSelectedComponents(new object[] { Component }, SelectionTypes.Primary); + } + + // Get the event handler service. We push a handler to handle the escape + // key. + // + IEventHandlerService eventSvc = (IEventHandlerService)GetService(typeof(IEventHandlerService)); + //UNDONE: Behavior Work + //Debug.Assert(escapeHandler == null, "Why is there already an escape handler?"); + + if (eventSvc != null && _escapeHandler == null) + { + _escapeHandler = new EscapeHandler(this); + eventSvc.PushHandler(_escapeHandler); + } + + //Need this since we are drawing the frame in the adorner window + _adornerWindowToScreenOffset = BehaviorService.AdornerWindowToScreen(); + } + + /// + /// Called at the end of a drag operation. This either commits or rolls back the + /// drag. + /// + // Standard 'catch all - rethrow critical' exception pattern + protected override void OnMouseDragEnd(bool cancel) + { + // Do nothing if we're not dragging anything around + // + if (_mouseDragBase == InvalidPoint) + { + Debug.Assert(_graphics == null); + // make sure we force the drag end + base.OnMouseDragEnd(cancel); + return; + } + + // Important to null these out here, just in case we throw an exception + // + Rectangle offset = _mouseDragOffset; + ToolboxItem tool = _mouseDragTool; + Point baseVar = _mouseDragBase; + + _mouseDragOffset = Rectangle.Empty; + _mouseDragBase = InvalidPoint; + _mouseDragTool = null; + + Control.Capture = false; + Cursor.Clip = Rectangle.Empty; + + // Clear out the drag frame. + if (!offset.IsEmpty && _graphics != null) + { + Rectangle frameRect = new Rectangle(offset.X - _adornerWindowToScreenOffset.X, + offset.Y - _adornerWindowToScreenOffset.Y, + offset.Width, offset.Height); + + int frameWidth = FrameWidth(_mouseDragFrame); + _graphics.SetClip(frameRect); + + using (Region newRegion = new Region(frameRect)) + { + newRegion.Exclude(Rectangle.Inflate(frameRect, -frameWidth, -frameWidth)); + BehaviorService.Invalidate(newRegion); + } + + _graphics.ResetClip(); + } + + if (_graphics != null) + { + _graphics.Dispose(); + _graphics = null; + } + + //destroy the snapline engine (if we used it) + if (_dragManager != null) + { + _dragManager.OnMouseUp(); + _dragManager = null; + } + + // Get the event handler service and pop our handler. + // + IEventHandlerService eventSvc = (IEventHandlerService)GetService(typeof(IEventHandlerService)); + if (eventSvc != null && _escapeHandler != null) + { + eventSvc.PopHandler(_escapeHandler); + _escapeHandler = null; + } + + // Set Status Information - but only if the offset is not empty, if it is, the user didn't move the mouse + if (_statusCommandUI != null && !offset.IsEmpty) + { + Point location = new(baseVar.X, baseVar.Y); + User32.MapWindowPoints(IntPtr.Zero, Control.Handle, ref location, 1); + if (_statusCommandUI != null) + { + _statusCommandUI.SetStatusInformation(new Rectangle(location.X, location.Y, offset.Width, offset.Height)); + } + } + + // Quit now if we don't have an offset rect. This indicates that + // the user didn't move the mouse. + // + if (offset.IsEmpty && !cancel) + { + // BUT, if we have a selected tool, create it here + if (tool != null) + { + try + { + CreateTool(tool, baseVar); + if (_toolboxService != null) + { + _toolboxService.SelectedToolboxItemUsed(); + } + } + catch (Exception e) + { + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + else + { + DisplayError(e); + } + } + } + + return; + } + + // Don't do anything else if the user wants to cancel. + // + if (cancel) + { + return; + } + + // If we have a valid toolbox item, create the tool + // + if (tool != null) + { + try + { + //avoid allowing the user creating a 1x1 sized control (for ex) + //by enforcing a min size 2xMinDragSize... + Size minControlSize = new Size(DesignerUtils.MinDragSize.Width * 2, DesignerUtils.MinDragSize.Height * 2); + if (offset.Width < minControlSize.Width) + { + offset.Width = minControlSize.Width; + } + + if (offset.Height < minControlSize.Height) + { + offset.Height = minControlSize.Height; + } + + CreateTool(tool, offset); + if (_toolboxService != null) + { + _toolboxService.SelectedToolboxItemUsed(); + } + } + catch (Exception e) + { + if (ClientUtils.IsCriticalException(e)) + { + throw; + } + else + { + DisplayError(e); + } + } + } + else + { + // Now find the set of controls within this offset and + // select them. + // + var selSvc = (ISelectionService)GetService(typeof(ISelectionService)); + if (selSvc != null) + { + object[] selection = GetComponentsInRect(offset, true, false /*component does not need to be fully contained*/); + if (selection.Length > 0) + { + selSvc.SetSelectedComponents(selection); + } + } + } + } + + /// + /// Called for each movement of the mouse. This will check to see if a drag operation + /// is in progress. If so, it will pass the updated drag dimensions on to the selection + /// UI service. + /// + protected override void OnMouseDragMove(int x, int y) + { + //if we puhsed a snapline behavior during a drag operation - make sure we have popped it + //if we're now receiving mouse move messages. + if (_toolboxItemSnapLineBehavior != null && _toolboxItemSnapLineBehavior.IsPushed) + { + BehaviorService.PopBehavior(_toolboxItemSnapLineBehavior); + _toolboxItemSnapLineBehavior.IsPushed = false; + } + + // if we're doing an OLE drag, do nothing, or + // Do nothing if we haven't initiated a drag + // + if (GetOleDragHandler().Dragging || _mouseDragBase == InvalidPoint) + { + return; + } + + Rectangle oldFrameRect = _mouseDragOffset; + + // Calculate the new offset. + // + _mouseDragOffset.X = _mouseDragBase.X; + _mouseDragOffset.Y = _mouseDragBase.Y; + _mouseDragOffset.Width = x - _mouseDragBase.X; + _mouseDragOffset.Height = y - _mouseDragBase.Y; + + //if we have a valid dragtool - then we'll spin up our snapline engine + //and use it when the user drags a reversible rect -- but only if the + //parentcontroldesigner wants to allow Snaplines + + if (_dragManager == null && ParticipatesWithSnapLines && _mouseDragTool != null && BehaviorService.UseSnapLines) + { + _dragManager = new DragAssistanceManager(Component.Site); + } + + if (_dragManager != null) + { + //here, we build up our new rect (offset by the adorner window) + //and ask the snapline engine to adjust our coords + Rectangle r = new Rectangle(_mouseDragBase.X - _adornerWindowToScreenOffset.X, + _mouseDragBase.Y - _adornerWindowToScreenOffset.Y, + x - _mouseDragBase.X, y - _mouseDragBase.Y); + Point offset = _dragManager.OnMouseMove(r, GenerateNewToolSnapLines(r)); + _mouseDragOffset.Width += offset.X; + _mouseDragOffset.Height += offset.Y; + _dragManager.RenderSnapLinesInternal(); + } + + if (_mouseDragOffset.Width < 0) + { + _mouseDragOffset.X += _mouseDragOffset.Width; + _mouseDragOffset.Width = -_mouseDragOffset.Width; + } + + if (_mouseDragOffset.Height < 0) + { + _mouseDragOffset.Y += _mouseDragOffset.Height; + _mouseDragOffset.Height = -_mouseDragOffset.Height; + } + + // If we're dragging out a new component, update the drag rectangle + // to use snaps, if they're set. + // + if (_mouseDragTool != null) + { + // To snap properly, we must snap in client coordinates. So, convert, snap + // and re-convert. + // + _mouseDragOffset = Control.RectangleToClient(_mouseDragOffset); + _mouseDragOffset = GetUpdatedRect(Rectangle.Empty, _mouseDragOffset, true); + _mouseDragOffset = Control.RectangleToScreen(_mouseDragOffset); + } + + if (_graphics == null) + { + _graphics = BehaviorService.AdornerWindowGraphics; + } + + // And draw the new drag frame + if (!_mouseDragOffset.IsEmpty && _graphics != null) + { + Rectangle frameRect = new Rectangle(_mouseDragOffset.X - _adornerWindowToScreenOffset.X, + _mouseDragOffset.Y - _adornerWindowToScreenOffset.Y, + _mouseDragOffset.Width, _mouseDragOffset.Height); + + //graphics.SetClip(frameRect); + + //draw the new border + using (Region newRegion = new Region(frameRect)) + { + int frameWidth = FrameWidth(_mouseDragFrame); + newRegion.Exclude(Rectangle.Inflate(frameRect, -frameWidth, -frameWidth)); + + //erase the right part of the old frame + if (!oldFrameRect.IsEmpty) + { + oldFrameRect.X -= _adornerWindowToScreenOffset.X; + oldFrameRect.Y -= _adornerWindowToScreenOffset.Y; - protected override void OnMouseDragBegin(int x, int y) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + //Let's not try and be smart about invalidating just the part of the old frame + //that's not part of the new frame. When I did that (using the commented out + //lines below), you could get serious screen artifacts when dragging fast. I think + //this might be because of some bad region forming (bad region, bad), or some missing + //updates. - /// - /// Called at the end of a drag operation. This either commits or rolls back the - /// drag. - /// - // Standard 'catch all - rethrow critical' exception pattern - protected override void OnMouseDragEnd(bool cancel) - { - throw new NotImplementedException(SR.NotImplementedByDesign); - } + // Since we invalidate and then immediately redraw, the flicker should be minimal. + using (Region oldRegion = new Region(oldFrameRect)) + { + oldRegion.Exclude(Rectangle.Inflate(oldFrameRect, -frameWidth, -frameWidth)); + //oldRegion.Union(newRegion); + //oldRegion.Exclude(newRegion); + BehaviorService.Invalidate(oldRegion); + } + } - /// - /// Called for each movement of the mouse. This will check to see if a drag operation - /// is in progress. If so, it will pass the updated drag dimensions on to the selection - /// UI service. - /// - protected override void OnMouseDragMove(int x, int y) - { - throw new NotImplementedException(SR.NotImplementedByDesign); + DesignerUtils.DrawFrame(_graphics, newRegion, _mouseDragFrame, Control.BackColor); + } + + //graphics.ResetClip(); + } + + // We are looking at the primary control + if (_statusCommandUI != null) + { + Point offset = new(_mouseDragOffset.X, _mouseDragOffset.Y); + User32.MapWindowPoints(IntPtr.Zero, Control.Handle, ref offset, 1); + if (_statusCommandUI != null) + { + _statusCommandUI.SetStatusInformation(new Rectangle(offset.X, offset.Y, _mouseDragOffset.Width, _mouseDragOffset.Height)); + } + } } /// @@ -669,7 +2287,29 @@ protected override void OnMouseDragMove(int x, int y) /// protected override void OnPaintAdornments(PaintEventArgs pe) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (DrawGrid) + { + Control control = Control; + + Rectangle displayRect = Control.DisplayRectangle; + Rectangle clientRect = Control.ClientRectangle; + + Rectangle paintRect = new(Math.Min(displayRect.X, clientRect.X), + Math.Min(displayRect.Y, clientRect.Y), + Math.Max(displayRect.Width, clientRect.Width), + Math.Max(displayRect.Height, clientRect.Height)); + + float xlateX = paintRect.X; + float xlateY = paintRect.Y; + pe.Graphics.TranslateTransform(xlateX, xlateY); + paintRect.X = paintRect.Y = 0; + paintRect.Width++; // gpr: FillRectangle with a TextureBrush comes up one pixel short + paintRect.Height++; + ControlPaint.DrawGrid(pe.Graphics, paintRect, GridSize, control.BackColor); + pe.Graphics.TranslateTransform(-xlateX, -xlateY); + } + + base.OnPaintAdornments(pe); } /// @@ -677,7 +2317,7 @@ protected override void OnPaintAdornments(PaintEventArgs pe) /// private void OnScroll(object sender, ScrollEventArgs se) { - throw new NotImplementedException(SR.NotImplementedByDesign); + BehaviorService.Invalidate(BehaviorService.ControlRectInAdornerWindow(Control)); } /// @@ -689,7 +2329,23 @@ private void OnScroll(object sender, ScrollEventArgs se) /// protected override void OnSetCursor() { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (_toolboxService == null) + { + _toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); + } + + try + { + if (_toolboxService == null || !_toolboxService.SetCursor() || InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly)) + { + Cursor.Current = Cursors.Default; + } + } + + catch + { // VSWhidbey 502536 + Cursor.Current = Cursors.Default; + } } /// @@ -703,7 +2359,500 @@ protected override void OnSetCursor() /// protected override void PreFilterProperties(IDictionary properties) { - throw new NotImplementedException(SR.NotImplementedByDesign); + base.PreFilterProperties(properties); + + // add the "GridSize, SnapToGrid and DrawGrid" property from the property grid + // iff the LayoutOption.SnapToGrid Attribute is Set... + + if (!DefaultUseSnapLines) + { + properties["DrawGrid"] = TypeDescriptor.CreateProperty(typeof(ParentControlDesigner), "DrawGrid", typeof(bool), + BrowsableAttribute.Yes, + DesignOnlyAttribute.Yes, + new SRDescriptionAttribute("ParentControlDesignerDrawGridDescr"), + CategoryAttribute.Design); + + properties["SnapToGrid"] = TypeDescriptor.CreateProperty(typeof(ParentControlDesigner), "SnapToGrid", typeof(bool), + BrowsableAttribute.Yes, + DesignOnlyAttribute.Yes, + new SRDescriptionAttribute("ParentControlDesignerSnapToGridDescr"), + CategoryAttribute.Design); + + properties["GridSize"] = TypeDescriptor.CreateProperty(typeof(ParentControlDesigner), "GridSize", typeof(Size), + BrowsableAttribute.Yes, + new SRDescriptionAttribute(SR.ParentControlDesignerGridSizeDescr), + DesignOnlyAttribute.Yes, + CategoryAttribute.Design); + } + + // We need this one always to make sure that Format -> Horizontal/Vertical Spacing works. + properties["CurrentGridSize"] = TypeDescriptor.CreateProperty(typeof(ParentControlDesigner), "CurrentGridSize", typeof(Size), + BrowsableAttribute.No, + DesignerSerializationVisibilityAttribute.Hidden); + } + + /// + /// Called after we have decided that the user has drawn a control (with a toolbox item picked) onto the designer + /// surface and intends to have the controls beneath the new one re-parented. Example: A user selects the 'Panel' + /// Control in the toolbox then drags a rectangle around four Buttons on the Form's surface. We'll attempt + /// to re-parent those four Buttons to the newly created Panel. + /// + private void ReParentControls(Control newParent, ArrayList controls, string transactionName, IDesignerHost host) + { + using (DesignerTransaction dt = host.CreateTransaction(transactionName)) + { + IComponentChangeService changeSvc = GetService(typeof(IComponentChangeService)) as IComponentChangeService; + + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(newParent)["Controls"]; + PropertyDescriptor locationProp = TypeDescriptor.GetProperties(newParent)["Location"]; + + //get the location of our parent - so we can correctly offset the new lasso'd controls + //once they are re-parented + Point parentLoc = Point.Empty; + if (locationProp != null) + { + parentLoc = (Point)locationProp.GetValue(newParent); + } + + if (changeSvc != null) + { + changeSvc.OnComponentChanging(newParent, controlsProp); + } + + //enumerate the lasso'd controls relocate and re-parent... + // + foreach (object comp in controls) + { + Control control = comp as Control; + Control oldParent = control.Parent; + Point controlLoc = Point.Empty; + + //do not want to reparent any control that is inherited readonly + InheritanceAttribute inheritanceAttribute = (InheritanceAttribute)TypeDescriptor.GetAttributes(control)[typeof(InheritanceAttribute)]; + if (inheritanceAttribute != null && inheritanceAttribute == InheritanceAttribute.InheritedReadOnly) + { + continue; + } + + //get the current location of the control + PropertyDescriptor locProp = TypeDescriptor.GetProperties(control)["Location"]; + if (locProp != null) + { + controlLoc = (Point)locProp.GetValue(control); + } + + //fire comp changing on parent and control + if (oldParent != null) + { + if (changeSvc != null) + { + changeSvc.OnComponentChanging(oldParent, controlsProp); + } + + //remove control from the old parent + oldParent.Controls.Remove(control); + } + + //finally add & relocate the control with the new parent + newParent.Controls.Add(control); + + Point newLoc = Point.Empty; + + //this condition will determine which way we need to 'offset' our control location + //based on whether we are moving controls into a child or bringing them out to + //a parent + if (oldParent != null) + { + if (oldParent.Controls.Contains(newParent)) + { + newLoc = new Point(controlLoc.X - parentLoc.X, controlLoc.Y - parentLoc.Y); + } + else + { + Point oldParentLoc = (Point)locProp.GetValue(oldParent); + newLoc = new Point(controlLoc.X + oldParentLoc.X, controlLoc.Y + oldParentLoc.Y); + } + } + + locProp.SetValue(control, newLoc); + + //fire our comp changed events + if (changeSvc != null && oldParent != null) + { + changeSvc.OnComponentChanged(oldParent, controlsProp, null, null); + } + } + + if (changeSvc != null) + { + changeSvc.OnComponentChanged(newParent, controlsProp, null, null); + } + + //commit the transaction + dt.Commit(); + } + } + + /// + /// Determines if the DrawGrid property should be persisted. + /// + private bool ShouldSerializeDrawGrid() + { + //To determine if we need to persist this value, we first need to check + //if we have a parent who is a parentcontroldesigner, then get their + //setting... + // + ParentControlDesigner parent = GetParentControlDesignerOfParent(); + if (parent != null) + { + return !(DrawGrid == parent.DrawGrid); + } + + //Otherwise, we'll compare the value to the options page... + // + return !IsOptionDefault("ShowGrid", DrawGrid); + } + + /// + /// Determines if the SnapToGrid property should be persisted. + /// + private bool ShouldSerializeSnapToGrid() + { + //To determine if we need to persist this value, we first need to check + //if we have a parent who is a parentcontroldesigner, then get their + //setting... + // + ParentControlDesigner parent = GetParentControlDesignerOfParent(); + if (parent != null) + { + return !(SnapToGrid == parent.SnapToGrid); + } + + //Otherwise, we'll compare the value to the options page... + // + return !IsOptionDefault("SnapToGrid", SnapToGrid); + } + + /// + /// Determines if the GridSize property should be persisted. + /// + private bool ShouldSerializeGridSize() + { + //To determine if we need to persist this value, we first need to check + //if we have a parent who is a parentcontroldesigner, then get their + //setting... + // + ParentControlDesigner parent = GetParentControlDesignerOfParent(); + if (parent != null) + { + return !(GridSize.Equals(parent.GridSize)); + } + + //Otherwise, we'll compare the value to the options page... + // + return !IsOptionDefault("GridSize", GridSize); + } + + private void ResetGridSize() + { + _getDefaultGridSize = true; + _parentCanSetGridSize = true; + //invalidate the control + Control control = Control; + if (control != null) + { + control.Invalidate(true); + } + } + + private void ResetDrawGrid() + { + _getDefaultDrawGrid = true; + _parentCanSetDrawGrid = true; + //invalidate the control + Control control = Control; + if (control != null) + { + control.Invalidate(true); + } + } + + private void ResetSnapToGrid() + { + _getDefaultGridSnap = true; + _parentCanSetGridSnap = true; + } + + /// + IComponent IOleDragClient.Component + { + get + { + return Component; + } + } + + /// + /// + /// Retrieves the control view instance for the designer that + /// is hosting the drag. + /// + bool IOleDragClient.AddComponent(IComponent component, string name, bool firstAdd) + { + IContainer container = DesignerUtils.CheckForNestedContainer(Component.Site.Container); // ...necessary to support SplitterPanel components + + bool containerMove = true; + IContainer oldContainer = null; + IDesignerHost localDesignerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); + + if (!firstAdd) + { + // just a move, so reparent + if (component.Site != null) + { + oldContainer = component.Site.Container; + containerMove = container != oldContainer; + if (containerMove) + { + oldContainer.Remove(component); + } + } + + if (containerMove) + { + // check if there's already a component by this name in the + // container + if (name != null && container.Components[name] != null) + { + name = null; + } + + // add it back + if (name != null) + { + container.Add(component, name); + } + else + { + container.Add(component); + } + } + } + + // make sure this designer will accept this component -- we wait until + // now to be sure the components designer has been created. + // + if (!((IOleDragClient)this).IsDropOk(component)) + { + try + { + IUIService uiSvc = (IUIService)GetService(typeof(IUIService)); + string error = string.Format(SR.DesignerCantParentType, component.GetType().Name, Component.GetType().Name); + if (uiSvc != null) + { + uiSvc.ShowError(error); + } + else + { + RTLAwareMessageBox.Show(null, error, null, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); + } + + return false; + } + finally + { + if (containerMove) + { + // move it back. + container.Remove(component); + if (oldContainer != null) + { + oldContainer.Add(component); + } + } + else + { + //there wad no container move ... but then this operation is not supported so + //just remove this component + container.Remove(component); + } + } + } + + // this is a chance to display a more specific error messages than on IsDropOK failure + if (!CanAddComponent(component)) + { + return false; + } + + // make sure we can handle this thing, otherwise hand it to the base components designer + // + Control c = GetControl(component); + + if (c != null) + { + // set it's handler to this + Control parent = GetParentForComponent(component); + Form form = c as Form; + + if (form == null || !form.TopLevel) + { + if (c.Parent != parent) + { + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(parent)["Controls"]; + // we want to insert rather than add it, so we add then move + // to the beginning + + if (c.Parent != null) + { + Control cParent = c.Parent; + if (_componentChangeSvc != null) + { + _componentChangeSvc.OnComponentChanging(cParent, controlsProp); + } + + cParent.Controls.Remove(c); + if (_componentChangeSvc != null) + { + _componentChangeSvc.OnComponentChanged(cParent, controlsProp, cParent.Controls, cParent.Controls); + } + } + + if (_suspendChanging == 0 && _componentChangeSvc != null) + { + _componentChangeSvc.OnComponentChanging(parent, controlsProp); + } + + parent.Controls.Add(c); + // sburke 78059 -- not sure why we need this call. this should move things to the beginning of the + // z-order, but do we need that? + // + //parent.Controls.SetChildIndex(c, 0); + if (_componentChangeSvc != null) + { + _componentChangeSvc.OnComponentChanged(parent, controlsProp, parent.Controls, parent.Controls); + } + } + else + { + // here, we redo the add to make sure the handlers get setup right + int childIndex = parent.Controls.GetChildIndex(c); + parent.Controls.Remove(c); + parent.Controls.Add(c); + parent.Controls.SetChildIndex(c, childIndex); + } + } + + c.Invalidate(true); + } + + if (localDesignerHost != null && containerMove) + { + // sburke -- looks like we always want to do this to ensure that sited children get + // handled properly. if we respected the boolean before, the ui selection handlers + // would cache designers, handlers, etc. and cause problems. + IComponentInitializer init = localDesignerHost.GetDesigner(component) as IComponentInitializer; + if (init != null) + { + init.InitializeExistingComponent(null); + } + + AddChildComponents(component, container, localDesignerHost); + } + + return true; + } + + /// + /// + /// Checks if the client is read only. That is, if components can + /// be added or removed from the designer. + /// + bool IOleDragClient.CanModifyComponents + { + get + { + return (!InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly)); + } + } + + /// + /// + /// Checks if it is valid to drop this type of a component on this client. + /// + bool IOleDragClient.IsDropOk(IComponent component) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + + if (host != null) + { + IDesigner designer = host.GetDesigner(component); + bool disposeDesigner = false; + + // we need to create one then + if (designer == null) + { + designer = TypeDescriptor.CreateDesigner(component, typeof(IDesigner)); + ControlDesigner cd = designer as ControlDesigner; + if (cd != null) + { + //Make sure the component doesn't get set to Visible + cd.ForceVisible = false; + } + + designer.Initialize(component); + disposeDesigner = true; + } + + try + { + ComponentDesigner cd = designer as ComponentDesigner; + if (cd != null) + { + if (cd.CanBeAssociatedWith(this)) + { + ControlDesigner controlDesigner = cd as ControlDesigner; + if (controlDesigner != null) + { + return CanParent(controlDesigner); + } + } + else + { + return false; + } + } + } + finally + { + if (disposeDesigner) + { + designer.Dispose(); + } + } + } + + return true; + } + + /// + /// + /// Retrieves the control view instance for the designer that + /// is hosting the drag. + /// + Control IOleDragClient.GetDesignerControl() + { + return Control; + } + + /// + /// + /// Retrieves the control view instance for the given component. + /// For Win32 designer, this will often be the component itself. + /// + Control IOleDragClient.GetControlForComponent(object component) + { + return GetControl(component); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs new file mode 100644 index 00000000000..2ca9afffc40 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Windows.Forms.Design +{ + internal partial class PbrsForward + { + private struct BufferedKey + { + public readonly Message KeyDown; + public readonly Message KeyUp; + public readonly Message KeyChar; + + public BufferedKey(Message keyDown, Message keyChar, Message keyUp) + { + KeyChar = keyChar; + KeyDown = keyDown; + KeyUp = keyUp; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs new file mode 100644 index 00000000000..27af8361269 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs @@ -0,0 +1,222 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel.Design; +using static Interop; + +namespace System.Windows.Forms.Design +{ + internal partial class PbrsForward : IWindowTarget + { + private readonly Control target; + private readonly IWindowTarget oldTarget; + + // we save the last key down so we can recreate the last message if we need to activate + // the properties window... + // + private Message lastKeyDown; + private ArrayList bufferedChars; + + private const int WM_PRIVATE_POSTCHAR = (int)User32.WM.USER + 0x1598; + private bool postCharMessage; + + private IMenuCommandService menuCommandSvc; + + private readonly IServiceProvider sp; + + private bool ignoreMessages; + + public PbrsForward(Control target, IServiceProvider sp) + { + this.target = target; + oldTarget = target.WindowTarget; + this.sp = sp; + target.WindowTarget = this; + } + + private IMenuCommandService MenuCommandService + { + get + { + if (menuCommandSvc == null && sp != null) + { + menuCommandSvc = (IMenuCommandService)sp.GetService(typeof(IMenuCommandService)); + } + + return menuCommandSvc; + } + } + + private ISupportInSituService InSituSupportService + { + get + { + return (ISupportInSituService)sp.GetService(typeof(ISupportInSituService)); + } + } + + public void Dispose() + { + target.WindowTarget = oldTarget; + } + + /// + /// Called when the window handle of the control has changed. + /// + void IWindowTarget.OnHandleChange(IntPtr newHandle) + { + } + + /// + /// Called to do control-specific processing for this window. + /// + void IWindowTarget.OnMessage(ref Message m) + { + // Get the Designer for the currently selected item on the Designer... + // SET STATE .. + ignoreMessages = false; + + // Here lets query for the ISupportInSituService. + // If we find the service then ask if it has a designer which is interested + // in getting the keychars by querring the IgnoreMessages. + if ((m.Msg >= (int)User32.WM.KEYFIRST && m.Msg <= (int)User32.WM.KEYLAST) + || (m.Msg >= (int)User32.WM.IME_STARTCOMPOSITION && m.Msg <= (int)User32.WM.IME_COMPOSITION)) + { + if (InSituSupportService != null) + { + ignoreMessages = InSituSupportService.IgnoreMessages; + } + } + + switch (m.Msg) + { + case WM_PRIVATE_POSTCHAR: + + if (bufferedChars == null) + { + return; + } + + // recreate the keystroke to the newly activated window + IntPtr hWnd; + if (!ignoreMessages) + { + hWnd = User32.GetFocus(); + } + else + { + if (InSituSupportService != null) + { + hWnd = InSituSupportService.GetEditWindow(); + } + else + { + hWnd = User32.GetFocus(); + } + } + + if (hWnd != m.HWnd) + { + foreach (BufferedKey bk in bufferedChars) + { + if (bk.KeyChar.Msg == (int)User32.WM.CHAR) + { + if (bk.KeyDown.Msg != 0) + { + User32.SendMessageW(hWnd, User32.WM.KEYDOWN, bk.KeyDown.WParam, bk.KeyDown.LParam); + } + + User32.SendMessageW(hWnd, User32.WM.CHAR, bk.KeyChar.WParam, bk.KeyChar.LParam); + if (bk.KeyUp.Msg != 0) + { + User32.SendMessageW(hWnd, User32.WM.KEYUP, bk.KeyUp.WParam, bk.KeyUp.LParam); + } + } + else + { + User32.SendMessageW(hWnd, (User32.WM)bk.KeyChar.Msg, bk.KeyChar.WParam, bk.KeyChar.LParam); + } + } + } + + bufferedChars.Clear(); + return; + + case (int)User32.WM.KEYDOWN: + lastKeyDown = m; + break; + + case (int)User32.WM.IME_ENDCOMPOSITION: + case (int)User32.WM.KEYUP: + lastKeyDown.Msg = 0; + break; + + case (int)User32.WM.CHAR: + case (int)User32.WM.IME_STARTCOMPOSITION: + case (int)User32.WM.IME_COMPOSITION: + if ((Control.ModifierKeys & (Keys.Control | Keys.Alt)) != 0) + { + break; + } + + if (bufferedChars == null) + { + bufferedChars = new ArrayList(); + } + + bufferedChars.Add(new BufferedKey(lastKeyDown, m, lastKeyDown)); + + if (!ignoreMessages && MenuCommandService != null) + { + // throw the properties window command, we will redo the keystroke when we actually + // lose focus + postCharMessage = true; + MenuCommandService.GlobalInvoke(StandardCommands.PropertiesWindow); + } + else if (ignoreMessages && m.Msg != (int)User32.WM.IME_COMPOSITION) + { + if (InSituSupportService != null) + { + postCharMessage = true; + InSituSupportService.HandleKeyChar(); + } + } + + if (postCharMessage) + { + // If copy of message has been buffered for forwarding, eat the original now + return; + } + + break; + + case (int)User32.WM.KILLFOCUS: + if (postCharMessage) + { + // see ASURT 45313 + // now that we've actually lost focus, post this message to the queue. This allows + // any activity that's in the queue to settle down before our characters are posted. + // to the queue. + // + // we post because we need to allow the focus to actually happen before we send + // our strokes so we know where to send them + // + // we can't use the wParam here because it may not be the actual window that needs + // to pick up the strokes. + // + User32.PostMessageW(target.Handle, (User32.WM)WM_PRIVATE_POSTCHAR, IntPtr.Zero, IntPtr.Zero); + postCharMessage = false; + } + + break; + } + + if (oldTarget != null) + { + oldTarget.OnMessage(ref m); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs new file mode 100644 index 00000000000..c5635164b00 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; + +namespace System.Windows.Forms.Design +{ + internal class PictureBoxActionList : DesignerActionList + { + private readonly PictureBoxDesigner _designer; + public PictureBoxActionList(PictureBoxDesigner designer) : base(designer.Component) + { + _designer = designer; + } + + public PictureBoxSizeMode SizeMode + { + get + { + return ((PictureBox)Component).SizeMode; + } + set + { + TypeDescriptor.GetProperties(Component)["SizeMode"].SetValue(Component, value); + } + } + + public void ChooseImage() + { + EditorServiceContext.EditValue(_designer, Component, "Image"); + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionMethodItem(this, "ChooseImage", SR.ChooseImageDisplayName, SR.PropertiesCategoryName, SR.ChooseImageDescription, true)); + items.Add(new DesignerActionPropertyItem("SizeMode", SR.SizeModeDisplayName, SR.PropertiesCategoryName, SR.SizeModeDescription)); + return items; + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs new file mode 100644 index 00000000000..380dd78d5d5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs @@ -0,0 +1,118 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace System.Windows.Forms.Design +{ + /// + /// This class handles all design time behavior for the group box class. Group + /// boxes may contain sub-components and therefore use the frame designer. + /// + internal class PictureBoxDesigner : ControlDesigner + { + private DesignerActionListCollection _actionLists; + + public PictureBoxDesigner() + { + AutoResizeHandles = true; + } + + /// + /// This draws a nice border around our pictureBox. We need + /// this because the pictureBox can have no border and you can't + /// tell where it is. + /// + /// + private void DrawBorder(Graphics graphics) + { + Control ctl = Control; + Rectangle rc = ctl.ClientRectangle; + Color penColor; + + // Black or white pen? Depends on the color of the control. + // + if (ctl.BackColor.GetBrightness() < .5) + { + penColor = ControlPaint.Light(ctl.BackColor); + } + else + { + penColor = ControlPaint.Dark(ctl.BackColor); + ; + } + + Pen pen = new Pen(penColor); + pen.DashStyle = DashStyle.Dash; + + rc.Width--; + rc.Height--; + graphics.DrawRectangle(pen, rc); + + pen.Dispose(); + } + + /// + /// Overrides our base class. Here we check to see if there + /// is no border on the pictureBox. If not, we draw one so that + /// the pictureBox shape is visible at design time. + /// + protected override void OnPaintAdornments(PaintEventArgs pe) + { + PictureBox pictureBox = (PictureBox)Component; + + if (pictureBox.BorderStyle == BorderStyle.None) + { + DrawBorder(pe.Graphics); + } + + base.OnPaintAdornments(pe); + } + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + object component = Component; + + PropertyDescriptor propSizeMode = TypeDescriptor.GetProperties(Component)["SizeMode"]; + if (propSizeMode != null) + { + PictureBoxSizeMode sizeMode = (PictureBoxSizeMode)propSizeMode.GetValue(component); + + if (sizeMode == PictureBoxSizeMode.AutoSize) + { + rules &= ~SelectionRules.AllSizeable; + } + } + + return rules; + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + _actionLists.Add(new PictureBoxActionList(this)); + } + + return _actionLists; + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs new file mode 100644 index 00000000000..705ced63fa6 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// Provides a designer that can design components + /// that extend ButtonBase. + /// + internal class RadioButtonDesigner : ButtonBaseDesigner + { + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + // In Whidbey, default the TabStop to true. + PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["TabStop"]; + if (prop != null && prop.PropertyType == typeof(bool) && !prop.IsReadOnly && prop.IsBrowsable) + { + prop.SetValue(Component, true); + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs new file mode 100644 index 00000000000..ff07414f79b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal class RichTextBoxActionList : DesignerActionList + { + private readonly RichTextBoxDesigner _designer; + + public RichTextBoxActionList(RichTextBoxDesigner designer) : base(designer.Component) + { + _designer = designer; + } + + public void EditLines() + { + EditorServiceContext.EditValue(_designer, Component, "Lines"); + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionMethodItem(this, "EditLines", SR.EditLinesDisplayName, SR.LinksCategoryName, SR.EditLinesDescription, true)); + return items; + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs new file mode 100644 index 00000000000..4c2ce1b74aa --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Collections; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// The RichTextBoxDesigner provides rich designtime behavior for the + /// RichTextBox control. + /// + internal class RichTextBoxDesigner : TextBoxBaseDesigner + { + private DesignerActionListCollection _actionLists; + + /// + /// Called when the designer is intialized. This allows the designer to provide some + /// meaningful default values in the control. The default implementation of this + /// sets the control's text to its name. + /// + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + // Disable DragDrop at design time. + // CONSIDER: Is this the correct function for doing this? + Control control = Control; + + if (control != null && control.Handle != IntPtr.Zero) + { + Ole32.RevokeDragDrop(control.Handle); + // DragAcceptFiles(control.Handle, false); + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + _actionLists.Add(new RichTextBoxActionList(this)); + } + + return _actionLists; + } + } + + /// + /// Allows a designer to filter the set of properties + /// the component it is designing will expose through the + /// TypeDescriptor object. This method is called + /// immediately before its corresponding "Post" method. + /// If you are overriding this method you should call + /// the base implementation before you perform your own + /// filtering. + /// + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + PropertyDescriptor prop; + + // Handle shadowed properties + // + string[] shadowProps = new string[] + { + nameof(Text) + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + prop = (PropertyDescriptor)properties[shadowProps[i]]; + if (prop != null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(RichTextBoxDesigner), prop, empty); + } + } + } + + /// + /// Accessor for Text. We need to replace "\r\n" with "\n" in the designer before deciding whether + /// the old value and new value match. + /// + private string Text + { + get + { + return Control.Text; + } + set + { + string oldText = Control.Text; + if (value != null) + { + value = value.Replace("\r\n", "\n"); + } + + if (oldText != value) + { + Control.Text = value; + } + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs index 80819823538..c04b0a71218 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Drawing; +using System.Windows.Forms.Design.Behavior; +using static Interop; namespace System.Windows.Forms.Design { @@ -12,6 +14,8 @@ namespace System.Windows.Forms.Design /// public class ScrollableControlDesigner : ParentControlDesigner { + private SelectionManager selManager; + /// /// Overrides the base class's GetHitTest method to determine regions of the /// control that should always be UI-Active. For a form, if it has autoscroll @@ -19,7 +23,24 @@ public class ScrollableControlDesigner : ParentControlDesigner /// protected override bool GetHitTest(Point pt) { - throw new NotImplementedException(SR.NotImplementedByDesign); + if (base.GetHitTest(pt)) + { + return true; + } + + // The scroll bars on a form are "live" + // + ScrollableControl f = (ScrollableControl)Control; + if (f.IsHandleCreated && f.AutoScroll) + { + int hitTest = (int)(long)User32.SendMessageW(f.Handle, User32.WM.NCHITTEST, IntPtr.Zero, PARAM.FromLowHigh(pt.X, pt.Y)); + if (hitTest == (int)User32.HT.VSCROLL || hitTest == (int)User32.HT.HSCROLL) + { + return true; + } + } + + return false; } /// @@ -27,7 +48,33 @@ protected override bool GetHitTest(Point pt) /// protected override void WndProc(ref Message m) { - throw new NotImplementedException(SR.NotImplementedByDesign); + base.WndProc(ref m); + + switch (m.Msg) + { + case (int)User32.WM.HSCROLL: + case (int)User32.WM.VSCROLL: + + // When we scroll, we reposition a control without causing a + // property change event. Therefore, we must tell the + // SelectionManager to refresh its glyphs. + if (selManager == null) + { + selManager = GetService(typeof(SelectionManager)) as SelectionManager; + } + + if (selManager != null) + { + selManager.Refresh(); + } + + // Now we must paint our adornments, since the scroll does not + // trigger a paint event + // + Control.Invalidate(); + Control.Update(); + break; + } } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionManager.cs deleted file mode 100644 index e2742589d0d..00000000000 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionManager.cs +++ /dev/null @@ -1,465 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using System.ComponentModel; -using System.ComponentModel.Design; -using System.Diagnostics; -using System.Drawing; -using System.Windows.Forms.Design.Behavior; - -namespace System.Windows.Forms.Design -{ - /// - /// The SelectionBehavior is pushed onto the BehaviorStack in response to apositively hit tested SelectionGlyph. The SelectionBehavior performs two main tasks: 1) forward messages to the related ControlDesigner, and 2) calls upon the SelectionManager to push a potention DragBehavior. - /// - internal sealed class SelectionManager : IDisposable - { - private Adorner _selectionAdorner;//used to provide all selection glyphs - private Adorner _bodyAdorner;//used to track all body glyphs for each control - private BehaviorService _behaviorService;//ptr back to our BehaviorService - private IServiceProvider _serviceProvider;//standard service provider - private readonly Hashtable _componentToDesigner;//used for quick look up of designers related to comps - private readonly Control _rootComponent;//root component being designed - private ISelectionService _selSvc;//we cache the selection service for perf. - private IDesignerHost _designerHost;//we cache the designerhost for perf. - private bool _needRefresh; // do we need to refresh? - private Rectangle[] _prevSelectionBounds;//used to only repaint the changing part of the selection - private object _prevPrimarySelection; //used to check if the primary selection changed - private Rectangle[] _curSelectionBounds; - private int _curCompIndex; - private DesignerActionUI _designerActionUI; // the "container" for all things related to the designer action (smartags) UI - private bool _selectionChanging; //we dont want the OnSelectionChanged to be recursively called. - - /// - /// Constructor. Here we query for necessary services and cache them for perf. reasons. We also hook to Component Added/Removed/Changed notifications so we can keep in sync when the designers' components change. Also, we create our custom Adorner and add it to the BehaviorService. - /// - public SelectionManager(IServiceProvider serviceProvider, BehaviorService behaviorService) - { - _prevSelectionBounds = null; - _prevPrimarySelection = null; - _behaviorService = behaviorService; - _serviceProvider = serviceProvider; - _selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService)); - _designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); - if (_designerHost is null || _selSvc is null) - { - Debug.Fail("SelectionManager - Host or SelSvc is null, can't continue"); - } - - _rootComponent = (Control)_designerHost.RootComponent; - //create and add both of our adorners, one for selection, one for bodies - _selectionAdorner = new Adorner(); - _bodyAdorner = new Adorner(); - behaviorService.Adorners.Add(_bodyAdorner); - behaviorService.Adorners.Add(_selectionAdorner);//adding this will cause the adorner to get setup with a ptr to the beh.svc. - _componentToDesigner = new Hashtable(); - // designeraction UI - if (_designerHost.GetService(typeof(DesignerOptionService)) is DesignerOptionService options) - { - PropertyDescriptor p = options.Options.Properties["UseSmartTags"]; - if (p != null && p.PropertyType == typeof(bool) && (bool)p.GetValue(null)) - { - _designerActionUI = new DesignerActionUI(serviceProvider, _selectionAdorner); - behaviorService.DesignerActionUI = _designerActionUI; - } - } - } - - /// - /// Returns the Adorner that contains all the BodyGlyphs for the current selection state. - /// - internal Adorner BodyGlyphAdorner - { - get => _bodyAdorner; - } - - /// - /// There are certain cases like Adding Item to ToolStrips through InSitu Editor, where there is ParentTransaction that has to be cancelled depending upon the user action. When this parent transaction is cancelled, there may be no reason to REFRESH the selectionManager which actually clears all the glyphs and readds them. This REFRESH causes a lot of flicker and can be avoided by setting this property to false. Since this property is checked in the TransactionClosed, the SelectionManager won't REFRESH and hence just eat up the refresh thus avoiding unnecessary flicker. - /// - internal bool NeedRefresh - { - get => _needRefresh; - set => _needRefresh = value; - } - - /// - /// Returns the Adorner that contains all the BodyGlyphs for the current selection state. - /// - internal Adorner SelectionGlyphAdorner - { - get => _selectionAdorner; - } - - /// - /// This method fist calls the recursive AddControlGlyphs() method. When finished, we add the final glyph(s) to the root comp. - /// - private void AddAllControlGlyphs(Control parent, ArrayList selComps, object primarySelection) - { - foreach (Control control in parent.Controls) - { - AddAllControlGlyphs(control, selComps, primarySelection); - } - - GlyphSelectionType selType = GlyphSelectionType.NotSelected; - if (selComps.Contains(parent)) - { - if (parent.Equals(primarySelection)) - { - selType = GlyphSelectionType.SelectedPrimary; - } - else - { - selType = GlyphSelectionType.Selected; - } - } - - AddControlGlyphs(parent, selType); - } - - /// - /// Recursive method that goes through and adds all the glyphs of every child to our global Adorner. - /// - private void AddControlGlyphs(Control c, GlyphSelectionType selType) - { - ControlDesigner cd = (ControlDesigner)_componentToDesigner[c]; - if (cd != null) - { - ControlBodyGlyph bodyGlyph = cd.GetControlGlyphInternal(selType); - if (bodyGlyph != null) - { - _bodyAdorner.Glyphs.Add(bodyGlyph); - if (selType == GlyphSelectionType.SelectedPrimary || - selType == GlyphSelectionType.Selected) - { - if (_curSelectionBounds[_curCompIndex] == Rectangle.Empty) - { - _curSelectionBounds[_curCompIndex] = bodyGlyph.Bounds; - } - else - { - _curSelectionBounds[_curCompIndex] = Rectangle.Union(_curSelectionBounds[_curCompIndex], bodyGlyph.Bounds); - } - } - } - - GlyphCollection glyphs = cd.GetGlyphs(selType); - if (glyphs != null) - { - _selectionAdorner.Glyphs.AddRange(glyphs); - if (selType == GlyphSelectionType.SelectedPrimary || - selType == GlyphSelectionType.Selected) - { - foreach (Glyph glyph in glyphs) - { - _curSelectionBounds[_curCompIndex] = Rectangle.Union(_curSelectionBounds[_curCompIndex], glyph.Bounds); - } - } - } - } - - if (selType == GlyphSelectionType.SelectedPrimary || selType == GlyphSelectionType.Selected) - { - _curCompIndex++; - } - } - - /// - /// Unhook all of our event notifications, clear our adorner and remove it from the Beh.Svc. - /// - public void Dispose() - { - if (_designerHost != null) - { - _designerHost = null; - } - - if (_serviceProvider != null) - { - if (_selSvc != null) - { - _selSvc = null; - } - - _serviceProvider = null; - } - - if (_behaviorService != null) - { - _behaviorService.Adorners.Remove(_bodyAdorner); - _behaviorService.Adorners.Remove(_selectionAdorner); - _behaviorService = null; - } - - if (_selectionAdorner != null) - { - _selectionAdorner.Glyphs.Clear(); - _selectionAdorner = null; - } - - if (_bodyAdorner != null) - { - _bodyAdorner.Glyphs.Clear(); - _bodyAdorner = null; - } - - if (_designerActionUI != null) - { - _designerActionUI.Dispose(); - _designerActionUI = null; - } - } - - /// - /// Refreshes all selection Glyphs. - /// - public void Refresh() - { - NeedRefresh = false; - OnSelectionChanged(this, null); - } - - /// - /// When a component is added, we get the designer and add it to our hashtable for quick lookup. - /// - private void OnComponentAdded(object source, ComponentEventArgs ce) - { - IComponent component = ce.Component; - IDesigner designer = _designerHost.GetDesigner(component); - if (designer is ControlDesigner) - { - _componentToDesigner.Add(component, designer); - } - } - - /// - /// Before a drag, remove all glyphs that are involved in the drag operation and any that don't allow drops. - /// - private void OnBeginDrag(object source, BehaviorDragDropEventArgs e) - { - ArrayList dragComps = new ArrayList(e.DragComponents); - ArrayList glyphsToRemove = new ArrayList(); - foreach (ControlBodyGlyph g in _bodyAdorner.Glyphs) - { - if (g.RelatedComponent is Control) - { - if (dragComps.Contains(g.RelatedComponent) || - !((Control)g.RelatedComponent).AllowDrop) - { - glyphsToRemove.Add(g); - } - } - } - - foreach (Glyph g in glyphsToRemove) - { - _bodyAdorner.Glyphs.Remove(g); - } - } - - // Called by the DropSourceBehavior when dragging into a new host - internal void OnBeginDrag(BehaviorDragDropEventArgs e) - { - OnBeginDrag(null, e); - } - - /// - /// When a component is changed - we need to refresh the selection. - /// - private void OnComponentChanged(object source, ComponentChangedEventArgs ce) - { - if (_selSvc.GetComponentSelected(ce.Component)) - { - if (!_designerHost.InTransaction) - { - Refresh(); - } - else - { - NeedRefresh = true; - } - } - } - - /// - /// When a component is removed - we remove the key and value from our hashtable. - /// - private void OnComponentRemoved(object source, ComponentEventArgs ce) - { - if (_componentToDesigner.Contains(ce.Component)) - { - _componentToDesigner.Remove(ce.Component); - } - - //remove the associated designeractionpanel - if (_designerActionUI != null) - { - _designerActionUI.RemoveActionGlyph(ce.Component); - } - } - - /// - /// Computes the region representing the difference between the old selection and the new selection. - /// - private Region DetermineRegionToRefresh(object primarySelection) - { - Region toRefresh = new Region(Rectangle.Empty); - Rectangle[] larger; - Rectangle[] smaller; - if (_curSelectionBounds.Length >= _prevSelectionBounds.Length) - { - larger = _curSelectionBounds; - smaller = _prevSelectionBounds; - } - else - { - larger = _prevSelectionBounds; - smaller = _curSelectionBounds; - } - - // we need to make sure all of the rects in the smaller array are accounted for. Any that don't intersect a rect in the larger array need to be included in the region to repaint. - bool[] intersected = new bool[smaller.Length]; - for (int i = 0; i < smaller.Length; i++) - { - intersected[i] = false; - } - - // determine which rects in the larger array need to be included in the region to invalidate by intersecting with rects in the smaller array. - for (int l = 0; l < larger.Length; l++) - { - bool largeIntersected = false; - Rectangle large = larger[l]; - for (int s = 0; s < smaller.Length; s++) - { - if (large.IntersectsWith(smaller[s])) - { - Rectangle small = smaller[s]; - largeIntersected = true; - if (large != small) - { - toRefresh.Union(large); - toRefresh.Union(small); - } - - intersected[s] = true; - break; - } - } - - if (!largeIntersected) - { - toRefresh.Union(large); - } - } - - // now add any rects from the smaller array that weren't accounted for - for (int k = 0; k < intersected.Length; k++) - { - if (!intersected[k]) - { - toRefresh.Union(smaller[k]); - } - } - - using (Graphics g = _behaviorService.AdornerWindowGraphics) - { - //If all that changed was the primary selection, then the refresh region was empty, but we do need to update the 2 controls. VSWhidbey #269806 - if (toRefresh.IsEmpty(g) && primarySelection != null && !primarySelection.Equals(_prevPrimarySelection)) - { - for (int i = 0; i < _curSelectionBounds.Length; i++) - { - toRefresh.Union(_curSelectionBounds[i]); - } - } - } - - return toRefresh; - } - - /// - /// Event handler for the behaviorService's Synchronize event - /// - private void OnSynchronize(object sender, EventArgs e) - { - Refresh(); - } - - /// - /// On every selectionchange, we remove all glyphs, get the newly selected components, and re-add all glyphs back to the Adorner. - /// - private void OnSelectionChanged(object sender, EventArgs e) - { - // Note: selectionChanging would guard against a re-entrant code... Since we dont want to be in messed up state when adding new Glyphs. - if (!_selectionChanging) - { - _selectionChanging = true; - _selectionAdorner.Glyphs.Clear(); - _bodyAdorner.Glyphs.Clear(); - ArrayList selComps = new ArrayList(_selSvc.GetSelectedComponents()); - object primarySelection = _selSvc.PrimarySelection; - - //add all control glyphs to all controls on rootComp - _curCompIndex = 0; - _curSelectionBounds = new Rectangle[selComps.Count]; - AddAllControlGlyphs(_rootComponent, selComps, primarySelection); - if (_prevSelectionBounds != null) - { - Region toUpdate = DetermineRegionToRefresh(primarySelection); - using (Graphics g = _behaviorService.AdornerWindowGraphics) - { - if (!toUpdate.IsEmpty(g)) - { - _selectionAdorner.Invalidate(toUpdate); - } - } - } - else - { - // There was no previous selection, so just invalidate the current selection - if (_curSelectionBounds.Length > 0) - { - Rectangle toUpdate = _curSelectionBounds[0]; - for (int i = 1; i < _curSelectionBounds.Length; i++) - { - toUpdate = Rectangle.Union(toUpdate, _curSelectionBounds[i]); - } - - if (toUpdate != Rectangle.Empty) - { - _selectionAdorner.Invalidate(toUpdate); - } - } - else - { - _selectionAdorner.Invalidate(); - } - } - - _prevPrimarySelection = primarySelection; - if (_curSelectionBounds.Length > 0) - { - _prevSelectionBounds = new Rectangle[_curSelectionBounds.Length]; - Array.Copy(_curSelectionBounds, _prevSelectionBounds, _curSelectionBounds.Length); - } - else - { - _prevSelectionBounds = null; - } - - _selectionChanging = false; - } - } - - /// - /// When a transaction that involves one of our components closes, refresh to reflect any changes. - /// - private void OnTransactionClosed(object sender, DesignerTransactionCloseEventArgs e) - { - if (e.LastTransaction && NeedRefresh) - { - Refresh(); - } - } - } -} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs index c1d871a776c..c68d1967879 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; - namespace System.Windows.Forms.Design { /// diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs index 9b4b16d9dbd..b2a84103fe6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs @@ -3,7 +3,10 @@ // See the LICENSE file in the project root for more information. using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; using System.Drawing; +using System.Globalization; namespace System.Windows.Forms.Design { @@ -14,6 +17,18 @@ namespace System.Windows.Forms.Design /// internal abstract class SelectionUIHandler { + // These handle our drag feedback. These come into play when we're + // actually moving components around. The selection UI service + // dictates when this happens. + // + private Rectangle dragOffset = Rectangle.Empty; // this gets added to a component's x, y, width, height + private Control[] dragControls; // the set of controls we're dragging + private BoundsInfo[] originalCoords; // the saved coordinates of the components we're dragging. + private SelectionRules rules; // the rules of the current drag. + + private const int MinControlWidth = 3; + private const int MinControlHeight = 3; + /// /// Begins a drag operation. A designer should examine the list of components /// to see if it wants to support the drag. If it does, it should return @@ -24,7 +39,94 @@ internal abstract class SelectionUIHandler /// public virtual bool BeginDrag(object[] components, SelectionRules rules, int initialX, int initialY) { - throw new NotImplementedException(SR.NotImplementedByDesign); + dragOffset = new Rectangle(); + originalCoords = null; + this.rules = rules; + + dragControls = new Control[components.Length]; + for (int i = 0; i < components.Length; i++) + { + Debug.Assert(components[i] is IComponent, "Selection UI handler only deals with IComponents"); + dragControls[i] = GetControl((IComponent)components[i]); + Debug.Assert(dragControls[i] != null, "Everyone must have a control"); + } + + // allow the cliprect to go just beyond the window by one grid. This helps with round off + // problems. We can only do this if the container itself is not in the selection. Also, + // if the container is a form and it has autoscroll turned on, we allow a drag beyond the + // container boundary on the width and height, but not top and left. + // + bool containerSelected = false; + IComponent container = GetComponent(); + for (int i = 0; i < components.Length; i++) + { + if (components[i] == container) + { + containerSelected = true; + break; + } + } + + if (!containerSelected) + { + Control containerControl = GetControl(); + Size snapSize = GetCurrentSnapSize(); + Rectangle containerRect = containerControl.RectangleToScreen(containerControl.ClientRectangle); + containerRect.Inflate(snapSize.Width, snapSize.Height); + ScrollableControl sc = GetControl() as ScrollableControl; + if (sc != null && sc.AutoScroll) + { + Rectangle screen = SystemInformation.VirtualScreen; + containerRect.Width = screen.Width; + containerRect.Height = screen.Height; + } + } + + return true; + } + + /// + /// This is called by MoveControls when the user has requested that the move be + /// cancelled. This puts all the controls back to where they were. + /// + private void CancelControlMove(Control[] controls, BoundsInfo[] bounds) + { + Debug.Assert(bounds != null && controls != null && bounds.Length == controls.Length, "bounds->controls mismatch"); + + Rectangle b = new Rectangle(); + + // Whip through each of the controls. + // + for (int i = 0; i < controls.Length; i++) + { + Control parent = controls[i].Parent; + + // Suspend parent layout so that we don't continously re-arrange components + // while we move. + // + if (parent != null) + { + parent.SuspendLayout(); + } + + b.X = bounds[i].X; + b.Y = bounds[i].Y; + b.Width = bounds[i].Width; + b.Height = bounds[i].Height; + + controls[i].Bounds = b; + } + + // And resume their layout + // + for (int i = 0; i < controls.Length; i++) + { + Control parent = controls[i].Parent; + if (parent != null) + { + parent.ResumeLayout(); + } + } } /// @@ -34,7 +136,9 @@ public virtual bool BeginDrag(object[] components, SelectionRules rules, int ini /// public virtual void DragMoved(object[] components, Rectangle offset) { - throw new NotImplementedException(SR.NotImplementedByDesign); + dragOffset = offset; + MoveControls(components, false, false); + Debug.Assert(originalCoords != null, "We are keying off of originalCoords, but MoveControls didn't set it"); } /// @@ -43,7 +147,21 @@ public virtual void DragMoved(object[] components, Rectangle offset) /// public virtual void EndDrag(object[] components, bool cancel) { - throw new NotImplementedException(SR.NotImplementedByDesign); + try + { + MoveControls(components, cancel, true); + } + catch (CheckoutException checkoutEx) + { + if (checkoutEx == CheckoutException.Canceled) + { + MoveControls(components, true, false); + } + else + { + throw; + } + } } /// @@ -86,6 +204,337 @@ public virtual void EndDrag(object[] components, bool cancel) /// public abstract Rectangle GetUpdatedRect(Rectangle orignalRect, Rectangle dragRect, bool updateSize); + /// + /// Called when we need to move the controls on our frame while dragging. This + /// can perform three operations: It can update the current controls location, + /// it can commit the new controls (final move), and it can roll back a movement + /// to the beginning of the operation. + /// + private void MoveControls(object[] components, bool cancel, bool finalMove) + { + Control[] controls = dragControls; + Rectangle offset = dragOffset; + BoundsInfo[] bounds = originalCoords; + Point adjustedLoc = new Point(); + + // Erase the clipping and other state if this is the final move. + // + if (finalMove) + { + Cursor.Clip = Rectangle.Empty; + dragOffset = Rectangle.Empty; + dragControls = null; + originalCoords = null; + } + + // If we haven't started to move yet, there's nothing to do. + // + if (offset.IsEmpty) + { + return; + } + + // Short circuit the work if we didn't move anything. + // This will prevent a change notification for just + // selecting components. + // + if (finalMove && offset.X == 0 && offset.Y == 0 && offset.Width == 0 && offset.Height == 0) + { + return; + } + + // If cancel was specified, we must roll all controls back to their original positions. + // + if (cancel) + { + CancelControlMove(controls, bounds); + return; + } + + // We must keep track of the original coordinates of each control, just in case + // the user cancels out of moving them. So, we create a "BoundsInfo" object for + // each control that saves this state. + // + if (originalCoords == null && !finalMove) + { + originalCoords = new BoundsInfo[controls.Length]; + for (int i = 0; i < controls.Length; i++) + { + originalCoords[i] = new BoundsInfo(controls[i]); + } + + bounds = originalCoords; + } + + // Two passes here. First pass suspends all parent layout and updates the + // component positions. Second pass re-enables layout. + // + for (int i = 0; i < controls.Length; i++) + { + Debug.Assert(controls[i] == GetControl((IComponent)components[i]), "Control->Component mapping is out of sync"); + + Control parent = controls[i].Parent; + + // Suspend parent layout so that we don't continously re-arrange components + // while we move. + // + if (parent != null) + { + parent.SuspendLayout(); + } + + BoundsInfo ctlBounds = bounds[i]; + + adjustedLoc.X = ctlBounds.lastRequestedX; + adjustedLoc.Y = ctlBounds.lastRequestedY; + + if (!finalMove) + { + ctlBounds.lastRequestedX += offset.X; + ctlBounds.lastRequestedY += offset.Y; + ctlBounds.lastRequestedWidth += offset.Width; + ctlBounds.lastRequestedHeight += offset.Height; + } + + // Our "target" values are the ones we would like to set + // the control to. We may modify them if they would mke the control + // size negative or zero, however. + // + int targetX = ctlBounds.lastRequestedX; + int targetY = ctlBounds.lastRequestedY; + int targetWidth = ctlBounds.lastRequestedWidth; + int targetHeight = ctlBounds.lastRequestedHeight; + + Rectangle oldBounds = controls[i].Bounds; + + if ((rules & SelectionRules.Moveable) == 0) + { + // We use the minimum size of either a grid snap or 1 + // + Size minSize; + + if (GetShouldSnapToGrid()) + { + minSize = GetCurrentSnapSize(); + } + else + { + minSize = new Size(1, 1); + } + + if (targetWidth < minSize.Width) + { + targetWidth = minSize.Width; + targetX = oldBounds.X; + } + + if (targetHeight < minSize.Height) + { + targetHeight = minSize.Height; + targetY = oldBounds.Y; + } + } + + //Bug #72905 Form X,Y defaulted to (0,0) + // + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + Debug.Assert(host != null, "No designer host"); + if (controls[i] == host.RootComponent) + { + targetX = 0; + targetY = 0; + } + + // Adjust our target dimensions by the grid snaps + // + Rectangle tempNewBounds = GetUpdatedRect(oldBounds, new Rectangle(targetX, targetY, targetWidth, targetHeight), true); + Rectangle newBounds = oldBounds; + + // Now apply the correct values to newBounds -- we only want to apply the new value if our + // selection rules dictate so. + // + if ((rules & SelectionRules.Moveable) != 0) + { + newBounds.X = tempNewBounds.X; + newBounds.Y = tempNewBounds.Y; + } + else + { + if ((rules & SelectionRules.TopSizeable) != 0) + { + newBounds.Y = tempNewBounds.Y; + newBounds.Height = tempNewBounds.Height; + } + + if ((rules & SelectionRules.BottomSizeable) != 0) + { + newBounds.Height = tempNewBounds.Height; + } + + if ((rules & SelectionRules.LeftSizeable) != 0) + { + newBounds.X = tempNewBounds.X; + newBounds.Width = tempNewBounds.Width; + } + + if ((rules & SelectionRules.RightSizeable) != 0) + { + newBounds.Width = tempNewBounds.Width; + } + } + + bool locChanged = (offset.X != 0 || offset.Y != 0); + bool sizeChanged = (offset.Width != 0 || offset.Height != 0); + + // If both the location and size changed, attempt to update the control in + // one step. This will prevent flicker. + // + if (locChanged && sizeChanged) + { + // We shouldn't care if we're directly manipulating the control or not during + // the move. For perf, just call directly on the control. For the final + // move, however, we must go through the property descriptor. + // + PropertyDescriptor boundsProp = TypeDescriptor.GetProperties(components[i])["Bounds"]; + + if (boundsProp != null && !boundsProp.IsReadOnly) + { + if (finalMove) + { + object component = components[i]; + boundsProp.SetValue(component, newBounds); + } + else + { + controls[i].Bounds = newBounds; + } + + // Now reset the loc and size changed flags so + // we don't try to change again. + // + locChanged = sizeChanged = false; + } + } + + // Adjust the location property with the new value. ONLY do this if the offset + // is nonzero, however. Otherwise we may get round-off errors that can cause flicker. + // Plus, why set the property if it shouldn't be? + // + if (locChanged) + { + adjustedLoc.X = newBounds.X; + adjustedLoc.Y = newBounds.Y; + + PropertyDescriptor trayProp = TypeDescriptor.GetProperties(components[i])["TrayLocation"]; + + if (trayProp != null && !trayProp.IsReadOnly) + { + trayProp.SetValue(components[i], adjustedLoc); + } + else + { + // We shouldn't care if we're directly manipulating the control or not during + // the move. For perf, just call directly on the control. For the final + // move, however, we must go through the property descriptor. + // + PropertyDescriptor leftProp = TypeDescriptor.GetProperties(components[i])["Left"]; + PropertyDescriptor topProp = TypeDescriptor.GetProperties(components[i])["Top"]; + if (topProp != null && !topProp.IsReadOnly) + { + if (finalMove) + { + object component = components[i]; + topProp.SetValue(component, adjustedLoc.Y); + } + else + { + controls[i].Top = adjustedLoc.Y; + } + } + + if (leftProp != null && !leftProp.IsReadOnly) + { + if (finalMove) + { + object component = components[i]; + leftProp.SetValue(component, adjustedLoc.X); + } + else + { + controls[i].Left = adjustedLoc.X; + } + } + + if (leftProp == null || topProp == null) + { + PropertyDescriptor locationProp = TypeDescriptor.GetProperties(components[i])["Location"]; + if (locationProp != null && !locationProp.IsReadOnly) + { + locationProp.SetValue(components[i], adjustedLoc); + } + } + } + } + + // Adjust the size property with the new value. ONLY do this if the offset + // is nonzero, however. Otherwise we may get round-off errors that can cause flicker. + // Plus, why set the property if it shouldn't be? + // + if (sizeChanged) + { + // If you are tempted to hoist this "new" out of the loop, don't. The undo + // unit below just holds a reference to it. + // + Size size = new Size(Math.Max(MinControlWidth, newBounds.Width), Math.Max(MinControlHeight, newBounds.Height)); + + PropertyDescriptor widthProp = TypeDescriptor.GetProperties(components[i])["Width"]; + PropertyDescriptor heightProp = TypeDescriptor.GetProperties(components[i])["Height"]; + + if (widthProp != null && !widthProp.IsReadOnly && size.Width != (int)widthProp.GetValue(components[i])) + { + if (finalMove) + { + object component = components[i]; + widthProp.SetValue(component, size); + } + else + { + controls[i].Width = size.Width; + } + } + + if (heightProp != null && !heightProp.IsReadOnly && size.Height != (int)heightProp.GetValue(components[i])) + { + if (finalMove) + { + object component = components[i]; + heightProp.SetValue(component, size); + } + else + { + controls[i].Height = size.Height; + } + } + } + } + + // Now resume the parent layouts + // + for (int i = 0; i < controls.Length; i++) + { + Control parent = controls[i].Parent; + + if (parent != null) + { + parent.ResumeLayout(); + parent.Update(); + } + + controls[i].Update(); + } + } + /// /// Queries to see if a drag operation /// is valid on this handler for the given set of components. @@ -93,7 +542,52 @@ public virtual void EndDrag(object[] components, bool cancel) /// public bool QueryBeginDrag(object[] components, SelectionRules rules, int initialX, int initialY) { - throw new NotImplementedException(SR.NotImplementedByDesign); + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs != null) + { + try + { + if (components != null && components.Length > 0) + { + foreach (object c in components) + { + cs.OnComponentChanging(c, TypeDescriptor.GetProperties(c)["Location"]); + PropertyDescriptor sizeProp = TypeDescriptor.GetProperties(c)["Size"]; + + if (sizeProp != null && sizeProp.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden)) + { + sizeProp = TypeDescriptor.GetProperties(c)["ClientSize"]; + } + + cs.OnComponentChanging(c, sizeProp); + } + } + else + { + cs.OnComponentChanging(GetComponent(), null); + } + } + catch (CheckoutException coEx) + { + if (coEx == CheckoutException.Canceled) + { + // cancel the drag. + return false; + } + + throw ; + } + catch (InvalidOperationException) + { + // If the doc data for this designer is currently locked, we will get an exception here. In this + // case, just eat the exception. If this exception was thrown by someone else, that's fine too. + // No point in bubbling exceptions here anyway. + + return false; + } + } + + return components != null && components.Length > 0; } /// @@ -116,5 +610,69 @@ public virtual void OleDragOver(DragEventArgs de) public virtual void OleDragLeave() { } + + /// + /// This class holds bounds information for controls that are being moved. + /// + private class BoundsInfo + { + public int X; // Original saved X + public int Y; // Original saved Y + public int Width; // Original saved width + public int Height; // Original saved height + public int lastRequestedX = -1; + public int lastRequestedY = -1; + public int lastRequestedWidth = -1; + public int lastRequestedHeight = -1; + + /// + /// Creates and initializes a new BoundsInfo object. + /// + public BoundsInfo(Control control) + { + // get the size & loc from the props so the designers can adjust them. + // + PropertyDescriptor sizeProp = TypeDescriptor.GetProperties(control)["Size"]; + PropertyDescriptor locProp = TypeDescriptor.GetProperties(control)["Location"]; + + Size sz; + Point loc; + + if (sizeProp != null) + { + sz = (Size)sizeProp.GetValue(control); + } + else + { + sz = control.Size; + } + + if (locProp != null) + { + loc = (Point)locProp.GetValue(control); + } + else + { + loc = control.Location; + } + + X = loc.X; + Y = loc.Y; + Width = sz.Width; + Height = sz.Height; + lastRequestedX = X; + lastRequestedY = Y; + lastRequestedWidth = Width; + lastRequestedHeight = Height; + } + + /// + /// Overrides object ToString. + /// + public override string ToString() + { + return $"{{X={X}, Y={Y}, Width={Width}, Height={Height}}}"; + } + } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs index e167526e46d..6b683f78379 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs @@ -243,7 +243,7 @@ public static string GetTransactionName(SelectionRules rules, object[] objects) { // Determine a nice name for the drag operation string transactionName; - if ((int)(rules & SelectionRules.Moveable) != 0) + if ((rules & SelectionRules.Moveable) != 0) { if (objects.Length > 1) { @@ -267,7 +267,7 @@ public static string GetTransactionName(SelectionRules rules, object[] objects) transactionName = string.Format(SR.DragDropMoveComponent, name); } } - else if ((int)(rules & SelectionRules.AllSizeable) != 0) + else if ((rules & SelectionRules.AllSizeable) != 0) { if (objects.Length > 1) { @@ -531,7 +531,7 @@ protected override void OnMouseDown(MouseEventArgs me) { SelectionRules rules = SelectionRules.None; // If the CTRL key isn't down, select this component, otherwise, we wait until the mouse up. Make sure the component is selected - _ctrlSelect = (Control.ModifierKeys & Keys.Control) != Keys.None; + _ctrlSelect = (ModifierKeys & Keys.Control) != Keys.None; if (!_ctrlSelect) { _selSvc.SetSelectedComponents(new object[] { hti.selectionUIHit._component }, SelectionTypes.Primary); @@ -1193,7 +1193,7 @@ object[] ISelectionUIService.FilterSelection(object[] components, SelectionRules } } - selection = (object[])list.ToArray(); + selection = list.ToArray(); } return selection ?? (Array.Empty()); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs index 02e866934df..5b957256720 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs @@ -103,7 +103,7 @@ public override Image Image } } - protected override void OnClick(System.EventArgs e) + protected override void OnClick(EventArgs e) { if (_menuCommand != null) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs index 71292b12b44..523aac92787 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.Drawing; using System.Globalization; +using System.Windows.Forms.Design.Behavior; namespace System.Windows.Forms.Design { @@ -66,7 +67,7 @@ public void InsertItems() /// /// Here is where all the fun stuff starts. We create the structure and apply the naming here. /// - private void CreateStandardMenuStrip(System.ComponentModel.Design.IDesignerHost host, MenuStrip tool) + private void CreateStandardMenuStrip(IDesignerHost host, MenuStrip tool) { // build the static menu items structure. string[][] menuItemNames = new string[][] diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs index 015e7ba13e0..a196e1fbce2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs @@ -44,7 +44,7 @@ private class StringCollectionForm : CollectionForm private Button _cancelButton; private TableLayoutPanel _overarchingLayoutPanel; - private StringCollectionEditor _editor; + private readonly StringCollectionEditor _editor; /// /// Constructs a StringCollectionForm. @@ -117,13 +117,13 @@ private void InitializeComponent() // okButton // resources.ApplyResources(_okButton, "okButton"); - _okButton.DialogResult = Forms.DialogResult.OK; + _okButton.DialogResult = DialogResult.OK; _okButton.Name = "okButton"; // // cancelButton // resources.ApplyResources(_cancelButton, "cancelButton"); - _cancelButton.DialogResult = Forms.DialogResult.Cancel; + _cancelButton.DialogResult = DialogResult.Cancel; _cancelButton.Name = "cancelButton"; // // overarchingLayoutPanel @@ -138,7 +138,7 @@ private void InitializeComponent() // StringCollectionEditor // resources.ApplyResources(this, "$this"); - AutoScaleMode = Forms.AutoScaleMode.Font; + AutoScaleMode = AutoScaleMode.Font; Controls.Add(_overarchingLayoutPanel); HelpButton = true; MaximizeBox = false; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs new file mode 100644 index 00000000000..31314c282d2 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs @@ -0,0 +1,934 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Design; +using System.Globalization; +using System.Text; + +namespace System.Windows.Forms.Design +{ + /// + /// This class encapsulates the tab order UI for our form designer. + /// + [DesignTimeVisible(false)] + [ToolboxItem(false)] + internal class TabOrder : Control, IMouseHandler, IMenuStatusHandler + { + private IDesignerHost host; + private Control ctlHover; + private ArrayList tabControls; + private Rectangle[] tabGlyphs; + private ArrayList tabComplete; + private Hashtable tabNext; + private readonly Font tabFont; + private readonly StringBuilder drawString; + private readonly Brush highlightTextBrush; + private readonly Pen highlightPen; + private readonly int selSize; + private readonly Hashtable tabProperties; + private Region region; + private readonly MenuCommand[] commands; + private readonly MenuCommand[] newCommands; + private readonly string decimalSep; + + /// + /// Creates a new tab order control that displays the tab order + /// UI for a form. + /// + public TabOrder(IDesignerHost host) + { + this.host = host; + + // Determine a font for us to use. + // + IUIService uisvc = (IUIService)host.GetService(typeof(IUIService)); + if (uisvc != null) + { + tabFont = (Font)uisvc.Styles["DialogFont"]; + } + else + { + tabFont = DefaultFont; + } + + tabFont = new Font(tabFont, FontStyle.Bold); + + // And compute the proper highlight dimensions. + // + selSize = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width; + + // Colors and brushes... + // + drawString = new StringBuilder(12); + highlightTextBrush = new SolidBrush(SystemColors.HighlightText); + highlightPen = new Pen(SystemColors.Highlight); + + // The decimal separator + // + NumberFormatInfo formatInfo = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo)); + if (formatInfo != null) + { + decimalSep = formatInfo.NumberDecimalSeparator; + } + else + { + decimalSep = "."; + } + + tabProperties = new Hashtable(); + + // Set up a NULL brush so we never try to invalidate the control. This is + // more efficient for what we're doing + // + SetStyle(ControlStyles.Opaque, true); + + // We're an overlay on top of the form + // + IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService)); + Debug.Assert(os != null, "No overlay service -- tab order UI cannot be shown"); + if (os != null) + { + os.PushOverlay(this); + } + + // Push a help keyword so the help system knows we're in place. + // + IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService)); + if (hs != null) + { + hs.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword); + } + + commands = new MenuCommand[] + { + new MenuCommand(new EventHandler(OnKeyCancel), + MenuCommands.KeyCancel), + + new MenuCommand(new EventHandler(OnKeyDefault), + MenuCommands.KeyDefaultAction), + + new MenuCommand(new EventHandler(OnKeyPrevious), + MenuCommands.KeyMoveUp), + + new MenuCommand(new EventHandler(OnKeyNext), + MenuCommands.KeyMoveDown), + + new MenuCommand(new EventHandler(OnKeyPrevious), + MenuCommands.KeyMoveLeft), + + new MenuCommand(new EventHandler(OnKeyNext), + MenuCommands.KeyMoveRight), + + new MenuCommand(new EventHandler(OnKeyNext), + MenuCommands.KeySelectNext), + + new MenuCommand(new EventHandler(OnKeyPrevious), + MenuCommands.KeySelectPrevious), + }; + + newCommands = new MenuCommand[] + { + new MenuCommand(new EventHandler(OnKeyDefault), + MenuCommands.KeyTabOrderSelect), + }; + + IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService)); + if (mcs != null) + { + foreach (MenuCommand mc in newCommands) + { + mcs.AddCommand(mc); + } + } + + // We also override keyboard, menu and mouse handlers. Our override relies on the + // above array of menu commands, so this must come after we initialize the array. + // + IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService)); + if (ehs != null) + { + ehs.PushHandler(this); + } + + // We sync add, remove and change events so we remain in sync with any nastiness that the + // form may pull on us. + // + IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded += new ComponentEventHandler(OnComponentAddRemove); + cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddRemove); + cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + } + } + + /// + /// Called when it is time for the tab order UI to go away. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (region != null) + { + region.Dispose(); + region = null; + } + + if (host != null) + { + IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService)); + if (os != null) + { + os.RemoveOverlay(this); + } + + IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService)); + if (ehs != null) + { + ehs.PopHandler(this); + } + + IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService)); + if (mcs != null) + { + foreach (MenuCommand mc in newCommands) + { + mcs.RemoveCommand(mc); + } + } + + // We sync add, remove and change events so we remain in sync with any nastiness that the + // form may pull on us. + // + IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); + if (cs != null) + { + cs.ComponentAdded -= new ComponentEventHandler(OnComponentAddRemove); + cs.ComponentRemoved -= new ComponentEventHandler(OnComponentAddRemove); + cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + } + + IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService)); + if (hs != null) + { + hs.RemoveContextAttribute("Keyword", "TabOrderView"); + } + + host = null; + } + } + + base.Dispose(disposing); + } + + /// + /// this function does double duty: it draws the tabs if fRegion is false, or it + /// computes control region rects if fRegion is true (both require that we essentially + /// "draw" the tabs) + /// + private void DrawTabs(IList tabs, Graphics gr, bool fRegion) + { + IEnumerator e = tabs.GetEnumerator(); + int iCtl = 0; + Control ctl; + Control parent; + string str; + + Font font = tabFont; + + if (fRegion) + { + region = new Region(new Rectangle(0, 0, 0, 0)); + } + + if (ctlHover != null) + { + Rectangle ctlInner = GetConvertedBounds(ctlHover); + Rectangle ctlOuter = ctlInner; + ctlOuter.Inflate(selSize, selSize); + + if (fRegion) + { + region = new Region(ctlOuter); + region.Exclude(ctlInner); + } + else + { + Control p = ctlHover.Parent; + Color backColor; + backColor = p.BackColor; + + Region clip = gr.Clip; + gr.ExcludeClip(ctlInner); + using (SolidBrush brush = new SolidBrush(backColor)) + { + gr.FillRectangle(brush, ctlOuter); + } + + ControlPaint.DrawSelectionFrame(gr, false, ctlOuter, ctlInner, backColor); + gr.Clip = clip; + } + } + + Rectangle rc; + while (e.MoveNext()) + { + ctl = (Control)e.Current; + rc = GetConvertedBounds(ctl); + + drawString.Length = 0; + + parent = GetSitedParent(ctl); + Control baseControl = (Control)host.RootComponent; + + while (parent != baseControl && parent != null) + { + drawString.Insert(0, decimalSep); + drawString.Insert(0, parent.TabIndex.ToString(CultureInfo.CurrentCulture)); + parent = GetSitedParent(parent); + } + + drawString.Insert(0, ' '); + drawString.Append(ctl.TabIndex.ToString(CultureInfo.CurrentCulture)); + drawString.Append(' '); + + if (((PropertyDescriptor)tabProperties[ctl]).IsReadOnly) + { + drawString.Append(SR.WindowsFormsTabOrderReadOnly); + drawString.Append(' '); + } + + str = drawString.ToString(); + var sz = Size.Ceiling(gr.MeasureString(str, font)); + rc.Width = sz.Width + 2; + rc.Height = sz.Height + 2; + + tabGlyphs[iCtl++] = rc; + + Brush brush; + Pen pen; + Color textColor; + if (fRegion) + { + region.Union(rc); + } + else + { + if (tabComplete.IndexOf(ctl) != -1) + { + brush = highlightTextBrush; + pen = highlightPen; + textColor = SystemColors.Highlight; + } + else + { + brush = SystemBrushes.Highlight; + pen = SystemPens.HighlightText; + textColor = SystemColors.HighlightText; + } + + gr.FillRectangle(brush, rc); + gr.DrawRectangle(pen, rc.X, rc.Y, rc.Width - 1, rc.Height - 1); + + Brush foreBrush = new SolidBrush(textColor); + gr.DrawString(str, font, foreBrush, rc.X + 1, rc.Y + 1); + foreBrush.Dispose(); + } + } + + if (fRegion) + { + ctl = (Control)host.RootComponent; + rc = GetConvertedBounds(ctl); + region.Intersect(rc); + Region = region; + } + } + + /// + /// returns a control in the given tab vector that is at the given point, in + /// screen coords. + /// + private Control GetControlAtPoint(IList tabs, int x, int y) + { + IEnumerator e = tabs.GetEnumerator(); + Rectangle rc; + Control ctlFound = null; + Control ctl; + Control parent; + + while (e.MoveNext()) + { + ctl = (Control)e.Current; + parent = GetSitedParent(ctl); + rc = ctl.Bounds; + rc = parent.RectangleToScreen(rc); + + // We do not break if we find it here. The vector is already setup + // to have all controls in the current tabbing order, and child controls + // are always after their parents. If we broke, we wouldn't necessarially + // find the appropriate child. + // + if (rc.Contains(x, y)) + { + ctlFound = ctl; + } + } + + return ctlFound; + } + + /// + /// returns a rectangle in our own client space that represents the bounds + /// if the given control + /// + private Rectangle GetConvertedBounds(Control ctl) + { + Control parent = ctl.Parent; + Rectangle rc = ctl.Bounds; + rc = parent.RectangleToScreen(rc); + rc = RectangleToClient(rc); + return rc; + } + + /// + /// returns the maximum valid control count for the given control. This + /// may be less than Control.getControlCount() because of invisible controls + /// and our own control + /// + private int GetMaxControlCount(Control ctl) + { + int count = 0; + + for (int n = 0; n < ctl.Controls.Count; n++) + { + if (GetTabbable(ctl.Controls[n])) + { + count++; + } + } + + return count; + } + + /// + /// Retrieves the next parent control that would be usable + /// by the tab order UI. We only want parents that are + /// sited by the designer host. + /// + private Control GetSitedParent(Control child) + { + Control parent = child.Parent; + + while (parent != null) + { + ISite site = parent.Site; + IContainer container = null; + + if (site != null) + { + container = site.Container; + } + + container = DesignerUtils.CheckForNestedContainer(container); // ...necessary to support SplitterPanel components + + if (site != null && container == host) + { + break; + } + + parent = parent.Parent; + } + + return parent; + } + + /// + /// recursively fills the given tab vector with a control list + /// + private void GetTabbing(Control ctl, IList tabs) + { + Control ctlTab; + + // Now actually count the controls. We add them to the list in reverse + // order because the Controls collection is in z-order, and our list + // needs to be in reverse z-order. When done, we want this list to be + // in z-order from back-most to top-most, and from parent-most to + // child-most. + // + int cnt = ctl.Controls.Count; + for (int i = cnt - 1; i >= 0; i--) + { + ctlTab = ctl.Controls[i]; + + if (null != GetSitedParent(ctlTab) && GetTabbable(ctlTab)) + { + tabs.Add(ctlTab); + } + + if (ctlTab.Controls.Count > 0) + { + GetTabbing(ctlTab, tabs); + } + } + } + + /// + /// returns true if this component should show up in our tab list + /// + private bool GetTabbable(Control control) + { + for (Control c = control; c != null; c = c.Parent) + { + if (!c.Visible) + return false; + } + + ISite site = control.Site; + if (site == null || site.Container != host) + { + return false; + } + + PropertyDescriptor prop = TypeDescriptor.GetProperties(control)["TabIndex"]; + + if (prop == null || !prop.IsBrowsable) + { + return false; + } + + tabProperties[control] = prop; + return true; + } + + /// + /// Called in response to a component add or remove event. Here we re-aquire our + /// set of tabs. + /// + private void OnComponentAddRemove(object sender, ComponentEventArgs ce) + { + ctlHover = null; + tabControls = null; + tabGlyphs = null; + + if (tabComplete != null) + { + tabComplete.Clear(); + } + + if (tabNext != null) + { + tabNext.Clear(); + } + + if (region != null) + { + region.Dispose(); + region = null; + } + + Invalidate(); + } + + /// + /// Called in response to a component change event. Here we update our + /// tab order and redraw. + /// + private void OnComponentChanged(object sender, ComponentChangedEventArgs ce) + { + tabControls = null; + tabGlyphs = null; + if (region != null) + { + region.Dispose(); + region = null; + } + + Invalidate(); + } + + /// + /// Closes the tab order UI. + /// + private void OnKeyCancel(object sender, EventArgs e) + { + IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService)); + Debug.Assert(mcs != null, "No menu command service, can't get out of tab order UI"); + if (mcs != null) + { + MenuCommand mc = mcs.FindCommand(StandardCommands.TabOrder); + Debug.Assert(mc != null, "No tab order menu command, can't get out of tab order UI"); + if (mc != null) + { + mc.Invoke(); + } + } + } + + /// + /// Sets the current tab order selection. + /// + private void OnKeyDefault(object sender, EventArgs e) + { + if (ctlHover != null) + { + SetNextTabIndex(ctlHover); + RotateControls(true); + } + } + + /// + /// Selects the next component in the tab order. + /// + private void OnKeyNext(object sender, EventArgs e) + { + RotateControls(true); + } + + /// + /// Selects the previous component in the tab order. + /// + private void OnKeyPrevious(object sender, EventArgs e) + { + RotateControls(false); + } + + /// + /// This is called when the user double clicks on a component. The typical + /// behavior is to create an event handler for the component's default event + /// and nativagate to the handler. + /// + public virtual void OnMouseDoubleClick(IComponent component) + { + } + + /// + /// This is called when a mouse button is depressed. This will perform + /// the default drag action for the selected components, which is to + /// move those components around by the mouse. + /// + public virtual void OnMouseDown(IComponent component, MouseButtons button, int x, int y) + { + if (ctlHover != null) + { + SetNextTabIndex(ctlHover); + } + } + + /// + /// Overrides control.OnMouseDown. Here we set the tab index. We must + /// do this as well as the above OnMouseDown to take into account clicks + /// in the tab index numbers. + /// + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + if (ctlHover != null) + { + SetNextTabIndex(ctlHover); + } + } + + /// + /// This is called when the mouse momentarially hovers over the + /// view for the given component. + /// + public virtual void OnMouseHover(IComponent component) + { + } + + /// + /// This is called for each movement of the mouse. + /// + public virtual void OnMouseMove(IComponent component, int x, int y) + { + if (tabControls != null) + { + Control ctl = GetControlAtPoint(tabControls, x, y); + SetNewHover(ctl); + } + } + + /// + /// Overrides control. We update our cursor here. We must do this + /// as well as the OnSetCursor to take into account mouse movements + /// over the tab index numbers. + /// + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (tabGlyphs != null) + { + Control ctl = null; + + for (int i = 0; i < tabGlyphs.Length; i++) + { + if (tabGlyphs[i].Contains(e.X, e.Y)) + { + // Do not break if we find it -- we must + // work for nested children too. + ctl = (Control)tabControls[i]; + } + } + + SetNewHover(ctl); + } + + SetAppropriateCursor(); + } + + /// + /// This is called when the user releases the mouse from a component. + /// This will update the UI to reflect the release of the mouse. + /// + public virtual void OnMouseUp(IComponent component, MouseButtons button) + { + } + + private void SetAppropriateCursor() + { + if (ctlHover != null) + { + Cursor.Current = Cursors.Cross; + } + else + { + Cursor.Current = Cursors.Default; + } + } + + /// + /// This is called when the cursor for the given component should be updated. + /// The mouse is always over the given component's view when this is called. + /// + public virtual void OnSetCursor(IComponent component) + { + SetAppropriateCursor(); + } + + /// + /// Paints the tab control. + /// + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + if (null == tabControls) + { + tabControls = new ArrayList(); + GetTabbing((Control)host.RootComponent, tabControls); + tabGlyphs = new Rectangle[tabControls.Count]; + } + + if (null == tabComplete) + { + tabComplete = new ArrayList(); + } + + if (null == tabNext) + { + tabNext = new Hashtable(); + } + + if (null == region) + { + DrawTabs(tabControls, e.Graphics, true); + } + + DrawTabs(tabControls, e.Graphics, false); + } + + /// + /// CommandSet will check with this handler on each status update + /// to see if the handler wants to override the availability of + /// this command. + /// + public bool OverrideInvoke(MenuCommand cmd) + { + for (int i = 0; i < commands.Length; i++) + { + if (commands[i].CommandID.Equals(cmd.CommandID)) + { + commands[i].Invoke(); + return true; + } + } + + return false; + } + + /// + /// CommandSet will check with this handler on each status update + /// to see if the handler wants to override the availability of + /// this command. + /// + public bool OverrideStatus(MenuCommand cmd) + { + for (int i = 0; i < commands.Length; i++) + { + if (commands[i].CommandID.Equals(cmd.CommandID)) + { + cmd.Enabled = commands[i].Enabled; + return true; + } + } + + // Overriding the status of commands is easy. We only + // get commands that the designer implements, so we don't + // have to pick and choose which ones to get rid of. We + // keep a select view and disable the rest. + // + if (!cmd.CommandID.Equals(StandardCommands.TabOrder)) + { + cmd.Enabled = false; + return true; + } + + return false; + } + + /// + /// Called when the keyboard has been pressed to rotate us + /// through the control list. + /// + private void RotateControls(bool forward) + { + Control ctl = ctlHover; + Control form = (Control)host.RootComponent; + + if (ctl == null) + { + ctl = form; + } + + while (null != (ctl = form.GetNextControl(ctl, forward))) + { + if (GetTabbable(ctl)) + break; + } + + SetNewHover(ctl); + } + + /// + /// Establishes a new hover control. + /// + private void SetNewHover(Control ctl) + { + if (ctlHover != ctl) + { + if (null != ctlHover) + { + if (region != null) + { + region.Dispose(); + region = null; + } + + Rectangle rc = GetConvertedBounds(ctlHover); + rc.Inflate(selSize, selSize); + Invalidate(rc); + } + + ctlHover = ctl; + + if (null != ctlHover) + { + if (region != null) + { + region.Dispose(); + region = null; + } + + Rectangle rc = GetConvertedBounds(ctlHover); + rc.Inflate(selSize, selSize); + Invalidate(rc); + } + } + } + + /// + /// sets up the next tab index for the given control + /// + // Standard 'catch all - rethrow critical' exception pattern + private void SetNextTabIndex(Control ctl) + { + if (tabControls != null) + { + int index, max; + Control parent = GetSitedParent(ctl); + object nextIndex = tabNext[parent]; + + if (tabComplete.IndexOf(ctl) == -1) + tabComplete.Add(ctl); + + if (null != nextIndex) + index = (int)nextIndex; + else + index = 0; + + try + { + PropertyDescriptor prop = (PropertyDescriptor)tabProperties[ctl]; + if (prop != null) + { + int newIndex = index + 1; + + if (prop.IsReadOnly) + { + newIndex = (int)prop.GetValue(ctl) + 1; + } + + max = GetMaxControlCount(parent); + + if (newIndex >= max) + { + newIndex = 0; + } + + tabNext[parent] = newIndex; + + if (tabComplete.Count == tabControls.Count) + tabComplete.Clear(); + + // Now set the property + // + if (!prop.IsReadOnly) + { + try + { + prop.SetValue(ctl, index); + } + catch (Exception) + { + } + } + else + { + // If the property is read only, we still count it + // so that other properties can "flow" around it. + // Therefore, we need a paint. + // + Invalidate(); + } + } + } + catch (Exception ex) + { + if (ClientUtils.IsCriticalException(ex)) + { + throw; + } + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs index 85e84e2eba5..3676c7fb1ce 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs @@ -5,7 +5,6 @@ using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Drawing; namespace System.Windows.Forms.Design @@ -145,7 +144,6 @@ private void InsertToolStripItem(Type t) if (newItemTransaction != null) { newItemTransaction.Commit(); - newItemTransaction = null; } // turn off Adding/Added events listened to by the ToolStripDesigner... diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs new file mode 100644 index 00000000000..ab85c964bc5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal class TextBoxActionList : DesignerActionList + { + public TextBoxActionList(TextBoxDesigner designer) : base(designer.Component) + { + } + + public bool Multiline + { + get + { + return ((TextBox)Component).Multiline; + } + set + { + TypeDescriptor.GetProperties(Component)["Multiline"].SetValue(Component, value); + } + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionPropertyItem("Multiline", string.Format(SR.MultiLineDisplayName, SR.PropertiesCategoryName, SR.MultiLineDescription))); + return items; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs index 061ed3afe4f..9d5474e89ee 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs @@ -31,7 +31,7 @@ public override IList SnapLines { ArrayList snapLines = base.SnapLines as ArrayList; - int baseline = DesignerUtils.GetTextBaseline(Control, System.Drawing.ContentAlignment.TopLeft); + int baseline = DesignerUtils.GetTextBaseline(Control, Drawing.ContentAlignment.TopLeft); BorderStyle borderStyle = BorderStyle.Fixed3D; PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["BorderStyle"]; @@ -149,13 +149,13 @@ public override SelectionRules SelectionRules PropertyDescriptor prop = TypeDescriptor.GetProperties(component)["Multiline"]; if (prop != null) { - Object value = prop.GetValue(component); + object value = prop.GetValue(component); if (value is bool && (bool)value == false) { PropertyDescriptor propAuto = TypeDescriptor.GetProperties(component)["AutoSize"]; if (propAuto != null) { - Object auto = propAuto.GetValue(component); + object auto = propAuto.GetValue(component); if (auto is bool && (bool)auto == true) { rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs new file mode 100644 index 00000000000..5a5b0b21d5f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs @@ -0,0 +1,99 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// Provides a designer for TextBox. + /// + internal class TextBoxDesigner : TextBoxBaseDesigner + { + private char passwordChar; + + private DesignerActionListCollection _actionLists; + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + _actionLists.Add(new TextBoxActionList(this)); + } + + return _actionLists; + } + } + + /// + /// Allows a designer to filter the set of properties + /// the component it is designing will expose through the + /// TypeDescriptor object. This method is called + /// immediately before its corresponding "Post" method. + /// If you are overriding this method you should call + /// the base implementation before you perform your own + /// filtering. + /// + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + PropertyDescriptor prop; + + string[] shadowProps = new string[] + { + "PasswordChar" + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + prop = (PropertyDescriptor)properties[shadowProps[i]]; + if (prop != null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(TextBoxDesigner), prop, empty); + } + } + } + + /// + /// Shadows the PasswordChar. UseSystemPasswordChar overrides PasswordChar so independent on the value + /// of PasswordChar it will return the systemp password char. However, the value of PasswordChar is + /// cached so if UseSystemPasswordChar is reset at design time the PasswordChar value can be restored. + /// So in the case both properties are set, we need to serialize the real PasswordChar value as well. + /// + private char PasswordChar + { + get + { + TextBox tb = Control as TextBox; + Debug.Assert(tb != null, "Designed control is not a TextBox."); + + if (tb.UseSystemPasswordChar) + { + return passwordChar; + } + else + { + return tb.PasswordChar; + } + } + set + { + TextBox tb = Control as TextBox; + Debug.Assert(tb != null, "Designed control is not a TextBox."); + + passwordChar = value; + tb.PasswordChar = value; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs index 94d36d1cd3b..56583c6aa7b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs @@ -108,7 +108,7 @@ public DockStyle Dock { if (value != Dock) { - ChangeProperty(nameof(Dock), (object)value); + ChangeProperty(nameof(Dock), value); } } } @@ -120,7 +120,7 @@ public ToolStripRenderMode RenderMode { if (value != RenderMode) { - ChangeProperty(nameof(RenderMode), (object)value); + ChangeProperty(nameof(RenderMode), value); } } } @@ -132,7 +132,7 @@ public ToolStripGripStyle GripStyle { if (value != GripStyle) { - ChangeProperty(nameof(GripStyle), (object)value); + ChangeProperty(nameof(GripStyle), value); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs index f277be25bda..34cbb67ec4b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs @@ -143,7 +143,7 @@ private bool AllowItemReorder /// /// The ToolStripItems are the associated components. We want those to come with in any cut, copy opreations. /// - public override System.Collections.ICollection AssociatedComponents + public override ICollection AssociatedComponents { get { @@ -156,7 +156,7 @@ public override System.Collections.ICollection AssociatedComponents } } - return (ICollection)items; + return items; } } @@ -532,7 +532,7 @@ private ToolStripItem AddNewItem(Type t) designer.InternalCreate = true; if (designer is ComponentDesigner) { - ((ComponentDesigner)designer).InitializeNewComponent(null); + designer.InitializeNewComponent(null); } } finally @@ -593,7 +593,7 @@ internal ToolStripItem AddNewItem(Type t, string text, bool enterKeyPressed, boo if (designer is ComponentDesigner) { - ((ComponentDesigner)designer).InitializeNewComponent(null); + designer.InitializeNewComponent(null); } } finally @@ -735,7 +735,6 @@ internal ToolStripItem AddNewItem(Type t, string text, bool enterKeyPressed, boo else if (outerTransaction != null) { outerTransaction.Commit(); - outerTransaction = null; } _addingItem = false; @@ -937,7 +936,7 @@ private void ComponentChangeSvc_ComponentAdded(object sender, ComponentEventArgs // notify the designer what's changed. try { - base.RaiseComponentChanging(TypeDescriptor.GetProperties(Component)["Items"]); + RaiseComponentChanging(TypeDescriptor.GetProperties(Component)["Items"]); if (SelectionService.PrimarySelection is ToolStripItem selectedItem) { //ADD at the current Selection ... @@ -959,7 +958,7 @@ private void ComponentChangeSvc_ComponentAdded(object sender, ComponentEventArgs } finally { - base.RaiseComponentChanged(TypeDescriptor.GetProperties(Component)["Items"], null, null); + RaiseComponentChanged(TypeDescriptor.GetProperties(Component)["Items"], null, null); } } } @@ -1071,7 +1070,7 @@ private void ComponentChangeSvc_ComponentRemoved(object sender, ComponentEventAr if (itemIndex != -1) { ToolStrip.Items.Remove(item); - base.RaiseComponentChanged(TypeDescriptor.GetProperties(Component)["Items"], null, null); + RaiseComponentChanged(TypeDescriptor.GetProperties(Component)["Items"], null, null); } } finally @@ -1112,7 +1111,7 @@ private void ComponentChangeSvc_ComponentRemoved(object sender, ComponentEventAr if (KeyboardHandlingService.CutOrDeleteInProgress) { - IComponent targetSelection = (itemIndex == -1) ? (IComponent)ToolStrip : (IComponent)ToolStrip.Items[itemIndex]; + IComponent targetSelection = (itemIndex == -1) ? ToolStrip : ToolStrip.Items[itemIndex]; // if the TemplateNode becomes the targetSelection, then set the targetSelection to null. if (targetSelection != null) { @@ -1146,7 +1145,7 @@ private void ComponentChangeSvc_ComponentRemoving(object sender, ComponentEventA try { _pendingTransaction = _host.CreateTransaction(SR.ToolStripDesignerTransactionRemovingItem); - base.RaiseComponentChanging(TypeDescriptor.GetProperties(Component)["Items"]); + RaiseComponentChanging(TypeDescriptor.GetProperties(Component)["Items"]); if (e.Component is ToolStripDropDownItem dropDownItem) { dropDownItem.HideDropDown(); @@ -1712,7 +1711,7 @@ internal static string NameFromText(string text, Type componentType, IServicePro string nameSuffix = componentType.Name; // remove all the non letter and number characters. Append length of the item name... - System.Text.StringBuilder name = new System.Text.StringBuilder(text.Length + nameSuffix.Length); + Text.StringBuilder name = new Text.StringBuilder(text.Length + nameSuffix.Length); bool nextCharToUpper = false; for (int i = 0; i < text.Length; i++) { @@ -1862,7 +1861,7 @@ protected override void OnDragDrop(DragEventArgs de) string transDesc; ArrayList components = data.DragComponents; - ToolStripItem primaryItem = data.PrimarySelection as ToolStripItem; + ToolStripItem primaryItem = data.PrimarySelection; int primaryIndex = -1; bool copy = (de.Effect == DragDropEffects.Copy); @@ -1976,7 +1975,6 @@ protected override void OnDragDrop(DragEventArgs de) if (changeParent != null) { changeParent.Commit(); - changeParent = null; } } } @@ -2077,7 +2075,7 @@ private void OnOverFlowDropDownOpened(object sender, EventArgs e) /// /// In Order to Draw the Selection Glyphs we need to reforce painting on the the AdonerWindow.This method forces the repaint /// - private void OnOverFlowDropDownPaint(object sender, System.Windows.Forms.PaintEventArgs e) + private void OnOverFlowDropDownPaint(object sender, PaintEventArgs e) { foreach (ToolStripItem item in ToolStrip.Items) { @@ -2195,7 +2193,7 @@ private void OnUndoing(object source, EventArgs e) /// /// SyncSelection on ToolStrip move. /// - private void OnToolStripMove(object sender, System.EventArgs e) + private void OnToolStripMove(object sender, EventArgs e) { if (SelectionService.GetComponentSelected(ToolStrip)) { @@ -2365,9 +2363,8 @@ private void SelSvc_SelectionChanged(object sender, EventArgs e) { if (_miniToolStrip != null && _host != null) { - bool showToolStrip = false; bool itemSelected = CheckIfItemSelected(); - showToolStrip = itemSelected || SelectionService.GetComponentSelected(ToolStrip); + bool showToolStrip = itemSelected || SelectionService.GetComponentSelected(ToolStrip); //Check All the SelectedComponents to find is toolstrips are selected if (showToolStrip) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs index 5cc352fd603..07ead1a68e1 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs @@ -76,7 +76,7 @@ public override DesignerActionListCollection ActionLists /// /// The ToolStripItems are the associated components. We want those to come with in any cut, copy opreations. /// - public override System.Collections.ICollection AssociatedComponents + public override ICollection AssociatedComponents { get => ((ToolStrip)Component).Items; } @@ -655,7 +655,7 @@ public void ShowMenu(ToolStripItem selectedItem) return; } - Control parent = designMenu.Parent as Control; + Control parent = designMenu.Parent; if (parent is Form parentForm) { parentFormDesigner = host.GetDesigner(parentForm) as FormDocumentDesigner; @@ -754,7 +754,7 @@ private void OnUndone(object source, EventArgs e) /// /// This is an internal class which provides the Behavior for our MenuStrip Body Glyph. This will just eat the MouseUps... /// - internal class ContextMenuStripBehavior : System.Windows.Forms.Design.Behavior.Behavior + internal class ContextMenuStripBehavior : Behavior.Behavior { readonly ToolStripMenuItem _item; internal ContextMenuStripBehavior(ToolStripMenuItem menuItem) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs index 62113e1c0d0..bd6c036fdc4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs @@ -22,7 +22,7 @@ public override void Initialize(IComponent component) /// /// The ToolStripItems are the associated components. We want those to come with in any cut, copy opreations. /// - public override System.Collections.ICollection AssociatedComponents + public override Collections.ICollection AssociatedComponents { get { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs index 729cf42aff0..765131da04a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.ComponentModel.Design; -using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Windows.Forms.Design.Behavior; @@ -73,7 +72,7 @@ internal void ActivateEditor(ToolStripItem item, bool clicked) _itemDesigner = (ToolStripItemDesigner)_designerHost.GetDesigner(_currentItem); } - _editorUI = (ToolStripTemplateNode)_itemDesigner.Editor; + _editorUI = _itemDesigner.Editor; // If we got an editor, position and focus it. if (_editorUI != null) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs index d3e02eaf0f2..644327b244b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs @@ -94,7 +94,6 @@ private void ClearInsertionMark(ToolStripItem item) finally { rgn.Dispose(); - rgn = null; } } } @@ -191,7 +190,7 @@ private void OnDoubleClickTimerTick(object sender, EventArgs e) if (_timer != null) { _timer.Enabled = false; - _timer.Tick -= new System.EventHandler(OnDoubleClickTimerTick); + _timer.Tick -= new EventHandler(OnDoubleClickTimerTick); _timer.Dispose(); _timer = null; // Enter Insitu ... @@ -242,7 +241,7 @@ public override bool OnMouseUp(Glyph g, MouseButtons button) if (_timer != null) { _timer.Enabled = false; - _timer.Tick -= new System.EventHandler(OnDoubleClickTimerTick); + _timer.Tick -= new EventHandler(OnDoubleClickTimerTick); _timer.Dispose(); _timer = null; } @@ -569,7 +568,7 @@ public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) if (_timer != null) { _timer.Enabled = false; - _timer.Tick -= new System.EventHandler(OnDoubleClickTimerTick); + _timer.Tick -= new EventHandler(OnDoubleClickTimerTick); _timer.Dispose(); _timer = null; } @@ -647,7 +646,7 @@ public override void OnDragDrop(Glyph g, DragEventArgs e) if (currentDropItem != selectedItem && designerHost != null) { ArrayList components = data.DragComponents; - ToolStrip parentToolStrip = currentDropItem.GetCurrentParent() as ToolStrip; + ToolStrip parentToolStrip = currentDropItem.GetCurrentParent(); int primaryIndex = -1; string transDesc; bool copy = (e.Effect == DragDropEffects.Copy); @@ -824,7 +823,6 @@ public override void OnDragDrop(Glyph g, DragEventArgs e) if (designerTransaction != null) { designerTransaction.Commit(); - designerTransaction = null; } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs index 32c04b09a29..995c463a01f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs @@ -5,7 +5,6 @@ using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Drawing; namespace System.Windows.Forms.Design @@ -131,7 +130,7 @@ private void PopulateList() { checkedToolStripMenuItem = CreateBooleanItem("C&hecked", "Checked"); showShortcutKeysToolStripMenuItem = CreateBooleanItem("ShowShortcut&Keys", "ShowShortcutKeys"); - AddRange(new System.Windows.Forms.ToolStripItem[] { checkedToolStripMenuItem, showShortcutKeysToolStripMenuItem }); + AddRange(new ToolStripItem[] { checkedToolStripMenuItem, showShortcutKeysToolStripMenuItem }); } else { @@ -180,10 +179,10 @@ private void PopulateList() } } - AddRange(new System.Windows.Forms.ToolStripItem[] { alignmentToolStripMenuItem, displayStyleToolStripMenuItem, }); + AddRange(new ToolStripItem[] { alignmentToolStripMenuItem, displayStyleToolStripMenuItem, }); } - toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + toolStripSeparator1 = new ToolStripSeparator(); Add(toolStripSeparator1); } @@ -198,7 +197,7 @@ private void PopulateList() DropDown = ToolStripDesignerUtils.GetNewItemDropDown(ParentTool, currentItem, new EventHandler(AddNewItemClick), false, serviceProvider, true) }; - AddRange(new System.Windows.Forms.ToolStripItem[] { convertToolStripMenuItem, insertToolStripMenuItem }); + AddRange(new ToolStripItem[] { convertToolStripMenuItem, insertToolStripMenuItem }); if (currentItem is ToolStripDropDownItem) { @@ -427,7 +426,6 @@ private void InsertIntoDropDown(ToolStripDropDown parent, Type t) if (newItemTransaction != null) { newItemTransaction.Commit(); - newItemTransaction = null; } } } @@ -473,7 +471,6 @@ private void InsertIntoMainMenu(MenuStrip parent, Type t) if (newItemTransaction != null) { newItemTransaction.Commit(); - newItemTransaction = null; } } } @@ -519,7 +516,6 @@ private void InsertIntoStatusStrip(StatusStrip parent, Type t) if (newItemTransaction != null) { newItemTransaction.Commit(); - newItemTransaction = null; } } } @@ -593,7 +589,6 @@ private void InsertToolStripItem(Type t) if (newItemTransaction != null) { newItemTransaction.Commit(); - newItemTransaction = null; } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs index c0a56d2dc39..c4fd43111b0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs @@ -176,7 +176,7 @@ private ToolStripItemOverflow Overflow // first Hide the Overflow.. if (ToolStripItem.IsOnOverflow) { - ToolStrip strip = ToolStripItem.Owner as ToolStrip; + ToolStrip strip = ToolStripItem.Owner; if (strip.OverflowButton.DropDown.Visible) { strip.OverflowButton.HideDropDown(); @@ -419,7 +419,6 @@ internal virtual void CommitEdit(Type type, string text, bool commit, bool enter if (designerTransaction != null) { designerTransaction.Commit(); - designerTransaction = null; } } } @@ -486,7 +485,7 @@ protected override void Dispose(bool disposing) if (ToolStripItem != null) { - ToolStripItem.Paint -= new System.Windows.Forms.PaintEventHandler(OnItemPaint); + ToolStripItem.Paint -= new PaintEventHandler(OnItemPaint); } // Now, unhook the component rename event @@ -590,7 +589,7 @@ private void FireComponentChanged(ToolStripDropDownItem parent) } } - public void GetGlyphs(ref GlyphCollection glyphs, System.Windows.Forms.Design.Behavior.Behavior standardBehavior) + public void GetGlyphs(ref GlyphCollection glyphs, Behavior.Behavior standardBehavior) { if (ImmediateParent == null) { @@ -939,7 +938,6 @@ internal virtual ToolStripItem MorphCurrentItem(Type t) if (designerTransaction != null) { designerTransaction.Commit(); - designerTransaction = null; } } @@ -1123,7 +1121,7 @@ public void RemoveItem() private void ResetAutoSize() => ShadowProperties[nameof(AutoSize)] = false; /// - /// Restores the AutoSize to be the value set in the property grid. + /// Restores the AutoSize to be the value set in the property grid. /// private void RestoreAutoSize() => ToolStripItem.AutoSize = (bool)ShadowProperties[nameof(AutoSize)]; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs index 45bb52d9d69..d20b78a633e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs @@ -16,7 +16,7 @@ internal class ToolStripItemGlyph : ControlBodyGlyph private Rectangle _bounds; private readonly ToolStripItemDesigner _itemDesigner; - public ToolStripItemGlyph(ToolStripItem item, ToolStripItemDesigner itemDesigner, Rectangle bounds, System.Windows.Forms.Design.Behavior.Behavior b) : base(bounds, Cursors.Default, item, b) + public ToolStripItemGlyph(ToolStripItem item, ToolStripItemDesigner itemDesigner, Rectangle bounds, Behavior.Behavior b) : base(bounds, Cursors.Default, item, b) { _item = item; _bounds = bounds; @@ -58,7 +58,7 @@ public override void Paint(PaintEventArgs pe) { if (_item is ToolStripControlHost && _item.IsOnDropDown) { - if (_item is System.Windows.Forms.ToolStripComboBox && VisualStyles.VisualStyleRenderer.IsSupported) + if (_item is ToolStripComboBox && VisualStyles.VisualStyleRenderer.IsSupported) { // When processing WM_PAINT and the OS has a theme enabled, the native ComboBox sends a WM_PAINT message to its parent when a theme is enabled in the OS forcing a repaint in the AdornerWindow generating an infinite WM_PAINT message processing loop. We guard against this here. return; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs index 942cdae26e5..922a7a7b443 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs @@ -165,7 +165,7 @@ internal object SelectedDesignerControl if (curDesignerNode.AccessibilityObject is ToolStripItem.ToolStripItemAccessibleObject acc) { acc.AddState(AccessibleStates.Selected | AccessibleStates.Focused); - ToolStrip owner = curDesignerNode.GetCurrentParent() as ToolStrip; + ToolStrip owner = curDesignerNode.GetCurrentParent(); int focusIndex = 0; if (owner != null) { @@ -312,7 +312,7 @@ private Control GetNextControlInTab(Control basectl, Control ctl, bool forward) Control p = ctl.Parent; // Cycle through the controls in z-order looking for the one with the next highest tab index. Because there can be dups, we have to start with the existing tab index and remember to exclude the current control. int parentControlCount = 0; - Control.ControlCollection parentControls = (Control.ControlCollection)p.Controls; + Control.ControlCollection parentControls = p.Controls; if (parentControls != null) { parentControlCount = parentControls.Count; @@ -362,7 +362,7 @@ private Control GetNextControlInTab(Control basectl, Control ctl, bool forward) Control p = ctl.Parent; // Cycle through the controls in reverse z-order looking for the next lowest tab index. We must start with the same tab index as ctl, because there can be dups. int parentControlCount = 0; - Control.ControlCollection parentControls = (Control.ControlCollection)p.Controls; + Control.ControlCollection parentControls = p.Controls; if (parentControls != null) { parentControlCount = parentControls.Count; @@ -599,7 +599,7 @@ private void OnCommandPaste(object sender, EventArgs e) //Case 1: If SelectedObj is ToolStripItem select all items in its immediate parent. if (item != null) { - parent = item.GetCurrentParent() as ToolStrip; + parent = item.GetCurrentParent(); } if (parent != null) @@ -765,7 +765,7 @@ private void OnCommandSelectAll(object sender, EventArgs e) if (selectedObj is ToolStripItem) { ToolStripItem selectedItem = selectedObj as ToolStripItem; - ToolStrip parent = selectedItem.GetCurrentParent() as ToolStrip; + ToolStrip parent = selectedItem.GetCurrentParent(); if (parent is ToolStripOverflow) { parent = selectedItem.Owner; @@ -793,7 +793,7 @@ private void OnCommandSelectAll(object sender, EventArgs e) if (selectedObj is ToolStripPanel) { ToolStripPanel parentToolStripPanel = selectedObj as ToolStripPanel; - selSvc.SetSelectedComponents((ICollection)parentToolStripPanel.Controls, SelectionTypes.Replace); + selSvc.SetSelectedComponents(parentToolStripPanel.Controls, SelectionTypes.Replace); return; } } @@ -1452,7 +1452,7 @@ public void ProcessUpDown(bool down) { if (item.Owner is ToolStrip owner) { - targetSelection = GetNextItem(owner, ((ToolStripDropDown)parentToMoveOn).OwnerItem, ArrowDirection.Left); + targetSelection = GetNextItem(owner, parentToMoveOn.OwnerItem, ArrowDirection.Left); } } else @@ -1533,7 +1533,7 @@ private void PopulateOldCommands() _oldCommands.Add(mcs.FindCommand(MenuCommands.KeyInvokeSmartTag)); _oldCommands.Add(mcs.FindCommand(StandardCommands.Cut)); - _oldCommands.Add(mcs.FindCommand(MenuCommands.Delete)); + _oldCommands.Add(mcs.FindCommand(StandardCommands.Delete)); } } @@ -1579,7 +1579,7 @@ private void PopulateNewCommands() _newCommands.Add(new MenuCommand(new EventHandler(OnKeyShowDesignerActions), MenuCommands.KeyInvokeSmartTag)); _newCommands.Add(new MenuCommand(new EventHandler(OnCommandCopy), StandardCommands.Cut)); - _newCommands.Add(new MenuCommand(new EventHandler(OnCommandDelete), MenuCommands.Delete)); + _newCommands.Add(new MenuCommand(new EventHandler(OnCommandDelete), StandardCommands.Delete)); } // restores the old commands back into the menu command service. diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs index c32e8906c62..96b4ff89434 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs @@ -38,7 +38,7 @@ private CodeDomSerializer GetBaseSerializer(IDesignerSerializationManager manage public override object Serialize(IDesignerSerializationManager manager, object value) { ToolStripMenuItem item = value as ToolStripMenuItem; - ToolStrip parent = item.GetCurrentParent() as ToolStrip; + ToolStrip parent = item.GetCurrentParent(); //Dont Serialize if we are Dummy Item ... if ((item != null) && !(item.IsOnDropDown) && (parent != null) && (parent.Site is null)) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs index 43e82f24d2f..dd6078d42b6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs @@ -89,7 +89,7 @@ public override ICollection AssociatedComponents } } - return (ICollection)items; + return items; } } @@ -420,15 +420,15 @@ internal override void CommitEdit(Type type, string text, bool commit, bool ente } else if (commit) { - int index = -1; bool dummyItem = dummyItemAdded; dummyItemAdded = false; MenuItem.DropDown.SuspendLayout(); + int index; if (commitedEditorNode != null) { // This means we have a valid node and we just changed some properties. index = MenuItem.DropDownItems.IndexOf(commitedEditorNode); - ToolStripItem editedItem = (ToolStripItem)MenuItem.DropDownItems[index + 1]; + ToolStripItem editedItem = MenuItem.DropDownItems[index + 1]; // Remove TemplatENode MenuItem.DropDown.Items.Remove(commitedEditorNode); // Get rid of the templateNode... @@ -552,7 +552,6 @@ internal override void CommitEdit(Type type, string text, bool commit, bool ente if (designerTransaction != null) { designerTransaction.Commit(); - designerTransaction = null; } } } @@ -636,7 +635,7 @@ internal override void CommitEdit(Type type, string text, bool commit, bool ente bool dummyItem = dummyItemAdded; dummyItemAdded = false; int index = MenuItem.DropDownItems.IndexOf(commitedEditorNode); - ToolStripItem editedItem = (ToolStripItem)MenuItem.DropDownItems[index + 1]; + ToolStripItem editedItem = MenuItem.DropDownItems[index + 1]; MenuItem.DropDown.Items.Remove(commitedEditorNode); // put the item back... editedItem.Visible = true; @@ -710,8 +709,6 @@ internal override void CommitEdit(Type type, string text, bool commit, bool ente dummyItemAdded = false; } } - - dummyItem = false; } // Added for Separators... @@ -810,7 +807,7 @@ private ToolStripItem CreateDummyItem(Type t, int dummyIndex) designer.InternalCreate = true; if (designer is ComponentDesigner) { - ((ComponentDesigner)designer).InitializeNewComponent(null); + designer.InitializeNewComponent(null); } } finally @@ -888,7 +885,7 @@ private ToolStripItem CreateNewItem(Type t, int dummyIndex, string newText) if (designer is ComponentDesigner) { - ((ComponentDesigner)designer).InitializeNewComponent(null); + designer.InitializeNewComponent(null); } } finally @@ -922,7 +919,6 @@ private ToolStripItem CreateNewItem(Type t, int dummyIndex, string newText) if (outerTransaction != null) { outerTransaction.Commit(); - outerTransaction = null; } // turn on Adding/Added events listened to by the ToolStripDesigner... @@ -1508,7 +1504,7 @@ internal void HookEvents() MenuItem.DropDownOpening += new EventHandler(DropDownItem_DropDownOpening); MenuItem.DropDownOpened += new EventHandler(DropDownItem_DropDownOpened); MenuItem.DropDownClosed += new EventHandler(DropDownItem_DropDownClosed); - MenuItem.DropDown.Resize += new System.EventHandler(DropDownResize); + MenuItem.DropDown.Resize += new EventHandler(DropDownResize); MenuItem.DropDown.ItemAdded += new ToolStripItemEventHandler(OnItemAdded); MenuItem.DropDown.Paint += new PaintEventHandler(DropDownPaint); MenuItem.DropDown.Click += new EventHandler(DropDownClick); @@ -1669,7 +1665,6 @@ internal override ToolStripItem MorphCurrentItem(Type t) if (toolStripservice != null) { toolStripservice.Invalidate(boundstoInvalidate); - toolStripservice = null; } return newItem; @@ -1804,7 +1799,7 @@ private void ComponentChangeSvc_ComponentAdded(object sender, ComponentEventArgs } else { - base.RaiseComponentChanged(TypeDescriptor.GetProperties(MenuItem)["DropDownItems"], null, null); + RaiseComponentChanged(TypeDescriptor.GetProperties(MenuItem)["DropDownItems"], null, null); } CommitInsertTransaction(/*commit=*/true); @@ -1904,7 +1899,7 @@ private void ComponentChangeSvc_ComponentRemoved(object sender, ComponentEventAr if (itemIndex != -1) { ownerItem.DropDownItems.Remove(itemToBeDeleted); - base.RaiseComponentChanged(TypeDescriptor.GetProperties(ownerItem)["DropDownItems"], null, null); + RaiseComponentChanged(TypeDescriptor.GetProperties(ownerItem)["DropDownItems"], null, null); } } finally @@ -1945,7 +1940,7 @@ private void ComponentChangeSvc_ComponentRemoved(object sender, ComponentEventAr { if (_selectionService != null && !dummyItemAdded) { - IComponent targetSelection = (itemIndex == -1) ? (IComponent)ownerItem : (IComponent)ownerItem.DropDownItems[itemIndex]; + IComponent targetSelection = (itemIndex == -1) ? ownerItem : ownerItem.DropDownItems[itemIndex]; // if the TemplateNode becomes the targetSelection, then set the targetSelection to null. if (targetSelection is DesignerToolStripControlHost) { @@ -1996,7 +1991,7 @@ private void ComponentChangeSvc_ComponentRemoving(object sender, ComponentEventA try { _pendingTransaction = _designerHost.CreateTransaction(SR.ToolStripDesignerTransactionRemovingItem); - base.RaiseComponentChanging(TypeDescriptor.GetProperties(ownerItem)["DropDownItems"]); + RaiseComponentChanging(TypeDescriptor.GetProperties(ownerItem)["DropDownItems"]); } catch { @@ -2232,7 +2227,7 @@ private void OnSelectionChanged(object sender, EventArgs e) } else { - parent = ((ToolStripItem)(parent.OwnerItem)).Owner as ToolStripDropDown; + parent = parent.OwnerItem.Owner as ToolStripDropDown; } } } @@ -2258,7 +2253,7 @@ private void OnSelectionChanged(object sender, EventArgs e) } else { - parent = ((ToolStripItem)(parent.OwnerItem)).Owner as ToolStripDropDown; + parent = parent.OwnerItem.Owner as ToolStripDropDown; } } } @@ -2616,7 +2611,7 @@ internal void UnHookEvents() internal class ToolStripDropDownGlyph : Glyph { private Rectangle _bounds; - internal ToolStripDropDownGlyph(Rectangle bounds, System.Windows.Forms.Design.Behavior.Behavior b) : base(b) + internal ToolStripDropDownGlyph(Rectangle bounds, Behavior.Behavior b) : base(b) { _bounds = bounds; } @@ -2830,8 +2825,6 @@ public override void OnDragDrop(Glyph g, DragEventArgs e) { changeParent.Commit(); } - - changeParent = null; } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs index 50d1a5cce87..69ca08d232d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs @@ -171,13 +171,13 @@ public bool Active IMenuCommandService menuService = (IMenuCommandService)_component.Site.GetService(typeof(IMenuCommandService)); if (menuService != null) { - _oldUndoCommand = menuService.FindCommand(MenuCommands.Undo); + _oldUndoCommand = menuService.FindCommand(StandardCommands.Undo); if (_oldUndoCommand != null) { menuService.RemoveCommand(_oldUndoCommand); } - _oldRedoCommand = menuService.FindCommand(MenuCommands.Redo); + _oldRedoCommand = menuService.FindCommand(StandardCommands.Redo); if (_oldRedoCommand != null) { menuService.RemoveCommand(_oldRedoCommand); @@ -443,7 +443,7 @@ private void AddNewItemClick(object sender, EventArgs e) // Set the property used in the CommitEditor (.. ) to add the correct Type. ToolStripItemType = senderItem.ItemType; //Select the parent before adding - ToolStrip parent = _controlHost.GetCurrentParent() as ToolStrip; + ToolStrip parent = _controlHost.GetCurrentParent(); // this will add the item to the ToolStrip.. if (parent is MenuStrip) { @@ -538,7 +538,7 @@ private void CenterLabelClick(object sender, MouseEventArgs e) if (_designer is ToolStripMenuItemDesigner) { // cache the serviceProvider (Site) since the component can potential get disposed after the call to CommitAndSelect(); - IServiceProvider svcProvider = _component.Site as IServiceProvider; + IServiceProvider svcProvider = _component.Site; // Commit any InsituEdit Node. if (KeyboardService.TemplateNodeActive) { @@ -692,13 +692,13 @@ internal void CloseEditor() if (_component is ToolStrip strip) { - strip.RightToLeftChanged -= new System.EventHandler(OnRightToLeftChanged); + strip.RightToLeftChanged -= new EventHandler(OnRightToLeftChanged); } else { if (_component is ToolStripDropDownItem stripItem) { - stripItem.RightToLeftChanged -= new System.EventHandler(OnRightToLeftChanged); + stripItem.RightToLeftChanged -= new EventHandler(OnRightToLeftChanged); } } @@ -886,11 +886,11 @@ private void EnterInSituEdit() if (_activeItem is ToolStripDropDownItem item && !item.IsOnDropDown) { - _centerTextBox.Margin = new System.Windows.Forms.Padding(1, 2, 1, 3); + _centerTextBox.Margin = new Padding(1, 2, 1, 3); } else { - _centerTextBox.Margin = new System.Windows.Forms.Padding(1); + _centerTextBox.Margin = new Padding(1); } _centerTextBox.Size = _miniToolStrip.DisplayRectangle.Size - _centerTextBox.Margin.Size; @@ -1249,7 +1249,7 @@ public bool OverrideInvoke(MenuCommand cmd) { if (_commands[i].CommandID.Equals(cmd.CommandID)) { - if (cmd.CommandID == MenuCommands.Delete || cmd.CommandID == MenuCommands.Cut || cmd.CommandID == MenuCommands.Copy) + if (cmd.CommandID == StandardCommands.Delete || cmd.CommandID == StandardCommands.Cut || cmd.CommandID == StandardCommands.Copy) { _commands[i].Invoke(); return true; @@ -1407,9 +1407,9 @@ private void SetUpToolTemplateNode(ToolStripTemplateNode owner, string text, Ima _addItemButton.ToolTipText = SR.ToolStripDesignerTemplateNodeSplitButtonToolTip; } - _addItemButton.MouseDown += new System.Windows.Forms.MouseEventHandler(OnMouseDown); - _addItemButton.MouseMove += new System.Windows.Forms.MouseEventHandler(OnMouseMove); - _addItemButton.MouseUp += new System.Windows.Forms.MouseEventHandler(OnMouseUp); + _addItemButton.MouseDown += new MouseEventHandler(OnMouseDown); + _addItemButton.MouseMove += new MouseEventHandler(OnMouseMove); + _addItemButton.MouseUp += new MouseEventHandler(OnMouseUp); _addItemButton.DropDownOpened += OnAddItemButtonDropDownOpened; _contextMenu = ToolStripDesignerUtils.GetNewItemDropDown(component, null, new EventHandler(AddNewItemClick), false, component.Site, false); _contextMenu.Text = "ItemSelectionMenu"; @@ -1446,7 +1446,7 @@ private void SetUpToolTemplateNode(ToolStripTemplateNode owner, string text, Ima } } - _miniToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] + _miniToolStrip.Items.AddRange(new ToolStripItem[] { _addItemButton }); @@ -1463,7 +1463,7 @@ private void SetupNewEditNode(ToolStripTemplateNode owner, string text, Image im if (currentItem is ToolStrip strip) { _miniToolStrip.RightToLeft = strip.RightToLeft; - strip.RightToLeftChanged += new System.EventHandler(OnRightToLeftChanged); + strip.RightToLeftChanged += new EventHandler(OnRightToLeftChanged); // Make TransparentToolStrip has the same "Site" as ToolStrip. This could make sure TransparentToolStrip has the same design time behavior as ToolStrip. _miniToolStrip.Site = strip.Site; } @@ -1471,14 +1471,14 @@ private void SetupNewEditNode(ToolStripTemplateNode owner, string text, Image im if (currentItem is ToolStripDropDownItem stripItem) { _miniToolStrip.RightToLeft = stripItem.RightToLeft; - stripItem.RightToLeftChanged += new System.EventHandler(OnRightToLeftChanged); + stripItem.RightToLeftChanged += new EventHandler(OnRightToLeftChanged); } _miniToolStrip.SuspendLayout(); _miniToolStrip.CanOverflow = false; - _miniToolStrip.Cursor = System.Windows.Forms.Cursors.Default; - _miniToolStrip.Dock = System.Windows.Forms.DockStyle.None; - _miniToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + _miniToolStrip.Cursor = Cursors.Default; + _miniToolStrip.Dock = DockStyle.None; + _miniToolStrip.GripStyle = ToolStripGripStyle.Hidden; _miniToolStrip.Name = "miniToolStrip"; _miniToolStrip.TabIndex = 0; _miniToolStrip.Visible = true; @@ -1497,7 +1497,7 @@ private void SetupNewEditNode(ToolStripTemplateNode owner, string text, Image im _miniToolStrip.AccessibleRole = AccessibleRole.ButtonDropDown; } - _miniToolStrip.MouseLeave += new System.EventHandler(OnMouseLeave); + _miniToolStrip.MouseLeave += new EventHandler(OnMouseLeave); _miniToolStrip.ResumeLayout(); } @@ -1586,7 +1586,7 @@ protected override void WndProc(ref Message m) { case User32.WM.KILLFOCUS: base.WndProc(ref m); - IntPtr focussedWindow = (IntPtr)m.WParam; + IntPtr focussedWindow = m.WParam; if (!IsParentWindow(focussedWindow)) { owner.Commit(false, false); @@ -1704,7 +1704,7 @@ protected override bool ProcessDialogKey(Keys keyData) { if ((keyData & (Keys.Alt | Keys.Control)) == Keys.None) { - Keys keyCode = (Keys)keyData & Keys.KeyCode; + Keys keyCode = keyData & Keys.KeyCode; switch (keyCode) { case Keys.Tab: @@ -1971,7 +1971,6 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr } Rectangle bounds = new Rectangle(Point.Empty, splitButton.Size); - Pen selectborderPen = null; bool splitButtonSelected = false; if (splitButton.DropDownButtonPressed) { @@ -2009,6 +2008,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr splitButtonSelected = true; } + Pen selectborderPen; if (splitButtonSelected) { //DrawSeleted Boder @@ -2032,7 +2032,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { ToolStripItem item = e.Item as ToolStripLabel; - if (item != null && String.Equals(item.Name, CenterLabelName, StringComparison.InvariantCulture) && SystemInformation.HighContrast) + if (item != null && string.Equals(item.Name, CenterLabelName, StringComparison.InvariantCulture) && SystemInformation.HighContrast) { // "Type Here" node always has white background, text should be painted in black e.TextColor = Color.Black; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs new file mode 100644 index 00000000000..046393d6bb5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal class TreeViewActionList : DesignerActionList + { + private readonly TreeViewDesigner _designer; + public TreeViewActionList(TreeViewDesigner designer) : base(designer.Component) + { + _designer = designer; + } + + public void InvokeNodesDialog() + { + EditorServiceContext.EditValue(_designer, Component, "Nodes"); + } + + public ImageList ImageList + { + get + { + return ((TreeView)Component).ImageList; + } + set + { + TypeDescriptor.GetProperties(Component)["ImageList"].SetValue(Component, value); + } + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionMethodItem(this, "InvokeNodesDialog", SR.InvokeNodesDialogDisplayName, SR.PropertiesCategoryName, SR.InvokeNodesDialogDescription, true)); + items.Add(new DesignerActionPropertyItem("ImageList", SR.ImageListDisplayName, SR.PropertiesCategoryName, SR.ImageListDescription)); + return items; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs new file mode 100644 index 00000000000..cf007f67100 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs @@ -0,0 +1,97 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Diagnostics; +using static Interop; + +namespace System.Windows.Forms.Design +{ + /// + /// This is the designer for tree view controls. It inherits + /// from the base control designer and adds live hit testing + /// capabilites for the tree view control. + /// + internal class TreeViewDesigner : ControlDesigner + { + private ComCtl32.TVHITTESTINFO tvhit; + private DesignerActionListCollection _actionLists; + private TreeView treeView; + + public TreeViewDesigner() + { + AutoResizeHandles = true; + } + + /// + /// Disposes of this object. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (treeView != null) + { + treeView.AfterExpand -= new TreeViewEventHandler(TreeViewInvalidate); + treeView.AfterCollapse -= new TreeViewEventHandler(TreeViewInvalidate); + treeView = null; + } + } + + base.Dispose(disposing); + } + + /// + /// Allows your component to support a design time user interface. A TabStrip + /// control, for example, has a design time user interface that allows the user + /// to click the tabs to change tabs. To implement this, TabStrip returns + /// true whenever the given point is within its tabs. + /// + protected override bool GetHitTest(Point point) + { + point = Control.PointToClient(point); + tvhit.pt = point; + User32.SendMessageW(Control, (User32.WM)ComCtl32.TVM.HITTEST, IntPtr.Zero, ref tvhit); + if (tvhit.flags == ComCtl32.TVHT.ONITEMBUTTON) + return true; + return false; + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + treeView = component as TreeView; + Debug.Assert(treeView != null, "TreeView is null in TreeViewDesigner"); + if (treeView != null) + { + treeView.AfterExpand += new TreeViewEventHandler(TreeViewInvalidate); + treeView.AfterCollapse += new TreeViewEventHandler(TreeViewInvalidate); + } + } + + private void TreeViewInvalidate(object sender, TreeViewEventArgs e) + { + if (treeView != null) + { + treeView.Invalidate(); + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists == null) + { + _actionLists = new DesignerActionListCollection(); + _actionLists.Add(new TreeViewActionList(this)); + } + + return _actionLists; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs new file mode 100644 index 00000000000..81b68db3a1d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.Collections; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design +{ + /// + /// + /// Provides a designer that can design components + /// that extend UpDownBase. + /// + internal class UpDownBaseDesigner : ControlDesigner + { + public UpDownBaseDesigner() + { + AutoResizeHandles = true; + } + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable); + return rules; + } + } + + /// + /// Adds a baseline SnapLine to the list of SnapLines related to this control. + /// + public override IList SnapLines + { + get + { + ArrayList snapLines = base.SnapLines as ArrayList; + + int baseline = DesignerUtils.GetTextBaseline(Control, Drawing.ContentAlignment.TopLeft); + + BorderStyle borderStyle = BorderStyle.Fixed3D; + PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["BorderStyle"]; + if (prop != null) + { + borderStyle = (BorderStyle)prop.GetValue(Component); + } + + if (borderStyle == BorderStyle.None) + { + baseline -= 1; + } + else + { + baseline += 2; + } + + snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium)); + + return snapLines; + } + } + } +} + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs new file mode 100644 index 00000000000..666e0d761d3 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.Collections; +using System.ComponentModel.Design; +using System.Drawing; + +namespace System.Windows.Forms.Design +{ + /// + /// Provides a base implementation of a designer for user controls. + /// + [ToolboxItemFilter("System.Windows.Forms.UserControl", ToolboxItemFilterType.Custom)] + internal class UserControlDocumentDesigner : DocumentDesigner + { + public UserControlDocumentDesigner() + { + AutoResizeHandles = true; + } + + /// + /// On user controls, size == client size. We do this so we can mess around + /// with the non-client area of the user control when editing menus and not + /// mess up the size property. + /// + private Size Size + { + get + { + return Control.ClientSize; + } + set + { + Control.ClientSize = value; + } + } + + /// + /// Allows a designer to filter the set of properties + /// the component it is designing will expose through the + /// TypeDescriptor object. This method is called + /// immediately before its corresponding "Post" method. + /// If you are overriding this method you should call + /// the base implementation before you perform your own + /// filtering. + /// + protected override void PreFilterProperties(IDictionary properties) + { + PropertyDescriptor prop; + + base.PreFilterProperties(properties); + + // Handle shadowed properties + // + string[] shadowProps = new string[] + { + "Size" + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + prop = (PropertyDescriptor)properties[shadowProps[i]]; + if (prop != null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(UserControlDocumentDesigner), prop, empty); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs new file mode 100644 index 00000000000..dd9534976be --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Linq; +using Xunit; + +namespace System.Windows.Forms.Design.Editors.Tests +{ + public class EnsureDesignerTests : IClassFixture + { + [WinFormsFact] + public void Ensure_designer_type_forwarded() + { + SystemDesignMetadataReader metadataReader = new(); + IReadOnlyList forwardedTypes = metadataReader.GetExportedTypeNames(); + + IEnumerable designers = typeof(ComponentDesigner).Assembly + .GetTypes() + .Where(t => t.IsSubclassOf(typeof(ComponentDesigner)) + && !t.IsPublic); + foreach (Type designer in designers) + { + Assert.True(forwardedTypes.Contains(designer.FullName), $"{designer.FullName} must be type forwarded"); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs index 42560758e98..1bbe868cb94 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs @@ -18,6 +18,29 @@ namespace System.Windows.Forms.Design.Editors.Tests { public class EnsureEditorsTests : IClassFixture { + [WinFormsFact] + public void Ensure_editors_type_forwarded() + { + // The list of editors which either didn't exist in .NET Framework + Type[] nonTypeForwardedEditors = + { + typeof(InitialDirectoryEditor), // introduced in .NET 6.0, https://github.com/dotnet/winforms/pull/4645 + }; + + SystemDesignMetadataReader metadataReader = new(); + IReadOnlyList forwardedTypes = metadataReader.GetExportedTypeNames(); + + IEnumerable editors = typeof(ComponentDesigner).Assembly + .GetTypes() + .Where(t => t.IsSubclassOf(typeof(UITypeEditor)) + && !t.IsPublic + && !nonTypeForwardedEditors.Contains(t)); + foreach (Type editor in editors) + { + Assert.True(forwardedTypes.Contains(editor.FullName), $"{editor.FullName} must be type forwarded"); + } + } + [WinFormsTheory] // In Table [InlineData(typeof(Array), typeof(ArrayEditor))] diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTest.cs b/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTest.cs deleted file mode 100644 index f89a6f1c38a..00000000000 --- a/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTest.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.ComponentModel.Design; -using Xunit; - -namespace System.Windows.Forms.Design.Editors.Tests.Serialization -{ - public class SerializableAttributeTests : IClassFixture - { - [Fact] - public void EnsureSerializableAttribute() - { - BinarySerialization.EnsureSerializableAttribute( - typeof(ArrayEditor).Assembly, - new HashSet - { - // This Assembly does not have any serializable types. - }); - } - } -} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs index 9071b95695c..8ad632accf3 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs @@ -16,6 +16,7 @@ public void EnsureSerializableAttribute() typeof(Behavior.Behavior).Assembly, new HashSet { + typeof(OleDragDropHandler.CfCodeToolboxItem).FullName, { "System.Windows.Forms.Design.Behavior.DesignerActionKeyboardBehavior+<>c"} }); } diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj b/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj index 103ab50d46d..0e7e3b462e2 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj @@ -21,6 +21,11 @@ + + + + + PreserveNewest diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs b/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs new file mode 100644 index 00000000000..9347fd0e43a --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using Xunit; + +namespace System.Windows.Forms.Design.Editors.Tests +{ + internal sealed class SystemDesignMetadataReader + { + public IReadOnlyList GetExportedTypeNames() + { + // Force load System.Design into the appdomain + DesignSurface designSurface = new (); + IDesigner designer = designSurface.CreateDesigner(new Control(), true); + Assert.NotNull(designer); + + Assembly systemDesign = AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "System.Design"); + + using var fs = new FileStream(systemDesign.Location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using var peReader = new PEReader(fs); + + MetadataReader metadataReader = peReader.GetMetadataReader(); + List typeNames = new(); + + foreach (ExportedTypeHandle typeHandle in metadataReader.ExportedTypes) + { + ExportedType type = metadataReader.GetExportedType(typeHandle); + + string ns = metadataReader.GetString(type.Namespace); + string name = metadataReader.GetString(type.Name); + + typeNames.Add($"{ns}.{name}"); + } + + return typeNames; + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs new file mode 100644 index 00000000000..62279d1f4a1 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + [StructLayout(LayoutKind.Sequential)] + public unsafe struct HDHITTESTINFO + { + public Point pt; + public HHT flags; + public int iItem; + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HHT.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HHT.cs new file mode 100644 index 00000000000..3b66949828e --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HHT.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + public enum HHT : uint + { + NOWHERE = 0x0001, + ONHEADER = 0x0002, + ONDIVIDER = 0x0004, + ONDIVOPEN = 0x0008, + ONFILTER = 0x0010, + ONFILTERBUTTON = 0x0020, + ABOVE = 0x0100, + BELOW = 0x0200, + TORIGHT = 0x0400, + TOLEFT = 0x0800, + ONITEMSTATEICON = 0x1000, + ONDROPDOWN = 0x2000, + ONOVERFLOW = 0x4000, + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.LoadRegTypeLib.cs b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.LoadRegTypeLib.cs new file mode 100644 index 00000000000..003745e1933 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.LoadRegTypeLib.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; +using System.Runtime.Versioning; + +internal partial class Interop +{ + internal static partial class Oleaut32 + { + [DllImport(Libraries.Oleaut32, ExactSpelling = true, PreserveSig = false)] + [ResourceExposure(ResourceScope.Machine)] + public static extern ITypeLib LoadRegTypeLib(ref Guid clsid, short majorVersion, short minorVersion, int lcid); + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.LoadTypeLib.cs b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.LoadTypeLib.cs new file mode 100644 index 00000000000..5f60a5afca2 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.LoadTypeLib.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; +using System.Runtime.Versioning; + +internal partial class Interop +{ + internal static partial class Oleaut32 + { + [DllImport(Libraries.Oleaut32, ExactSpelling = true, PreserveSig = false)] + [ResourceExposure(ResourceScope.Machine)] + public extern static ITypeLib LoadTypeLib([In, MarshalAs(UnmanagedType.LPWStr)] string typelib); + } +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButton.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButton.cs new file mode 100644 index 00000000000..b6e3515dfc1 --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButton.cs @@ -0,0 +1,10 @@ +using System.Windows.Forms; +using System.ComponentModel; + +namespace TestConsole +{ + [Designer(typeof(CustomButtonDesigner), typeof(System.ComponentModel.Design.IDesigner))] + public class CustomButton : Button + { + } +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButtonDesigner.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButtonDesigner.cs new file mode 100644 index 00000000000..3402d3a94a4 --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButtonDesigner.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.Design; +using System.Windows.Forms.Design; + +namespace TestConsole +{ + public class CustomButtonDesigner : ControlDesigner + { + private DesignerActionListCollection _actionLists; + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists is null) + { + _actionLists = new DesignerActionListCollection + { + new CustomButtonDesignerActionList(Component) + }; + } + + return _actionLists; + } + } + } +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButtonDesignerActionList.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButtonDesignerActionList.cs new file mode 100644 index 00000000000..97c51187c77 --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/CustomButtonDesignerActionList.cs @@ -0,0 +1,102 @@ +using System.ComponentModel; +using System; +using System.ComponentModel.Design; +using System.Windows.Forms; +using System.Drawing; + +namespace TestConsole +{ + public class CustomButtonDesignerActionList : DesignerActionList + { + private readonly IDesignerHost _host; + private readonly CustomButton _control; + private DesignerActionItemCollection _actonListItems; + + public CustomButtonDesignerActionList(IComponent component) + : base(component) + { + _control = component as CustomButton; + _host = GetService(typeof(IDesignerHost)) as IDesignerHost; + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + _actonListItems = new DesignerActionItemCollection(); + _actonListItems.Add(new DesignerActionHeaderItem("Change color")); + _actonListItems.Add(new DesignerActionVerbItem(new DesignerVerb(GetActionName(), OnColorActionClick))); + + return _actonListItems; + } + + public string Name + { + get + { + string name = string.Empty; + if (_control != null) + { + CustomButton control = _control; + name = control.Name; + } + + return name; + } + set + { + SetValue(nameof(Name), value); + } + } + + private string GetActionName() + { + PropertyDescriptor dockProp = TypeDescriptor.GetProperties(Component)[nameof(CustomButton.BackColor)]; + if (dockProp != null) + { + Color backColor = (Color)dockProp.GetValue(Component); + if (backColor != Color.Yellow) + { + return "Make Yellow"; + } + else + { + return "Turn Blue"; + } + } + + return null; + } + + private void OnColorActionClick(object sender, EventArgs e) + { + if (_host is null || sender is not DesignerVerb designerVerb) + { + return; + } + + using DesignerTransaction t = _host.CreateTransaction(designerVerb.Text); + + Color backColor = _control.BackColor; + _control.BackColor = backColor != Color.Yellow ? Color.Yellow : Color.Blue; + + t.Commit(); + } + + protected void SetValue(string propertyName, object value) + { + GetProperty(propertyName).SetValue(_control, value); + } + + protected PropertyDescriptor GetProperty(string propertyName) + { + PropertyDescriptor pd = TypeDescriptor.GetProperties(_control)[propertyName]; + if (pd is null) + { + throw new ArgumentException("Property " + propertyName + " not found in " + typeof(CustomButton).Name); + } + else + { + return pd; + } + } + } +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/DesignerActionVerbItem.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/DesignerActionVerbItem.cs new file mode 100644 index 00000000000..fdf70e6b46a --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/CustomControls/DesignerActionVerbItem.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.Design; +using System.Diagnostics; + +namespace TestConsole +{ + internal class DesignerActionVerbItem : DesignerActionMethodItem + { + private readonly DesignerVerb _targetVerb; + + public DesignerActionVerbItem(DesignerVerb verb) : base(null, null, null) + { + Debug.Assert(verb != null, "All callers check whether the verb is null."); + _targetVerb = verb; + } + + public override string Category => "Verbs"; + + public override string DisplayName => _targetVerb.Text; + + public override void Invoke() => _targetVerb.Invoke(); + } +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj new file mode 100644 index 00000000000..f2aba3402dd --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj @@ -0,0 +1,40 @@ + + + + DesignSurface + TestConsole + painter.ico + WinExe + + false + false + + $(NoWarn),SA1633,CS8002 + Copyright © Paolo Foti 2008 + + Paolo Foti + CPOL + https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful + + true + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs new file mode 100644 index 00000000000..dbfe8cc18d6 --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs @@ -0,0 +1,310 @@ +namespace TestConsole +{ +partial class MainForm { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose ( bool disposing ) { + if ( disposing && ( components != null ) ) { + components.Dispose(); + } + base.Dispose ( disposing ); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager( typeof( MainForm ) ); + this.splitContainer = new System.Windows.Forms.SplitContainer(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.propertyGrid = new System.Windows.Forms.PropertyGrid(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ToolStripMenuItemUnDo = new System.Windows.Forms.ToolStripMenuItem(); + this.ToolStripMenuItemReDo = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.ToolStripMenuItemCut = new System.Windows.Forms.ToolStripMenuItem(); + this.ToolStripMenuItemCopy = new System.Windows.Forms.ToolStripMenuItem(); + this.ToolStripMenuItemPaste = new System.Windows.Forms.ToolStripMenuItem(); + this.ToolStripMenuItemDelete = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemTools = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemTabOrder = new System.Windows.Forms.ToolStripMenuItem(); + this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ToolStripMenuItemAbout = new System.Windows.Forms.ToolStripMenuItem(); + this.splitContainer.Panel1.SuspendLayout(); + this.splitContainer.Panel2.SuspendLayout(); + this.splitContainer.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer + // + this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer.Location = new System.Drawing.Point( 0, 28 ); + this.splitContainer.Margin = new System.Windows.Forms.Padding( 4 ); + this.splitContainer.Name = "splitContainer"; + // + // splitContainer.Panel1 + // + this.splitContainer.Panel1.BackColor = System.Drawing.SystemColors.Window; + this.splitContainer.Panel1.Controls.Add( this.tabControl1 ); + // + // splitContainer.Panel2 + // + this.splitContainer.Panel2.Controls.Add( this.propertyGrid ); + this.splitContainer.Size = new System.Drawing.Size( 824, 502 ); + this.splitContainer.SplitterDistance = 593; + this.splitContainer.SplitterWidth = 5; + this.splitContainer.TabIndex = 0; + // + // tabControl1 + // + this.tabControl1.Controls.Add( this.tabPage1 ); + this.tabControl1.Controls.Add( this.tabPage2 ); + this.tabControl1.Controls.Add( this.tabPage3 ); + this.tabControl1.Controls.Add( this.tabPage4 ); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point( 0, 0 ); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size( 593, 502 ); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.Location = new System.Drawing.Point( 4, 25 ); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding( 3 ); + this.tabPage1.Size = new System.Drawing.Size( 585, 473 ); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "tabPage1"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // tabPage2 + // + this.tabPage2.Location = new System.Drawing.Point( 4, 25 ); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding( 3 ); + this.tabPage2.Size = new System.Drawing.Size( 585, 473 ); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "tabPage2"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // tabPage3 + // + this.tabPage3.Location = new System.Drawing.Point( 4, 25 ); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Padding = new System.Windows.Forms.Padding( 3 ); + this.tabPage3.Size = new System.Drawing.Size( 585, 473 ); + this.tabPage3.TabIndex = 2; + this.tabPage3.Text = "tabPage3"; + this.tabPage3.UseVisualStyleBackColor = true; + // + // tabPage4 + // + this.tabPage4.Location = new System.Drawing.Point( 4, 25 ); + this.tabPage4.Name = "tabPage4"; + this.tabPage4.Padding = new System.Windows.Forms.Padding( 3 ); + this.tabPage4.Size = new System.Drawing.Size( 585, 473 ); + this.tabPage4.TabIndex = 3; + this.tabPage4.Text = "tabPage4"; + this.tabPage4.UseVisualStyleBackColor = true; + // + // propertyGrid + // + this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid.Location = new System.Drawing.Point( 0, 0 ); + this.propertyGrid.Margin = new System.Windows.Forms.Padding( 4 ); + this.propertyGrid.Name = "propertyGrid"; + this.propertyGrid.Size = new System.Drawing.Size( 226, 502 ); + this.propertyGrid.TabIndex = 0; + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange( new System.Windows.Forms.ToolStripItem[] { + this.editToolStripMenuItem, + this.toolStripMenuItemTools, + this.helpToolStripMenuItem} ); + this.menuStrip1.Location = new System.Drawing.Point( 0, 0 ); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding( 8, 2, 0, 2 ); + this.menuStrip1.Size = new System.Drawing.Size( 824, 28 ); + this.menuStrip1.TabIndex = 1; + this.menuStrip1.Text = "menuStrip1"; + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.DropDownItems.AddRange( new System.Windows.Forms.ToolStripItem[] { + this.ToolStripMenuItemUnDo, + this.ToolStripMenuItemReDo, + this.toolStripSeparator3, + this.ToolStripMenuItemCut, + this.ToolStripMenuItemCopy, + this.ToolStripMenuItemPaste, + this.ToolStripMenuItemDelete, + this.toolStripSeparator4} ); + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size( 47, 24 ); + this.editToolStripMenuItem.Text = "&Edit"; + // + // ToolStripMenuItemUnDo + // + this.ToolStripMenuItemUnDo.Name = "ToolStripMenuItemUnDo"; + this.ToolStripMenuItemUnDo.ShortcutKeys = ((System.Windows.Forms.Keys) ((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); + this.ToolStripMenuItemUnDo.Size = new System.Drawing.Size( 165, 24 ); + this.ToolStripMenuItemUnDo.Text = "Undo"; + this.ToolStripMenuItemUnDo.Click += new System.EventHandler( this.undoToolStripMenuItem_Click ); + // + // ToolStripMenuItemReDo + // + this.ToolStripMenuItemReDo.Name = "ToolStripMenuItemReDo"; + this.ToolStripMenuItemReDo.ShortcutKeys = ((System.Windows.Forms.Keys) ((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); + this.ToolStripMenuItemReDo.Size = new System.Drawing.Size( 165, 24 ); + this.ToolStripMenuItemReDo.Text = "Redo"; + this.ToolStripMenuItemReDo.Click += new System.EventHandler( this.redoToolStripMenuItem_Click ); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size( 162, 6 ); + // + // ToolStripMenuItemCut + // + this.ToolStripMenuItemCut.Image = ((System.Drawing.Image) (resources.GetObject( "ToolStripMenuItemCut.Image" ))); + this.ToolStripMenuItemCut.ImageTransparentColor = System.Drawing.Color.Magenta; + this.ToolStripMenuItemCut.Name = "ToolStripMenuItemCut"; + this.ToolStripMenuItemCut.ShortcutKeys = ((System.Windows.Forms.Keys) ((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); + this.ToolStripMenuItemCut.Size = new System.Drawing.Size( 165, 24 ); + this.ToolStripMenuItemCut.Text = "Cut"; + this.ToolStripMenuItemCut.Click += new System.EventHandler( this.OnMenuClick ); + // + // ToolStripMenuItemCopy + // + this.ToolStripMenuItemCopy.Image = ((System.Drawing.Image) (resources.GetObject( "ToolStripMenuItemCopy.Image" ))); + this.ToolStripMenuItemCopy.ImageTransparentColor = System.Drawing.Color.Magenta; + this.ToolStripMenuItemCopy.Name = "ToolStripMenuItemCopy"; + this.ToolStripMenuItemCopy.ShortcutKeys = ((System.Windows.Forms.Keys) ((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); + this.ToolStripMenuItemCopy.Size = new System.Drawing.Size( 165, 24 ); + this.ToolStripMenuItemCopy.Text = "Copy"; + this.ToolStripMenuItemCopy.Click += new System.EventHandler( this.OnMenuClick ); + // + // ToolStripMenuItemPaste + // + this.ToolStripMenuItemPaste.Image = ((System.Drawing.Image) (resources.GetObject( "ToolStripMenuItemPaste.Image" ))); + this.ToolStripMenuItemPaste.ImageTransparentColor = System.Drawing.Color.Magenta; + this.ToolStripMenuItemPaste.Name = "ToolStripMenuItemPaste"; + this.ToolStripMenuItemPaste.ShortcutKeys = ((System.Windows.Forms.Keys) ((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); + this.ToolStripMenuItemPaste.Size = new System.Drawing.Size( 165, 24 ); + this.ToolStripMenuItemPaste.Text = "Paste"; + this.ToolStripMenuItemPaste.Click += new System.EventHandler( this.OnMenuClick ); + // + // ToolStripMenuItemDelete + // + this.ToolStripMenuItemDelete.Name = "ToolStripMenuItemDelete"; + this.ToolStripMenuItemDelete.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.ToolStripMenuItemDelete.Size = new System.Drawing.Size( 165, 24 ); + this.ToolStripMenuItemDelete.Text = "Delete"; + this.ToolStripMenuItemDelete.Click += new System.EventHandler( this.OnMenuClick ); + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size( 162, 6 ); + // + // toolStripMenuItemTools + // + this.toolStripMenuItemTools.DropDownItems.AddRange( new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemTabOrder} ); + this.toolStripMenuItemTools.Name = "toolStripMenuItemTools"; + this.toolStripMenuItemTools.Size = new System.Drawing.Size( 57, 24 ); + this.toolStripMenuItemTools.Text = "&Tools"; + // + // toolStripMenuItemTabOrder + // + this.toolStripMenuItemTabOrder.Name = "toolStripMenuItemTabOrder"; + this.toolStripMenuItemTabOrder.Size = new System.Drawing.Size( 145, 24 ); + this.toolStripMenuItemTabOrder.Text = "Tab Order"; + this.toolStripMenuItemTabOrder.Click += new System.EventHandler( this.toolStripMenuItemTabOrder_Click ); + // + // helpToolStripMenuItem + // + this.helpToolStripMenuItem.DropDownItems.AddRange( new System.Windows.Forms.ToolStripItem[] { + this.ToolStripMenuItemAbout} ); + this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; + this.helpToolStripMenuItem.Size = new System.Drawing.Size( 53, 24 ); + this.helpToolStripMenuItem.Text = "&Help"; + // + // ToolStripMenuItemAbout + // + this.ToolStripMenuItemAbout.Name = "ToolStripMenuItemAbout"; + this.ToolStripMenuItemAbout.Size = new System.Drawing.Size( 128, 24 ); + this.ToolStripMenuItemAbout.Text = "About..."; + this.ToolStripMenuItemAbout.Click += new System.EventHandler( this.OnAbout ); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF( 8F, 16F ); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size( 824, 530 ); + this.Controls.Add( this.splitContainer ); + this.Controls.Add( this.menuStrip1 ); + this.Icon = ((System.Drawing.Icon) (resources.GetObject( "$this.Icon" ))); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding( 4 ); + this.Name = "MainForm"; + this.Text = "Tiny Form Designer"; + this.Load += new System.EventHandler( this.MainForm_Load ); + this.splitContainer.Panel1.ResumeLayout( false ); + this.splitContainer.Panel2.ResumeLayout( false ); + this.splitContainer.ResumeLayout( false ); + this.tabControl1.ResumeLayout( false ); + this.menuStrip1.ResumeLayout( false ); + this.menuStrip1.PerformLayout(); + this.ResumeLayout( false ); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer; + private System.Windows.Forms.PropertyGrid propertyGrid; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemUnDo; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemReDo; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemCut; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemCopy; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemPaste; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemDelete; + private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemAbout; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.TabPage tabPage4; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTools; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTabOrder; + +} +} + diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs new file mode 100644 index 00000000000..aa788970576 --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs @@ -0,0 +1,308 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using System.ComponentModel.Design; + +using DesignSurfaceExt; + +namespace TestConsole +{ + public partial class MainForm : Form + { + ISelectionService _selectionService; + + private List _listOfDesignSurface = new List(); + + public MainForm() + { + InitializeComponent(); + } + + private void InitFormDesigner() + { + CreateDesignSurface(1); + CreateDesignSurface(2); + CreateDesignSurface(3); + CreateDesignSurface(4); + + tabPage1.Text = "Use SnapLines"; + tabPage2.Text = "Use Grid (Snap to the grid)"; + tabPage3.Text = "Use Grid"; + tabPage4.Text = "Align control by hand"; + + //- enable the UndoEngines + for (int i = 0; i < tabControl1.TabCount; i++) + { + IDesignSurfaceExt isurf = _listOfDesignSurface[i]; + isurf.GetUndoEngineExt().Enabled = true; + } + + //- ISelectionService + //- try to get a ptr to ISelectionService interface + //- if we obtain it then hook the SelectionChanged event + for (int i = 0; i < tabControl1.TabCount; i++) + { + IDesignSurfaceExt isurf = _listOfDesignSurface[i]; + _selectionService = (ISelectionService)(isurf.GetIDesignerHost().GetService(typeof(ISelectionService))); + if (null != _selectionService) + _selectionService.SelectionChanged += new System.EventHandler(OnSelectionChanged); + } + } + + //- When the selection changes this sets the PropertyGrid's selected component + private void OnSelectionChanged(object sender, System.EventArgs e) + { + if (_selectionService == null) + return; + + IDesignSurfaceExt isurf = _listOfDesignSurface[tabControl1.SelectedIndex]; + if (null != isurf) + { + ISelectionService selectionService = isurf.GetIDesignerHost().GetService(typeof(ISelectionService)) as ISelectionService; + propertyGrid.SelectedObject = selectionService.PrimarySelection; + } + } + + private void CreateDesignSurface(int n) + { + //- step.0 + //- create a DesignSurface and put it inside a Form in DesignTime + DesignSurfaceExt.DesignSurfaceExt surface = new DesignSurfaceExt.DesignSurfaceExt(); + //- + //- + //- store for later use + _listOfDesignSurface.Add(surface); + //- + //- + //- step.1 + //- choose an alignment mode... + switch (n) + { + case 1: + surface.UseSnapLines(); + break; + case 2: + surface.UseGrid(new System.Drawing.Size(16, 16)); + break; + case 3: + surface.UseGridWithoutSnapping(new System.Drawing.Size(32, 32)); + break; + case 4: + surface.UseNoGuides(); + break; + default: + Console.WriteLine("Invalid selection"); + break; + } + + //- + //- + //- step.2 + //- create the Root compoment, in these cases a Form + try + { + Form rootComponent = null; + switch (n) + { + case 1: + { + rootComponent = surface.CreateRootComponent
(new Size(400, 400)); + rootComponent.BackColor = Color.Gray; + rootComponent.Text = "Root Component hosted by the DesignSurface N.1"; + //- step.3 + //- create some Controls at DesignTime + TextBox t1 = surface.CreateControl(new Size(200, 23), new Point(172, 12)); + Button b1 = surface.CreateControl