Browse Source

Hex Validator for BuildOptionsXaml.xaml

pull/30/head
PeterForstmeier 13 years ago
parent
commit
872c673bad
  1. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  2. 101
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml
  3. 15
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs
  4. 32
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/HexValidator.cs

1
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -80,6 +80,7 @@ @@ -80,6 +80,7 @@
<DependentUpon>BuildOptionsXaml.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\OptionPanels\HexValidator.cs" />
<Compile Include="Src\Parser\Parser.cs" />
<Compile Include="Src\Project\RemoveMembersInRangeVisitor.cs" />
<Compile Include="Src\Project\VBNetToCSharpConvertVisitorWithMyFormsSupport.cs" />

101
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml

@ -1,10 +1,20 @@ @@ -1,10 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<optionpanels:ProjectOptionPanel
x:Class="CSharpBinding.OptionPanels.BuildOptionsXaml" 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;assembly=ICSharpCode.SharpDevelop" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels;assembly=ICSharpCode.SharpDevelop" xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project;assembly=ICSharpCode.SharpDevelop" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets">
x:Class="CSharpBinding.OptionPanels.BuildOptionsXaml"
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;assembly=ICSharpCode.SharpDevelop"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels;assembly=ICSharpCode.SharpDevelop"
xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project;assembly=ICSharpCode.SharpDevelop"
xmlns:local="clr-namespace:CSharpBinding.OptionPanels"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets">
<optionpanels:ProjectOptionPanel.Resources>
<optionpanels:StringToBoolConverter
x:Key="strTobool"></optionpanels:StringToBoolConverter>
</optionpanels:ProjectOptionPanel.Resources>
<ScrollViewer
VerticalScrollBarVisibility="Auto">
<StackPanel
@ -78,10 +88,8 @@ @@ -78,10 +88,8 @@
VerticalAlignment="Center"
IsChecked="{Binding CheckForOverflowUnderflow.Value,Converter={StaticResource strTobool}}"
Content="{core:Localize Dialog.ProjectOptions.BuildOptions.CheckForOverflow}"></CheckBox>
<optionpanels:StorageLocationPicker
Grid.Row="5"
Location="{Binding NoStdLib.Location}"
DockPanel.Dock="Left" />
<optionpanels:StorageLocationPicker Grid.Row="5" DockPanel.Dock="Left" Location="{Binding NoStdLib.Location}"/>
<CheckBox
x:Name="noCorlibCheckBox"
Grid.Row="5"
@ -117,18 +125,13 @@ @@ -117,18 +125,13 @@
<ColumnDefinition
Width="50"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label
Content="{core:Localize Dialog.ProjectOptions.Build.OutputPath}"
Grid.ColumnSpan="2"></Label>
<Label Grid.ColumnSpan="2" Content="{core:Localize Dialog.ProjectOptions.Build.OutputPath}"></Label>
<optionpanels:StorageLocationPicker
Grid.Row="1"
Location="{Binding OutputPath.Location}"
DockPanel.Dock="Left" />
<TextBox
x:Name="outputPathTextBox"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
<TextBox x:Name="outputPathTextBox" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
Text="{Binding OutputPath.Value, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Button
Grid.Row="1"
@ -136,30 +139,21 @@ @@ -136,30 +139,21 @@
Margin="3,0,3,0"
Content="..."
Command="{Binding ChangeOutputPath}"></Button>
<!-- Documentfile missing and only partial implemented -->
<!-- ??????? -->
<optionpanels:StorageLocationPicker Grid.Row="2" DockPanel.Dock="Left"
Location="{Binding DocumentationFile.Location}"/>
<CheckBox
x:Name="xmlDocumentationCheckBox"
Grid.Row="2"
Grid.Column="1"
<optionpanels:StorageLocationPicker Grid.Row="2" DockPanel.Dock="Left" Location="{Binding DocumentationFile.Location}"/>
<CheckBox x:Name="xmlDocumentationCheckBox" Grid.Row="2" Grid.Column="1"
VerticalAlignment="Center"
IsChecked="{Binding DocumentFileIsChecked}"
Content="{core:Localize Dialog.ProjectOptions.Build.XmlDocumentationFile}"></CheckBox>
<TextBox
x:Name="xmlDocumentationTextBox"
<TextBox x:Name="xmlDocumentationTextBox"
Grid.ColumnSpan="2"
Grid.Row="2"
Grid.Column="2"
IsEnabled="{Binding DocumentFileIsChecked}"
Text="{Binding DocumentationFile.Value, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<optionpanels:StorageLocationPicker
Grid.Row="3"
Location="{Binding DebugType.Location}"
DockPanel.Dock="Left" />
<optionpanels:StorageLocationPicker Grid.Row="3" DockPanel.Dock="Left" Location="{Binding DebugType.Location}" />
<Label
Grid.Row="3"
Grid.Column="1"
@ -225,6 +219,14 @@ @@ -225,6 +219,14 @@
<ColumnDefinition
Width="50"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- location multibinding http://dotnet-forum.de/blogs/larsschmitt/archive/2009/11/07/wpf-multibinding.aspx -->
<optionpanels:StorageLocationPicker
Grid.Row="2"
Location="{Binding dddddd.Location}"
DockPanel.Dock="Left" />
<CheckBox
x:Name="registerCOMInteropCheckBox"
Grid.Column="2"
@ -245,10 +247,7 @@ @@ -245,10 +247,7 @@
DisplayMemberPath="DisplayValue"
SelectedValuePath="Key"
SelectedIndex="2"></ComboBox>
<optionpanels:StorageLocationPicker
Grid.Row="2"
Location="{Binding AssemblyName.Location}"
DockPanel.Dock="Left" />
<Label
Grid.Row="2"
Grid.Column="1"
@ -290,15 +289,22 @@ @@ -290,15 +289,22 @@
<TextBox
x:Name="dllBaseAddressTextBox"
Grid.Row="4"
Grid.Column="2"
Text="{Binding BaseAddress.Value, UpdateSourceTrigger=PropertyChanged}"></TextBox>
Grid.Column="2">
<TextBox.Text>
<Binding Path="BaseAddress.Value" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:HexValidator />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<!-- location multibinding -->
<Label
Grid.Row="6"
Grid.ColumnSpan="2"
Content="{core:Localize Dialog.ProjectOptions.Build.BaseIntermediateOutputPath}"></Label>
<!-- ok -->
<optionpanels:StorageLocationPicker
Grid.Row="7"
Location="{Binding BaseIntermediateOutputPath.Location}"
@ -389,23 +395,16 @@ @@ -389,23 +395,16 @@
<GroupBox
Margin="0,8,0,0"
Header="{core:Localize Dialog.ProjectOptions.Build.TreatWarningsAsErrors}">
<Grid
ShowGridLines="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="25"></ColumnDefinition>
<ColumnDefinition
Width="*"></ColumnDefinition>
<ColumnDefinition
Width="3*"></ColumnDefinition>
<ColumnDefinition Width="25"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions>
<RadioButton
x:Name="noneRadioButton"

