WinForms Designer

From Mono


Table of contents

Installation

The WinForms Designer requires Mono SVN Head.

svn co svn://anonsvn.mono-project.com/source/trunk/mwf-designer
make; make run

Bugs, Patches, Questions

Bugs can be filed on the Mono bug tracker and should be assigned to me (Ivan N. Zlatev) - contact AT i-nz.net.. For more information on how to file bugs take a look at the Bugs wiki page.

Patches can be send to the mono-devel-list or mono-winforms-list Mailing Lists. That's also the place to ask questions.

Debugging on Windows

For the purpose of debugging the Design-Time code on MSNET/Windows I maintain a Mono.Design assembly that contains all of the necessary design-time code to build mwf-designer. This allows me to quickly debug issues with the CLR Debugger. It should be noted that compiling the mwf designer with Mono.Design won't make it work on Mono <= 1.2.5 as it misses fixes and updates to several classes in the class library.

svn co svn://anonsvn.mono-project.com/source/trunk/mwf-designer
svn co http://svn.i-nz.net/monodt/trunk/Mono.Design
cd Mono.Design; make; cd ..
cd mwf-designer; make mono-design; make mono-design-run

Screenshots

Enlarge
Enlarge

Roadmap

The roadmap consists of TODO packs to be completed in a chronological order. It also includes a list of Designers, Serializers and PropertyGrid editors which have to be implemented in order for the designer to function properly.

TODO Packs

New, Close

  • Implement New ->*
  • Implement Close Document
  • Doesn't support multi-component selection, because it only handles the ISelectionService.PrimarySelection and not the GetSelectedComponents.

Error Reporting

  • Designer
    • Implement an IUIService. An easy to access place in the frontend where errors/warning will be shown, but also debug and trace information from the Design-Time code in debug mode.
  • Serialization
    • Make use of the IUIService.
    • Uncomment the try-catches in DesignerSerializationManager.
    • Refactor current CWLs in the serializers to something actually useful to print more detailed information on the currently (de)serialized expression.
    • May be create some sort of a TraceContext?

Undo/Redo (Cut, Copy, Paste)

  • Serialization
    • Implement: UndoEngine, ComponentSerializationService, CodeDomComponentSerializationService, CodeDomDesignerLoader.IDesignerSerializationService
  • Surface
    • Implement MenuCommandService : IMenuCommandService
    • MenuCommand - update to 2.0 and review current code.
    • Transactions must be created for:
      • creating components
      • destroying components
      • moving controls


Quick Fixes Fun Pack

  • Serializers
    • ControlCodeDomSerializer - Resume/SuspendLayout.
    • ContainerCodeDomSerializer - to serialize the container for the components and its disposing.
  • MWF Designers
    • DocumentDesigner has "is Form" code (sets TopLevel to false) which should go in a FormDocumentDesigner.
  • Surface
    • IDesignerHost.Activate is invoked after the root component is added to the host. This is just my guess. It has to be further investigated when, where and by what should that be invoked.
    • DesignerHost.Deactivated is never fired.
    • Currently there is a fallback DesignerHost.CreateDesigner because many designers are missing.
  • Designers
    • Check ControlDesigner.OnContextMenu and related.

Resources (De)Serialization

Everything that has Localizable (true) attribute gets serialized to a resource.

VS.Net creates a global Properties.resx for the project, where it stores the resources and also Properties.Designer.cs, where it generates properties with the name of the resource. On this basis it just serializes property references when it comes to resource serialization. Properties.* probably get's compiled and loaded from a temporary assembly before the deserialization process is invoked.

PropertyGrid

  • Current designer's custom PropertyGrid.cs code is ugly and needs a clean rewrite.
  • Events Editing (MWF)
    • Implement EventsTab.
    • Add EventsTab support in the PropertyGrid control.

New selection/DnD/resize service

  • Implement the System.Windows.Forms.Design.Behavior namespace (BehaviorService, etc) to replace the current IUISelectionService.
  • Requires true Control transparency (WS_EX_TRANSPARENT), which is not yet supported by the MWF X11 backend. MWF bug - http://bugzilla.ximian.com/show_bug.cgi?id=81135 .

