Browse Source

Add support for WPF project option pages (ProjectOptionPanel base class + WPF StorageLocationPicker).

Ported BuildEvents project option page to WPF.
pull/23/head
Daniel Grunwald 14 years ago
parent
commit
1787d2b699
  1. 2
      SharpDevelop.sln
  2. 5
      src/AddIns/BackendBindings/CppBinding/CppBinding/CppBinding.addin
  3. 3
      src/AddIns/BackendBindings/CppBinding/CppBinding/Project/BuildEventOptions.cs
  4. 6
      src/Main/Base/Project/Configuration/AssemblyInfo.cs
  5. 11
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  6. 72
      src/Main/Base/Project/Resources/ProjectOptions/BuildEvents.xfrm
  7. 2
      src/Main/Base/Project/Src/Gui/App.xaml
  8. 34
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.cs
  9. 32
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.xaml
  10. 267
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.cs
  11. 62
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.xaml
  12. 149
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/StorageLocationPicker.cs
  13. 79
      src/Main/Base/Project/Src/Gui/EnumBinding.cs
  14. 7
      src/Main/Base/Project/themes/generic.xaml
  15. 1
      src/Main/ICSharpCode.Core.Presentation/LocalizeExtension.cs
  16. 2
      src/Main/ICSharpCode.SharpDevelop.Widgets/Project/RadioButtonGroup.cs

2
SharpDevelop.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.2.0.7998-alpha
# SharpDevelop 4.2.0.8103-alpha
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection

5
src/AddIns/BackendBindings/CppBinding/CppBinding/CppBinding.addin

@ -23,9 +23,10 @@ @@ -23,9 +23,10 @@
<OptionPanel id = "Linker"
label = "${res:ICSharpCode.CppBinding.ProjectOptions.Linker}"
class = "ICSharpCode.CppBinding.Project.LinkerOptions" />
<OptionPanel id = "BuildEvents"
<!--<OptionPanel id = "BuildEvents"
label = "${res:Dialog.ProjectOptions.BuildEvents}"
class = "ICSharpCode.CppBinding.Project.BuildEventOptions"/>
class = "ICSharpCode.CppBinding.Project.BuildEventOptions"/>-->
<!--<OptionPanel id = "ReferencePaths"
label = "${res:Dialog.ProjectOptions.ReferencePaths}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.ReferencePaths"/>

3
src/AddIns/BackendBindings/CppBinding/CppBinding/Project/BuildEventOptions.cs

@ -14,6 +14,7 @@ using System.Windows.Forms; @@ -14,6 +14,7 @@ using System.Windows.Forms;
namespace ICSharpCode.CppBinding.Project
{
/*
/// <summary>
/// Description of BuildEventOptions.
/// </summary>
@ -32,5 +33,5 @@ namespace ICSharpCode.CppBinding.Project @@ -32,5 +33,5 @@ namespace ICSharpCode.CppBinding.Project
ComboBox runPostBuildEventComboBox = Get<ComboBox>("runPostBuildEvent");
runPostBuildEventComboBox.Enabled = false;
}
}
}*/
}

6
src/Main/Base/Project/Configuration/AssemblyInfo.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows;
[assembly: CLSCompliant(false)]
[assembly: StringFreezing()]
@ -22,6 +23,11 @@ using System.Runtime.CompilerServices; @@ -22,6 +23,11 @@ using System.Runtime.CompilerServices;
[assembly: Dependency("System.Xml", LoadHint.Always)]
[assembly: Dependency("System.Windows.Forms", LoadHint.Always)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly, //where theme specific resource dictionaries are located
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
)]
[assembly: AssemblyTitle("SharpDevelopBase")]
[assembly: AssemblyDescription("The base add-in of SharpDevelop")]
[assembly: AssemblyConfiguration("")]

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

