Browse Source

- fixed bug in OptionBinding

- ported Profiler option panels to new architecture

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4898 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
7dc8e0b947
  1. 11
      src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj
  2. 2
      src/AddIns/Misc/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin
  3. 7
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfileExecutableForm.xaml.cs
  4. 4
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml.cs
  5. 31
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionPanels/General.cs
  6. 72
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionPanels/General.xaml
  7. 53
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionPanels/OptionWrapper.cs
  8. 82
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionsPanels/General.cs
  9. 53
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionsPanels/GeneralOptionsPanel.xaml
  10. 81
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionsPanels/GeneralOptionsPanel.xaml.cs
  11. 11
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs
  12. 36
      src/AddIns/Misc/Profiler/Profiler.sln
  13. 35
      src/Main/ICSharpCode.Core.Presentation/OptionBinding.cs

11
src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
<RootNamespace>ICSharpCode.Profiler.AddIn</RootNamespace>
<AssemblyName>ICSharpCode.Profiler.AddIn</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SourceAnalysisOverrideSettingsFile>C:\Dokumente und Einstellungen\HP\Anwendungsdaten\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
@ -63,12 +62,10 @@ @@ -63,12 +62,10 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Extensions.cs" />
<Compile Include="Src\OptionsPanels\General.cs">
</Compile>
<Compile Include="Src\OptionsPanels\GeneralOptionsPanel.xaml.cs">
<DependentUpon>GeneralOptionsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
<Compile Include="Src\OptionPanels\General.cs">
<DependentUpon>General.xaml</DependentUpon>
</Compile>
<Compile Include="Src\OptionPanels\OptionWrapper.cs" />
<Compile Include="Src\ProfilerRunner.cs" />
<Compile Include="Src\SharpDevelopTranslation.cs" />
<Compile Include="Src\Views\ProfilerView.xaml.cs">
@ -84,7 +81,7 @@ @@ -84,7 +81,7 @@
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Src\Dialogs\ProfilerControlWindow.xaml" />
<Page Include="Src\OptionsPanels\GeneralOptionsPanel.xaml" />
<Page Include="Src\OptionPanels\General.xaml" />
<Page Include="Src\Views\ProfilerView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

2
src/AddIns/Misc/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin

@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
<Path name="/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<OptionPanel id = "Profiling"
label = "${res:AddIns.Profiler.Options.Title}"
class = "ICSharpCode.Profiler.AddIn.OptionsPanels.General"
class = "ICSharpCode.Profiler.AddIn.OptionPanels.General"
insertbefore = "TextEditorOptions" />
</Path>

7
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfileExecutableForm.xaml.cs

@ -1,14 +1,13 @@ @@ -1,14 +1,13 @@
using ICSharpCode.SharpDevelop;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Windows;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.OptionsPanels;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Win32;

4
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs @@ -39,7 +39,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
try {
this.runner.Profiler.EnableDataCollection();
} catch (Exception ex) {
MessageService.ShowError(ex);
MessageService.ShowException(ex);
}
}
@ -48,7 +48,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs @@ -48,7 +48,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
try {
this.runner.Profiler.DisableDataCollection();
} catch (Exception ex) {
MessageService.ShowError(ex);
MessageService.ShowException(ex);
}
}

31
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionPanels/General.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using System.Windows.Threading;
namespace ICSharpCode.Profiler.AddIn.OptionPanels
{
/// <summary>
/// Description of General
/// </summary>
public partial class General : OptionPanel
{
public General()
{
InitializeComponent();
}
}
}