ComponentTray

  • Depends on the Behavior-based selection service.

Menu editing

  • Designer
    • Implement IMenuEditorService.
  • MWF Designers
    • Menu has a designer in a Visual Studio assembly (Microsoft.VisualStudio.Windows.Forms.MenuDesigner) - fix that.

DesignerActions

  • Surface
    • Implement DesignerActionService, DesignerActionUIService, DesignerAction* and DesignerActionUI*

Extender Providers

  • Surface
    • Review ExtenderService : IExtenderProviderService, IExtenderListServiceIExtenderService implementation.
  • Serializers
    • Support for (De)Serialization of "provided" properties.


AmbientValueAttribute - http://msdn2.microsoft.com/en-us/library/system.componentmodel.ambientvalueattribute.aspx

  • Serializers
    • Just add a handling of AmbientValueAttribute in PropertyCodeDomSerializer.ShouldSerialize(...)


ISupportInitialize and ctor (IContainer container)


Visual Inheritance

  • InheritanceService, InheritanceAttribute, "Modifier" Design-Time property. How is the Modifier property persisted for the project?


Support Classes

Serializers

  • ControlCodeDomSerializer
  • ControlCollectionCodeDomSerializer
  • DataGridViewRowCollectionCodeDomSerializer
  • ImageListCodeDomSerializer
  • TableLayoutControlCollectionCodeDomSerializer
  • TableLayoutPanelCodeDomSerializer
  • ToolStripCodeDomSerializer
  • ToolStripMenuItemCodeDomSerializer

Designers

  • AxHostDesigner
  • BindingNavigatorDesigner
  • BindingSourceDesigner
  • ButtonBaseDesigner
  • ComboBoxDesigner
  • DataGridDesigner
  • DataGridViewColumnDesigner
  • DataGridViewComboBoxColumnDesigner
  • DataGridViewDesigner
  • DateTimePickerDesigner
  • FlowLayoutPanelDesigner
  • FolderBrowserDialogDesigner
  • GroupBoxDesigner
  • ImageListDesigner
  • LabelDesigner
  • ListBoxDesigner
  • ListViewDesigner
  • MaskedTextBoxDesigner
  • MonthCalendarDesigner
  • NotifyIconDesigner
  • OpenFileDialogDesigner
  • PanelDesigner
  • PictureBoxDesigner
  • PrintDialogDesigner
  • PropertyGridDesigner
  • RadioButtonDesigner
  • SaveFileDialogDesigner
  • ScrollableControlDesigner
  • SplitContainerDesigner
  • SplitterDesigner
  • SplitterPanelDesigner
  • StatusBarDesigner
  • TabControlDesigner
  • TableLayoutPanelDesigner
  • TabPageDesigner
  • TextBoxBaseDesigner
  • TextBoxDesigner
  • ToolBarButtonDesigner
  • ToolBarDesigner
  • ToolStripContainerDesigner
  • ToolStripContentPanelDesigner
  • ToolStripDesigner
  • ToolStripDropDownDesigner
  • ToolStripItemDesigner
  • ToolStripMenuItemDesigner
  • ToolStripPanelDesigner
  • TrackBarDesigner
  • TreeViewDesigner
  • UpDownBaseDesigner
  • WebBrowserBaseDesigner

