Browse Source

C# BuildOptions

pull/30/head
PeterForstmeier 13 years ago
parent
commit
d350c9cbde
  1. 17
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml
  2. 89
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml.cs
  3. 11
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml
  4. 21
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/HexValidator.cs

17
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml

@ -224,18 +224,25 @@
<Label Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" <Label Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right"
Content="{core:Localize Dialog.ProjectOptions.Build.DLLBaseAddress}"></Label> Content="{core:Localize Dialog.ProjectOptions.Build.DLLBaseAddress}"></Label>
<!-- Hex binding --> <!-- Hex binding
<!--x:Name="dllBaseAddressTextBox"-->
<TextBox Grid.Row="4" Grid.Column="2"> <TextBox x:Name="dllBaseAddressTextBox" Grid.Row="4" Grid.Column="2">
<TextBox.Text> <TextBox.Text>
<Binding Path="BaseAddress.Value" UpdateSourceTrigger="PropertyChanged"> <Binding Path="DllBaseAdress" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules> <Binding.ValidationRules>
<optionpanels:HexValidator /> <optionpanels:BaseAdressValidator />
</Binding.ValidationRules> </Binding.ValidationRules>
</Binding> </Binding>
</TextBox.Text> </TextBox.Text>
</TextBox> -->
<!--x:Name="dllBaseAddressTextBox"-->
<TextBox Grid.Row="4" Grid.Column="2"
Text="{Binding DllBaseAdress, UpdateSourceTrigger=PropertyChanged}">
</TextBox> </TextBox>
<!-- location multibinding --> <!-- location multibinding -->
<Label Grid.Row="6" Grid.ColumnSpan="2" <Label Grid.Row="6" Grid.ColumnSpan="2"
Content="{core:Localize Dialog.ProjectOptions.Build.BaseIntermediateOutputPath}"></Label> Content="{core:Localize Dialog.ProjectOptions.Build.BaseIntermediateOutputPath}"></Label>

89
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml.cs

@ -7,6 +7,8 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO; using System.IO;
using Gui.Dialogs.OptionPanels.ProjectOptions; using Gui.Dialogs.OptionPanels.ProjectOptions;
@ -70,7 +72,7 @@ namespace CSharpBinding.OptionPanels
this.warnLevel.Add(new KeyItemPair("2","2")); this.warnLevel.Add(new KeyItemPair("2","2"));
this.warnLevel.Add(new KeyItemPair("3","3")); this.warnLevel.Add(new KeyItemPair("3","3"));
this.warnLevel.Add(new KeyItemPair("4","4")); this.warnLevel.Add(new KeyItemPair("4","4"));
this.WarnLevel = warnLevel; this.WarnLevel = warnLevel;
} }
private void Initialize() private void Initialize()
@ -85,6 +87,7 @@ namespace CSharpBinding.OptionPanels
this.BaseIntermediateOutputPathCommand = new RelayCommand(BaseIntermediateOutputPathExecute); this.BaseIntermediateOutputPathCommand = new RelayCommand(BaseIntermediateOutputPathExecute);
this.IntermediateOutputPathCommand = new RelayCommand(IntermediateOutputPathExecute); this.IntermediateOutputPathCommand = new RelayCommand(IntermediateOutputPathExecute);
SetTreatWarningAsErrorRadioButtons(); SetTreatWarningAsErrorRadioButtons();
IsDirty = false;
} }
#region properties #region properties
@ -146,7 +149,7 @@ namespace CSharpBinding.OptionPanels
} }
public ProjectProperty<string> BaseAddress { public ProjectProperty<string> BaseAddress {
get {return GetProperty("BaseAddress","0x400000", get {return GetProperty("BaseAddress","1000",
TextBoxEditMode.EditEvaluatedProperty,PropertyStorageLocations.PlatformSpecific ); } TextBoxEditMode.EditEvaluatedProperty,PropertyStorageLocations.PlatformSpecific ); }
} }
@ -198,6 +201,16 @@ namespace CSharpBinding.OptionPanels
{ {
SaveTreatWarningAsErrorRadioButtons(); SaveTreatWarningAsErrorRadioButtons();
NumberStyles style = NumberStyles.Integer;
if (dllBaseAdress.StartsWith("0x")) {
dllBaseAdress = dllBaseAdress.Substring(2);
style = NumberStyles.HexNumber;
}
int val;
if (int.TryParse(dllBaseAdress, style, NumberFormatInfo.InvariantInfo, out val)) {
BaseAddress.Value = val.ToString(NumberFormatInfo.InvariantInfo);
}
return base.Save(project, configuration, platform); return base.Save(project, configuration, platform);
} }
#endregion #endregion
@ -268,8 +281,8 @@ namespace CSharpBinding.OptionPanels
private void ChangeOutputPathExecute() private void ChangeOutputPathExecute()
{ {
OutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", OutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}",
base.BaseDirectory,base.BaseDirectory, base.BaseDirectory,base.BaseDirectory,
outputPathTextBox.Text,TextBoxEditMode.EditRawProperty); outputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.RaisePropertyChanged(()=> OutputPath); base.RaisePropertyChanged(()=> OutputPath);
} }
@ -285,7 +298,7 @@ namespace CSharpBinding.OptionPanels
} }
#endregion #endregion
#region TargetCPU #region TargetCPU
@ -306,6 +319,54 @@ namespace CSharpBinding.OptionPanels
} }
} }
#endregion
#region DLL BaseAdress
private string dllBaseAdress;
public string DllBaseAdress {
get {
int val;
if (!int.TryParse(BaseAddress.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out val)) {
val = 1000;
}
return "0x" + val.ToString("x", NumberFormatInfo.InvariantInfo);
}
set {
dllBaseAdress = value;
if (CheckBaseAdress(value)) {
IsDirty = true;
base.RaisePropertyChanged(() => DllBaseAdress);
} else {
MessageService.ShowMessage("${res:Dialog.ProjectOptions.PleaseEnterValidNumber}");
}
}
}
private bool CheckBaseAdress(string toCheck)
{
NumberStyles style = NumberStyles.Integer;
if (toCheck.StartsWith("0x")) {
toCheck = toCheck.Substring(2);
style = NumberStyles.HexNumber;
}
if (!String.IsNullOrEmpty(toCheck)) {
int val;
if (int.TryParse(toCheck, style, NumberFormatInfo.InvariantInfo, out val)) {
return true;
} else {
MessageService.ShowMessage("${res:Dialog.ProjectOptions.PleaseEnterValidNumber}");
return false;
}
}
return false;
}
#endregion #endregion
#region BaseIntermediateOutputPath #region BaseIntermediateOutputPath
@ -315,13 +376,13 @@ namespace CSharpBinding.OptionPanels
set {this.baseIntermediateOutputPathCommand = value; set {this.baseIntermediateOutputPathCommand = value;
base.RaisePropertyChanged(() => BaseIntermediateOutputPathCommand);} base.RaisePropertyChanged(() => BaseIntermediateOutputPathCommand);}
} }
private void BaseIntermediateOutputPathExecute () private void BaseIntermediateOutputPathExecute ()
{ {
BaseIntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", BaseIntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}",
base.BaseDirectory,base.BaseDirectory, base.BaseDirectory,base.BaseDirectory,
this.baseIntermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty); this.baseIntermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.RaisePropertyChanged(()=> BaseIntermediateOutputPath); base.RaisePropertyChanged(()=> BaseIntermediateOutputPath);
} }
@ -339,8 +400,8 @@ namespace CSharpBinding.OptionPanels
private void IntermediateOutputPathExecute () private void IntermediateOutputPathExecute ()
{ {
IntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", IntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}",
base.BaseDirectory,base.BaseDirectory, base.BaseDirectory,base.BaseDirectory,
this.intermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty); this.intermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.RaisePropertyChanged(()=> IntermediateOutputPath); base.RaisePropertyChanged(()=> IntermediateOutputPath);
} }
@ -375,10 +436,10 @@ namespace CSharpBinding.OptionPanels
this.specificWarningsRadioButton.Checked += ErrorButton_Checked; this.specificWarningsRadioButton.Checked += ErrorButton_Checked;
} }
private void SaveTreatWarningAsErrorRadioButtons()
private void SaveTreatWarningAsErrorRadioButtons()
{ {
if ((bool)this.noneRadioButton.IsChecked){ if ((bool)this.noneRadioButton.IsChecked){
@ -403,4 +464,6 @@ namespace CSharpBinding.OptionPanels
#endregion #endregion
} }
} }

