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

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

@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using Gui.Dialogs.OptionPanels.ProjectOptions;
@ -70,7 +72,7 @@ namespace CSharpBinding.OptionPanels @@ -70,7 +72,7 @@ namespace CSharpBinding.OptionPanels
this.warnLevel.Add(new KeyItemPair("2","2"));
this.warnLevel.Add(new KeyItemPair("3","3"));
this.warnLevel.Add(new KeyItemPair("4","4"));
this.WarnLevel = warnLevel;
this.WarnLevel = warnLevel;
}
private void Initialize()
@ -85,6 +87,7 @@ namespace CSharpBinding.OptionPanels @@ -85,6 +87,7 @@ namespace CSharpBinding.OptionPanels
this.BaseIntermediateOutputPathCommand = new RelayCommand(BaseIntermediateOutputPathExecute);
this.IntermediateOutputPathCommand = new RelayCommand(IntermediateOutputPathExecute);
SetTreatWarningAsErrorRadioButtons();
IsDirty = false;
}
#region properties
@ -146,7 +149,7 @@ namespace CSharpBinding.OptionPanels @@ -146,7 +149,7 @@ namespace CSharpBinding.OptionPanels
}
public ProjectProperty<string> BaseAddress {
get {return GetProperty("BaseAddress","0x400000",
get {return GetProperty("BaseAddress","1000",
TextBoxEditMode.EditEvaluatedProperty,PropertyStorageLocations.PlatformSpecific ); }
}
@ -198,6 +201,16 @@ namespace CSharpBinding.OptionPanels @@ -198,6 +201,16 @@ namespace CSharpBinding.OptionPanels
{
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);
}
#endregion
@ -268,8 +281,8 @@ namespace CSharpBinding.OptionPanels @@ -268,8 +281,8 @@ namespace CSharpBinding.OptionPanels
private void ChangeOutputPathExecute()
{
OutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}",
base.BaseDirectory,base.BaseDirectory,
outputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.BaseDirectory,base.BaseDirectory,
outputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.RaisePropertyChanged(()=> OutputPath);
}
@ -285,7 +298,7 @@ namespace CSharpBinding.OptionPanels @@ -285,7 +298,7 @@ namespace CSharpBinding.OptionPanels
}
#endregion
#region TargetCPU
@ -306,6 +319,54 @@ namespace CSharpBinding.OptionPanels @@ -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
#region BaseIntermediateOutputPath
@ -315,13 +376,13 @@ namespace CSharpBinding.OptionPanels @@ -315,13 +376,13 @@ namespace CSharpBinding.OptionPanels
set {this.baseIntermediateOutputPathCommand = value;
base.RaisePropertyChanged(() => BaseIntermediateOutputPathCommand);}
}
private void BaseIntermediateOutputPathExecute ()
{
BaseIntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}",
base.BaseDirectory,base.BaseDirectory,
this.baseIntermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.BaseDirectory,base.BaseDirectory,
this.baseIntermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.RaisePropertyChanged(()=> BaseIntermediateOutputPath);
}
@ -339,8 +400,8 @@ namespace CSharpBinding.OptionPanels @@ -339,8 +400,8 @@ namespace CSharpBinding.OptionPanels
private void IntermediateOutputPathExecute ()
{
IntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}",
base.BaseDirectory,base.BaseDirectory,
this.intermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.BaseDirectory,base.BaseDirectory,
this.intermediateOutputPathTextBox.Text,TextBoxEditMode.EditRawProperty);
base.RaisePropertyChanged(()=> IntermediateOutputPath);
}
@ -375,10 +436,10 @@ namespace CSharpBinding.OptionPanels @@ -375,10 +436,10 @@ namespace CSharpBinding.OptionPanels
this.specificWarningsRadioButton.Checked += ErrorButton_Checked;
}
private void SaveTreatWarningAsErrorRadioButtons()
private void SaveTreatWarningAsErrorRadioButtons()
{
if ((bool)this.noneRadioButton.IsChecked){
@ -403,4 +464,6 @@ namespace CSharpBinding.OptionPanels @@ -403,4 +464,6 @@ namespace CSharpBinding.OptionPanels
#endregion
}
}

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

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

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

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Controls;
@ -29,4 +30,24 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -29,4 +30,24 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
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