Permalink
Browse files

Start Cleanup

  • Loading branch information...
1 parent b55cbb1 commit 585bb4e81836996c833550d0fbffcf045bcc97ac @PeterForstmeier PeterForstmeier committed May 26, 2012
@@ -278,8 +278,8 @@ public System.Windows.Input.ICommand ChangeOutputPath
}
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 @@ public string SelectedFileAlign
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 @@ private void BaseIntermediateOutputPathExecute ()
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
@@ -279,6 +279,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\KeyValuePair.cs" />
+ <Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\OptionsHelper.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\ProjectOptionPanel.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\ReferencePathsXAML.xaml.cs">
<DependentUpon>ReferencePathsXAML.xaml</DependentUpon>
@@ -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
/// <summary>
/// Simple implementation of IOptionPanel with support for OptionBinding markup extensions.
/// </summary>
- 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 @@ public virtual bool SaveOptions()
return true;
}
+
+
+ #region INotifyPropertyChanged implementation
+
+ protected void RaisePropertyChanged(string propertyName)
+ {
+ RaiseInternal(propertyName);
+ }
+
+
+ protected void RaisePropertyChanged<T>(Expression<Func<T>> 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<T>(Expression<Func<T>> 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
}
}
@@ -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
+{
+ /// <summary>
+ /// Description of OptionsHelper.
+ /// </summary>
+ 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;
+ }
+ }
+}
@@ -9,12 +9,17 @@
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 @@ private static String ExtractPropertyName<T>(Expression<Func<T>> propertyExpress
#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
+
}
}

0 comments on commit 585bb4e

Please sign in to comment.