diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs index aa0f7cb870..ff4a665762 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs @@ -278,8 +278,8 @@ namespace CSharpBinding.OptionPanels } private void ChangeOutputPathExecute() { - OutputPath.Value = base.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", - base.BaseDirectory,outputPathTextBox.Text); + OutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", + base.BaseDirectory,base.BaseDirectory,outputPathTextBox.Text); base.RaisePropertyChanged(()=> OutputPath); } @@ -339,8 +339,8 @@ namespace CSharpBinding.OptionPanels private void BaseIntermediateOutputPathExecute () { - BaseIntermediateOutputPath.Value = base.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", - base.BaseDirectory,this.baseIntermediateOutputPathTextBox.Text); + BaseIntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", + base.BaseDirectory,base.BaseDirectory,this.baseIntermediateOutputPathTextBox.Text); base.RaisePropertyChanged(()=> BaseIntermediateOutputPath); } @@ -357,8 +357,8 @@ namespace CSharpBinding.OptionPanels private void IntermediateOutputPathExecute () { - IntermediateOutputPath.Value = base.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", - base.BaseDirectory,this.intermediateOutputPathTextBox.Text); + IntermediateOutputPath.Value = OptionsHelper.BrowseForFolder("${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", + base.BaseDirectory,base.BaseDirectory,this.intermediateOutputPathTextBox.Text); base.RaisePropertyChanged(()=> IntermediateOutputPath); } #endregion diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 1c059d6106..974a92bdde 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -279,6 +279,7 @@ Code + ReferencePathsXAML.xaml diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs index 6310affe3c..55da6e4ca8 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs @@ -3,10 +3,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics; +using System.ComponentModel; +using System.Linq.Expressions; +using System.Reflection; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using ICSharpCode.Core.Presentation; @@ -15,8 +16,11 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// Simple implementation of IOptionPanel with support for OptionBinding markup extensions. /// - public class OptionPanel : UserControl, IOptionPanel, IOptionBindingContainer + public class OptionPanel : UserControl, IOptionPanel, IOptionBindingContainer,INotifyPropertyChanged { + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + static OptionPanel() { MarginProperty.OverrideMetadata(typeof(OptionPanel), @@ -62,5 +66,60 @@ namespace ICSharpCode.SharpDevelop.Gui return true; } + + + #region INotifyPropertyChanged implementation + + protected void RaisePropertyChanged(string propertyName) + { + RaiseInternal(propertyName); + } + + + protected void RaisePropertyChanged(Expression> propertyExpresssion) + { + var propertyName = ExtractPropertyName(propertyExpresssion); + RaiseInternal(propertyName); + } + + + private void RaiseInternal (string propertyName) + { + var handler = this.PropertyChanged; + if (handler != null) + { + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + + private static String ExtractPropertyName(Expression> propertyExpresssion) + { + if (propertyExpresssion == null) + { + throw new ArgumentNullException("propertyExpresssion"); + } + + var memberExpression = propertyExpresssion.Body as MemberExpression; + if (memberExpression == null) + { + throw new ArgumentException("The expression is not a member access expression.", "propertyExpresssion"); + } + + var property = memberExpression.Member as PropertyInfo; + if (property == null) + { + throw new ArgumentException("The member access expression does not access a property.", "propertyExpresssion"); + } + + var getMethod = property.GetGetMethod(true); + if (getMethod.IsStatic) + { + throw new ArgumentException("The referenced property is a static property.", "propertyExpresssion"); + } + + return memberExpression.Member.Name; + } + + #endregion } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs new file mode 100644 index 0000000000..a211d852b3 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs @@ -0,0 +1,51 @@ +// 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 Microsoft.Win32; +namespace ICSharpCode.SharpDevelop.Gui.OptionPanels +{ + /// + /// Description of OptionsHelper. + /// + public class OptionsHelper + { + + public static string BrowseForFolder(string description,string baseDirectory,string startLocation,string relativeLocation) + { + string startAt = startLocation; + if (!String.IsNullOrEmpty(relativeLocation)) { + startAt = FileUtility.GetAbsolutePath(startLocation,relativeLocation); + } + + + using (System.Windows.Forms.FolderBrowserDialog fdiag = FileService.CreateFolderBrowserDialog(description,startAt)) + { + if (fdiag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { + string path = fdiag.SelectedPath; + if (baseDirectory != null) { + path = FileUtility.GetRelativePath(baseDirectory, path); + } + if (!path.EndsWith("\\") && !path.EndsWith("/")) + path += "\\"; + return path; + } + + } + return startLocation; + } + + + public static string OpenFile (string filter) + { + var dialog = new OpenFileDialog(); + dialog.Filter = filter; + if (dialog.ShowDialog() ?? false) { + return dialog.FileName; + } + return string.Empty; + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs index 968290bee2..8bcd78ea59 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs @@ -9,12 +9,17 @@ using System.Linq.Expressions; using System.Reflection; using System.Windows; using System.Windows.Controls; -//using System.Windows.Forms; using System.Windows.Shapes; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Project; -using Microsoft.Win32; + +//using System.Windows.Forms; + + + + + namespace ICSharpCode.SharpDevelop.Gui.OptionPanels { @@ -360,53 +365,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels #endregion - - #region OpenFileDialog - -// protected string OpenFile(string fileFilter) -// { -// var dialog = new OpenFileDialog(); -// -// //dialog.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe"); -// var x = StringParser.Parse(fileFilter); -// dialog.Filter = StringParser.Parse(x); -// if (dialog.ShowDialog() ?? false) { -// return dialog.FileName; -// } -// return String.Empty; -// } -// - - protected string BrowseForFolder(string description,string startLocation,string relativeLocation) - { - string startAt = startLocation; - if (!String.IsNullOrEmpty(relativeLocation)) { - startAt = FileUtility.GetAbsolutePath(startLocation,relativeLocation); - } - - - using (System.Windows.Forms.FolderBrowserDialog fdiag = FileService.CreateFolderBrowserDialog(description,startAt)) - { - if (fdiag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - string path = fdiag.SelectedPath; - if (BaseDirectory != null) { - path = FileUtility.GetRelativePath(BaseDirectory, path); - } - if (!path.EndsWith("\\") && !path.EndsWith("/")) - path += "\\"; - -// if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { - //// panel.ControlDictionary[target].Text = path; -// } else { -// panel.ControlDictionary[target].Text = MSBuildInternals.Escape(path); - //// } - return path; - } - - } - return startLocation; - } - - #endregion + } }