72
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionPanels/General.xaml

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel
x:Class="ICSharpCode.Profiler.AddIn.OptionPanels.General"
xmlns:sd="http://icsharpcode.net/sharpdevelop/core"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:addin="clr-namespace:ICSharpCode.Profiler.AddIn.OptionPanels;assembly=ICSharpCode.Profiler.AddIn">
<StackPanel
Orientation="Vertical">
<GroupBox
Header="{sd:Localize AddIns.Profiler.Options.General.DataCollection.Header}">
<StackPanel
Orientation="Vertical">
<CheckBox
Margin="3"
IsChecked="{sd:OptionBinding addin:OptionWrapper.EnableDC}"
VerticalAlignment="Top">
<TextBlock
TextWrapping="Wrap"
Text="{sd:Localize AddIns.Profiler.Options.General.DataCollection.EnableDC}" />
</CheckBox>
<CheckBox
Margin="3"
IsChecked="{sd:OptionBinding addin:OptionWrapper.EnableDCAtStart}"
VerticalAlignment="Top">
<TextBlock
TextWrapping="Wrap"
Text="{sd:Localize AddIns.Profiler.Options.General.DataCollection.EnableDCAtStartup}" />
</CheckBox>
<Label
Margin="3"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="{sd:Localize AddIns.Profiler.Options.General.DataCollection.SizeOfStorageDescription}" />
<StackPanel
Margin="3"
Orientation="Horizontal">
<Slider
Name="sharedMemorySize"
Margin="3"
Width="100"
IsDirectionReversed="False"
TickPlacement="Both"
Minimum="64"
Maximum="512"
TickFrequency="64"
SmallChange="64"
Value="{sd:OptionBinding addin:OptionWrapper.SharedMemorySize}"
LargeChange="128"
IsSnapToTickEnabled="True"
VerticalAlignment="Top" />
<TextBlock
Margin="3"
HorizontalAlignment="Left"
Text="{Binding Value, ElementName=sharedMemorySize, StringFormat=\{0\} MB}"
VerticalAlignment="Center" />
</StackPanel>
<CheckBox
Margin="3"
IsChecked="{sd:OptionBinding addin:OptionWrapper.DoNotProfileNetInternals}"
VerticalAlignment="Top"
Content="{sd:Localize AddIns.Profiler.Options.General.DataCollection.DoNotProfileNetInternals}" />
<CheckBox
Margin="3"
IsChecked="{sd:OptionBinding addin:OptionWrapper.CombineRecursiveCalls}"
VerticalAlignment="Top"
Content="{sd:Localize AddIns.Profiler.Options.General.DataCollection.CombineRecursiveCalls}" />
</StackPanel>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

53
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionPanels/OptionWrapper.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Profiler.Controller;
using System;
using ICSharpCode.Core;
namespace ICSharpCode.Profiler.AddIn.OptionPanels
{
public static class OptionWrapper
{
static Properties properties = PropertyService.Get("ProfilerOptions", new Properties());
public static int SharedMemorySize {
get { return properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize) / 1024 / 1024; }
set { properties.Set("SharedMemorySize", value * 1024 * 1024); }
}
public static bool EnableDC {
get { return !properties.Get("EnableDC", true); }
set { properties.Set("EnableDC", !value); }
}
public static bool DoNotProfileNetInternals {
get { return properties.Get("DoNotProfileNetInternals", false); }
set { properties.Set("DoNotProfileNetInternals", value); }
}
public static bool CombineRecursiveCalls {
get { return properties.Get("CombineRecursiveFunction", false); }
set { properties.Set("CombineRecursiveFunction", value); }
}
public static bool EnableDCAtStart {
get { return properties.Get("EnableDCAtStart", true); }
set { properties.Set("EnableDCAtStart", value); }
}
public static ProfilerOptions CreateProfilerOptions()
{
return new ProfilerOptions(
properties.Get("EnableDC", true),
properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize),
properties.Get("DoNotProfileNetInternals", false),
properties.Get("CombineRecursiveFunction", false),
properties.Get("EnableDCAtStart", true)
);
}
}
}

82
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionsPanels/General.cs

@ -1,82 +0,0 @@ @@ -1,82 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using System.Windows.Threading;
namespace ICSharpCode.Profiler.AddIn.OptionsPanels
{
/// <summary>
/// Description of General
/// </summary>
public class General : OptionPanel
{
GeneralOptionsPanel panel;
static Properties properties = PropertyService.Get("ProfilerOptions", new Properties());
public General()
{
panel = new GeneralOptionsPanel();
}
public override object Control {
get {
return panel;
}
}
public override void LoadOptions()
{
try {
panel.SetOptionValue("EnableDC", !properties.Get("EnableDC", true));
panel.SetOptionValue("SharedMemorySize", properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize) / 1024 / 1024);
panel.SetOptionValue("DoNotProfileNetInternals", properties.Get("DoNotProfileNetInternals", false));
panel.SetOptionValue("CombineRecursiveFunction", properties.Get("CombineRecursiveFunction", false));
panel.SetOptionValue("EnableDCAtStart", properties.Get("EnableDCAtStart", true));
base.LoadPanelContents();
} catch (Exception e) {
MessageService.ShowError(e);
}
}
public override bool SaveOptions()
{
try {
properties.Set("EnableDC", !panel.GetOptionValue<bool>("EnableDC"));
properties.Set("SharedMemorySize", (int)panel.GetOptionValue<double>("SharedMemorySize") * 1024 * 1024);
properties.Set("DoNotProfileNetInternals", panel.GetOptionValue<bool>("DoNotProfileNetInternals"));
properties.Set("CombineRecursiveFunction", panel.GetOptionValue<bool>("CombineRecursiveFunction"));
properties.Set("EnableDCAtStart", panel.GetOptionValue<bool>("EnableDCAtStart"));
return base.StorePanelContents();
} catch (Exception e) {
MessageService.ShowError(e);
}
return false;
}
public static ProfilerOptions CreateProfilerOptions()
{
return new ProfilerOptions(
properties.Get("EnableDC", true),
properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize),
properties.Get("DoNotProfileNetInternals", false),
properties.Get("CombineRecursiveFunction", false),
properties.Get("EnableDCAtStart", true)
);
}
}
}