PropertyGrid Editors

  • System.Windows.Forms.Design.BorderSidesEditor
  • Windows.Forms.Design.HelpNamespaceEditor
  • Windows.Forms.Design.ImageCollectionEditor
  • Windows.Forms.Design.ImageIndexEditor
  • Windows.Forms.Design.LinkAreaEditor
  • Windows.Forms.Design.ListViewSubItemCollectionEditor
  • Windows.Forms.Design.MaskedTextBoxTextEditor
  • Windows.Forms.Design.MaskPropertyEditor
  • Windows.Forms.Design.SelectedPathEditor
  • Windows.Forms.Design.ShortcutKeysEditor
  • Windows.Forms.Design.StyleCollectionEditor
  • Windows.Forms.Design.ToolStripCollectionEditor
  • Windows.Forms.Design.ToolStripImageIndexEditor
  • Windows.Forms.Design.TreeNodeCollectionEditor
  • Windows.Forms.Design.DataGridColumnCollectionEditor
  • Windows.Forms.Design.DataGridColumnStyleFormatEditor
  • Windows.Forms.Design.DataGridColumnStyleMappingNameEditor
  • Windows.Forms.Design.DataGridTableStyleMappingNameEditor
  • Windows.Forms.Design.DataGridViewCellStyleEditor
  • Windows.Forms.Design.DataGridViewColumnCollectionEditor
  • Windows.Forms.Design.DataGridViewColumnDataPropertyNameEditor
  • Windows.Forms.Design.DataGridViewComponentEditor
  • System.ComponentModel.Design.MultilineStringEditor - stubbed
  • Windows.Forms.Design.DataMemberFieldEditor - stubbed
  • Windows.Forms.Design.DataMemberListEditor - stubbed
  • Windows.Forms.Design.FormatStringEditor - stubbed
  • Windows.Forms.Design.ListControlStringCollectionEditor
  • Windows.Forms.Design.StringArrayEditor
  • Windows.Forms.Design.StringCollectionEditor
  • Windows.Forms.Design.TabPageCollectionEditor

Menu Commands

All of the commands below are added by DocumentDesigner.Initialize(...). This was found by the means of the following SpyMenuCommandService added to a DesignerSurface on MSNET.

public class SpyMenuCommandService : MenuCommandService
{
	public SpyMenuCommandService (IServiceProvider provider) : base (provider)
	{
	}
	
	public override void AddCommand (MenuCommand command)
	{
		Console.WriteLine ("[Command:] " + command.ToString () + Environment.NewLine);
		Console.WriteLine ("=== Stack Trace ===" + Environment.NewLine);
		Console.WriteLine (Environment.StackTrace);
		Console.WriteLine ("===================" + Environment.NewLine);
		base.AddCommand (command);
	}
}
  • StandardCommands
    • AlignBottom
    • AlignHorizontalCenters
    • AlignLeft
    • AlignRight
    • AlignToGrid
    • AlignTop
    • AlignVerticalCenters
    • BringToFront
    • CenterHorizontally
    • CenterVertically
    • Copy
    • Cut
    • Delete
    • HorizSpaceConcatenate
    • HorizSpaceDecrease
    • HorizSpaceIncrease
    • HorizSpaceMakeEqual
    • Paste
    • SelectAll
    • SendToBack
    • SizeToControl
    • SizeToControlHeight
    • SizeToControlWidth
    • SizeToGrid
    • SnapToGrid
    • TabOrder
    • VertSpaceConcatenate
    • VertSpaceDecrease
    • VertSpaceIncrease
    • VertSpaceMakeEqual
    • ShowGrid
    • LockControls
  • MenuCommands
    • KeyDefaultAction
    • KeySelectNext
    • KeySelectPrevious
    • KeyMoveLeft
    • KeySizeWidthDecrease
    • KeyMoveRight
    • KeySizeWidthIncrease
    • KeyMoveUp
    • KeySizeHeightIncrease
    • KeyMoveDown
    • KeySizeHeightDecrease
    • KeyCancel
    • KeyNudgeLeft
    • KeyNudgeDown
    • KeyNudgeRight
    • KeyNudgeUp
    • KeyNudgeHeightIncrease
    • KeyNudgeHeightDecrease
    • KeyNudgeWidthDecrease
    • KeyNudgeWidthIncrease
    • DesignerProperties
    • KeyReverseCancel

Known Limitations

Not supported currently are, as follows.

Surface

CodeDom (De)Serialization

  • No creation expression is serialized for nested components by the ComponentCodeDomSerializer. I can't think of a use case where this would be required.
  • InheritanceService, InheritanceAttribute - what are those for?

Documentation Resources