@ -243,6 +243,8 @@ @@ -243,6 +243,8 @@
<DependentUpon>SelectCulturePanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\ProjectOptionPanel.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\StorageLocationPicker.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\WebProjectOptions\WebProjectOptions.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\WebProjectOptions\WebProjectOptionsPanel.xaml.cs">
<DependentUpon>WebProjectOptionsPanel.xaml</DependentUpon>
@ -264,6 +266,7 @@ @@ -264,6 +266,7 @@
<DependentUpon>TreeViewOptionsDialog.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\EnumBinding.cs" />
<Compile Include="Src\Gui\IImage.cs" />
<Compile Include="Src\Gui\Pads\AbstractConsolePad.cs" />
<Compile Include="Src\Gui\Pads\BaseWatchBox.cs" />
@ -666,7 +669,6 @@ @@ -666,7 +669,6 @@
<Compile Include="Src\Gui\Pads\PropertyPad\PropertyContainer.cs" />
<EmbeddedResource Include="Resources\ProjectOptions\Publish.xfrm" />
<EmbeddedResource Include="Resources\ProjectOptions\Signing.xfrm" />
<EmbeddedResource Include="Resources\ProjectOptions\BuildEvents.xfrm" />
<EmbeddedResource Include="Resources\ProjectOptions\DebugOptions.xfrm" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\Signing.cs">
<SubType>UserControl</SubType>
@ -682,6 +684,7 @@ @@ -682,6 +684,7 @@
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.cs">
<SubType>UserControl</SubType>
<DependentUpon>BuildEvents.xaml</DependentUpon>
</Compile>
<Compile Include="Src\Gui\BrowserDisplayBinding\SchemeExtension.cs" />
<Compile Include="Src\Gui\BrowserDisplayBinding\ExtendedWebBrowser.cs">
@ -821,10 +824,15 @@ @@ -821,10 +824,15 @@
</ItemGroup>
<ItemGroup>
<Page Include="Src\Bookmarks\Pad\Controls\ListViewPad.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\ProjectOptionPanel.xaml">
<DependentUpon>ProjectOptionPanel.cs</DependentUpon>
</Page>
<Page Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\WebProjectOptions\WebProjectOptionsPanel.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsBulbControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsHeaderedControl.xaml" />
<Page Include="themes\generic.xaml" />
<ProjectReference Include="..\..\..\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj">
<Project>{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}</Project>
<Name>AvalonDock</Name>
@ -849,6 +857,7 @@ @@ -849,6 +857,7 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Folder Include="themes" />
<Folder Include="Src\Bookmarks\Pad\Controls" />
<Folder Include="Src\Editor\AvalonEdit" />
<Folder Include="Src\Editor\CodeCompletion" />

72
src/Main/Base/Project/Resources/ProjectOptions/BuildEvents.xfrm

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="XmlUserControl1" />
<ClientSize value="{Width=384, Height=355}" />
<Controls>
<System.Windows.Forms.GroupBox>
<Name value="groupBox1" />
<Location value="8, 8" />
<Text value="${res:Dialog.ProjectOptions.BuildEvents}" />
<Size value="364, 285" />
<Anchor value="Top, Left, Right" />
<TabIndex value="0" />
<Controls>
<System.Windows.Forms.ComboBox>
<Name value="runPostBuildEventComboBox" />
<TabIndex value="8" />
<Location value="6, 255" />
<Anchor value="Top, Left, Right" />
<Size value="184, 21" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label>
<Name value="label3" />
<Location value="6, 229" />
<Text value="${res:Dialog.ProjectOptions.BuildEvents.RunPostBuild}" />
<Size value="352, 23" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="7" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="postBuildEventTextBox" />
<TabIndex value="5" />
<Location value="6, 151" />
<Anchor value="Top, Left, Right" />
<ScrollBars value="Both" />
<Size value="348, 75" />
<Multiline value="True" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="label2" />
<Location value="6, 125" />
<Text value="${res:Dialog.ProjectOptions.BuildEvents.PostBuild}" />
<Size value="344, 23" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="4" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="preBuildEventTextBox" />
<TabIndex value="2" />
<Location value="8, 49" />
<Anchor value="Top, Left, Right" />
<ScrollBars value="Both" />
<Size value="346, 75" />
<Multiline value="True" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="label1" />
<Location value="8, 23" />
<Text value="${res:Dialog.ProjectOptions.BuildEvents.PreBuild}" />
<Size value="344, 23" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

