Browse Source

Convert EditStandardHeaderPanel.cs to Wpf

pull/30/head
PeterForstmeier 13 years ago
parent
commit
5129e1b5d4
  1. 12
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  2. 58
      src/Main/Base/Project/Resources/EditStandardHeaderPanel.xfrm
  3. 50
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.cs
  4. 24
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml
  5. 67
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml.cs
  6. 56
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/old_ReferencePaths.cs

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

@ -241,6 +241,10 @@ @@ -241,6 +241,10 @@
<Compile Include="Src\Gui\Dialogs\OpenWithDialog.Designer.cs">
<DependentUpon>OpenWithDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\EditStandardHeaderPanel.xaml.cs">
<DependentUpon>EditStandardHeaderPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\LoadSaveOptions.xaml.cs">
<DependentUpon>LoadSaveOptions.xaml</DependentUpon>
<SubType>Code</SubType>
@ -581,9 +585,6 @@ @@ -581,9 +585,6 @@
<Compile Include="Src\Internal\Templates\File\ScriptRunner.cs" />
<Compile Include="Src\Gui\Components\LocalizedPropertyGrid\CustomTypeConverter\BooleanTypeConverter.cs" />
<Compile Include="Src\Gui\Components\LocalizedPropertyGrid\CustomTypeConverter\TemplateTypeConverter.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\EditStandardHeaderPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Internal\Templates\StandardHeaders.cs" />
<Compile Include="Src\Gui\Components\LocalizedPropertyGrid\LocalizedProperty.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\IsProcessRunningEvaluator.cs" />
@ -702,7 +703,6 @@ @@ -702,7 +703,6 @@
<EmbeddedResource Include="Resources\CodeGenerationOptionsPanel.xfrm" />
<EmbeddedResource Include="Resources\CommonAboutDialog.xfrm" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<EmbeddedResource Include="Resources\EditStandardHeaderPanel.xfrm" />
<EmbeddedResource Include="Resources\ExternalToolOptions.xfrm" />
<EmbeddedResource Include="Resources\FontSelectionPanel.xfrm" />
<EmbeddedResource Include="Resources\NewFileWithNameDialog.xfrm" />
@ -735,9 +735,6 @@ @@ -735,9 +735,6 @@
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\Signing.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\old_ReferencePaths.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\Publish.cs">
<SubType>UserControl</SubType>
</Compile>
@ -885,6 +882,7 @@ @@ -885,6 +882,7 @@
<ItemGroup>
<Page Include="Src\Bookmarks\Pad\Controls\ListViewPad.xaml" />
<Page Include="Src\Gui\Components\StringListEditorXaml.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\EditStandardHeaderPanel.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectStylePanel.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\TaskListOptionsl.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.xaml" />

58
src/Main/Base/Project/Resources/EditStandardHeaderPanel.xfrm

@ -1,58 +0,0 @@ @@ -1,58 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="MyUserControl" />
<DockPadding value="" />
<ClientSize value="{Width=344, Height=296}" />
<Controls>
<System.Windows.Forms.Panel>
<Name value="panel1" />
<Location value="{X=8,Y=72}" />
<Size value="{Width=328, Height=216}" />
<DockPadding value="" />
<Anchor value="Top, Bottom, Left, Right" />
<TabIndex value="4" />
<Controls>
<System.Windows.Forms.TextBox>
<Name value="headerTextBox" />
<TabIndex value="3" />
<Dock value="Fill" />
<Location value="{X=0,Y=0}" />
<AcceptsReturn value="True" />
<Size value="{Width=328, Height=216}" />
<Multiline value="True" />
<AcceptsTab value="True" />
<AutoSize value="False" />
<Text value="" />
<RightToLeft value="No" />
</System.Windows.Forms.TextBox>
</Controls>
</System.Windows.Forms.Panel>
<System.Windows.Forms.Label>
<Name value="label2" />
<Text value="${res:Dialog.Options.IDEOptions.EditStandardHeaderPanel.LanguageLabel}" />
<TextAlign value="MiddleRight" />
<TabIndex value="0" />
<Size value="{Width=136, Height=23}" />
<Location value="{X=4,Y=8}" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Label>
<Name value="label" />
<Text value="${res:Dialog.Options.IDEOptions.EditStandardHeaderPanel.HeaderLabel}" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="2" />
<Size value="{Width=328, Height=16}" />
<Location value="{X=8,Y=48}" />
</System.Windows.Forms.Label>
<System.Windows.Forms.ComboBox>
<Name value="headerChooser" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
<Location value="{X=144,Y=8}" />
<Size value="{Width=192, Height=21}" />
<DropDownStyle value="DropDownList" />
<RightToLeft value="No" />
</System.Windows.Forms.ComboBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

50
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.cs

