Browse Source

Convert FormsDesigner GridOptionsPanel to WPF

pull/18/head
PeterForstmeier 14 years ago
parent
commit
c2123ecb5c
  1. 8
      src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.addin
  2. 5
      src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
  3. 52
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/OptionPanels/GridOptionsPanelXAML.xaml
  4. 98
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/OptionPanels/GridOptionsPanelXAML.xaml.cs

8
src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.addin

@ -307,12 +307,18 @@ @@ -307,12 +307,18 @@
<OptionPanel id = "GeneralOptions"
label = "${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GeneralOptionsPanel.PanelName}"
class = "ICSharpCode.FormsDesigner.Gui.OptionPanels.GeneralOptionsPanel"/>
<!--
<OptionPanel id = "GridOptions"
label = "${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.PanelName}"
class = "ICSharpCode.FormsDesigner.Gui.OptionPanels.GridOptionsPanel"/>
class = "ICSharpCode.FormsDesigner.Gui.OptionPanels.GridOptionsPanel"/>-->
<OptionPanel id = "GridOptions"
label = "${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.PanelName}"
class = "ICSharpCode.FormsDesigner.Gui.OptionPanels.GridOptionsPanelXAML"/>
<OptionPanel id = "LocalizationModelOptions"
label = "${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.LocalizationModelOptionsPanel.PanelName}"
class = "ICSharpCode.FormsDesigner.Gui.OptionPanels.LocalizationModelOptionsPanel"/>
</OptionPanel>
</Path>
</AddIn>

5
src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj

@ -85,6 +85,10 @@ @@ -85,6 +85,10 @@
<Compile Include="Src\Gui\ImageResourceEditorDialog.Designer.cs">
<DependentUpon>ImageResourceEditorDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\OptionPanels\GridOptionsPanelXAML.xaml.cs">
<DependentUpon>GridOptionsPanelXAML.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\OptionPanels\LocalizationModelOptionsPanel.xaml.cs">
<DependentUpon>LocalizationModelOptionsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
@ -190,6 +194,7 @@ @@ -190,6 +194,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\Gui\OptionPanels\GridOptionsPanelXAML.xaml" />
<Page Include="Src\Gui\OptionPanels\LocalizationModelOptionsPanel.xaml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

52
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/OptionPanels/GridOptionsPanelXAML.xaml

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
<gui:OptionPanel x:Class="ICSharpCode.FormsDesigner.Gui.OptionPanels.GridOptionsPanelXAML"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sd="http://icsharpcode.net/sharpdevelop/core"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets">
<StackPanel>
<GroupBox Margin="0,10,0,0"
Header="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.SnapModeGroupBox}">
<widgets:StackPanelWithSpacing SpaceBetweenItems="15">
<RadioButton x:Name="snapToGridRadioButton"
Checked="SnapToGridRadioButton_Checked"
Content="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.SnapToGridRadioButton}"></RadioButton>
<RadioButton x:Name="snapLinesRadioButton"
Checked="SnapLinesRadioButton_Checked"
Content="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.SnapLinesRadioButton}"></RadioButton>
</widgets:StackPanelWithSpacing>
</GroupBox>
<GroupBox Header="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.GridPropertiesGroupBox}">
<widgets:StackPanelWithSpacing SpaceBetweenItems="15">
<Grid Margin="40,5,30,0">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.WidthLabel}"></TextBlock>
<TextBox x:Name="widthTextBox" Margin="0,0,0,30" IsEnabled="False" Grid.Column="1" ></TextBox>
<TextBlock Grid.Row="1"
Text="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.HeightLabel}"></TextBlock>
<TextBox x:Name="heightTextBox" Margin="0,0,0,30"
IsEnabled="False" Grid.Row="1" Grid.Column="1" ></TextBox>
</Grid>
<CheckBox IsEnabled="False" x:Name="showGridCheckBox"
Content="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.ShowGridComboBox}"></CheckBox>
<CheckBox IsEnabled="False" x:Name="snapToGridCheckBox"
Content="{sd:Localize ICSharpCode.SharpDevelop.FormDesigner.Gui.OptionPanels.GridOptionsPanel.SnapToGridRadioButton}"></CheckBox>
</widgets:StackPanelWithSpacing>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

98
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/OptionPanels/GridOptionsPanelXAML.xaml.cs

@ -0,0 +1,98 @@ @@ -0,0 +1,98 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 29.02.2012
* Time: 20:20
*
* 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 System.ComponentModel.Design.Serialization;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.FormsDesigner.Gui.OptionPanels
{
/// <summary>
/// Interaction logic for GridOptrionsXAML.xaml
/// </summary>
public partial class GridOptionsPanelXAML : OptionPanel
{
public GridOptionsPanelXAML()
{
InitializeComponent();
bool snapToGridOn = PropertyService.Get("FormsDesigner.DesignerOptions.SnapToGridMode", false);
this.snapToGridRadioButton.IsChecked = snapToGridOn;
this.snapLinesRadioButton.IsChecked = !snapToGridOn;
this.widthTextBox.Text = PropertyService.Get("FormsDesigner.DesignerOptions.GridSizeWidth", 8).ToString();
this.heightTextBox.Text = PropertyService.Get("FormsDesigner.DesignerOptions.GridSizeHeight", 8).ToString();
this.showGridCheckBox.IsChecked = PropertyService.Get("FormsDesigner.DesignerOptions.ShowGrid", true);
this.snapToGridCheckBox.IsChecked = PropertyService.Get("FormsDesigner.DesignerOptions.SnapToGrid", true);
EnableGridOptions(snapToGridOn);
}
public override bool SaveOptions()
{
PropertyService.Set("FormsDesigner.DesignerOptions.SnapToGridMode", this.snapToGridCheckBox.IsChecked);
PropertyService.Set("FormsDesigner.DesignerOptions.UseSnapLines", this.snapLinesRadioButton.IsChecked);
PropertyService.Set("FormsDesigner.DesignerOptions.ShowGrid", this.showGridCheckBox.IsChecked);
PropertyService.Set("FormsDesigner.DesignerOptions.SnapToGrid", this.snapToGridRadioButton.IsChecked);
int width;
bool result = Int32.TryParse(this.widthTextBox.Text, out width);
if (result) {
PropertyService.Set("FormsDesigner.DesignerOptions.GridSizeWidth", width);
} else {
MessageService.ShowError("Forms Designer grid width is invalid");
return false;
}
int height = 0;
result = Int32.TryParse(this.heightTextBox.Text, out height);
if (result) {
PropertyService.Set("FormsDesigner.DesignerOptions.GridSizeHeight", height);
}else {
MessageService.ShowError("Forms Designer grid height is invalid");
return false;
}
return true;
}
void EnableGridOptions (bool enable)
{
this.widthTextBox.IsEnabled = enable;
this.heightTextBox.IsEnabled = enable;
this.showGridCheckBox.IsEnabled = enable;
this.snapToGridCheckBox.IsEnabled = enable;
}
void SnapToGridRadioButton_Checked(object sender, RoutedEventArgs e)
{
EnableGridOptions(true);
}
void SnapLinesRadioButton_Checked(object sender, RoutedEventArgs e)
{
EnableGridOptions(false);
}
}
}
Loading…
Cancel
Save