2
src/Main/Base/Project/Src/Gui/App.xaml

@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core = "http://icsharpcode.net/sharpdevelop/core"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels"
xmlns:avalondock = "clr-namespace:AvalonDock;assembly=AvalonDock">
<Application.Resources>
<!-- Style AvalonDock windows -->
<Style TargetType="{x:Type avalondock:DockableFloatingWindow}" BasedOn="{x:Static core:GlobalStyles.WindowStyle}"/>

34
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.cs

@ -7,27 +7,23 @@ using ICSharpCode.SharpDevelop.Project; @@ -7,27 +7,23 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public class BuildEvents : AbstractXmlFormsProjectOptionPanel
partial class BuildEvents : ProjectOptionPanel
{
public override void LoadPanelContents()
public BuildEvents()
{
SetupFromXmlResource("ProjectOptions.BuildEvents.xfrm");
InitializeHelper();
baseDirectory = Path.GetDirectoryName(project.OutputAssemblyFullPath);
ConfigurationGuiBinding b;
b = helper.BindString("preBuildEventTextBox", "PreBuildEvent", TextBoxEditMode.EditRawProperty);
b.CreateLocationButton("preBuildEventTextBox");
b = helper.BindString("postBuildEventTextBox", "PostBuildEvent", TextBoxEditMode.EditRawProperty);
b.CreateLocationButton("postBuildEventTextBox");
b = helper.BindEnum<RunPostBuildEvent>("runPostBuildEventComboBox", "RunPostBuildEvent");
b.CreateLocationButton("runPostBuildEventComboBox");
helper.AddConfigurationSelector(this);
InitializeComponent();
}
public ProjectProperty<string> PreBuildEvent {
get { return GetProperty("PreBuildEvent", "", TextBoxEditMode.EditRawProperty); }
}
public ProjectProperty<string> PostBuildEvent {
get { return GetProperty("PostBuildEvent", "", TextBoxEditMode.EditRawProperty); }
}
public ProjectProperty<RunPostBuildEvent> RunPostBuildEvent {
get { return GetProperty("RunPostBuildEvent", Project.RunPostBuildEvent.OnBuildSuccess); }
}
}
}

32
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.xaml

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
<optionpanels:ProjectOptionPanel x:Class="ICSharpCode.SharpDevelop.Gui.OptionPanels.BuildEvents"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels">
<GroupBox Header="{core:Localize Dialog.ProjectOptions.BuildEvents}">
<StackPanel>
<Label Content="{core:Localize Dialog.ProjectOptions.BuildEvents.PreBuild}" Target="{Binding ElementName=preBuild}"/>
<DockPanel>
<optionpanels:StorageLocationPicker Location="{Binding PreBuildEvent.Location}" DockPanel.Dock="Left" />
<TextBox Name="preBuild" Text="{Binding PreBuildEvent.Value, UpdateSourceTrigger=PropertyChanged}" Height="75"
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" />
</DockPanel>
<Label Content="{core:Localize Dialog.ProjectOptions.BuildEvents.PostBuild}" Target="{Binding ElementName=postBuild}"/>
<DockPanel>
<optionpanels:StorageLocationPicker Location="{Binding PostBuildEvent.Location}" DockPanel.Dock="Left" />
<TextBox Name="postBuild" Text="{Binding PostBuildEvent.Value, UpdateSourceTrigger=PropertyChanged}" Height="75"
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" />
</DockPanel>
<Label Content="{core:Localize Dialog.ProjectOptions.BuildEvents.RunPostBuild}" />
<DockPanel>
<optionpanels:StorageLocationPicker Location="{Binding RunPostBuildEvent.Location}" DockPanel.Dock="Left" />
<ComboBox gui:EnumBinding.EnumType="{x:Type project:RunPostBuildEvent}" SelectedValue="{Binding RunPostBuildEvent.Value}" />
</DockPanel>
</StackPanel>
</GroupBox>
</optionpanels:ProjectOptionPanel>

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

