Browse Source

StringListEditorXaml.xaml

pull/30/head
PeterForstmeier 14 years ago
parent
commit
f4a5cc6400
  1. 5
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  2. 75
      src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml
  3. 147
      src/Main/Base/Project/Src/Gui/Components/StringListEditorXaml.xaml.cs
  4. 10
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml
  5. 11
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePathsXAML.xaml.cs

5
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -201,6 +201,10 @@
</Compile> </Compile>
<Compile Include="Src\Gui\Components\LocalizedPropertyGrid\StringParserPropertyContainer.cs" /> <Compile Include="Src\Gui\Components\LocalizedPropertyGrid\StringParserPropertyContainer.cs" />
<Compile Include="Src\Gui\Components\SideBar\TextEditorSideBar.cs" /> <Compile Include="Src\Gui\Components\SideBar\TextEditorSideBar.cs" />
<Compile Include="Src\Gui\Components\StringListEditorXaml.xaml.cs">
<DependentUpon>StringListEditorXaml.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\CustomFocusManager.cs" /> <Compile Include="Src\Gui\CustomFocusManager.cs" />
<Compile Include="Src\Gui\Dialogs\AddOpenWithEntryDialog.cs" /> <Compile Include="Src\Gui\Dialogs\AddOpenWithEntryDialog.cs" />
<Compile Include="Src\Gui\Dialogs\AddOpenWithEntryDialog.Designer.cs"> <Compile Include="Src\Gui\Dialogs\AddOpenWithEntryDialog.Designer.cs">
@ -880,6 +884,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Src\Bookmarks\Pad\Controls\ListViewPad.xaml" /> <Page Include="Src\Bookmarks\Pad\Controls\ListViewPad.xaml" />
<Page Include="Src\Gui\Components\StringListEditorXaml.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\TaskListOptionsl.xaml" /> <Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\TaskListOptionsl.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.xaml" /> <Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\DebugOptions.xaml" /> <Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\DebugOptions.xaml" />

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

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition Height="150"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="300"></ColumnDefinition>
<ColumnDefinition
Width="40"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label
x:Name="title"
Content="Title"></Label>
<TextBox
x:Name="editTextBox"
Margin="5,3,5,3"
TextChanged="EditTextBox_TextChanged"
Grid.Row="1"></TextBox>
<Button
x:Name="browseButton"
Content="..."
Visibility="Hidden"
Margin="0,3,5,0"
Grid.Column="1"
Grid.Row="1"
Click="BrowseButtonClick"
/>
<widgets:StackPanelWithSpacing
Orientation="Horizontal"
Margin="5,3,5,3"
SpaceBetweenItems="5"
Grid.Row="2">
<Button
x:Name="addButton"
IsEnabled="False"
Click="AddButton_Click"
Content="{core:Localize Global.AddButtonText}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"></Button>
<Button
x:Name="updateButton"
IsEnabled="False"
Click="UpdateButton_Click"
Content="{core:Localize Global.UpdateButtonText}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"></Button>
<Button
x:Name="removeButton"
Visibility="Hidden"
Content="{core:Localize Global.DeleteButtonText}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"></Button>
</widgets:StackPanelWithSpacing>
<Label
x:Name="listlabel"
Grid.Row="3"
Content="List"></Label>
<ListBox
x:Name="listBox"
Margin="5,3,5,3"
SelectionChanged="ListBox_SelectionChanged"
Grid.Row="4"></ListBox>
</Grid>
</UserControl>

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

@ -0,0 +1,147 @@
/*
* Erstellt mit SharpDevelop.
* Benutzer: Peter Forstmeier
* Datum: 23.03.2012
* Zeit: 19:44
*
* Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
*/
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 Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// Interaction logic for StringListEditorXaml.xaml
/// </summary>
public partial class StringListEditorXaml : UserControl
{
bool browseForDirectory;
public event EventHandler ListChanged;
public string TitleText {
get { return this.title.Content.ToString(); }
set { this.title.Content = value;}
}
public string ListCaption
{
get {return this.listlabel.Content.ToString();}
set {this.listlabel.Content = value;}
}
public string AddButtonText {
get {return addButton.Content.ToString();}
set {addButton.Content = value;}
}
public bool BrowseForDirectory {
get {
return browseForDirectory;
}
set {
browseForDirectory = value;
if (browseForDirectory) {
browseButton.Visibility = Visibility.Visible;
} else {
browseButton.Visibility = Visibility.Hidden;
}
}
}
public bool AutoAddAfterBrowse {get;set;}
void AddButton_Click(object sender, RoutedEventArgs e)
{
editTextBox.Text = editTextBox.Text.Trim();
if (editTextBox.Text.Length > 0) {
int index = listBox.Items.IndexOf(editTextBox.Text);
if (index < 0) {
index = listBox.Items.Add(editTextBox.Text);
OnListChanged(EventArgs.Empty);
}
listBox.SelectedIndex = index;
}
}
void UpdateButton_Click(object sender, RoutedEventArgs e)
{
editTextBox.Text = editTextBox.Text.Trim();
if (editTextBox.Text.Length > 0) {
listBox.Items[listBox.SelectedIndex] = editTextBox.Text;
OnListChanged(EventArgs.Empty);
}
}
private void BrowseButtonClick (object sender, EventArgs e)
{
using (System.Windows.Forms.FolderBrowserDialog fdiag = FileService.CreateFolderBrowserDialog("${res:Dialog.ProjectOptions.SelectFolderTitle}"))
{
if (fdiag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string path = fdiag.SelectedPath;
if (!path.EndsWith("\\") && !path.EndsWith("/"))
path += "\\";
editTextBox.Text = path;
if (AutoAddAfterBrowse) {
AddButton_Click(null, null);
}
}
}
}
void EditTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
addButton.IsEnabled = editTextBox.Text.Length > 0;
updateButton.IsEnabled = listBox.SelectedIndex >= 0 && editTextBox.Text.Length > 0;
}
protected virtual void OnListChanged(EventArgs e)
{
if (ListChanged != null) {
ListChanged(this, e);
}
}
void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
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;
updateButton.IsEnabled = listBox.SelectedIndex >= 0 && editTextBox.Text.Length > 0;
}
public StringListEditorXaml()
{
InitializeComponent();
}
}
}

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

@ -16,16 +16,18 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition <ColumnDefinition
Width="40"></ColumnDefinition> Width="40"></ColumnDefinition>
<ColumnDefinition <ColumnDefinition></ColumnDefinition>
Width="300"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<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"> <WindowsFormsHost Grid.Column="1" Grid.RowSpan="2">
<gui:StringListEditor x:Name="editor"/> <gui:StringListEditor x:Name="editor"/>
</WindowsFormsHost> </WindowsFormsHost>-->
<gui:StringListEditorXaml x:Name="editor" Grid.Column="1" Grid.RowSpan="2"></gui:StringListEditorXaml>
</Grid> </Grid>
</optionpanels:ProjectOptionPanel> </optionpanels:ProjectOptionPanel>

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

@ -20,11 +20,13 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
public ReferencePaths() public ReferencePaths()
{ {
InitializeComponent(); InitializeComponent();
/*
editor.ListChanged += delegate { IsDirty = true; };*/
editor.BrowseForDirectory = true; editor.BrowseForDirectory = true;
editor.ListCaption = StringParser.Parse("&${res:Dialog.ProjectOptions.ReferencePaths}:"); 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.ListChanged += delegate { IsDirty = true; }; editor.ListCaption = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths}:");
} }
@ -34,7 +36,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);
@ -54,5 +56,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
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