Browse Source

Start Cleanup

pull/30/head
PeterForstmeier 13 years ago
parent
commit
585bb4e818
  1. 12
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptionsXaml.xaml.cs
  2. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 65
      src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
  4. 51
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs
  5. 58
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs

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

@ -278,8 +278,8 @@ namespace CSharpBinding.OptionPanels @@ -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 @@ -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 @@ -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

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -279,6 +279,7 @@ @@ -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>

65
src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs

@ -3,10 +3,11 @@ @@ -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 @@ -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 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -62,5 +66,60 @@ namespace ICSharpCode.SharpDevelop.Gui
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
}
}

51
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs

@ -0,0 +1,51 @@ @@ -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;
}
}
}

58
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs

@ -9,12 +9,17 @@ using System.Linq.Expressions; @@ -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 @@ -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
}
}

Loading…
Cancel
Save