@ -0,0 +1,267 @@ @@ -0,0 +1,267 @@
// 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 System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
/// <summary>
/// Base class for project option panels with configuration picker.
/// </summary>
public class ProjectOptionPanel : UserControl, IOptionPanel, ICanBeDirty
{
static ProjectOptionPanel()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ProjectOptionPanel), new FrameworkPropertyMetadata(typeof(ProjectOptionPanel)));
}
public ProjectOptionPanel()
{
this.DataContext = this;
}
ComboBox configurationComboBox;
ComboBox platformComboBox;
MSBuildBasedProject project;
string activeConfiguration;
string activePlatform;
bool resettingIndex;
protected virtual void Load(MSBuildBasedProject project, string configuration, string platform)
{
foreach (IProjectProperty p in projectProperties.Values)
p.Load(project, configuration, platform);
this.IsDirty = false;
}
protected virtual bool Save(MSBuildBasedProject project, string configuration, string platform)
{
foreach (IProjectProperty p in projectProperties.Values)
p.Save(project, configuration, platform);
this.IsDirty = false;
return true;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
configurationComboBox = Template.FindName("PART_configuration", this) as ComboBox;
platformComboBox = Template.FindName("PART_platform", this) as ComboBox;
}
object owner;
object IOptionPanel.Owner {
get { return owner; }
set { owner = value; }
}
object IOptionPanel.Control {
get { return this; }
}
void IOptionPanel.LoadOptions()
{
ApplyTemplate();
project = (MSBuildBasedProject)owner;
if (configurationComboBox != null) {
List<string> configurations = project.ConfigurationNames.Union(new[] { project.ActiveConfiguration }).ToList();
configurations.Sort();
configurationComboBox.ItemsSource = configurations;
configurationComboBox.SelectedItem = project.ActiveConfiguration;
configurationComboBox.SelectionChanged += comboBox_SelectionChanged;
}
if (platformComboBox != null) {
List<string> platforms = project.PlatformNames.Union(new[] { project.ActivePlatform }).ToList();
platforms.Sort();
platformComboBox.ItemsSource = platforms;
platformComboBox.SelectedItem = project.ActivePlatform;
platformComboBox.SelectionChanged += comboBox_SelectionChanged;
}
Load();
}
void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (resettingIndex)
return;
if (isDirty) {
if (!MessageService.AskQuestion("${res:Dialog.ProjectOptions.ContinueSwitchConfiguration}")) {
ResetComboBoxIndex();
return;
}
if (!Save(project, activeConfiguration, activePlatform)) {
ResetComboBoxIndex();
return;
}
project.Save();
}
Load();
}
void ResetComboBoxIndex()
{
resettingIndex = true;
if (configurationComboBox != null)
configurationComboBox.SelectedItem = activeConfiguration;
if (platformComboBox != null)
platformComboBox.SelectedItem = activePlatform;
resettingIndex = false;
}
void Load()
{
if (configurationComboBox != null)
activeConfiguration = (string)configurationComboBox.SelectedItem;
else
activeConfiguration = project.ActiveConfiguration;
if (platformComboBox != null)
activePlatform = (string)platformComboBox.SelectedItem;
else
activePlatform = project.ActivePlatform;
Load(project, activeConfiguration, activePlatform);
}
bool IOptionPanel.SaveOptions()
{
return Save(project, activeConfiguration, activePlatform);
}
bool isDirty;
public bool IsDirty {
get { return isDirty; }
set {
if (isDirty != value) {
isDirty = value;
if (IsDirtyChanged != null)
IsDirtyChanged(this, EventArgs.Empty);
}
}
}
public event EventHandler IsDirtyChanged;
#region Manage MSBuild properties
Dictionary<string, IProjectProperty> projectProperties = new Dictionary<string, IProjectProperty>();
public ProjectProperty<string> GetProperty(string propertyName, string defaultValue,
TextBoxEditMode textBoxEditMode = TextBoxEditMode.EditEvaluatedProperty,
PropertyStorageLocations defaultLocation = PropertyStorageLocations.Base)
{
IProjectProperty existingProperty;
if (projectProperties.TryGetValue(propertyName, out existingProperty))
return (ProjectProperty<string>)existingProperty;
bool treatAsLiteral = (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty);
ProjectProperty<string> newProperty = new ProjectProperty<string>(this, propertyName, defaultValue, defaultLocation, treatAsLiteral);
projectProperties.Add(propertyName, newProperty);
return newProperty;
}
public ProjectProperty<T> GetProperty<T>(string propertyName, T defaultValue,
PropertyStorageLocations defaultLocation = PropertyStorageLocations.Base)
{
IProjectProperty existingProperty;
if (projectProperties.TryGetValue(propertyName, out existingProperty))
return (ProjectProperty<T>)existingProperty;
ProjectProperty<T> newProperty = new ProjectProperty<T>(this, propertyName, defaultValue, defaultLocation, true);
projectProperties.Add(propertyName, newProperty);
return newProperty;
}
interface IProjectProperty
{
void Load(MSBuildBasedProject project, string configuration, string platform);
void Save(MSBuildBasedProject project, string configuration, string platform);
}
public class ProjectProperty<T> : IProjectProperty, INotifyPropertyChanged
{
readonly ProjectOptionPanel parentPanel;
readonly string propertyName;
readonly T defaultValue;
readonly PropertyStorageLocations defaultLocation;
readonly bool treatPropertyValueAsLiteral;
T val;
PropertyStorageLocations location;
public ProjectProperty(ProjectOptionPanel parentPanel, string propertyName, T defaultValue, PropertyStorageLocations defaultLocation, bool treatPropertyValueAsLiteral)
{
this.parentPanel = parentPanel;
this.propertyName = propertyName;
this.defaultValue = defaultValue;
this.defaultLocation = defaultLocation;
this.treatPropertyValueAsLiteral = treatPropertyValueAsLiteral;
this.val = defaultValue;
this.location = defaultLocation;
}
public string PropertyName {
get { return propertyName; }
}
public T Value {
get { return val; }
set {
if (!object.Equals(val, value)) {
val = value;
if (PropertyChanged != null)
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Value"));
parentPanel.IsDirty = true;
}
}
}
public PropertyStorageLocations Location {
get { return location; }
set {
if (location != value) {
location = value;
if (PropertyChanged != null)
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Location"));
parentPanel.IsDirty = true;
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
public void Load(MSBuildBasedProject project, string configuration, string platform)
{
PropertyStorageLocations newLocation;
string v;
if (treatPropertyValueAsLiteral)
v = project.GetProperty(configuration, platform, propertyName, out newLocation);
else
v = project.GetUnevalatedProperty(configuration, platform, propertyName, out newLocation);
if (newLocation == PropertyStorageLocations.Unknown)
newLocation = defaultLocation;
this.Value = GenericConverter.FromString(v, defaultValue);
this.Location = newLocation;
}
public void Save(MSBuildBasedProject project, string configuration, string platform)
{
string newValue = GenericConverter.ToString(val);
project.SetProperty(configuration, platform, propertyName, newValue, location, treatPropertyValueAsLiteral);
}
}
#endregion
}
}

62
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.xaml

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels">
<Style TargetType="{x:Type optionpanels:ProjectOptionPanel}" BasedOn="{StaticResource {x:Type UserControl}}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="optionpanels:ProjectOptionPanel">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Label Content="{core:StringParse ${res:Dialog.ProjectOptions.Configuration}:}" Target="{Binding ElementName=PART_configuration}" />
<ComboBox Name="PART_configuration" Width="120" />
<Label Content="{core:StringParse ${res:Dialog.ProjectOptions.Platform}:}" Target="{Binding ElementName=PART_platform}" />
<ComboBox Name="PART_platform" Width="120" />
</StackPanel>
<Line X1="0" X2="1" Margin="0,4" StrokeThickness="3" Stroke="Gray" DockPanel.Dock="Top" Stretch="Fill"/>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type optionpanels:StorageLocationPicker}">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
<Setter Property="Margin" Value="0,0,7,0" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="optionpanels:StorageLocationPicker">
<Button Name="PART_button" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Grid>
<Ellipse Name="ellipse" Fill="{TemplateBinding EllipseBackground}" Width="8" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Path Name="uPath" Data="M .5,.5 V 6.5 H 4.5 V 0.5" SnapsToDevicePixels="True"
StrokeThickness="1" Stroke="DarkGreen"
HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" />
</Grid>
</Button>
<ControlTemplate.Triggers>
<Trigger Property="IsUserFile" Value="true">
<Setter TargetName="uPath" Property="Visibility" Value="Visible" />
<Setter TargetName="ellipse" Property="HorizontalAlignment" Value="Left" />
<Setter TargetName="ellipse" Property="VerticalAlignment" Value="Top" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

