Browse Source

StringListEditorXaml.xaml, DataBinding still missing

pull/30/head
PeterForstmeier 14 years ago
parent
commit
d912c0b6d5
  1. 9
      src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml
  2. 71
      src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs
  3. 4
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml
  4. 9
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs

9
src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<UserControl <UserControl
x:Class="ICSharpCode.SharpDevelop.Gui.StringListEditorXaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" xmlns:core="http://icsharpcode.net/sharpdevelop/core"> x:Class="ICSharpCode.SharpDevelop.Gui.StringListEditorXaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<Grid> <Grid>
@ -71,5 +71,12 @@
Margin="5,3,5,3" Margin="5,3,5,3"
SelectionChanged="ListBox_SelectionChanged" SelectionChanged="ListBox_SelectionChanged"
Grid.Row="4"></ListBox> Grid.Row="4"></ListBox>
<widgets:StackPanelWithSpacing Orientation="Vertical" SpaceBetweenItems="5"
Grid.Row="4" Grid.Column="1">
<Button Content="b1" x:Name="moveUpButton" Click="MoveUpButtonClick"></Button>
<Button Content="b2" x:Name="moveDownButton" Click="MoveDownButtonClick"></Button>
<Button Content="b3" x:Name="deleteButton" Click="RemoveButtonClick"></Button>
</widgets:StackPanelWithSpacing>
</Grid> </Grid>
</UserControl> </UserControl>

71
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.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Core.Presentation;
using Microsoft.Win32; using Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
@ -75,7 +77,30 @@ namespace ICSharpCode.SharpDevelop.Gui
listBox.SelectedIndex = index; listBox.SelectedIndex = index;
} }
} }
#region Load/Save List
public void LoadList(IEnumerable<string> 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) void UpdateButton_Click(object sender, RoutedEventArgs e)
{ {
@ -115,7 +140,6 @@ namespace ICSharpCode.SharpDevelop.Gui
protected virtual void OnListChanged(EventArgs e) protected virtual void OnListChanged(EventArgs e)
{ {
if (ListChanged != null) { if (ListChanged != null) {
ListChanged(this, e); ListChanged(this, e);
} }
@ -127,21 +151,52 @@ namespace ICSharpCode.SharpDevelop.Gui
if (listBox.SelectedIndex >= 0) { if (listBox.SelectedIndex >= 0) {
editTextBox.Text = listBox.Items[listBox.SelectedIndex].ToString(); editTextBox.Text = listBox.Items[listBox.SelectedIndex].ToString();
} }
// moveUpButton.Enabled = listBox.SelectedIndex > 0; moveUpButton.IsEnabled = listBox.SelectedIndex > 0;
// moveDownButton.Enabled = listBox.SelectedIndex >= 0 && listBox.SelectedIndex < listBox.Items.Count - 1; moveDownButton.IsEnabled = listBox.SelectedIndex >= 0 && listBox.SelectedIndex < listBox.Items.Count - 1;
// removeButton.IsEnabled = deleteButton.Enabled = listBox.SelectedIndex >= 0; removeButton.IsEnabled = deleteButton.IsEnabled = listBox.SelectedIndex >= 0;
updateButton.IsEnabled = listBox.SelectedIndex >= 0 && editTextBox.Text.Length > 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")};
}
} }
} }

4
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml

@ -22,10 +22,6 @@
<optionpanels:StorageLocationPicker Margin="5,40,0,0" <optionpanels:StorageLocationPicker Margin="5,40,0,0"
x:Name="location" Location="{Binding ReferencePath.Location}" /> x:Name="location" Location="{Binding ReferencePath.Location}" />
<!--
<WindowsFormsHost Grid.Column="1" Grid.RowSpan="2">
<gui:StringListEditor x:Name="editor"/>
</WindowsFormsHost>-->
<gui:StringListEditorXaml x:Name="editor" Grid.Column="1" Grid.RowSpan="2"></gui:StringListEditorXaml> <gui:StringListEditorXaml x:Name="editor" Grid.Column="1" Grid.RowSpan="2"></gui:StringListEditorXaml>

9
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs

@ -20,13 +20,12 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
public ReferencePaths() public ReferencePaths()
{ {
InitializeComponent(); InitializeComponent();
/*
editor.ListChanged += delegate { IsDirty = true; };*/
editor.BrowseForDirectory = true; editor.BrowseForDirectory = true;
editor.TitleText = StringParser.Parse("${res:Global.Folder}:"); editor.TitleText = StringParser.Parse("${res:Global.Folder}:");
editor.AddButtonText = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths.AddPath}"); editor.AddButtonText = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths.AddPath}");
editor.ListCaption = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths}:"); 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) protected override void Load(MSBuildBasedProject project, string configuration, string platform)
{ {
base.Load(project, configuration, platform); base.Load(project, configuration, platform);
@ -49,13 +48,13 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
editor.LoadList(values); editor.LoadList(values);
} }
} }
protected override bool Save(MSBuildBasedProject project, string configuration, string platform) protected override bool Save(MSBuildBasedProject project, string configuration, string platform)
{ {
ReferencePath.Value = String.Join(";", editor.GetList()); ReferencePath.Value = String.Join(";", editor.GetList());
return base.Save(project, configuration, platform); return base.Save(project, configuration, platform);
} }
*/
} }
} }
Loading…
Cancel
Save