-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added all the necessary classes for toolbar design-time functionality.
- Loading branch information
1 parent
b633aca
commit c248e5e
Showing
16 changed files
with
701 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/BetterControls.Design.Client/BetterControls.Design.Client.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<LangVersion>9.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.WinForms.Designer.SDK" Version="1.1.0-prerelease-preview3.22076.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BetterControls.Design.ClientServerProtocol\BetterControls.Design.ClientServerProtocol.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
</Project> |
45 changes: 45 additions & 0 deletions
45
src/BetterControls.Design.Client/BetterToolbarTypeRoutingProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using BetterControls.Design.Protocol; | ||
using Microsoft.DotNet.DesignTools.Client.TypeRouting; | ||
using System.Collections.Generic; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Represents the toolbar type routing provider. | ||
/// </summary> | ||
[ExportTypeRoutingDefinitionProvider] | ||
internal class BetterToolbarTypeRoutingProvider : TypeRoutingDefinitionProvider | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterToolbarTypeRoutingProvider"/>. | ||
/// </summary> | ||
public BetterToolbarTypeRoutingProvider() { } | ||
|
||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
/// <returns><inheritdoc/></returns> | ||
public override IEnumerable<TypeRoutingDefinition> GetDefinitions() | ||
{ | ||
return new[] | ||
{ | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Editor, | ||
nameof(EditorNames.BetterToolbarItemCollectionEditor), | ||
typeof(BetterToolbarItemCollectionEditor)), | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Editor, | ||
nameof(EditorNames.BetterMenuBarItemCollectionEditor), | ||
typeof(BetterMenuBarItemCollectionEditor)), | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Editor, | ||
nameof(EditorNames.BetterMenuItemCollectionEditor), | ||
typeof(BetterMenuItemCollectionEditor)), | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Editor, | ||
nameof(EditorNames.ImageIndexEditor), | ||
typeof(ImageIndexEditor)), | ||
}; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/BetterControls.Design.Client/Editors/BetterCollectionEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.DotNet.DesignTools.Client.Editors; | ||
using System; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Extend this class to create a collection editor. | ||
/// </summary> | ||
public abstract class BetterCollectionEditor : CollectionEditor | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterCollectionEditor"/>. | ||
/// </summary> | ||
/// <param name="collectionType">The type that this collection editor is associated with.</param> | ||
public BetterCollectionEditor(Type collectionType) | ||
: base(collectionType) | ||
{ } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...terControls.Design.ClientServerProtocol/BetterControls.Design.ClientServerProtocol.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0-windows;net472</TargetFrameworks> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>9.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.WinForms.Designer.SDK" Version="1.1.0-prerelease-preview3.22076.5" /> | ||
</ItemGroup> | ||
</Project> |
9 changes: 9 additions & 0 deletions
9
src/BetterControls.Design.ClientServerProtocol/CollectionEditorNames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace WinForms.Tiles.ClientServerProtocol | ||
{ | ||
public static class CollectionEditorNames | ||
{ | ||
public const string BetterToolbarItemCollectionEditor = nameof(BetterToolbarItemCollectionEditor); | ||
public const string BetterMenuBarItemCollectionEditor = nameof(BetterMenuBarItemCollectionEditor); | ||
public const string BetterMenuItemCollectionEditor = nameof(BetterMenuItemCollectionEditor); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/BetterControls.Design.ClientServerProtocol/EditorNames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace BetterControls.Design.Protocol | ||
{ | ||
public static class EditorNames | ||
{ | ||
public const string BetterToolbarItemCollectionEditor = nameof(BetterToolbarItemCollectionEditor); | ||
public const string BetterMenuBarItemCollectionEditor = nameof(BetterMenuBarItemCollectionEditor); | ||
public const string BetterMenuItemCollectionEditor = nameof(BetterMenuItemCollectionEditor); | ||
public const string ImageIndexEditor = nameof(ImageIndexEditor); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/BetterControls.Design.Server/BetterControls.Design.Server.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.WinForms.Designer.SDK" Version="1.1.0-prerelease-preview3.22076.5" /> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BetterControls.Design.ClientServerProtocol\BetterControls.Design.ClientServerProtocol.csproj" /> | ||
<ProjectReference Include="..\BetterControls\BetterControls.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
42 changes: 42 additions & 0 deletions
42
src/BetterControls.Design.Server/BetterToolbarTypeRoutingProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.DotNet.DesignTools.TypeRouting; | ||
using System.Collections.Generic; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Represents the toolbar type routing provider. | ||
/// </summary> | ||
[ExportTypeRoutingDefinitionProvider] | ||
internal class BetterToolbarTypeRoutingProvider : TypeRoutingDefinitionProvider | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterToolbarTypeRoutingProvider"/>. | ||
/// </summary> | ||
public BetterToolbarTypeRoutingProvider() { } | ||
|
||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
/// <returns><inheritdoc/></returns> | ||
public override IEnumerable<TypeRoutingDefinition> GetDefinitions() | ||
=> new[] | ||
{ | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Designer, | ||
nameof(BetterToolbarDesigner), | ||
typeof(BetterToolbarDesigner)), | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Designer, | ||
nameof(BetterToolbarItemDesigner), | ||
typeof(BetterToolbarItemDesigner)), | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Designer, | ||
nameof(BetterToolbarButtonDesigner), | ||
typeof(BetterToolbarButtonDesigner)), | ||
new TypeRoutingDefinition( | ||
TypeRoutingKinds.Designer, | ||
nameof(BetterMenuBarDesigner), | ||
typeof(BetterMenuBarDesigner)) | ||
}; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/BetterControls.Design.Server/Designers/BetterComponentDesigner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.DotNet.DesignTools.Designers; | ||
using System.ComponentModel.Design; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Extend this class to create a component designer. | ||
/// </summary> | ||
public abstract class BetterComponentDesigner : ComponentDesigner | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterComponentDesigner"/>. | ||
/// </summary> | ||
public BetterComponentDesigner() { } | ||
|
||
#region Private Member Fields | ||
|
||
private IDesignerHost _designerHost; | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Gets the designer host associated with this component. | ||
/// </summary> | ||
protected IDesignerHost DesignerHost | ||
{ | ||
get | ||
{ | ||
if (_designerHost is null) | ||
_designerHost = GetService<IDesignerHost>(); | ||
|
||
return _designerHost; | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/BetterControls.Design.Server/Designers/BetterControlActionList.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.DotNet.DesignTools.Designers; | ||
using Microsoft.DotNet.DesignTools.Designers.Actions; | ||
using System; | ||
using System.ComponentModel.Design; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Extend from this class to indicate that the implementing class is an action list. | ||
/// </summary> | ||
internal class BetterControlActionList : DesignerActionList | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterControlActionList"/>. | ||
/// </summary> | ||
/// <param name="designer">The designer that is associated with this action list.</param> | ||
internal BetterControlActionList(Microsoft.DotNet.DesignTools.Designers.ControlDesigner designer) | ||
: base(designer.Component) | ||
{ | ||
Designer = designer ?? throw new ArgumentNullException(nameof(designer)); | ||
} | ||
|
||
#region Private Member Fields | ||
|
||
private IDesignerHost _designerHost; | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Gets the designer that is associated with this action list. | ||
/// </summary> | ||
protected Microsoft.DotNet.DesignTools.Designers.ControlDesigner Designer { get; } | ||
|
||
/// <summary> | ||
/// Gets the designer host associated with this component. | ||
/// </summary> | ||
protected IDesignerHost DesignerHost | ||
{ | ||
get | ||
{ | ||
if(_designerHost is null) | ||
_designerHost = GetService<IDesignerHost>(); | ||
|
||
return _designerHost; | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/BetterControls.Design.Server/Designers/BetterControlDesigner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.DotNet.DesignTools.Designers; | ||
using System.ComponentModel.Design; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Extend this class to create a control designer. | ||
/// </summary> | ||
public abstract class BetterControlDesigner : ControlDesigner | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterControlDesigner"/>. | ||
/// </summary> | ||
public BetterControlDesigner() { } | ||
|
||
#region Private Member Fields | ||
|
||
private IDesignerHost _designerHost; | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Gets the designer host associated with this component. | ||
/// </summary> | ||
protected IDesignerHost DesignerHost | ||
{ | ||
get | ||
{ | ||
if (_designerHost is null) | ||
_designerHost = GetService<IDesignerHost>(); | ||
|
||
return _designerHost; | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/BetterControls.Design.Server/Designers/BetterToolbarButtonDesigner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections; | ||
using System.ComponentModel; | ||
|
||
namespace BetterControls.Design | ||
{ | ||
/// <summary> | ||
/// Designer for <see cref="BetterToolbarButton"/>. | ||
/// </summary> | ||
internal class BetterToolbarButtonDesigner : BetterToolbarItemDesigner | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterToolbarButtonDesigner"/>. | ||
/// </summary> | ||
public BetterToolbarButtonDesigner() { } | ||
|
||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
/// <param name="defaultValues"><inheritdoc/></param> | ||
public override void InitializeNewComponent(IDictionary defaultValues) | ||
{ | ||
base.InitializeNewComponent(defaultValues); | ||
|
||
PropertyDescriptor nameProperty = TypeDescriptor.GetProperties(Component)["Name"]; | ||
if (nameProperty != null && nameProperty.PropertyType == typeof(string)) | ||
{ | ||
string itemText = (string)nameProperty.GetValue(Component); | ||
|
||
PropertyDescriptor textProperty = TypeDescriptor.GetProperties(Component)["Text"]; | ||
if (textProperty != null) | ||
{ | ||
textProperty.SetValue(Component, itemText); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.