15
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Controls;
@ -85,11 +86,25 @@ namespace CSharpBinding.OptionPanels @@ -85,11 +86,25 @@ namespace CSharpBinding.OptionPanels
this.UpdateProjectCommand = new RelayCommand(UpdateProjectExecute);
this.ChangeOutputPath = new RelayCommand(ChangeOutputPathExecute);
UpdateTargetFrameworkCombo();
if (DocumentationFile.Value.Length > 0) {
documentFileIsChecked = true;
}
XmlDocHelper();
this.BaseIntermediateOutputPathCommand = new RelayCommand(BaseIntermediateOutputPathExecute);
this.IntermediateOutputPathCommand = new RelayCommand(IntermediateOutputPathExecute);
SetTreatWarningAsErrorRadioButtons();
this.DefineConstants.Location = PropertyStorageLocations.ConfigurationSpecific;
this.Optimize.Location = PropertyStorageLocations.ConfigurationSpecific;
this.AllowUnsafeBlocks.Location = PropertyStorageLocations.ConfigurationSpecific;
this.CheckForOverflowUnderflow.Location = PropertyStorageLocations.ConfigurationSpecific;
base.RaisePropertyChanged(string.Empty);
var s = BaseAddress.Value;
int val;
if (!int.TryParse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out val)) {
val = 32;
}
var x = val;
var y = "0x" + val.ToString("x", NumberFormatInfo.InvariantInfo);
}
#region properties

32
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/HexValidator.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 22.05.2012
* Time: 20:46
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Globalization;
using System.Windows.Controls;
namespace CSharpBinding.OptionPanels
{
/// <summary>
/// Description of HexValidator.
/// </summary>
public class HexValidator :ValidationRule
{
// http://www.codeproject.com/Articles/15239/Validation-in-Windows-Presentation-Foundation
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
ValidationResult result = new ValidationResult(true, null);
var str = value.ToString();
var y = 0;
var res = Int32.TryParse(str,NumberStyles.HexNumber,CultureInfo.InvariantCulture,out y);
if (!res) {
result = new ValidationResult(false, "No Valid hex Digit");
}
return result;
}
}
}
Loading…
Cancel
Save