53
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionsPanels/GeneralOptionsPanel.xaml

@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="ICSharpCode.Profiler.AddIn.OptionsPanels.GeneralOptionsPanel" xmlns:sd="http://icsharpcode.net/sharpdevelop/core" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel
Orientation="Vertical">
<GroupBox
Header="{sd:Localize AddIns.Profiler.Options.General.DataCollection.Header}">
<StackPanel
Orientation="Vertical">
<CheckBox Margin="3"
Name="chkEnableDC"
VerticalAlignment="Top">
<TextBlock TextWrapping="Wrap" Text="{sd:Localize AddIns.Profiler.Options.General.DataCollection.EnableDC}" />
</CheckBox>
<CheckBox Margin="3"
Name="chkEnableDCAtStartup"
VerticalAlignment="Top">
<TextBlock TextWrapping="Wrap" Text="{sd:Localize AddIns.Profiler.Options.General.DataCollection.EnableDCAtStartup}" />
</CheckBox>
<Label Margin="3"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="{sd:Localize AddIns.Profiler.Options.General.DataCollection.SizeOfStorageDescription}" />
<StackPanel Margin="3"
Orientation="Horizontal">
<Slider Margin="3" Width="100"
Name="slSharedMemorySize"
IsDirectionReversed="False"
TickPlacement="Both"
Minimum="64"
Maximum="512"
TickFrequency="64"
SmallChange="64"
LargeChange="128"
IsSnapToTickEnabled="True"
VerticalAlignment="Top" />
<TextBlock Margin="3"
HorizontalAlignment="Left"
Text="{Binding Value, ElementName=slSharedMemorySize, StringFormat=\{0\} MB}"
VerticalAlignment="Center" />
</StackPanel>
<CheckBox Margin="3"
Name="chkDoNotProfileNetInternals"
VerticalAlignment="Top"
Content="{sd:Localize AddIns.Profiler.Options.General.DataCollection.DoNotProfileNetInternals}" />
<CheckBox Margin="3"
Name="chkCombineRecursiveCalls"
VerticalAlignment="Top"
Content="{sd:Localize AddIns.Profiler.Options.General.DataCollection.CombineRecursiveCalls}" />
</StackPanel>
</GroupBox>
</StackPanel>
</UserControl>

81
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/OptionsPanels/GeneralOptionsPanel.xaml.cs

@ -1,81 +0,0 @@ @@ -1,81 +0,0 @@
using ICSharpCode.Profiler.Interprocess;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Management;
using System.Linq;
namespace ICSharpCode.Profiler.AddIn.OptionsPanels
{
/// <summary>
/// Interaction logic for GeneralOptionsPanel.xaml
/// </summary>
public partial class GeneralOptionsPanel : UserControl
{
public GeneralOptionsPanel()
{
InitializeComponent();
}
public T GetOptionValue<T>(string name)
{
object o = null;
switch (name) {
case "SharedMemorySize":
o = this.slSharedMemorySize.Value;
break;
case "EnableDC":
o = this.chkEnableDC.IsChecked;
break;
case "DoNotProfileNetInternals":
o = this.chkDoNotProfileNetInternals.IsChecked;
break;
case "CombineRecursiveFunction":
o = this.chkCombineRecursiveCalls.IsChecked;
break;
case "EnableDCAtStart":
o = this.chkEnableDCAtStartup.IsChecked;
break;
default:
throw new NotSupportedException("value '" + name + "' is not supported!");
}
return (T)o;
}
public void SetOptionValue<T>(string name, T value)
{
object o = value;
switch (name) {
case "SharedMemorySize":
this.slSharedMemorySize.Value = (int)o;
break;
case "EnableDC":
this.chkEnableDC.IsChecked = (bool)o;
break;
case "DoNotProfileNetInternals":
this.chkDoNotProfileNetInternals.IsChecked = (bool)o;
break;
case "CombineRecursiveFunction":
this.chkCombineRecursiveCalls.IsChecked = (bool)o;
break;
case "EnableDCAtStart":
this.chkEnableDCAtStartup.IsChecked = (bool)o;
break;
default:
throw new NotSupportedException("value '" + name + "' is not supported!");
}
}
}
}

