Browse Source

Added option to generate Visual Studio style event handlers in the Windows Forms designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5916 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 15 years ago
parent
commit
d4d0a1aaed
  1. 16
      src/AddIns/DisplayBindings/FormsDesigner/Project/Resources/WindowsFormsGeneralOptions.xfrm
  2. 11
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/OptionPanels/GeneralOptions.cs
  3. 25
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/EventBindingService.cs

16
src/AddIns/DisplayBindings/FormsDesigner/Project/Resources/WindowsFormsGeneralOptions.xfrm

@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
<Controls>
<System.Windows.Forms.GroupBox>
<Name value="propertyPadOptionsGroupBox" />
<Location value="8, 180" />
<Location value="8, 206" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.PropertyGridGroupBox}" />
<Anchor value="Top, Left, Right" />
<Size value="373, 56" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
<Controls>
<System.Windows.Forms.CheckBox>
@ -25,10 +25,18 @@ @@ -25,10 +25,18 @@
<Name value="generalOptionsGroupBox" />
<Location value="8, 8" />
<Text value="${res:Dialog.Options.IDEOptions.TextEditor.General.GeneralOptionsGroupBox}" />
<Size value="373, 192" />
<Anchor value="Top, Left, Right" />
<Size value="373, 166" />
<TabIndex value="0" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="generateVSStyleHandlersCheckBox" />
<Location value="6, 162" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GenerateVisualStudioStyleEventHandlers}" />
<TabIndex value="4" />
<Size value="367, 24" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="insertTodoCommentCheckBox" />
<Location value="6, 136" />
@ -73,4 +81,4 @@ @@ -73,4 +81,4 @@
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>
</Components>

11
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/OptionPanels/GeneralOptions.cs

@ -25,6 +25,7 @@ namespace ICSharpCode.FormsDesigner.Gui.OptionPanels @@ -25,6 +25,7 @@ namespace ICSharpCode.FormsDesigner.Gui.OptionPanels
((CheckBox)ControlDictionary["inPlaceEditCheckBox"]).Checked = PropertyService.Get("FormsDesigner.DesignerOptions.EnableInSituEditing", true);
((CheckBox)ControlDictionary["useSmartTagsCheckBox"]).Checked = UseSmartTags;
((CheckBox)ControlDictionary["insertTodoCommentCheckBox"]).Checked = InsertTodoComment;
((CheckBox)ControlDictionary["generateVSStyleHandlersCheckBox"]).Checked = GenerateVisualStudioStyleEventHandlers;
}
public static bool UseSmartTags {
@ -54,6 +55,15 @@ namespace ICSharpCode.FormsDesigner.Gui.OptionPanels @@ -54,6 +55,15 @@ namespace ICSharpCode.FormsDesigner.Gui.OptionPanels
}
}
public static bool GenerateVisualStudioStyleEventHandlers {
get {
return PropertyService.Get("FormsDesigner.DesignerOptions.GenerateVisualStudioStyleEventHandlers", false);
}
set {
PropertyService.Set("FormsDesigner.DesignerOptions.GenerateVisualStudioStyleEventHandlers", value);
}
}
public override bool StorePanelContents()
{
PropertyService.Set("FormsDesigner.DesignerOptions.PropertyGridSortAlphabetical", ((CheckBox)ControlDictionary["sortAlphabeticalCheckBox"]).Checked);
@ -62,6 +72,7 @@ namespace ICSharpCode.FormsDesigner.Gui.OptionPanels @@ -62,6 +72,7 @@ namespace ICSharpCode.FormsDesigner.Gui.OptionPanels
PropertyService.Set("FormsDesigner.DesignerOptions.EnableInSituEditing", ((CheckBox)ControlDictionary["inPlaceEditCheckBox"]).Checked);
UseSmartTags = ((CheckBox)ControlDictionary["useSmartTagsCheckBox"]).Checked;
InsertTodoComment = ((CheckBox)ControlDictionary["insertTodoCommentCheckBox"]).Checked;
GenerateVisualStudioStyleEventHandlers = ((CheckBox)ControlDictionary["generateVSStyleHandlersCheckBox"]).Checked;
return true;
}

25
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/EventBindingService.cs

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
using System;
using System.Collections;
using System.ComponentModel;
using ICSharpCode.FormsDesigner.Gui.OptionPanels;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.FormsDesigner.Services
@ -26,7 +26,28 @@ namespace ICSharpCode.FormsDesigner.Services @@ -26,7 +26,28 @@ namespace ICSharpCode.FormsDesigner.Services
protected override string CreateUniqueMethodName(IComponent component, EventDescriptor e)
{
return String.Format("{0}{1}", Char.ToUpper(component.Site.Name[0]) + component.Site.Name.Substring(1), e.DisplayName);
string componentName = GetComponentName(component);
return GetEventHandlerName(componentName, e.DisplayName);
}
string GetComponentName(IComponent component)
{
string siteName = component.Site.Name;
return Char.ToUpper(siteName[0]) + siteName.Substring(1);
}
string GetEventHandlerName(string componentName, string eventName)
{
string eventHandlerNameFormat = GetEventHandlerNameFormat();
return String.Format(eventHandlerNameFormat, componentName, eventName);
}
string GetEventHandlerNameFormat()
{
if (GeneralOptionsPanel.GenerateVisualStudioStyleEventHandlers) {
return "{0}_{1}";
}
return "{0}{1}";
}
// sohuld look around in form class for compatiable methodes

Loading…
Cancel
Save