149
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/StorageLocationPicker.cs

@ -0,0 +1,149 @@ @@ -0,0 +1,149 @@
// 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 System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
/// <summary>
/// Allows choosing the storage location for an MSBuild property.
/// </summary>
public class StorageLocationPicker : Control
{
static StorageLocationPicker()
{
// Style is defined in ProjectOptionPanel.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(StorageLocationPicker), new FrameworkPropertyMetadata(typeof(StorageLocationPicker)));
}
public static readonly DependencyProperty LocationProperty =
DependencyProperty.Register(
"Location", typeof(PropertyStorageLocations), typeof(StorageLocationPicker),
new FrameworkPropertyMetadata(PropertyStorageLocations.Base, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnLocationChanged, CoerceLocation));
public PropertyStorageLocations Location {
get { return (PropertyStorageLocations)GetValue(LocationProperty); }
set { SetValue(LocationProperty, value); }
}
internal static readonly DependencyProperty EllipseBackgroundProperty =
DependencyProperty.Register("EllipseBackground", typeof(Brush), typeof(StorageLocationPicker),
new FrameworkPropertyMetadata(Brushes.Black));
internal Brush EllipseBackground {
get { return (Brush)GetValue(EllipseBackgroundProperty); }
set { SetValue(EllipseBackgroundProperty, value); }
}
internal static readonly DependencyProperty IsUserFileProperty =
DependencyProperty.Register("IsUserFile", typeof(bool), typeof(StorageLocationPicker),
new FrameworkPropertyMetadata(false));
internal bool IsUserFile {
get { return (bool)GetValue(IsUserFileProperty); }
set { SetValue(IsUserFileProperty, value); }
}
static void OnLocationChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
StorageLocationPicker p = o as StorageLocationPicker;
if (p != null) {
PropertyStorageLocations location = (PropertyStorageLocations)e.NewValue;
p.IsUserFile = (location & PropertyStorageLocations.UserFile) == PropertyStorageLocations.UserFile;
switch (location & PropertyStorageLocations.ConfigurationAndPlatformSpecific) {
case PropertyStorageLocations.ConfigurationSpecific:
p.EllipseBackground = Brushes.Blue;
break;
case PropertyStorageLocations.PlatformSpecific:
p.EllipseBackground = Brushes.Red;
break;
case PropertyStorageLocations.ConfigurationAndPlatformSpecific:
p.EllipseBackground = Brushes.Violet;
break;
default:
p.EllipseBackground = Brushes.Black;
break;
}
if (p.contextMenu != null) {
p.SetIsCheckedOnMenu(location);
}
}
}
static object CoerceLocation(DependencyObject d, object baseValue)
{
PropertyStorageLocations location = (PropertyStorageLocations)baseValue;
if ((location & PropertyStorageLocations.ConfigurationAndPlatformSpecific) != 0) {
// remove 'Base' flag if any of the specific flags is set
location &= ~PropertyStorageLocations.Base;
} else {
// otherwise, add 'Base' flag
location |= PropertyStorageLocations.Base;
}
return location;
}
ContextMenu contextMenu;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
Button button = Template.FindName("PART_button", this) as Button;
if (button != null) {
button.Click += button_Click;
contextMenu = new ContextMenu();
contextMenu.Items.Add(CreateMenuItem("${res:Dialog.ProjectOptions.ConfigurationSpecific}", PropertyStorageLocations.ConfigurationSpecific));
contextMenu.Items.Add(CreateMenuItem("${res:Dialog.ProjectOptions.PlatformSpecific}", PropertyStorageLocations.PlatformSpecific));
contextMenu.Items.Add(CreateMenuItem("${res:Dialog.ProjectOptions.StoreInUserFile}", PropertyStorageLocations.UserFile));
contextMenu.Items.Add(new Separator());
MenuItem helpButton = new MenuItem();
helpButton.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("Global.HelpButtonText"));
helpButton.Click += delegate(object sender, RoutedEventArgs e) {
e.Handled = true;
Core.MessageService.ShowMessage("${res:Dialog.ProjectOptions.StorageLocationHelp}");
};
contextMenu.Items.Add(helpButton);
button.ContextMenu = contextMenu;
SetIsCheckedOnMenu(this.Location);
}
}
void SetIsCheckedOnMenu(PropertyStorageLocations location)
{
((MenuItem)contextMenu.Items[0]).IsChecked = (location & PropertyStorageLocations.ConfigurationSpecific) != 0;
((MenuItem)contextMenu.Items[1]).IsChecked = (location & PropertyStorageLocations.PlatformSpecific) != 0;
((MenuItem)contextMenu.Items[2]).IsChecked = (location & PropertyStorageLocations.UserFile) != 0;
}
MenuItem CreateMenuItem(string text, PropertyStorageLocations location)
{
MenuItem item = new MenuItem();
item.SetValueToExtension(MenuItem.HeaderProperty, new StringParseExtension(text));
item.Click += delegate(object sender, RoutedEventArgs e) {
if ((this.Location & location) == 0) {
this.Location |= location;
} else {
this.Location &= ~location;
}
e.Handled = true;
};
return item;
}
void button_Click(object sender, RoutedEventArgs e)
{
e.Handled = true;
contextMenu.IsOpen = true;
}
}
}