11
src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml

@ -241,15 +241,20 @@
Content="{core:Localize Dialog.ProjectOptions.Build.DLLBaseAddress}"></Label> Content="{core:Localize Dialog.ProjectOptions.Build.DLLBaseAddress}"></Label>
<!-- Hex binding --> <!-- Hex binding -->
<!--x:Name="dllBaseAddressTextBox"--> <!--x:Name="dllBaseAddressTextBox"
<TextBox Grid.Row="4" Grid.Column="2"> <TextBox Grid.Row="4" Grid.Column="2">
<TextBox.Text> <TextBox.Text>
<Binding Path="BaseAddress.Value" UpdateSourceTrigger="PropertyChanged"> <Binding Path="DllBaseAdress" UpdateSourceTrigger="LostFocus">
<Binding.ValidationRules> <Binding.ValidationRules>
<optionpanels:HexValidator /> <optionpanels:BaseAdressValidator />
</Binding.ValidationRules> </Binding.ValidationRules>
</Binding> </Binding>
</TextBox.Text> </TextBox.Text>
</TextBox>-->
<!-- Hex binding -->
<TextBox Grid.Row="4" Grid.Column="2"
Text="{Binding DllBaseAdress, UpdateSourceTrigger=LostFocus}">
</TextBox> </TextBox>
<!-- location multibinding --> <!-- location multibinding -->

21
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/HexValidator.cs

@ -6,6 +6,7 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System; using System;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Windows.Controls; using System.Windows.Controls;
@ -29,4 +30,24 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
return result; return result;
} }
} }
public class BaseAdressValidator :ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
Trace.WriteLine("-------------");
ValidationResult result = new ValidationResult(true, null);
string dllBaseAdress = value.ToString().Trim();
NumberStyles style = NumberStyles.Integer;
if (dllBaseAdress.StartsWith("0x")) {
dllBaseAdress = dllBaseAdress.Substring(2);
style = NumberStyles.HexNumber;
}
int val;
if (!int.TryParse(dllBaseAdress, style, NumberFormatInfo.InvariantInfo, out val)) {
result = new ValidationResult(false, "No valid Hex Digit");
}
return result;
}
}
} }

Loading…
Cancel
Save