@ -1,50 +0,0 @@ @@ -1,50 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Internal.Templates;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public class EditStandardHeaderPanel : XmlFormsOptionPanel
{
public override void LoadPanelContents()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.EditStandardHeaderPanel.xfrm"));
ControlDictionary["headerTextBox"].Font = WinFormsResourceService.DefaultMonospacedFont;
foreach (StandardHeader header in StandardHeader.StandardHeaders) {
((ComboBox)ControlDictionary["headerChooser"]).Items.Add(header);
}
((ComboBox)ControlDictionary["headerChooser"]).SelectedIndexChanged += new EventHandler(SelectedIndexChanged);
((ComboBox)ControlDictionary["headerChooser"]).SelectedIndex = 0;
((TextBox)ControlDictionary["headerTextBox"]).TextChanged += new EventHandler(TextChangedEvent);
}
void TextChangedEvent(object sender , EventArgs e)
{
((StandardHeader)((ComboBox)ControlDictionary["headerChooser"]).SelectedItem).Header = ControlDictionary["headerTextBox"].Text;
}
void SelectedIndexChanged(object sender , EventArgs e)
{
((TextBox)ControlDictionary["headerTextBox"]).TextChanged -= new EventHandler(TextChangedEvent);
int idx =((ComboBox)ControlDictionary["headerChooser"]).SelectedIndex;
if (idx >= 0) {
ControlDictionary["headerTextBox"].Text = ((StandardHeader)((ComboBox)ControlDictionary["headerChooser"]).SelectedItem).Header;
ControlDictionary["headerTextBox"].Enabled = true;
} else {
ControlDictionary["headerTextBox"].Text = "";
ControlDictionary["headerTextBox"].Enabled = false;
}
((TextBox)ControlDictionary["headerTextBox"]).TextChanged += new EventHandler(TextChangedEvent);
}
public override bool StorePanelContents()
{
StandardHeader.StoreHeaders();
return true;
}
}
}

24
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
<gui:OptionPanel x:Class="ICSharpCode.SharpDevelop.Gui.OptionPanels.EditStandardHeaderPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<StackPanel>
<widgets:StackPanelWithSpacing SpaceBetweenItems="5" Margin="50,8,0,0" Orientation="Horizontal">
<Label Content="{core:Localize Dialog.Options.IDEOptions.EditStandardHeaderPanel.LanguageLabel}"></Label>
<ComboBox x:Name="headerChooser" Width="150"
SelectionChanged="HeaderChooser_SelectionChanged"></ComboBox>
</widgets:StackPanelWithSpacing >
<Label Margin="0,8,0,0"
Content="{core:Localize Dialog.Options.IDEOptions.EditStandardHeaderPanel.HeaderLabel}"></Label>
<TextBox x:Name="headerTextBox"
TextChanged="HeaderTextBox_TextChanged"
Margin="0,2,0,0" Height="200"></TextBox>
</StackPanel>
</gui:OptionPanel>

67
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 30.03.2012
* Time: 20:41
*
* 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.Core.WinForms;
using ICSharpCode.SharpDevelop.Internal.Templates;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
/// <summary>
/// Interaction logic for EditStandardHeaderPanelXaml.xaml
/// </summary>
public partial class EditStandardHeaderPanel : OptionPanel
{
public EditStandardHeaderPanel()
{
InitializeComponent();
}
public override void LoadOptions()
{
headerTextBox.FontFamily = new FontFamily("Consolas, Courier New");
foreach (StandardHeader header in StandardHeader.StandardHeaders) {
headerChooser.Items.Add(header);
}
headerChooser.SelectionChanged += HeaderChooser_SelectionChanged;
headerChooser.SelectedIndex = 0;
headerTextBox.TextChanged += HeaderTextBox_TextChanged;
}
void HeaderChooser_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
headerTextBox.TextChanged -= HeaderTextBox_TextChanged;
int idx =headerChooser.SelectedIndex;
if (idx >= 0) {
headerTextBox.Text = ((StandardHeader)((ComboBox)headerChooser).SelectedItem).Header;
headerTextBox.IsEnabled = true;
} else {
headerTextBox.Text = "";
headerTextBox.IsEnabled = false;
}
headerTextBox.TextChanged += HeaderTextBox_TextChanged;
}
void HeaderTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
((StandardHeader)((ComboBox)headerChooser).SelectedItem).Header = headerTextBox.Text;
}
}
}

56
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/old_ReferencePaths.cs

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public class old_ReferencePaths : AbstractXmlFormsProjectOptionPanel
{
public override void LoadPanelContents()
{
InitializeHelper();
StringListEditor editor = new StringListEditor();
editor.BrowseForDirectory = true;
editor.ListCaption = StringParser.Parse("&${res:Dialog.ProjectOptions.ReferencePaths}:");
editor.TitleText = StringParser.Parse("&${res:Global.Folder}:");
editor.AddButtonText = StringParser.Parse("${res:Dialog.ProjectOptions.ReferencePaths.AddPath}");
editor.ListChanged += delegate { IsDirty = true; };
SemicolonSeparatedStringListBinding b = new SemicolonSeparatedStringListBinding(editor);
helper.AddBinding("ReferencePath", b);
this.Controls.Add(editor);
b.CreateLocationButton(editor);
helper.AddConfigurationSelector(this);
}
sealed class SemicolonSeparatedStringListBinding : ConfigurationGuiBinding
{
StringListEditor editor;
public SemicolonSeparatedStringListBinding(StringListEditor editor)
{
this.editor = editor;
}
public override void Load()
{
string[] values = Get("").Split(';');
if (values.Length == 1 && values[0].Length == 0) {
editor.LoadList(new string[0]);
} else {
editor.LoadList(values);
}
}
public override bool Save()
{
Set(string.Join(";", editor.GetList()));
return true;
}
}
}
}
Loading…
Cancel
Save