From 6d2f62853d639deec559d435e206afb859b046a9 Mon Sep 17 00:00:00 2001 From: PeterForstmeier Date: Tue, 28 Feb 2012 19:11:49 +0100 Subject: [PATCH] Convert TaskList Option's to WPF --- .../Project/ICSharpCode.SharpDevelop.addin | 9 +- .../Project/ICSharpCode.SharpDevelop.csproj | 5 + .../OptionPanels/IDEOptions/TaskListXaml.xaml | 74 +++++++++++++++ .../IDEOptions/TaskListXaml.xaml.cs | 92 +++++++++++++++++++ 4 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml create mode 100644 src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml.cs diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin index 03c55e0972..1706202a2d 100755 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin @@ -1186,15 +1186,22 @@ + + + + + diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 9c3971a46a..1d9cc6130c 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -249,6 +249,10 @@ SelectCulturePanel.xaml Code + + TaskListXaml.xaml + Code + DebugOptions.xaml Code @@ -874,6 +878,7 @@ + diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml new file mode 100644 index 0000000000..7a446a4a80 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml.cs new file mode 100644 index 0000000000..ba00a5e8cc --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListXaml.xaml.cs @@ -0,0 +1,92 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 26.02.2012 + * Time: 19:46 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; + +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.SharpDevelop.Gui.OptionPanels +{ + /// + /// Interaction logic for TaskListXaml.xaml + /// + public partial class TaskListXaml : OptionPanel + { + public TaskListXaml() + { + InitializeComponent(); + string[] tokens = ParserService.TaskListTokens; + foreach (var token in tokens) { + listView.Items.Add(token); + }; + } + + + void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (listView.SelectedItem != null) { + taskText.Text = listView.SelectedItem.ToString(); + changeBtn.IsEnabled = true; + removeBtn.IsEnabled = true; + } + } + + + void ChangeBtn_Click(object sender, RoutedEventArgs e) + { + if ((listView.SelectedItem != null) && (!String.IsNullOrWhiteSpace(taskText.Text))) { + var i = listView.Items.IndexOf(listView.SelectedItem); + listView.Items[i] = taskText.Text; + } + } + + + void RemoveBtn_Click(object sender, RoutedEventArgs e) + { + if (listView.SelectedItem != null) { + listView.Items.Remove(listView.SelectedItem); + taskText.Text = String.Empty; + } + } + + + void AddButton_Click(object sender, RoutedEventArgs e) + { + if (!String.IsNullOrWhiteSpace(taskText.Text)) { + var i = listView.Items.IndexOf(taskText.Text); + if (i < 0) { + + listView.Items.Add(taskText.Text); + } + } + } + + + public override bool SaveOptions() + { + List tokens = new List(); + + foreach (var item in listView.Items) { + string text = item.ToString().Trim(); + if (text.Length > 0) { + tokens.Add(text); + } + } + ParserService.TaskListTokens = tokens.ToArray(); + return true; + } + } +} \ No newline at end of file