Browse Source

StringListEditor and StringListEditorDialog.xaml

pull/30/head
PeterForstmeier 14 years ago
parent
commit
1076612de1
  1. 22
      src/Main/Base/Project/Src/Gui/Components/StringListEditorDialog.xaml
  2. 18
      src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml
  3. 49
      src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs

22
src/Main/Base/Project/Src/Gui/Components/StringListEditorDialog.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="ICSharpCode.SharpDevelop.Gui.StringListEditorDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@ -6,25 +6,25 @@ @@ -6,25 +6,25 @@
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
Width="400" Height="400"
Height="300" Width="400"
Title="ICSharpCode.CppBinding.Project">
<Grid>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition ></RowDefinition>
<RowDefinition Height="30" ></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="70"></ColumnDefinition>
<ColumnDefinition Width="70"></ColumnDefinition>
</Grid.ColumnDefinitions>
<local:StringListEditorXaml x:Name="stringListEditor" Grid.ColumnSpan="3"></local:StringListEditorXaml>
<local:StringListEditorXaml x:Name="stringListEditor" Grid.ColumnSpan="3" VerticalAlignment="Stretch"></local:StringListEditorXaml>
<Button Margin="0,3,5,3" Grid.Row="1" Grid.Column="1" IsDefault="True" Click="Button_Click" Content="{core:Localize Global.OKButtonText}"></Button>
<Button Margin="0,3,5,3" Grid.Row="1" Grid.Column="2" IsCancel="True" Content="{core:Localize Global.CancelButtonText}"></Button>
<Button Grid.Row="1" Grid.Column="1" IsCancel="True" Margin="5" Content="{core:Localize Global.CancelButtonText}"></Button>
<Button Grid.Row="1" Grid.Column="2" IsDefault="True" Margin="5" Click="Button_Click" Content="{core:Localize Global.OKButtonText}"></Button>
</Grid>
</Window>

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

@ -6,17 +6,17 @@ @@ -6,17 +6,17 @@
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="150"></RowDefinition>
<RowDefinition ></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
<ColumnDefinition ></ColumnDefinition>
<ColumnDefinition Width="60"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Content="{Binding TitleText}"></Label>
@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
</TextBox>
<Button x:Name="browseButton" Grid.Column="1" Grid.Row="1" Margin="0,3,5,0"
<Button x:Name="browseButton" Grid.Column="1" Grid.Row="1" Margin="5,3,5,3"
Content="..."
Visibility="Hidden"
Click="BrowseButtonClick">
@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
Style="{x:Static core:GlobalStyles.ButtonStyle}">
</Button>
<Button x:Name="removeButton"
<Button x:Name="removeButton" Margin="5,3,5,3"
Visibility="Hidden"
Content="{core:Localize Global.DeleteButtonText}"
Style="{x:Static core:GlobalStyles.ButtonStyle}">
@ -65,9 +65,9 @@ @@ -65,9 +65,9 @@
</ListBox>
<widgets:StackPanelWithSpacing Orientation="Vertical" Grid.Row="4" Grid.Column="1" SpaceBetweenItems="5">
<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>
<Button x:Name="moveUpButton" Margin="5,3,5,0" Click="MoveUpButtonClick"></Button>
<Button x:Name="moveDownButton" Margin="5,0,5,0" Click="MoveDownButtonClick"></Button>
<Button x:Name="deleteButton" Margin="5,0,5,0" Click="RemoveButtonClick"></Button>
</widgets:StackPanelWithSpacing>
</Grid>
</UserControl>

49
src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs

@ -35,8 +35,8 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -35,8 +35,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public string TitleText {get;set;}
public string ListCaption {get;set;}
public bool BrowseForDirectory {
get {
return browseForDirectory;
@ -51,8 +51,10 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -51,8 +51,10 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
public bool AutoAddAfterBrowse {get;set;}
void AddButton_Click(object sender, RoutedEventArgs e)
{
editTextBox.Text = editTextBox.Text.Trim();
@ -68,13 +70,13 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -68,13 +70,13 @@ namespace ICSharpCode.SharpDevelop.Gui
#region Load/Save List
public void LoadList(IEnumerable<string> list)
{
listBox.Items.Clear();
foreach (string str in list) {
listBox.Items.Add(str);
}
CheckEnableState();
}
@ -88,9 +90,10 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -88,9 +90,10 @@ namespace ICSharpCode.SharpDevelop.Gui
}
#endregion
#endregion
void UpdateButton_Click(object sender, RoutedEventArgs e)
private void UpdateButton_Click(object sender, RoutedEventArgs e)
{
editTextBox.Text = editTextBox.Text.Trim();
if (editTextBox.Text.Length > 0) {
@ -110,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -110,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (!path.EndsWith("\\") && !path.EndsWith("/"))
path += "\\";
editTextBox.Text = path;
if (AutoAddAfterBrowse) {
AddButton_Click(null, null);
}
@ -119,10 +122,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -119,10 +122,11 @@ namespace ICSharpCode.SharpDevelop.Gui
}
void EditTextBox_TextChanged(object sender, TextChangedEventArgs e)
private void EditTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
addButton.IsEnabled = editTextBox.Text.Length > 0;
updateButton.IsEnabled = listBox.SelectedIndex >= 0 && editTextBox.Text.Length > 0;
// updateButton.IsEnabled = listBox.SelectedIndex >= 0 && editTextBox.Text.Length > 0;
CheckEnableState();
}
@ -131,45 +135,54 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -131,45 +135,54 @@ namespace ICSharpCode.SharpDevelop.Gui
if (ListChanged != null) {
ListChanged(this, e);
}
CheckEnableState();
}
void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (listBox.SelectedIndex >= 0) {
editTextBox.Text = listBox.Items[listBox.SelectedIndex].ToString();
}
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;
CheckEnableState();
}
private void CheckEnableState()
{
moveUpButton.IsEnabled = listBox.SelectedIndex > -1 && listBox.Items.Count > 1;
moveDownButton.IsEnabled = listBox.SelectedIndex > -1 && listBox.Items.Count > 1;
removeButton.IsEnabled = listBox.SelectedIndex > -1;
deleteButton.IsEnabled = listBox.SelectedIndex > -1;
updateButton.IsEnabled = listBox.SelectedIndex > -1 && editTextBox.Text.Length > 0;
}
#region MoveUp-MoveDow-DeleteButton
void MoveUpButtonClick(object sender, RoutedEventArgs e)
private void MoveUpButtonClick(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;
// listBox.SelectedIndex = index - 1;
OnListChanged(EventArgs.Empty);
}
void MoveDownButtonClick(object sender, RoutedEventArgs e)
private 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;
// listBox.SelectedIndex = index + 1;
OnListChanged(EventArgs.Empty);
}
void RemoveButtonClick(object sender, RoutedEventArgs e)
private void RemoveButtonClick(object sender, RoutedEventArgs e)
{
if (listBox.SelectedIndex >= 0) {
listBox.Items.RemoveAt(listBox.SelectedIndex);

Loading…
Cancel
Save