79
src/Main/Base/Project/Src/Gui/EnumBinding.cs

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
// 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 System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// Used to bind ComboBoxes or RadioButtonGroups to enums.
/// </summary>
public static class EnumBinding
{
public static readonly DependencyProperty EnumTypeProperty =
DependencyProperty.RegisterAttached("EnumType", typeof(Type), typeof(EnumBinding),
new FrameworkPropertyMetadata(OnEnumTypePropertyChanged));
public static Type GetEnumType(Selector element)
{
return (Type)element.GetValue(EnumTypeProperty);
}
public static void SetEnumType(Selector element, Type enumType)
{
element.SetValue(EnumTypeProperty, enumType);
}
static string GetDescription(FieldInfo field)
{
foreach (DescriptionAttribute d in field.GetCustomAttributes(typeof(DescriptionAttribute), false))
return d.Description;
return field.Name;
}
static void OnEnumTypePropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
Type enumType = e.NewValue as Type;
if (enumType != null && enumType.IsEnum) {
ComboBox comboBox = o as ComboBox;
if (comboBox != null) {
comboBox.SelectedValuePath = "Tag";
comboBox.Items.Clear();
foreach (FieldInfo field in enumType.GetFields()) {
if (field.IsStatic) {
ComboBoxItem item = new ComboBoxItem();
item.Tag = field.GetValue(null);
string description = GetDescription(field);
item.SetValueToExtension(ComboBoxItem.ContentProperty, new StringParseExtension(description));
comboBox.Items.Add(item);
}
}
}
RadioButtonGroup rbg = o as RadioButtonGroup;
if (rbg != null) {
rbg.Items.Clear();
foreach (FieldInfo field in enumType.GetFields()) {
if (field.IsStatic) {
RadioButton b = new RadioButton();
b.Tag = field.GetValue(null);
string description = GetDescription(field);
b.SetValueToExtension(RadioButton.ContentProperty, new StringParseExtension(description));
rbg.Items.Add(b);
}
}
}
}
}
}
}

7
src/Main/Base/Project/themes/generic.xaml

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.SharpDevelop;component/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ProjectOptionPanel.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

1
src/Main/ICSharpCode.Core.Presentation/LocalizeExtension.cs

@ -113,5 +113,4 @@ namespace ICSharpCode.Core.Presentation @@ -113,5 +113,4 @@ namespace ICSharpCode.Core.Presentation
return true;
}
}
}

2
src/Main/ICSharpCode.SharpDevelop.Widgets/Project/RadioButtonGroup.cs

@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

Loading…
Cancel
Save