From 3255344abaaf216c9e3c9003c56f50b61dce5f9b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 28 Jan 2006 17:25:30 +0000 Subject: [PATCH] Fixed SD2-652: Code completion for form component with modifier set to public Fixed SD2-659: No code completion for newly added components to a partial form class git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1045 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../AbstractDesignerGenerator.cs | 6 ++- .../Src/Project/ConfigurationGuiHelper.cs | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs index c41279481c..360907a53f 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs @@ -196,10 +196,11 @@ namespace ICSharpCode.FormsDesigner removedFields.Add(field.Name); } } - // removing fields is done in two steps because + // removing fields is done in two steps because // we must not modify the c.Fields collection while it is enumerated removedFields.ForEach(RemoveField); + ParserService.EnqueueForParsing(designerFile, document.TextContent); } /// @@ -240,6 +241,7 @@ namespace ICSharpCode.FormsDesigner IDocument document; string saveDocumentToFile; // only set when InitializeComponent was loaded from code-behind file that was not opened + string designerFile; // file that contains InitializeComponents void SaveDocument() { @@ -265,7 +267,7 @@ namespace ICSharpCode.FormsDesigner if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) { initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c); if (initializeComponents != null) { - string designerFile = initializeComponents.DeclaringType.CompilationUnit.FileName; + designerFile = initializeComponents.DeclaringType.CompilationUnit.FileName; string designerContent; if (FileUtility.IsEqualFileName(viewContent.TextEditorControl.FileName, designerFile)) { designerContent = content; diff --git a/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs b/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs index 178805b7d5..b70e0800f4 100644 --- a/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs +++ b/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs @@ -248,6 +248,56 @@ namespace ICSharpCode.SharpDevelop.Project } #endregion + #region Bind int to NumericUpDown + public ConfigurationGuiBinding BindInt(string control, string property, int defaultValue) + { + return BindInt(controlDictionary[control], property, defaultValue); + } + + public ConfigurationGuiBinding BindInt(Control control, string property, int defaultValue) + { + if (control is NumericUpDown) { + SimpleIntBinding binding = new SimpleIntBinding((NumericUpDown)control, defaultValue); + AddBinding(property, binding); + control.TextChanged += ControlValueChanged; + return binding; + } else { + throw new ApplicationException("Cannot bind " + control.GetType().Name + " to int property."); + } + } + + class SimpleIntBinding : ConfigurationGuiBinding + { + NumericUpDown control; + int defaultValue; + + public SimpleIntBinding(NumericUpDown control, int defaultValue) + { + this.control = control; + this.defaultValue = defaultValue; + } + + public override void Load() + { + int val; + if (!int.TryParse(Get(defaultValue.ToString(NumberFormatInfo.InvariantInfo)), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out val)) { + val = defaultValue; + } + control.Text = val.ToString(); + } + + public override bool Save() + { + string txt = control.Text.Trim(); + NumberStyles style = NumberStyles.Integer; + int val; + val = int.Parse(txt, style, NumberFormatInfo.InvariantInfo); + Set(val.ToString(NumberFormatInfo.InvariantInfo)); + return true; + } + } + #endregion + #region Bind hex number to TextBox public ConfigurationGuiBinding BindHexadecimal(TextBoxBase textBox, string property, int defaultValue) {