From d912c0b6d5dfe360e59eda058e36cb8eba9cd6d4 Mon Sep 17 00:00:00 2001 From: PeterForstmeier Date: Thu, 29 Mar 2012 20:37:57 +0200 Subject: [PATCH] StringListEditorXaml.xaml, DataBinding still missing --- .../Gui/Components/StringListEditorXaml.xaml | 9 ++- .../Components/StringListEditorXaml.xaml.cs | 71 ++++++++++++++++--- .../ProjectOptions/ReferencePathsXAML.xaml | 4 -- .../ProjectOptions/ReferencePathsXAML.xaml.cs | 9 ++- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml b/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml index 03c15cc126..9e7c9f16bf 100644 --- a/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml +++ b/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml @@ -1,4 +1,4 @@ - + @@ -71,5 +71,12 @@ Margin="5,3,5,3" SelectionChanged="ListBox_SelectionChanged" Grid.Row="4"> + + + + + + \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs b/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs index 8daab77c84..61527ebc20 100644 --- a/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs +++ b/src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs @@ -15,6 +15,8 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; + +using ICSharpCode.Core.Presentation; using Microsoft.Win32; namespace ICSharpCode.SharpDevelop.Gui @@ -75,7 +77,30 @@ namespace ICSharpCode.SharpDevelop.Gui listBox.SelectedIndex = index; } } - + + #region Load/Save List + + + public void LoadList(IEnumerable list) + { + listBox.Items.Clear(); + foreach (string str in list) { + listBox.Items.Add(str); + } + } + + + public string[] GetList() + { + string[] list = new string[listBox.Items.Count]; + for (int i = 0; i < list.Length; i++) { + list[i] = listBox.Items[i].ToString(); + } + return list; + } + + + #endregion void UpdateButton_Click(object sender, RoutedEventArgs e) { @@ -115,7 +140,6 @@ namespace ICSharpCode.SharpDevelop.Gui protected virtual void OnListChanged(EventArgs e) { - if (ListChanged != null) { ListChanged(this, e); } @@ -127,21 +151,52 @@ namespace ICSharpCode.SharpDevelop.Gui if (listBox.SelectedIndex >= 0) { editTextBox.Text = listBox.Items[listBox.SelectedIndex].ToString(); } - // moveUpButton.Enabled = listBox.SelectedIndex > 0; - // moveDownButton.Enabled = listBox.SelectedIndex >= 0 && listBox.SelectedIndex < listBox.Items.Count - 1; - // removeButton.IsEnabled = deleteButton.Enabled = listBox.SelectedIndex >= 0; + moveUpButton.IsEnabled = listBox.SelectedIndex > 0; + moveDownButton.IsEnabled = listBox.SelectedIndex >= 0 && listBox.SelectedIndex < listBox.Items.Count - 1; + removeButton.IsEnabled = deleteButton.IsEnabled = listBox.SelectedIndex >= 0; updateButton.IsEnabled = listBox.SelectedIndex >= 0 && editTextBox.Text.Length > 0; + Console.WriteLine("{0} - {1} - {2} - {3}",moveUpButton.IsEnabled,moveDownButton.IsEnabled,removeButton.IsEnabled,updateButton.IsEnabled); } + #region MoveUp-MoveDow-DeleteButton - public StringListEditorXaml() + void MoveUpButtonClick(object sender, RoutedEventArgs e) { - InitializeComponent(); + int index = listBox.SelectedIndex; + object tmp = listBox.Items[index]; + listBox.Items[index] = listBox.Items[index - 1]; + listBox.Items[index - 1] = tmp; + listBox.SelectedIndex = index - 1; + OnListChanged(EventArgs.Empty); } + void MoveDownButtonClick(object sender, RoutedEventArgs e) + { + int index = listBox.SelectedIndex; + object tmp = listBox.Items[index]; + listBox.Items[index] = listBox.Items[index + 1]; + listBox.Items[index + 1] = tmp; + listBox.SelectedIndex = index + 1; + OnListChanged(EventArgs.Empty); + } + void RemoveButtonClick(object sender, RoutedEventArgs e) + { + if (listBox.SelectedIndex >= 0) { + listBox.Items.RemoveAt(listBox.SelectedIndex); + OnListChanged(EventArgs.Empty); + } + } + + #endregion - + public StringListEditorXaml() + { + InitializeComponent(); + moveUpButton.Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.ArrowUp") }; + moveDownButton.Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.ArrowDown")}; + deleteButton.Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.DeleteIcon")}; + } } } \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml index d0806065b6..a4ab2f774f 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml @@ -22,10 +22,6 @@ - diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs index 175831e01c..c3ba2ba464 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs @@ -20,13 +20,12 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels public ReferencePaths() { InitializeComponent(); - /* - editor.ListChanged += delegate { IsDirty = true; };*/ editor.BrowseForDirectory = true; editor.TitleText = StringParser.Parse("${res:Global.Folder}:"); editor.AddButtonText = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths.AddPath}"); editor.ListCaption = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths}:"); + editor.ListChanged += delegate { IsDirty = true; }; } @@ -36,7 +35,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels } } - /* + protected override void Load(MSBuildBasedProject project, string configuration, string platform) { base.Load(project, configuration, platform); @@ -49,13 +48,13 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels editor.LoadList(values); } } - + protected override bool Save(MSBuildBasedProject project, string configuration, string platform) { ReferencePath.Value = String.Join(";", editor.GetList()); return base.Save(project, configuration, platform); } - */ + } } \ No newline at end of file