11
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs

@ -8,13 +8,10 @@ @@ -8,13 +8,10 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Dialogs;
using ICSharpCode.Profiler.AddIn.OptionsPanels;
using ICSharpCode.Profiler.AddIn.OptionPanels;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
@ -57,11 +54,11 @@ namespace ICSharpCode.Profiler.AddIn @@ -57,11 +54,11 @@ namespace ICSharpCode.Profiler.AddIn
if (useTempFileDatabase) {
this.database = new TempFileDatabase();
this.writer = writer;
this.profiler = new Controller.Profiler(startInfo, this.database.GetWriter(), General.CreateProfilerOptions());
this.profiler = new Controller.Profiler(startInfo, this.database.GetWriter(), OptionWrapper.CreateProfilerOptions());
} else {
this.database = null;
this.writer = writer;
this.profiler = new Controller.Profiler(startInfo, writer, General.CreateProfilerOptions());
this.profiler = new Controller.Profiler(startInfo, writer, OptionWrapper.CreateProfilerOptions());
}
PrintProfilerOptions();
@ -73,7 +70,7 @@ namespace ICSharpCode.Profiler.AddIn @@ -73,7 +70,7 @@ namespace ICSharpCode.Profiler.AddIn
void PrintProfilerOptions()
{
var options = General.CreateProfilerOptions();
var options = OptionWrapper.CreateProfilerOptions();
LoggingService.Info("Profiler settings:");
LoggingService.Info("Shared memory size: " + options.SharedMemorySize + " (" + (options.SharedMemorySize / 1024 / 1024) + " MB)");
LoggingService.Info("Combine recursive calls: " + options.CombineRecursiveFunction);

36
src/AddIns/Misc/Profiler/Profiler.sln

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

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 10
# SharpDevelop 4.0.0.4504
# SharpDevelop 4.0.0.4879
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5147BA25-8362-481D-8CF9-450096595B7A}"
ProjectSection(SolutionItems) = preProject
TODO.txt = TODO.txt
@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend", "Frontend", "{E0 @@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend", "Frontend", "{E0
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls", "Frontend\Controls\Controls.csproj", "{BDA49550-5ED1-4C6B-B648-657B2CACD8E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddIn", "Frontend\AddIn\AddIn.csproj", "{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkRunner", "Frontend\BenchmarkRunner\BenchmarkRunner.csproj", "{DBEF953E-F7BC-4D54-8A27-B758EC875C49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gui", "Frontend\Gui\Gui.csproj", "{FF09FBA1-86DA-4D8D-B549-A4FC70FC5AE9}"
ProjectSection(ProjectDependencies) = postProject
{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}
@ -21,25 +27,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gui", "Frontend\Gui\Gui.csp @@ -21,25 +27,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gui", "Frontend\Gui\Gui.csp
{778BA9AE-EE77-444F-A0C9-D795BB977C1A} = {778BA9AE-EE77-444F-A0C9-D795BB977C1A}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkRunner", "Frontend\BenchmarkRunner\BenchmarkRunner.csproj", "{DBEF953E-F7BC-4D54-8A27-B758EC875C49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddIn", "Frontend\AddIn\AddIn.csproj", "{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls", "Frontend\Controls\Controls.csproj", "{BDA49550-5ED1-4C6B-B648-657B2CACD8E0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{791AE00B-AD96-410A-AAA8-957DDD83C57A}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmark", "Tests\Benchmark\Benchmark.csproj", "{F09B6132-5DF9-4E63-BA23-EE82D75CD5B9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnicodeTest", "Tests\UnicodeTest\UnicodeTest.csproj", "{D336926C-6180-4F62-B88D-E366B240127B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "Tests\HelloWorld\HelloWorld.csproj", "{778BA9AE-EE77-444F-A0C9-D795BB977C1A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Tests", "Tests\Profiler.Tests\Profiler.Tests.csproj", "{068F9531-5D29-49E0-980E-59982A3A0469}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PauseTest", "Tests\PauseTest\PauseTest.csproj", "{650AEAA0-0678-4A75-A1CC-F46DC4E44D2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Tests", "Tests\Profiler.Tests\Profiler.Tests.csproj", "{068F9531-5D29-49E0-980E-59982A3A0469}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "Tests\HelloWorld\HelloWorld.csproj", "{778BA9AE-EE77-444F-A0C9-D795BB977C1A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnicodeTest", "Tests\UnicodeTest\UnicodeTest.csproj", "{D336926C-6180-4F62-B88D-E366B240127B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmark", "Tests\Benchmark\Benchmark.csproj", "{F09B6132-5DF9-4E63-BA23-EE82D75CD5B9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hook", "Hook\Hook.vcproj", "{68D5EE3B-0C35-4DF1-BD29-6606851A02C1}"
EndProject
@ -211,14 +211,14 @@ Global @@ -211,14 +211,14 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BDA49550-5ED1-4C6B-B648-657B2CACD8E0} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{DBEF953E-F7BC-4D54-8A27-B758EC875C49} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{FF09FBA1-86DA-4D8D-B549-A4FC70FC5AE9} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{D336926C-6180-4F62-B88D-E366B240127B} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{068F9531-5D29-49E0-980E-59982A3A0469} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{650AEAA0-0678-4A75-A1CC-F46DC4E44D2A} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{778BA9AE-EE77-444F-A0C9-D795BB977C1A} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{DBEF953E-F7BC-4D54-8A27-B758EC875C49} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{BDA49550-5ED1-4C6B-B648-657B2CACD8E0} = {E06867E9-6942-4DB6-89F5-DE0BF56C44DE}
{F09B6132-5DF9-4E63-BA23-EE82D75CD5B9} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{778BA9AE-EE77-444F-A0C9-D795BB977C1A} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{650AEAA0-0678-4A75-A1CC-F46DC4E44D2A} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{068F9531-5D29-49E0-980E-59982A3A0469} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
{D336926C-6180-4F62-B88D-E366B240127B} = {791AE00B-AD96-410A-AAA8-957DDD83C57A}
EndGlobalSection
EndGlobal

35
src/Main/ICSharpCode.Core.Presentation/OptionBinding.cs

@ -6,8 +6,10 @@ @@ -6,8 +6,10 @@
// </file>
using System;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
@ -35,6 +37,8 @@ namespace ICSharpCode.Core.Presentation @@ -35,6 +37,8 @@ namespace ICSharpCode.Core.Presentation
{
public string PropertyName { get; set; }
static readonly Regex regex = new Regex("^.+\\:.+\\..+$", RegexOptions.Compiled);
DependencyObject target;
DependencyProperty dp;
@ -42,6 +46,9 @@ namespace ICSharpCode.Core.Presentation @@ -42,6 +46,9 @@ namespace ICSharpCode.Core.Presentation
public OptionBinding(string propertyName)
{
if (!regex.IsMatch(propertyName))
throw new ArgumentException("parameter must have the following format: namespace:ClassName.FieldOrProperty", "propertyName");
this.PropertyName = propertyName;
}
@ -71,15 +78,23 @@ namespace ICSharpCode.Core.Presentation @@ -71,15 +78,23 @@ namespace ICSharpCode.Core.Presentation
container.AddBinding(this);
object result = null;
if (this.propertyInfo is PropertyInfo)
return (propertyInfo as PropertyInfo).GetValue(null, null);
result = (propertyInfo as PropertyInfo).GetValue(null, null);
else {
this.propertyInfo = t.GetField(name[1]);
if (this.propertyInfo is FieldInfo)
return (propertyInfo as FieldInfo).GetValue(null);
result = (propertyInfo as FieldInfo).GetValue(null);
}
return null;
Type returnType = dp.PropertyType;
if (dp.PropertyType.IsGenericType && dp.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) {
returnType = dp.PropertyType.GetGenericArguments().First();
}
return Convert.ChangeType(result, returnType);
}
IOptionBindingContainer TryFindContainer(FrameworkElement start)
@ -95,13 +110,23 @@ namespace ICSharpCode.Core.Presentation @@ -95,13 +110,23 @@ namespace ICSharpCode.Core.Presentation
public bool Save()
{
object value = target.GetValue(dp);
Type returnType = null;
if (propertyInfo is PropertyInfo)
returnType = (propertyInfo as PropertyInfo).PropertyType;
if (propertyInfo is FieldInfo)
returnType = (propertyInfo as FieldInfo).FieldType;
value = Convert.ChangeType(value, returnType);
if (propertyInfo is PropertyInfo) {
(propertyInfo as PropertyInfo).SetValue(null, target.GetValue(dp), null);
(propertyInfo as PropertyInfo).SetValue(null, value, null);
return true;
}
if (propertyInfo is FieldInfo) {
(propertyInfo as FieldInfo).SetValue(null, target.GetValue(dp));
(propertyInfo as FieldInfo).SetValue(null, value);
return true;
}

Loading…
Cancel
Save