23 changed files with 5355 additions and 5352 deletions
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
*.cs text diff=csharp |
||||
*.sln text eol=crlf |
||||
*.csproj text eol=crlf |
@ -1,82 +1,82 @@
@@ -1,82 +1,82 @@
|
||||
// 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.Controls; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
public sealed class ShowZoomControlCommand : AbstractCheckableMenuCommand |
||||
{ |
||||
ParallelStackPad pad; |
||||
|
||||
public override object Owner { |
||||
get { return base.Owner; } |
||||
set { |
||||
if (!(value is ParallelStackPad)) |
||||
throw new Exception("Owner has to be a ParallelStackPad"); |
||||
pad = value as ParallelStackPad; |
||||
base.Owner = value; |
||||
} |
||||
} |
||||
|
||||
public override bool IsChecked { |
||||
get { return pad.IsZoomControlVisible; } |
||||
set { pad.IsZoomControlVisible = value; } |
||||
} |
||||
} |
||||
|
||||
public sealed class ToggleMethodViewCommand : AbstractCheckableMenuCommand |
||||
{ |
||||
ParallelStackPad pad; |
||||
|
||||
public override object Owner { |
||||
get { return base.Owner; } |
||||
set { |
||||
if (!(value is ParallelStackPad)) |
||||
throw new Exception("Owner has to be a AbstractConsolePad"); |
||||
pad = value as ParallelStackPad; |
||||
base.Owner = value; |
||||
} |
||||
} |
||||
|
||||
public override bool IsChecked { |
||||
get { return pad.IsMethodView; } |
||||
set { pad.IsMethodView = value; } |
||||
} |
||||
} |
||||
|
||||
public sealed class ParallelStacksViewCommand : AbstractComboBoxCommand |
||||
{ |
||||
ParallelStackPad pad; |
||||
ComboBox box; |
||||
|
||||
protected override void OnOwnerChanged(EventArgs e) |
||||
{ |
||||
this.pad = this.Owner as ParallelStackPad; |
||||
if (this.pad == null) |
||||
return; |
||||
|
||||
box = this.ComboBox as ComboBox; |
||||
|
||||
if (this.box == null) |
||||
return; |
||||
|
||||
foreach (var name in Enum.GetNames(typeof(ParallelStacksView))) |
||||
box.Items.Add(name); |
||||
|
||||
box.SelectedIndex = 0; |
||||
|
||||
base.OnOwnerChanged(e); |
||||
} |
||||
|
||||
public override void Run() |
||||
{ |
||||
if (this.pad != null && this.box != null) { |
||||
pad.ParallelStacksView = (ParallelStacksView)Enum.Parse(typeof(ParallelStacksView), box.SelectedValue.ToString()); |
||||
} |
||||
base.Run(); |
||||
} |
||||
} |
||||
// 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.Controls; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
public sealed class ShowZoomControlCommand : AbstractCheckableMenuCommand |
||||
{ |
||||
ParallelStackPad pad; |
||||
|
||||
public override object Owner { |
||||
get { return base.Owner; } |
||||
set { |
||||
if (!(value is ParallelStackPad)) |
||||
throw new Exception("Owner has to be a ParallelStackPad"); |
||||
pad = value as ParallelStackPad; |
||||
base.Owner = value; |
||||
} |
||||
} |
||||
|
||||
public override bool IsChecked { |
||||
get { return pad.IsZoomControlVisible; } |
||||
set { pad.IsZoomControlVisible = value; } |
||||
} |
||||
} |
||||
|
||||
public sealed class ToggleMethodViewCommand : AbstractCheckableMenuCommand |
||||
{ |
||||
ParallelStackPad pad; |
||||
|
||||
public override object Owner { |
||||
get { return base.Owner; } |
||||
set { |
||||
if (!(value is ParallelStackPad)) |
||||
throw new Exception("Owner has to be a AbstractConsolePad"); |
||||
pad = value as ParallelStackPad; |
||||
base.Owner = value; |
||||
} |
||||
} |
||||
|
||||
public override bool IsChecked { |
||||
get { return pad.IsMethodView; } |
||||
set { pad.IsMethodView = value; } |
||||
} |
||||
} |
||||
|
||||
public sealed class ParallelStacksViewCommand : AbstractComboBoxCommand |
||||
{ |
||||
ParallelStackPad pad; |
||||
ComboBox box; |
||||
|
||||
protected override void OnOwnerChanged(EventArgs e) |
||||
{ |
||||
this.pad = this.Owner as ParallelStackPad; |
||||
if (this.pad == null) |
||||
return; |
||||
|
||||
box = this.ComboBox as ComboBox; |
||||
|
||||
if (this.box == null) |
||||
return; |
||||
|
||||
foreach (var name in Enum.GetNames(typeof(ParallelStacksView))) |
||||
box.Items.Add(name); |
||||
|
||||
box.SelectedIndex = 0; |
||||
|
||||
base.OnOwnerChanged(e); |
||||
} |
||||
|
||||
public override void Run() |
||||
{ |
||||
if (this.pad != null && this.box != null) { |
||||
pad.ParallelStacksView = (ParallelStacksView)Enum.Parse(typeof(ParallelStacksView), box.SelectedValue.ToString()); |
||||
} |
||||
base.Run(); |
||||
} |
||||
} |
||||
} |
@ -1,47 +1,47 @@
@@ -1,47 +1,47 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System; |
||||
using Debugger; |
||||
using Debugger.AddIn; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
using System.Windows.Controls; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
class SelectLanguageCommand : AbstractComboBoxCommand |
||||
{ |
||||
ConsolePad pad; |
||||
ComboBox box; |
||||
|
||||
protected override void OnOwnerChanged(EventArgs e) |
||||
{ |
||||
this.pad = this.Owner as ConsolePad; |
||||
if (this.pad == null) |
||||
return; |
||||
|
||||
box = this.ComboBox as ComboBox; |
||||
|
||||
if (this.box == null) |
||||
return; |
||||
|
||||
foreach (var name in Enum.GetNames(typeof(SupportedLanguage))) |
||||
box.Items.Add(name); |
||||
|
||||
box.SelectedIndex = 0; |
||||
|
||||
base.OnOwnerChanged(e); |
||||
} |
||||
|
||||
public override void Run() |
||||
{ |
||||
if (this.pad != null && this.box != null) { |
||||
pad.SelectedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), box.SelectedValue.ToString()); |
||||
} |
||||
base.Run(); |
||||
} |
||||
} |
||||
} |
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System; |
||||
using Debugger; |
||||
using Debugger.AddIn; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
using System.Windows.Controls; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
class SelectLanguageCommand : AbstractComboBoxCommand |
||||
{ |
||||
ConsolePad pad; |
||||
ComboBox box; |
||||
|
||||
protected override void OnOwnerChanged(EventArgs e) |
||||
{ |
||||
this.pad = this.Owner as ConsolePad; |
||||
if (this.pad == null) |
||||
return; |
||||
|
||||
box = this.ComboBox as ComboBox; |
||||
|
||||
if (this.box == null) |
||||
return; |
||||
|
||||
foreach (var name in Enum.GetNames(typeof(SupportedLanguage))) |
||||
box.Items.Add(name); |
||||
|
||||
box.SelectedIndex = 0; |
||||
|
||||
base.OnOwnerChanged(e); |
||||
} |
||||
|
||||
public override void Run() |
||||
{ |
||||
if (this.pad != null && this.box != null) { |
||||
pad.SelectedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), box.SelectedValue.ToString()); |
||||
} |
||||
base.Run(); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,85 +1,85 @@
@@ -1,85 +1,85 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System.Windows.Controls; |
||||
using Debugger; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
public abstract class DebuggerPad : AbstractPadContent |
||||
{ |
||||
protected DockPanel panel; |
||||
ToolBar toolbar; |
||||
protected WindowsDebugger debugger; |
||||
|
||||
public override object Control { |
||||
get { |
||||
return panel; |
||||
} |
||||
} |
||||
|
||||
public DebuggerPad() |
||||
{ |
||||
// UI
|
||||
this.panel = new DockPanel(); |
||||
this.toolbar = BuildToolBar(); |
||||
|
||||
if (this.toolbar != null) { |
||||
this.toolbar.SetValue(DockPanel.DockProperty, Dock.Top); |
||||
|
||||
this.panel.Children.Add(toolbar); |
||||
} |
||||
|
||||
// logic
|
||||
debugger = (WindowsDebugger)DebuggerService.CurrentDebugger; |
||||
|
||||
InitializeComponents(); |
||||
|
||||
debugger.ProcessSelected += delegate(object sender, ProcessEventArgs e) { |
||||
SelectProcess(e.Process); |
||||
}; |
||||
SelectProcess(debugger.DebuggedProcess); |
||||
} |
||||
|
||||
protected virtual void InitializeComponents() |
||||
{ |
||||
|
||||
} |
||||
|
||||
protected virtual void SelectProcess(Process process) |
||||
{ |
||||
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Never call this directly. Always use InvalidatePad()
|
||||
/// </summary>
|
||||
protected virtual void RefreshPad() |
||||
{ |
||||
|
||||
} |
||||
|
||||
bool invalidatePadEnqueued; |
||||
|
||||
public void InvalidatePad() |
||||
{ |
||||
WorkbenchSingleton.AssertMainThread(); |
||||
if (invalidatePadEnqueued || WorkbenchSingleton.Workbench == null) |
||||
return; |
||||
invalidatePadEnqueued = true; |
||||
WorkbenchSingleton.SafeThreadAsyncCall( |
||||
delegate { |
||||
invalidatePadEnqueued = false; |
||||
RefreshPad(); |
||||
}); |
||||
|
||||
} |
||||
|
||||
protected virtual ToolBar BuildToolBar() |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System.Windows.Controls; |
||||
using Debugger; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
public abstract class DebuggerPad : AbstractPadContent |
||||
{ |
||||
protected DockPanel panel; |
||||
ToolBar toolbar; |
||||
protected WindowsDebugger debugger; |
||||
|
||||
public override object Control { |
||||
get { |
||||
return panel; |
||||
} |
||||
} |
||||
|
||||
public DebuggerPad() |
||||
{ |
||||
// UI
|
||||
this.panel = new DockPanel(); |
||||
this.toolbar = BuildToolBar(); |
||||
|
||||
if (this.toolbar != null) { |
||||
this.toolbar.SetValue(DockPanel.DockProperty, Dock.Top); |
||||
|
||||
this.panel.Children.Add(toolbar); |
||||
} |
||||
|
||||
// logic
|
||||
debugger = (WindowsDebugger)DebuggerService.CurrentDebugger; |
||||
|
||||
InitializeComponents(); |
||||
|
||||
debugger.ProcessSelected += delegate(object sender, ProcessEventArgs e) { |
||||
SelectProcess(e.Process); |
||||
}; |
||||
SelectProcess(debugger.DebuggedProcess); |
||||
} |
||||
|
||||
protected virtual void InitializeComponents() |
||||
{ |
||||
|
||||
} |
||||
|
||||
protected virtual void SelectProcess(Process process) |
||||
{ |
||||
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Never call this directly. Always use InvalidatePad()
|
||||
/// </summary>
|
||||
protected virtual void RefreshPad() |
||||
{ |
||||
|
||||
} |
||||
|
||||
bool invalidatePadEnqueued; |
||||
|
||||
public void InvalidatePad() |
||||
{ |
||||
WorkbenchSingleton.AssertMainThread(); |
||||
if (invalidatePadEnqueued || WorkbenchSingleton.Workbench == null) |
||||
return; |
||||
invalidatePadEnqueued = true; |
||||
WorkbenchSingleton.SafeThreadAsyncCall( |
||||
delegate { |
||||
invalidatePadEnqueued = false; |
||||
RefreshPad(); |
||||
}); |
||||
|
||||
} |
||||
|
||||
protected virtual ToolBar BuildToolBar() |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,72 +1,72 @@
@@ -1,72 +1,72 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using ICSharpCode.Core; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Windows; |
||||
using Debugger; |
||||
using Debugger.AddIn.Visualizers.Graph; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ObjectGraphPad.
|
||||
/// </summary>
|
||||
public class ObjectGraphPad : DebuggerPad |
||||
{ |
||||
Process debuggedProcess; |
||||
ObjectGraphControl objectGraphControl; |
||||
static ObjectGraphPad instance; |
||||
|
||||
public ObjectGraphPad() |
||||
{ |
||||
instance = this; |
||||
} |
||||
|
||||
/// <remarks>Always check if Instance is null, might be null if pad is not opened!</remarks>
|
||||
public static ObjectGraphPad Instance { |
||||
get { return instance; } |
||||
} |
||||
|
||||
protected override void InitializeComponents() |
||||
{ |
||||
objectGraphControl = new ObjectGraphControl(); |
||||
panel.Children.Add(objectGraphControl); |
||||
} |
||||
|
||||
|
||||
protected override void RefreshPad() |
||||
{ |
||||
// BUG: if pad window is undocked and floats standalone, IsVisible == false (so pad won't refresh)
|
||||
// REQUEST: need to refresh when pad becomes visible -> VisibleChanged event?
|
||||
if (!objectGraphControl.IsVisible) |
||||
{ |
||||
return; |
||||
} |
||||
if (debuggedProcess == null || debuggedProcess.IsRunning || debuggedProcess.SelectedStackFrame == null) { |
||||
this.objectGraphControl.Clear(); |
||||
return; |
||||
} |
||||
this.objectGraphControl.RefreshView(); |
||||
} |
||||
|
||||
protected override void SelectProcess(Process process) |
||||
{ |
||||
if (debuggedProcess != null) { |
||||
debuggedProcess.Paused -= debuggedProcess_Paused; |
||||
} |
||||
debuggedProcess = process; |
||||
if (debuggedProcess != null) { |
||||
debuggedProcess.Paused += debuggedProcess_Paused; |
||||
} |
||||
InvalidatePad(); |
||||
} |
||||
|
||||
void debuggedProcess_Paused(object sender, ProcessEventArgs e) |
||||
{ |
||||
InvalidatePad(); |
||||
} |
||||
} |
||||
} |
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using ICSharpCode.Core; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Windows; |
||||
using Debugger; |
||||
using Debugger.AddIn.Visualizers.Graph; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Pads |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ObjectGraphPad.
|
||||
/// </summary>
|
||||
public class ObjectGraphPad : DebuggerPad |
||||
{ |
||||
Process debuggedProcess; |
||||
ObjectGraphControl objectGraphControl; |
||||
static ObjectGraphPad instance; |
||||
|
||||
public ObjectGraphPad() |
||||
{ |
||||
instance = this; |
||||
} |
||||
|
||||
/// <remarks>Always check if Instance is null, might be null if pad is not opened!</remarks>
|
||||
public static ObjectGraphPad Instance { |
||||
get { return instance; } |
||||
} |
||||
|
||||
protected override void InitializeComponents() |
||||
{ |
||||
objectGraphControl = new ObjectGraphControl(); |
||||
panel.Children.Add(objectGraphControl); |
||||
} |
||||
|
||||
|
||||
protected override void RefreshPad() |
||||
{ |
||||
// BUG: if pad window is undocked and floats standalone, IsVisible == false (so pad won't refresh)
|
||||
// REQUEST: need to refresh when pad becomes visible -> VisibleChanged event?
|
||||
if (!objectGraphControl.IsVisible) |
||||
{ |
||||
return; |
||||
} |
||||
if (debuggedProcess == null || debuggedProcess.IsRunning || debuggedProcess.SelectedStackFrame == null) { |
||||
this.objectGraphControl.Clear(); |
||||
return; |
||||
} |
||||
this.objectGraphControl.RefreshView(); |
||||
} |
||||
|
||||
protected override void SelectProcess(Process process) |
||||
{ |
||||
if (debuggedProcess != null) { |
||||
debuggedProcess.Paused -= debuggedProcess_Paused; |
||||
} |
||||
debuggedProcess = process; |
||||
if (debuggedProcess != null) { |
||||
debuggedProcess.Paused += debuggedProcess_Paused; |
||||
} |
||||
InvalidatePad(); |
||||
} |
||||
|
||||
void debuggedProcess_Paused(object sender, ProcessEventArgs e) |
||||
{ |
||||
InvalidatePad(); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,71 +1,71 @@
@@ -1,71 +1,71 @@
|
||||
// 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.Input; |
||||
using System.Windows.Media; |
||||
using System.Windows.Shapes; |
||||
|
||||
using Microsoft.Windows.Themes; |
||||
|
||||
namespace Debugger.AddIn.Pads.ParallelPad |
||||
{ |
||||
public partial class DrawSurface : UserControl |
||||
{ |
||||
private ScaleTransform zoom = new ScaleTransform(); |
||||
|
||||
public DrawSurface() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
ContentControl.LayoutTransform = zoom; |
||||
} |
||||
|
||||
public void SetGraph(ParallelStacksGraph graph) |
||||
{ |
||||
this.ParallelStacksLayout.Graph = graph; |
||||
|
||||
if (graph == null) |
||||
this.ParallelStacksLayout.CancelLayout(); |
||||
else |
||||
this.ParallelStacksLayout.Relayout(); |
||||
} |
||||
|
||||
public bool IsZoomControlVisible { |
||||
get { return ZoomControl.Visibility == Visibility.Visible; } |
||||
set { |
||||
if (value) |
||||
ZoomControl.Visibility = Visibility.Visible; |
||||
else |
||||
ZoomControl.Visibility = Visibility.Hidden; |
||||
} |
||||
} |
||||
|
||||
#region Zoom
|
||||
|
||||
void SliderControl_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
||||
{ |
||||
if (e.OldValue == 0) |
||||
return; |
||||
|
||||
double value = (e.NewValue / 5d) * 100; |
||||
|
||||
this.PercentText.Text = string.Format("{0}%", value); |
||||
|
||||
// zoom canvas
|
||||
zoom.ScaleX = e.NewValue / 5d; |
||||
zoom.ScaleY = e.NewValue / 5d; |
||||
zoom.CenterX = drawingSurface.ActualWidth / 2d; |
||||
zoom.CenterY = drawingSurface.ActualHeight / 2d; |
||||
} |
||||
|
||||
void Reset_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.SliderControl.Value = 5; |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
// 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.Input; |
||||
using System.Windows.Media; |
||||
using System.Windows.Shapes; |
||||
|
||||
using Microsoft.Windows.Themes; |
||||
|
||||
namespace Debugger.AddIn.Pads.ParallelPad |
||||
{ |
||||
public partial class DrawSurface : UserControl |
||||
{ |
||||
private ScaleTransform zoom = new ScaleTransform(); |
||||
|
||||
public DrawSurface() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
ContentControl.LayoutTransform = zoom; |
||||
} |
||||
|
||||
public void SetGraph(ParallelStacksGraph graph) |
||||
{ |
||||
this.ParallelStacksLayout.Graph = graph; |
||||
|
||||
if (graph == null) |
||||
this.ParallelStacksLayout.CancelLayout(); |
||||
else |
||||
this.ParallelStacksLayout.Relayout(); |
||||
} |
||||
|
||||
public bool IsZoomControlVisible { |
||||
get { return ZoomControl.Visibility == Visibility.Visible; } |
||||
set { |
||||
if (value) |
||||
ZoomControl.Visibility = Visibility.Visible; |
||||
else |
||||
ZoomControl.Visibility = Visibility.Hidden; |
||||
} |
||||
} |
||||
|
||||
#region Zoom
|
||||
|
||||
void SliderControl_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
||||
{ |
||||
if (e.OldValue == 0) |
||||
return; |
||||
|
||||
double value = (e.NewValue / 5d) * 100; |
||||
|
||||
this.PercentText.Text = string.Format("{0}%", value); |
||||
|
||||
// zoom canvas
|
||||
zoom.ScaleX = e.NewValue / 5d; |
||||
zoom.ScaleY = e.NewValue / 5d; |
||||
zoom.CenterX = drawingSurface.ActualWidth / 2d; |
||||
zoom.CenterY = drawingSurface.ActualHeight / 2d; |
||||
} |
||||
|
||||
void Reset_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.SliderControl.Value = 5; |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,331 +1,331 @@
@@ -1,331 +1,331 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Dynamic; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui.Pads; |
||||
|
||||
namespace Debugger.AddIn.Pads.ParallelPad |
||||
{ |
||||
public class FrameSelectedEventArgs : EventArgs |
||||
{ |
||||
public StackFrame Item { |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public Location Location { |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public FrameSelectedEventArgs(StackFrame item, Location location) |
||||
{ |
||||
Item = item; |
||||
Location = location; |
||||
} |
||||
} |
||||
|
||||
public partial class ThreadStack : UserControl |
||||
{ |
||||
public static SolidColorBrush SelectedBrush = new SolidColorBrush(Color.FromRgb(84, 169, 255)); |
||||
|
||||
public static readonly DependencyProperty IsSelectedProperty = |
||||
DependencyProperty.Register("IsSelected", typeof(bool), typeof(ThreadStack), |
||||
new FrameworkPropertyMetadata()); |
||||
|
||||
public event EventHandler StackSelected; |
||||
|
||||
public event EventHandler<FrameSelectedEventArgs> FrameSelected; |
||||
|
||||
ObservableCollection<ParallelStackFrameModel> itemCollection = new ObservableCollection<ParallelStackFrameModel>(); |
||||
|
||||
ToolTip toolTip = new ToolTip(); |
||||
List<uint> threadIds = new List<uint>(); |
||||
|
||||
public ThreadStack() |
||||
{ |
||||
InitializeComponent(); |
||||
datagrid.ToolTip = toolTip; |
||||
datagrid.ToolTipOpening += OnToolTipOpening; |
||||
datagrid.PreviewMouseMove += new MouseEventHandler(datagrid_PreviewMouseMove); |
||||
datagrid.MouseLeave += delegate { toolTip.IsOpen = false; }; |
||||
} |
||||
|
||||
#region Public Properties
|
||||
|
||||
public Process Process { get; set; } |
||||
|
||||
public int Level { get; set; } |
||||
|
||||
public bool IsSelected { |
||||
get { return (bool)GetValue(IsSelectedProperty); } |
||||
set { |
||||
if (value) { |
||||
BorderParent.BorderBrush = SelectedBrush; |
||||
BorderParent.BorderThickness = new Thickness(5); |
||||
} |
||||
else { |
||||
BorderParent.BorderBrush = Brushes.Black; |
||||
BorderParent.BorderThickness = new Thickness(3); |
||||
} |
||||
|
||||
SetValue(IsSelectedProperty, value); |
||||
|
||||
SelectParent(value); |
||||
} |
||||
} |
||||
|
||||
public List<ThreadStack> ThreadStackParents { get; set; } |
||||
|
||||
public List<ThreadStack> ThreadStackChildren { get; set; } |
||||
|
||||
public List<uint> ThreadIds { |
||||
get { return threadIds; } |
||||
} |
||||
|
||||
public ObservableCollection<ParallelStackFrameModel> ItemCollection { |
||||
get { return itemCollection; } |
||||
set { |
||||
itemCollection = value; |
||||
this.datagrid.ItemsSource = itemCollection; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void UpdateThreadIds(bool isTask, params uint[] threadIds) |
||||
{ |
||||
var list = new List<uint>(); |
||||
foreach (uint id in threadIds) { |
||||
if (!this.threadIds.Contains(id)) { |
||||
list.Add(id); |
||||
} |
||||
} |
||||
this.threadIds.AddRange(list); |
||||
|
||||
if (this.threadIds.Count > 1) { |
||||
string suffix = isTask ? " Tasks" : " Threads"; |
||||
this.HeaderText.Text = this.threadIds.Count.ToString() + suffix; |
||||
} |
||||
else { |
||||
this.HeaderText.Text = isTask ? "1 Task" : "1 Thread"; |
||||
} |
||||
} |
||||
|
||||
public void ClearImages() |
||||
{ |
||||
foreach (ParallelStackFrameModel item in itemCollection) { |
||||
if (!item.IsRunningStackFrame) |
||||
item.Image = null; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void SelectParent(bool isSelected) |
||||
{ |
||||
if (this.ThreadStackParents == null || this.ThreadStackParents.Count == 0) |
||||
return; |
||||
|
||||
foreach (var ts in this.ThreadStackParents) |
||||
if (ts != null) |
||||
ts.IsSelected = isSelected; |
||||
} |
||||
|
||||
void datagrid_PreviewMouseMove(object sender, MouseEventArgs e) |
||||
{ |
||||
var result = VisualTreeHelper.HitTest(this, e.GetPosition(this)); |
||||
if (result != null) |
||||
{ |
||||
var row = TryFindParent<DataGridRow>(result.VisualHit); |
||||
if (row != null) |
||||
{ |
||||
datagrid.SelectedItem = row.DataContext; |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void Datagrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (Process.IsRunning) return; |
||||
|
||||
ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; |
||||
if (selectedItem != null) { |
||||
if (ThreadIds.Count > 1) { |
||||
datagrid.ContextMenu = CreateContextMenu(selectedItem); |
||||
datagrid.ContextMenu.IsOpen = true; |
||||
} |
||||
else |
||||
{ |
||||
SelectFrame(ThreadIds[0], selectedItem); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void SelectFrame(uint threadId, ParallelStackFrameModel selectedItem) |
||||
{ |
||||
if (selectedItem == null) |
||||
return; |
||||
|
||||
var thread = Process.Threads.Find(t => t.ID == threadId); |
||||
if (thread == null) |
||||
return; |
||||
|
||||
if (StackSelected != null) |
||||
StackSelected(this, EventArgs.Empty); |
||||
|
||||
this.IsSelected = true; |
||||
|
||||
foreach(var frame in thread.Callstack) |
||||
{ |
||||
if (frame.GetMethodName() == selectedItem.MethodName) |
||||
{ |
||||
if (!selectedItem.IsRunningStackFrame) |
||||
selectedItem.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source; |
||||
|
||||
SourcecodeSegment nextStatement = frame.NextStatement; |
||||
if (nextStatement != null) { |
||||
var location = new Location(nextStatement.StartColumn, nextStatement.StartLine); |
||||
FileService.JumpToFilePosition( |
||||
nextStatement.Filename, location.Line, location.Column); |
||||
|
||||
if (FrameSelected != null) |
||||
FrameSelected(this, new FrameSelectedEventArgs(frame, location)); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void Datagrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (Process.IsRunning) return; |
||||
|
||||
ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; |
||||
if (selectedItem == null) |
||||
return; |
||||
|
||||
datagrid.ContextMenu = CreateContextMenu(selectedItem); |
||||
datagrid.ContextMenu.IsOpen = true; |
||||
} |
||||
|
||||
ContextMenu CreateContextMenu(ParallelStackFrameModel item) |
||||
{ |
||||
var menu = new ContextMenu(); |
||||
|
||||
foreach (var id in ThreadIds) { |
||||
MenuItem m = new MenuItem(); |
||||
m.IsCheckable = true; |
||||
m.IsChecked = id == Process.SelectedThread.ID; |
||||
m.Click += delegate(object sender, RoutedEventArgs e) { |
||||
var menuItem = e.OriginalSource as MenuItem; |
||||
SelectFrame((uint)menuItem.Tag, item); |
||||
}; |
||||
m.Tag = id; |
||||
m.Header = id.ToString() + ":" + item.MethodName; |
||||
|
||||
menu.Items.Add(m); |
||||
} |
||||
|
||||
return menu; |
||||
} |
||||
|
||||
private void OnToolTipOpening(object sender, ToolTipEventArgs e) |
||||
{ |
||||
if (Process.IsRunning) |
||||
return; |
||||
|
||||
StackPanel panel = new StackPanel(); |
||||
|
||||
ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; |
||||
if (selectedItem == null) { |
||||
panel.Children.Add(new TextBlock { Text = "No item selected" }); |
||||
this.toolTip.Content = panel; |
||||
return; |
||||
} |
||||
|
||||
foreach(var thread in Process.Threads) |
||||
{ |
||||
if (ThreadIds.Contains(thread.ID)) |
||||
{ |
||||
foreach (var frame in thread.Callstack) |
||||
{ |
||||
if (selectedItem.MethodName == frame.GetMethodName()) |
||||
{ |
||||
TextBlock tb = new TextBlock(); |
||||
tb.Text = thread.ID + ": " + CallStackPadContent.GetFullName(frame); |
||||
panel.Children.Add(tb); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
this.toolTip.Content = panel; |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Static Methods
|
||||
|
||||
private static T TryFindParent<T>(DependencyObject child) where T : DependencyObject |
||||
{ |
||||
if (child is T) return child as T; |
||||
|
||||
DependencyObject parentObject = GetParentObject(child); |
||||
if (parentObject == null) return null; |
||||
|
||||
var parent = parentObject as T; |
||||
if (parent != null && parent is T) |
||||
{ |
||||
return parent; |
||||
} |
||||
else |
||||
{ |
||||
return TryFindParent<T>(parentObject); |
||||
} |
||||
} |
||||
|
||||
private static DependencyObject GetParentObject(DependencyObject child) |
||||
{ |
||||
if (child == null) return null; |
||||
|
||||
ContentElement contentElement = child as ContentElement; |
||||
if (contentElement != null) |
||||
{ |
||||
DependencyObject parent = ContentOperations.GetParent(contentElement); |
||||
if (parent != null) return parent; |
||||
|
||||
FrameworkContentElement fce = contentElement as FrameworkContentElement; |
||||
return fce != null ? fce.Parent : null; |
||||
} |
||||
|
||||
FrameworkElement frameworkElement = child as FrameworkElement; |
||||
if (frameworkElement != null) |
||||
{ |
||||
DependencyObject parent = frameworkElement.Parent; |
||||
if (parent != null) return parent; |
||||
} |
||||
|
||||
return VisualTreeHelper.GetParent(child); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
// 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.Collections.ObjectModel; |
||||
using System.Dynamic; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui.Pads; |
||||
|
||||
namespace Debugger.AddIn.Pads.ParallelPad |
||||
{ |
||||
public class FrameSelectedEventArgs : EventArgs |
||||
{ |
||||
public StackFrame Item { |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public Location Location { |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public FrameSelectedEventArgs(StackFrame item, Location location) |
||||
{ |
||||
Item = item; |
||||
Location = location; |
||||
} |
||||
} |
||||
|
||||
public partial class ThreadStack : UserControl |
||||
{ |
||||
public static SolidColorBrush SelectedBrush = new SolidColorBrush(Color.FromRgb(84, 169, 255)); |
||||
|
||||
public static readonly DependencyProperty IsSelectedProperty = |
||||
DependencyProperty.Register("IsSelected", typeof(bool), typeof(ThreadStack), |
||||
new FrameworkPropertyMetadata()); |
||||
|
||||
public event EventHandler StackSelected; |
||||
|
||||
public event EventHandler<FrameSelectedEventArgs> FrameSelected; |
||||
|
||||
ObservableCollection<ParallelStackFrameModel> itemCollection = new ObservableCollection<ParallelStackFrameModel>(); |
||||
|
||||
ToolTip toolTip = new ToolTip(); |
||||
List<uint> threadIds = new List<uint>(); |
||||
|
||||
public ThreadStack() |
||||
{ |
||||
InitializeComponent(); |
||||
datagrid.ToolTip = toolTip; |
||||
datagrid.ToolTipOpening += OnToolTipOpening; |
||||
datagrid.PreviewMouseMove += new MouseEventHandler(datagrid_PreviewMouseMove); |
||||
datagrid.MouseLeave += delegate { toolTip.IsOpen = false; }; |
||||
} |
||||
|
||||
#region Public Properties
|
||||
|
||||
public Process Process { get; set; } |
||||
|
||||
public int Level { get; set; } |
||||
|
||||
public bool IsSelected { |
||||
get { return (bool)GetValue(IsSelectedProperty); } |
||||
set { |
||||
if (value) { |
||||
BorderParent.BorderBrush = SelectedBrush; |
||||
BorderParent.BorderThickness = new Thickness(5); |
||||
} |
||||
else { |
||||
BorderParent.BorderBrush = Brushes.Black; |
||||
BorderParent.BorderThickness = new Thickness(3); |
||||
} |
||||
|
||||
SetValue(IsSelectedProperty, value); |
||||
|
||||
SelectParent(value); |
||||
} |
||||
} |
||||
|
||||
public List<ThreadStack> ThreadStackParents { get; set; } |
||||
|
||||
public List<ThreadStack> ThreadStackChildren { get; set; } |
||||
|
||||
public List<uint> ThreadIds { |
||||
get { return threadIds; } |
||||
} |
||||
|
||||
public ObservableCollection<ParallelStackFrameModel> ItemCollection { |
||||
get { return itemCollection; } |
||||
set { |
||||
itemCollection = value; |
||||
this.datagrid.ItemsSource = itemCollection; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void UpdateThreadIds(bool isTask, params uint[] threadIds) |
||||
{ |
||||
var list = new List<uint>(); |
||||
foreach (uint id in threadIds) { |
||||
if (!this.threadIds.Contains(id)) { |
||||
list.Add(id); |
||||
} |
||||
} |
||||
this.threadIds.AddRange(list); |
||||
|
||||
if (this.threadIds.Count > 1) { |
||||
string suffix = isTask ? " Tasks" : " Threads"; |
||||
this.HeaderText.Text = this.threadIds.Count.ToString() + suffix; |
||||
} |
||||
else { |
||||
this.HeaderText.Text = isTask ? "1 Task" : "1 Thread"; |
||||
} |
||||
} |
||||
|
||||
public void ClearImages() |
||||
{ |
||||
foreach (ParallelStackFrameModel item in itemCollection) { |
||||
if (!item.IsRunningStackFrame) |
||||
item.Image = null; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void SelectParent(bool isSelected) |
||||
{ |
||||
if (this.ThreadStackParents == null || this.ThreadStackParents.Count == 0) |
||||
return; |
||||
|
||||
foreach (var ts in this.ThreadStackParents) |
||||
if (ts != null) |
||||
ts.IsSelected = isSelected; |
||||
} |
||||
|
||||
void datagrid_PreviewMouseMove(object sender, MouseEventArgs e) |
||||
{ |
||||
var result = VisualTreeHelper.HitTest(this, e.GetPosition(this)); |
||||
if (result != null) |
||||
{ |
||||
var row = TryFindParent<DataGridRow>(result.VisualHit); |
||||
if (row != null) |
||||
{ |
||||
datagrid.SelectedItem = row.DataContext; |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void Datagrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (Process.IsRunning) return; |
||||
|
||||
ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; |
||||
if (selectedItem != null) { |
||||
if (ThreadIds.Count > 1) { |
||||
datagrid.ContextMenu = CreateContextMenu(selectedItem); |
||||
datagrid.ContextMenu.IsOpen = true; |
||||
} |
||||
else |
||||
{ |
||||
SelectFrame(ThreadIds[0], selectedItem); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void SelectFrame(uint threadId, ParallelStackFrameModel selectedItem) |
||||
{ |
||||
if (selectedItem == null) |
||||
return; |
||||
|
||||
var thread = Process.Threads.Find(t => t.ID == threadId); |
||||
if (thread == null) |
||||
return; |
||||
|
||||
if (StackSelected != null) |
||||
StackSelected(this, EventArgs.Empty); |
||||
|
||||
this.IsSelected = true; |
||||
|
||||
foreach(var frame in thread.Callstack) |
||||
{ |
||||
if (frame.GetMethodName() == selectedItem.MethodName) |
||||
{ |
||||
if (!selectedItem.IsRunningStackFrame) |
||||
selectedItem.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source; |
||||
|
||||
SourcecodeSegment nextStatement = frame.NextStatement; |
||||
if (nextStatement != null) { |
||||
var location = new Location(nextStatement.StartColumn, nextStatement.StartLine); |
||||
FileService.JumpToFilePosition( |
||||
nextStatement.Filename, location.Line, location.Column); |
||||
|
||||
if (FrameSelected != null) |
||||
FrameSelected(this, new FrameSelectedEventArgs(frame, location)); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void Datagrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (Process.IsRunning) return; |
||||
|
||||
ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; |
||||
if (selectedItem == null) |
||||
return; |
||||
|
||||
datagrid.ContextMenu = CreateContextMenu(selectedItem); |
||||
datagrid.ContextMenu.IsOpen = true; |
||||
} |
||||
|
||||
ContextMenu CreateContextMenu(ParallelStackFrameModel item) |
||||
{ |
||||
var menu = new ContextMenu(); |
||||
|
||||
foreach (var id in ThreadIds) { |
||||
MenuItem m = new MenuItem(); |
||||
m.IsCheckable = true; |
||||
m.IsChecked = id == Process.SelectedThread.ID; |
||||
m.Click += delegate(object sender, RoutedEventArgs e) { |
||||
var menuItem = e.OriginalSource as MenuItem; |
||||
SelectFrame((uint)menuItem.Tag, item); |
||||
}; |
||||
m.Tag = id; |
||||
m.Header = id.ToString() + ":" + item.MethodName; |
||||
|
||||
menu.Items.Add(m); |
||||
} |
||||
|
||||
return menu; |
||||
} |
||||
|
||||
private void OnToolTipOpening(object sender, ToolTipEventArgs e) |
||||
{ |
||||
if (Process.IsRunning) |
||||
return; |
||||
|
||||
StackPanel panel = new StackPanel(); |
||||
|
||||
ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; |
||||
if (selectedItem == null) { |
||||
panel.Children.Add(new TextBlock { Text = "No item selected" }); |
||||
this.toolTip.Content = panel; |
||||
return; |
||||
} |
||||
|
||||
foreach(var thread in Process.Threads) |
||||
{ |
||||
if (ThreadIds.Contains(thread.ID)) |
||||
{ |
||||
foreach (var frame in thread.Callstack) |
||||
{ |
||||
if (selectedItem.MethodName == frame.GetMethodName()) |
||||
{ |
||||
TextBlock tb = new TextBlock(); |
||||
tb.Text = thread.ID + ": " + CallStackPadContent.GetFullName(frame); |
||||
panel.Children.Add(tb); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
this.toolTip.Content = panel; |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Static Methods
|
||||
|
||||
private static T TryFindParent<T>(DependencyObject child) where T : DependencyObject |
||||
{ |
||||
if (child is T) return child as T; |
||||
|
||||
DependencyObject parentObject = GetParentObject(child); |
||||
if (parentObject == null) return null; |
||||
|
||||
var parent = parentObject as T; |
||||
if (parent != null && parent is T) |
||||
{ |
||||
return parent; |
||||
} |
||||
else |
||||
{ |
||||
return TryFindParent<T>(parentObject); |
||||
} |
||||
} |
||||
|
||||
private static DependencyObject GetParentObject(DependencyObject child) |
||||
{ |
||||
if (child == null) return null; |
||||
|
||||
ContentElement contentElement = child as ContentElement; |
||||
if (contentElement != null) |
||||
{ |
||||
DependencyObject parent = ContentOperations.GetParent(contentElement); |
||||
if (parent != null) return parent; |
||||
|
||||
FrameworkContentElement fce = contentElement as FrameworkContentElement; |
||||
return fce != null ? fce.Parent : null; |
||||
} |
||||
|
||||
FrameworkElement frameworkElement = child as FrameworkElement; |
||||
if (frameworkElement != null) |
||||
{ |
||||
DependencyObject parent = frameworkElement.Parent; |
||||
if (parent != null) return parent; |
||||
} |
||||
|
||||
return VisualTreeHelper.GetParent(child); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,228 +1,228 @@
@@ -1,228 +1,228 @@
|
||||
// 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.Runtime.InteropServices; |
||||
|
||||
using Debugger.Interop.CorDebug; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
public class Breakpoint: DebuggerObject |
||||
{ |
||||
NDebugger debugger; |
||||
|
||||
string fileName; |
||||
byte[] checkSum; |
||||
int line; |
||||
int column; |
||||
bool enabled; |
||||
|
||||
SourcecodeSegment originalLocation; |
||||
|
||||
protected List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>(); |
||||
|
||||
public event EventHandler<BreakpointEventArgs> Hit; |
||||
public event EventHandler<BreakpointEventArgs> Set; |
||||
|
||||
[Debugger.Tests.Ignore] |
||||
public NDebugger Debugger { |
||||
get { return debugger; } |
||||
protected set { debugger = value; } |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public byte[] CheckSum { |
||||
get { return checkSum; } |
||||
} |
||||
|
||||
public int Line { |
||||
get { return line; } |
||||
set { line = value; } |
||||
} |
||||
|
||||
public int Column { |
||||
get { return column; } |
||||
} |
||||
|
||||
public bool Enabled { |
||||
get { return enabled; } |
||||
set { |
||||
enabled = value; |
||||
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
||||
corBreakpoint.Activate(enabled ? 1 : 0); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public SourcecodeSegment OriginalLocation { |
||||
get { return originalLocation; } |
||||
} |
||||
|
||||
public bool IsSet { |
||||
get { |
||||
return corBreakpoints.Count > 0; |
||||
} |
||||
} |
||||
|
||||
public string TypeName { |
||||
get; protected set; |
||||
} |
||||
|
||||
protected virtual void OnHit(BreakpointEventArgs e) |
||||
{ |
||||
if (Hit != null) { |
||||
Hit(this, e); |
||||
} |
||||
} |
||||
|
||||
internal void NotifyHit() |
||||
{ |
||||
OnHit(new BreakpointEventArgs(this)); |
||||
debugger.Breakpoints.OnHit(this); |
||||
} |
||||
|
||||
protected virtual void OnSet(BreakpointEventArgs e) |
||||
{ |
||||
if (Set != null) { |
||||
Set(this, e); |
||||
} |
||||
} |
||||
|
||||
public Breakpoint() { } |
||||
|
||||
public Breakpoint(NDebugger debugger, ICorDebugFunctionBreakpoint corBreakpoint) |
||||
{ |
||||
this.debugger = debugger; |
||||
this.corBreakpoints.Add(corBreakpoint); |
||||
} |
||||
|
||||
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled) |
||||
{ |
||||
this.debugger = debugger; |
||||
this.fileName = fileName; |
||||
this.checkSum = checkSum; |
||||
this.line = line; |
||||
this.column = column; |
||||
this.enabled = enabled; |
||||
} |
||||
|
||||
internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint) |
||||
{ |
||||
foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) { |
||||
if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
internal void Deactivate() |
||||
{ |
||||
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
||||
#if DEBUG
|
||||
// Get repro
|
||||
corBreakpoint.Activate(0); |
||||
#else
|
||||
try { |
||||
corBreakpoint.Activate(0); |
||||
} catch(COMException e) { |
||||
// Sometimes happens, but we had not repro yet.
|
||||
// 0x80131301: Process was terminated.
|
||||
if ((uint)e.ErrorCode == 0x80131301) |
||||
continue; |
||||
throw; |
||||
} |
||||
#endif
|
||||
} |
||||
corBreakpoints.Clear(); |
||||
} |
||||
|
||||
internal void MarkAsDeactivated() |
||||
{ |
||||
corBreakpoints.Clear(); |
||||
} |
||||
|
||||
public virtual bool SetBreakpoint(Module module) |
||||
{ |
||||
if (this.fileName == null) |
||||
return false; |
||||
|
||||
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column); |
||||
if (segment == null) return false; |
||||
|
||||
originalLocation = segment; |
||||
|
||||
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart); |
||||
corBreakpoint.Activate(enabled ? 1 : 0); |
||||
|
||||
corBreakpoints.Add(corBreakpoint); |
||||
|
||||
OnSet(new BreakpointEventArgs(this)); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/// <summary> Remove this breakpoint </summary>
|
||||
public void Remove() |
||||
{ |
||||
debugger.Breakpoints.Remove(this); |
||||
} |
||||
} |
||||
|
||||
public class ILBreakpoint : Breakpoint |
||||
{ |
||||
public ILBreakpoint(NDebugger debugger, string typeName, int line, int metadataToken, int memberToken, int offset, bool enabled) |
||||
{ |
||||
this.Debugger = debugger; |
||||
this.Line = line; |
||||
this.TypeName = typeName; |
||||
this.MetadataToken = metadataToken; |
||||
this.MemberMetadataToken = memberToken; |
||||
this.ILOffset = offset; |
||||
this.Enabled = enabled; |
||||
} |
||||
|
||||
public int MetadataToken { get; private set; } |
||||
|
||||
public int MemberMetadataToken { get; private set; } |
||||
|
||||
public int ILOffset { get; private set; } |
||||
|
||||
public override bool SetBreakpoint(Module module) |
||||
{ |
||||
SourcecodeSegment segment = SourcecodeSegment.CreateForIL(module, this.Line, MemberMetadataToken, ILOffset); |
||||
if (segment == null) |
||||
return false; |
||||
try { |
||||
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart); |
||||
corBreakpoint.Activate(Enabled ? 1 : 0); |
||||
corBreakpoints.Add(corBreakpoint); |
||||
|
||||
OnSet(new BreakpointEventArgs(this)); |
||||
return true; |
||||
} catch |
||||
#if DEBUG
|
||||
(System.Exception) |
||||
#endif
|
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
[Serializable] |
||||
public class BreakpointEventArgs : DebuggerEventArgs |
||||
{ |
||||
public Breakpoint Breakpoint { |
||||
get; private set; |
||||
} |
||||
|
||||
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger) |
||||
{ |
||||
this.Breakpoint = breakpoint; |
||||
} |
||||
} |
||||
} |
||||
// 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.Runtime.InteropServices; |
||||
|
||||
using Debugger.Interop.CorDebug; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
public class Breakpoint: DebuggerObject |
||||
{ |
||||
NDebugger debugger; |
||||
|
||||
string fileName; |
||||
byte[] checkSum; |
||||
int line; |
||||
int column; |
||||
bool enabled; |
||||
|
||||
SourcecodeSegment originalLocation; |
||||
|
||||
protected List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>(); |
||||
|
||||
public event EventHandler<BreakpointEventArgs> Hit; |
||||
public event EventHandler<BreakpointEventArgs> Set; |
||||
|
||||
[Debugger.Tests.Ignore] |
||||
public NDebugger Debugger { |
||||
get { return debugger; } |
||||
protected set { debugger = value; } |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public byte[] CheckSum { |
||||
get { return checkSum; } |
||||
} |
||||
|
||||
public int Line { |
||||
get { return line; } |
||||
set { line = value; } |
||||
} |
||||
|
||||
public int Column { |
||||
get { return column; } |
||||
} |
||||
|
||||
public bool Enabled { |
||||
get { return enabled; } |
||||
set { |
||||
enabled = value; |
||||
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
||||
corBreakpoint.Activate(enabled ? 1 : 0); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public SourcecodeSegment OriginalLocation { |
||||
get { return originalLocation; } |
||||
} |
||||
|
||||
public bool IsSet { |
||||
get { |
||||
return corBreakpoints.Count > 0; |
||||
} |
||||
} |
||||
|
||||
public string TypeName { |
||||
get; protected set; |
||||
} |
||||
|
||||
protected virtual void OnHit(BreakpointEventArgs e) |
||||
{ |
||||
if (Hit != null) { |
||||
Hit(this, e); |
||||
} |
||||
} |
||||
|
||||
internal void NotifyHit() |
||||
{ |
||||
OnHit(new BreakpointEventArgs(this)); |
||||
debugger.Breakpoints.OnHit(this); |
||||
} |
||||
|
||||
protected virtual void OnSet(BreakpointEventArgs e) |
||||
{ |
||||
if (Set != null) { |
||||
Set(this, e); |
||||
} |
||||
} |
||||
|
||||
public Breakpoint() { } |
||||
|
||||
public Breakpoint(NDebugger debugger, ICorDebugFunctionBreakpoint corBreakpoint) |
||||
{ |
||||
this.debugger = debugger; |
||||
this.corBreakpoints.Add(corBreakpoint); |
||||
} |
||||
|
||||
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled) |
||||
{ |
||||
this.debugger = debugger; |
||||
this.fileName = fileName; |
||||
this.checkSum = checkSum; |
||||
this.line = line; |
||||
this.column = column; |
||||
this.enabled = enabled; |
||||
} |
||||
|
||||
internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint) |
||||
{ |
||||
foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) { |
||||
if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
internal void Deactivate() |
||||
{ |
||||
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
||||
#if DEBUG
|
||||
// Get repro
|
||||
corBreakpoint.Activate(0); |
||||
#else
|
||||
try { |
||||
corBreakpoint.Activate(0); |
||||
} catch(COMException e) { |
||||
// Sometimes happens, but we had not repro yet.
|
||||
// 0x80131301: Process was terminated.
|
||||
if ((uint)e.ErrorCode == 0x80131301) |
||||
continue; |
||||
throw; |
||||
} |
||||
#endif
|
||||
} |
||||
corBreakpoints.Clear(); |
||||
} |
||||
|
||||
internal void MarkAsDeactivated() |
||||
{ |
||||
corBreakpoints.Clear(); |
||||
} |
||||
|
||||
public virtual bool SetBreakpoint(Module module) |
||||
{ |
||||
if (this.fileName == null) |
||||
return false; |
||||
|
||||
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column); |
||||
if (segment == null) return false; |
||||
|
||||
originalLocation = segment; |
||||
|
||||
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart); |
||||
corBreakpoint.Activate(enabled ? 1 : 0); |
||||
|
||||
corBreakpoints.Add(corBreakpoint); |
||||
|
||||
OnSet(new BreakpointEventArgs(this)); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/// <summary> Remove this breakpoint </summary>
|
||||
public void Remove() |
||||
{ |
||||
debugger.Breakpoints.Remove(this); |
||||
} |
||||
} |
||||
|
||||
public class ILBreakpoint : Breakpoint |
||||
{ |
||||
public ILBreakpoint(NDebugger debugger, string typeName, int line, int metadataToken, int memberToken, int offset, bool enabled) |
||||
{ |
||||
this.Debugger = debugger; |
||||
this.Line = line; |
||||
this.TypeName = typeName; |
||||
this.MetadataToken = metadataToken; |
||||
this.MemberMetadataToken = memberToken; |
||||
this.ILOffset = offset; |
||||
this.Enabled = enabled; |
||||
} |
||||
|
||||
public int MetadataToken { get; private set; } |
||||
|
||||
public int MemberMetadataToken { get; private set; } |
||||
|
||||
public int ILOffset { get; private set; } |
||||
|
||||
public override bool SetBreakpoint(Module module) |
||||
{ |
||||
SourcecodeSegment segment = SourcecodeSegment.CreateForIL(module, this.Line, MemberMetadataToken, ILOffset); |
||||
if (segment == null) |
||||
return false; |
||||
try { |
||||
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart); |
||||
corBreakpoint.Activate(Enabled ? 1 : 0); |
||||
corBreakpoints.Add(corBreakpoint); |
||||
|
||||
OnSet(new BreakpointEventArgs(this)); |
||||
return true; |
||||
} catch |
||||
#if DEBUG
|
||||
(System.Exception) |
||||
#endif
|
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
[Serializable] |
||||
public class BreakpointEventArgs : DebuggerEventArgs |
||||
{ |
||||
public Breakpoint Breakpoint { |
||||
get; private set; |
||||
} |
||||
|
||||
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger) |
||||
{ |
||||
this.Breakpoint = breakpoint; |
||||
} |
||||
} |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,250 +1,250 @@
@@ -1,250 +1,250 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{0162E499-42D0-409B-AA25-EED21F75336B}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.AvalonEdit.AddIn</RootNamespace> |
||||
<AssemblyName>ICSharpCode.AvalonEdit.AddIn</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> |
||||
<OutputPath>..\..\..\..\AddIns\DisplayBindings\AvalonEdit\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<RunCodeAnalysis>False</RunCodeAnalysis> |
||||
<CodeAnalysisRules>-Microsoft.Design#CA1014;-Microsoft.Design#CA2210</CodeAnalysisRules> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile> |
||||
</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="Microsoft.CSharp" /> |
||||
<Reference Include="PresentationCore"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="PresentationFramework"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="ReachFramework"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Printing"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xaml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsBase"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsFormsIntegration"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Src\AvalonEditSyntaxHighlighterAdapter.cs" /> |
||||
<Compile Include="Src\DocumentSequence.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippetComparer.cs" /> |
||||
<Compile Include="Src\Utils.cs" /> |
||||
<None Include="AvalonEdit.AddIn.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\AvalonEditDisplayBinding.cs" /> |
||||
<Compile Include="Src\AvalonEditEditorUIService.cs" /> |
||||
<Compile Include="Src\AvalonEditorControlService.cs" /> |
||||
<Compile Include="Src\AvalonEditViewContent.cs" /> |
||||
<Compile Include="Src\BracketHighlightRenderer.cs" /> |
||||
<Compile Include="Src\CaretReferencesRenderer.cs" /> |
||||
<Compile Include="Src\ChangeMarkerMargin.cs" /> |
||||
<Compile Include="Src\ChooseEncodingDialog.xaml.cs"> |
||||
<DependentUpon>ChooseEncodingDialog.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\CodeCompletionEditorAdapter.cs" /> |
||||
<Compile Include="Src\CodeEditor.cs" /> |
||||
<Compile Include="Src\CodeEditorAdapter.cs" /> |
||||
<Compile Include="Src\CodeEditorView.cs" /> |
||||
<Compile Include="Src\ContextActionsRenderer.cs" /> |
||||
<Compile Include="Src\DefaultChangeWatcher.cs" /> |
||||
<Compile Include="Src\DiffControl.xaml.cs"> |
||||
<DependentUpon>DiffControl.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\ExpressionHighlightRenderer.cs" /> |
||||
<Compile Include="Src\CaretHighlightAdorner.cs" /> |
||||
<Compile Include="Src\HiddenDefinition\HiddenDefinitionControl.xaml.cs"> |
||||
<DependentUpon>HiddenDefinitionControl.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\HiddenDefinition\HiddenDefinitionRenderer.cs" /> |
||||
<Compile Include="Src\LineChangeInfo.cs" /> |
||||
<Compile Include="Src\NewLineConsistencyCheck.cs" /> |
||||
<Compile Include="Src\SearchPanelLocalization.cs" /> |
||||
<Compile Include="Src\SharpDevelopTextEditor.cs" /> |
||||
<Compile Include="Src\Commands\FoldingCommands.cs" /> |
||||
<Compile Include="Src\Commands\SaveFileWithEncoding.cs" /> |
||||
<Compile Include="Src\Commands\SortOptionsDialog.xaml.cs"> |
||||
<DependentUpon>SortOptionsDialog.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Commands\SortSelectionCommand.cs" /> |
||||
<Compile Include="Src\Commands\SurroundWithCommand.cs" /> |
||||
<Compile Include="Src\CustomCommands.cs" /> |
||||
<Compile Include="Src\CustomizableHighlightingColorizer.cs" /> |
||||
<Compile Include="Src\CustomizedHighlightingColor.cs" /> |
||||
<Compile Include="Src\DocumentPrinter.cs" /> |
||||
<Compile Include="Src\InlineUIElementGenerator.cs" /> |
||||
<Compile Include="Src\IconBarManager.cs" /> |
||||
<Compile Include="Src\IconBarMargin.cs" /> |
||||
<Compile Include="Src\Options\BehaviorOptions.xaml.cs"> |
||||
<DependentUpon>BehaviorOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Options\Converters.cs" /> |
||||
<Compile Include="Src\Options\CustomizedHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\GeneralEditorOptions.xaml.cs"> |
||||
<DependentUpon>GeneralEditorOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Options\CodeEditorOptions.cs" /> |
||||
<Compile Include="Src\Options\HighlightingOptions.xaml.cs"> |
||||
<DependentUpon>HighlightingOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Options\IHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\NamedColorHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\SimpleHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\TextViewOptions.xaml.cs"> |
||||
<DependentUpon>TextViewOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\PrintPreviewViewContent.cs" /> |
||||
<Compile Include="Src\Snippets\AnchorSnippetElementProvider.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippet.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippetCompletionWindow.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippetGroup.cs" /> |
||||
<Compile Include="Src\Snippets\DefaultSnippetElementProvider.cs" /> |
||||
<Compile Include="Src\Snippets\SnippetCompletionItem.cs" /> |
||||
<Compile Include="Src\Snippets\SnippetManager.cs" /> |
||||
<Compile Include="Src\Snippets\SnippetOptionPanel.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\ParserFoldingStrategy.cs" /> |
||||
<Compile Include="Src\QuickClassBrowser.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\SharpDevelopCompletionWindow.cs" /> |
||||
<Compile Include="Src\SharpDevelopInsightWindow.cs"> |
||||
</Compile> |
||||
<Compile Include="Src\StringToVisibilityConverter.cs" /> |
||||
<Compile Include="Src\SyntaxModeDoozer.cs" /> |
||||
<Compile Include="Src\TextMarkerService.cs" /> |
||||
<EmbeddedResource Include="Resources\IncrementalSearchCursor.cur" /> |
||||
<EmbeddedResource Include="Resources\ReverseIncrementalSearchCursor.cur" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Src\DiffControl.xaml" /> |
||||
<Page Include="Src\HiddenDefinition\HiddenDefinitionControl.xaml" /> |
||||
<Page Include="Src\SharpDevelopCompletionWindow.xaml"> |
||||
<DependentUpon>SharpDevelopCompletionWindow.cs</DependentUpon> |
||||
</Page> |
||||
<Page Include="themes\generic.xaml" /> |
||||
<ProjectReference Include="..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> |
||||
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> |
||||
<Name>ICSharpCode.AvalonEdit</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Libraries\Mono.Cecil\Mono.Cecil.csproj"> |
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project> |
||||
<Name>Mono.Cecil</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj"> |
||||
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project> |
||||
<Name>NRefactory</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj"> |
||||
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project> |
||||
<Name>ICSharpCode.Core.Presentation</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj"> |
||||
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> |
||||
<Name>ICSharpCode.Core.WinForms</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<Page Include="Src\ChooseEncodingDialog.xaml" /> |
||||
<Page Include="Src\Commands\SortOptionsDialog.xaml" /> |
||||
<Page Include="Src\Options\BehaviorOptions.xaml" /> |
||||
<Page Include="Src\Options\GeneralEditorOptions.xaml" /> |
||||
<Page Include="Src\Options\HighlightingOptions.xaml" /> |
||||
<Page Include="Src\Options\TextViewOptions.xaml" /> |
||||
<Page Include="Src\Snippets\SnippetOptionPanel.xaml"> |
||||
<DependentUpon>SnippetOptionPanel.cs</DependentUpon> |
||||
</Page> |
||||
<Page Include="Src\QuickClassBrowser.xaml"> |
||||
<DependentUpon>QuickClassBrowser.cs</DependentUpon> |
||||
</Page> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj"> |
||||
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Widgets</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Src\HiddenDefinition" /> |
||||
</ItemGroup> |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{0162E499-42D0-409B-AA25-EED21F75336B}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.AvalonEdit.AddIn</RootNamespace> |
||||
<AssemblyName>ICSharpCode.AvalonEdit.AddIn</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> |
||||
<OutputPath>..\..\..\..\AddIns\DisplayBindings\AvalonEdit\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<RunCodeAnalysis>False</RunCodeAnalysis> |
||||
<CodeAnalysisRules>-Microsoft.Design#CA1014;-Microsoft.Design#CA2210</CodeAnalysisRules> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile> |
||||
</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="Microsoft.CSharp" /> |
||||
<Reference Include="PresentationCore"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="PresentationFramework"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="ReachFramework"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Printing"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xaml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsBase"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsFormsIntegration"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Src\AvalonEditSyntaxHighlighterAdapter.cs" /> |
||||
<Compile Include="Src\DocumentSequence.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippetComparer.cs" /> |
||||
<Compile Include="Src\Utils.cs" /> |
||||
<None Include="AvalonEdit.AddIn.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\AvalonEditDisplayBinding.cs" /> |
||||
<Compile Include="Src\AvalonEditEditorUIService.cs" /> |
||||
<Compile Include="Src\AvalonEditorControlService.cs" /> |
||||
<Compile Include="Src\AvalonEditViewContent.cs" /> |
||||
<Compile Include="Src\BracketHighlightRenderer.cs" /> |
||||
<Compile Include="Src\CaretReferencesRenderer.cs" /> |
||||
<Compile Include="Src\ChangeMarkerMargin.cs" /> |
||||
<Compile Include="Src\ChooseEncodingDialog.xaml.cs"> |
||||
<DependentUpon>ChooseEncodingDialog.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\CodeCompletionEditorAdapter.cs" /> |
||||
<Compile Include="Src\CodeEditor.cs" /> |
||||
<Compile Include="Src\CodeEditorAdapter.cs" /> |
||||
<Compile Include="Src\CodeEditorView.cs" /> |
||||
<Compile Include="Src\ContextActionsRenderer.cs" /> |
||||
<Compile Include="Src\DefaultChangeWatcher.cs" /> |
||||
<Compile Include="Src\DiffControl.xaml.cs"> |
||||
<DependentUpon>DiffControl.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\ExpressionHighlightRenderer.cs" /> |
||||
<Compile Include="Src\CaretHighlightAdorner.cs" /> |
||||
<Compile Include="Src\HiddenDefinition\HiddenDefinitionControl.xaml.cs"> |
||||
<DependentUpon>HiddenDefinitionControl.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\HiddenDefinition\HiddenDefinitionRenderer.cs" /> |
||||
<Compile Include="Src\LineChangeInfo.cs" /> |
||||
<Compile Include="Src\NewLineConsistencyCheck.cs" /> |
||||
<Compile Include="Src\SearchPanelLocalization.cs" /> |
||||
<Compile Include="Src\SharpDevelopTextEditor.cs" /> |
||||
<Compile Include="Src\Commands\FoldingCommands.cs" /> |
||||
<Compile Include="Src\Commands\SaveFileWithEncoding.cs" /> |
||||
<Compile Include="Src\Commands\SortOptionsDialog.xaml.cs"> |
||||
<DependentUpon>SortOptionsDialog.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Commands\SortSelectionCommand.cs" /> |
||||
<Compile Include="Src\Commands\SurroundWithCommand.cs" /> |
||||
<Compile Include="Src\CustomCommands.cs" /> |
||||
<Compile Include="Src\CustomizableHighlightingColorizer.cs" /> |
||||
<Compile Include="Src\CustomizedHighlightingColor.cs" /> |
||||
<Compile Include="Src\DocumentPrinter.cs" /> |
||||
<Compile Include="Src\InlineUIElementGenerator.cs" /> |
||||
<Compile Include="Src\IconBarManager.cs" /> |
||||
<Compile Include="Src\IconBarMargin.cs" /> |
||||
<Compile Include="Src\Options\BehaviorOptions.xaml.cs"> |
||||
<DependentUpon>BehaviorOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Options\Converters.cs" /> |
||||
<Compile Include="Src\Options\CustomizedHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\GeneralEditorOptions.xaml.cs"> |
||||
<DependentUpon>GeneralEditorOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Options\CodeEditorOptions.cs" /> |
||||
<Compile Include="Src\Options\HighlightingOptions.xaml.cs"> |
||||
<DependentUpon>HighlightingOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Options\IHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\NamedColorHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\SimpleHighlightingItem.cs" /> |
||||
<Compile Include="Src\Options\TextViewOptions.xaml.cs"> |
||||
<DependentUpon>TextViewOptions.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\PrintPreviewViewContent.cs" /> |
||||
<Compile Include="Src\Snippets\AnchorSnippetElementProvider.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippet.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippetCompletionWindow.cs" /> |
||||
<Compile Include="Src\Snippets\CodeSnippetGroup.cs" /> |
||||
<Compile Include="Src\Snippets\DefaultSnippetElementProvider.cs" /> |
||||
<Compile Include="Src\Snippets\SnippetCompletionItem.cs" /> |
||||
<Compile Include="Src\Snippets\SnippetManager.cs" /> |
||||
<Compile Include="Src\Snippets\SnippetOptionPanel.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\ParserFoldingStrategy.cs" /> |
||||
<Compile Include="Src\QuickClassBrowser.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\SharpDevelopCompletionWindow.cs" /> |
||||
<Compile Include="Src\SharpDevelopInsightWindow.cs"> |
||||
</Compile> |
||||
<Compile Include="Src\StringToVisibilityConverter.cs" /> |
||||
<Compile Include="Src\SyntaxModeDoozer.cs" /> |
||||
<Compile Include="Src\TextMarkerService.cs" /> |
||||
<EmbeddedResource Include="Resources\IncrementalSearchCursor.cur" /> |
||||
<EmbeddedResource Include="Resources\ReverseIncrementalSearchCursor.cur" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Src\DiffControl.xaml" /> |
||||
<Page Include="Src\HiddenDefinition\HiddenDefinitionControl.xaml" /> |
||||
<Page Include="Src\SharpDevelopCompletionWindow.xaml"> |
||||
<DependentUpon>SharpDevelopCompletionWindow.cs</DependentUpon> |
||||
</Page> |
||||
<Page Include="themes\generic.xaml" /> |
||||
<ProjectReference Include="..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> |
||||
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> |
||||
<Name>ICSharpCode.AvalonEdit</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Libraries\Mono.Cecil\Mono.Cecil.csproj"> |
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project> |
||||
<Name>Mono.Cecil</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj"> |
||||
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project> |
||||
<Name>NRefactory</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj"> |
||||
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project> |
||||
<Name>ICSharpCode.Core.Presentation</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj"> |
||||
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> |
||||
<Name>ICSharpCode.Core.WinForms</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<Page Include="Src\ChooseEncodingDialog.xaml" /> |
||||
<Page Include="Src\Commands\SortOptionsDialog.xaml" /> |
||||
<Page Include="Src\Options\BehaviorOptions.xaml" /> |
||||
<Page Include="Src\Options\GeneralEditorOptions.xaml" /> |
||||
<Page Include="Src\Options\HighlightingOptions.xaml" /> |
||||
<Page Include="Src\Options\TextViewOptions.xaml" /> |
||||
<Page Include="Src\Snippets\SnippetOptionPanel.xaml"> |
||||
<DependentUpon>SnippetOptionPanel.cs</DependentUpon> |
||||
</Page> |
||||
<Page Include="Src\QuickClassBrowser.xaml"> |
||||
<DependentUpon>QuickClassBrowser.cs</DependentUpon> |
||||
</Page> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj"> |
||||
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Widgets</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Src\HiddenDefinition" /> |
||||
</ItemGroup> |
||||
</Project> |
@ -1,27 +1,27 @@
@@ -1,27 +1,27 @@
|
||||
// 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.AvalonEdit.AddIn.Options; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.AddIn.HiddenDefinition |
||||
{ |
||||
public partial class HiddenDefinitionControl : UserControl |
||||
{ |
||||
public HiddenDefinitionControl() |
||||
{ |
||||
InitializeComponent(); |
||||
DefinitionTextBlock.FontFamily = new FontFamily(CodeEditorOptions.Instance.FontFamily); |
||||
DefinitionTextBlock.FontSize = CodeEditorOptions.Instance.FontSize; |
||||
} |
||||
|
||||
public string DefinitionText { |
||||
get { return this.DefinitionTextBlock.Text; } |
||||
set { this.DefinitionTextBlock.Text = value; } |
||||
} |
||||
} |
||||
// 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.AvalonEdit.AddIn.Options; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.AddIn.HiddenDefinition |
||||
{ |
||||
public partial class HiddenDefinitionControl : UserControl |
||||
{ |
||||
public HiddenDefinitionControl() |
||||
{ |
||||
InitializeComponent(); |
||||
DefinitionTextBlock.FontFamily = new FontFamily(CodeEditorOptions.Instance.FontFamily); |
||||
DefinitionTextBlock.FontSize = CodeEditorOptions.Instance.FontSize; |
||||
} |
||||
|
||||
public string DefinitionText { |
||||
get { return this.DefinitionTextBlock.Text; } |
||||
set { this.DefinitionTextBlock.Text = value; } |
||||
} |
||||
} |
||||
} |
@ -1,102 +1,102 @@
@@ -1,102 +1,102 @@
|
||||
// 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.Controls.Primitives; |
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.AddIn.HiddenDefinition |
||||
{ |
||||
public class HiddenDefinitionRenderer : IDisposable |
||||
{ |
||||
private CodeEditorView editor; |
||||
private ExtendedPopup popup = new ExtendedPopup(); |
||||
private HiddenDefinitionControl control; |
||||
|
||||
public HiddenDefinitionRenderer(CodeEditorView editorView) |
||||
{ |
||||
this.editor = editorView; |
||||
control = new HiddenDefinitionControl(); |
||||
WorkbenchSingleton.Workbench.ActiveContentChanged += WorkbenchSingleton_Workbench_ActiveContentChanged; |
||||
} |
||||
|
||||
public BracketSearchResult BracketSearchResult { get; set; } |
||||
|
||||
public void Dispose() |
||||
{ |
||||
WorkbenchSingleton.Workbench.ActiveContentChanged -= WorkbenchSingleton_Workbench_ActiveContentChanged; |
||||
ClosePopup(); |
||||
popup = null; |
||||
} |
||||
|
||||
public void ClosePopup() |
||||
{ |
||||
if (popup != null && popup.IsOpen) |
||||
popup.IsOpen = false; |
||||
} |
||||
|
||||
public void Show() |
||||
{ |
||||
ClosePopup(); |
||||
|
||||
if (BracketSearchResult == null) return; |
||||
|
||||
// verify if we have a open bracket
|
||||
if (this.editor.Document.GetCharAt(BracketSearchResult.OpeningBracketOffset) != '{') |
||||
return; |
||||
|
||||
var line = GetLineText(BracketSearchResult.OpeningBracketOffset); |
||||
if(line == null) return; |
||||
|
||||
control.DefinitionText = line; |
||||
popup.Child = control; |
||||
popup.HorizontalOffset = 70; |
||||
popup.Placement = PlacementMode.Relative; |
||||
popup.PlacementTarget = editor.TextArea; |
||||
popup.IsOpen = true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the line text near the offset.
|
||||
/// </summary>
|
||||
/// <param name="offset">Offset.</param>
|
||||
/// <returns></returns>
|
||||
private string GetLineText(int offset) |
||||
{ |
||||
if (!editor.TextArea.TextView.VisualLinesValid) |
||||
return null; |
||||
|
||||
// get line
|
||||
var documentLine = editor.Document.GetLineByOffset(offset); |
||||
string documentText = editor.Document.Text; |
||||
string lineText = string.Empty; |
||||
int off, length; |
||||
|
||||
do { |
||||
if (documentLine == null || documentLine.IsDeleted) return null; |
||||
off = documentLine.Offset; |
||||
length = documentLine.Length; |
||||
lineText = documentText.Substring(off, length).Trim(); |
||||
|
||||
documentLine = documentLine.PreviousLine; |
||||
} |
||||
while (lineText == "{" || string.IsNullOrEmpty(lineText) || |
||||
lineText.StartsWith("//") || lineText.StartsWith("/*") || |
||||
lineText.StartsWith("*") || lineText.StartsWith("'")); |
||||
|
||||
// check whether the line is visible
|
||||
if (editor.TextArea.TextView.VisualLines[0].StartOffset > off) { |
||||
return this.editor.TextArea.TextView.Document.GetText(off, length); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
private void WorkbenchSingleton_Workbench_ActiveContentChanged(object sender, EventArgs e) |
||||
{ |
||||
ClosePopup(); |
||||
} |
||||
} |
||||
// 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.Controls.Primitives; |
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.AddIn.HiddenDefinition |
||||
{ |
||||
public class HiddenDefinitionRenderer : IDisposable |
||||
{ |
||||
private CodeEditorView editor; |
||||
private ExtendedPopup popup = new ExtendedPopup(); |
||||
private HiddenDefinitionControl control; |
||||
|
||||
public HiddenDefinitionRenderer(CodeEditorView editorView) |
||||
{ |
||||
this.editor = editorView; |
||||
control = new HiddenDefinitionControl(); |
||||
WorkbenchSingleton.Workbench.ActiveContentChanged += WorkbenchSingleton_Workbench_ActiveContentChanged; |
||||
} |
||||
|
||||
public BracketSearchResult BracketSearchResult { get; set; } |
||||
|
||||
public void Dispose() |
||||
{ |
||||
WorkbenchSingleton.Workbench.ActiveContentChanged -= WorkbenchSingleton_Workbench_ActiveContentChanged; |
||||
ClosePopup(); |
||||
popup = null; |
||||
} |
||||
|
||||
public void ClosePopup() |
||||
{ |
||||
if (popup != null && popup.IsOpen) |
||||
popup.IsOpen = false; |
||||
} |
||||
|
||||
public void Show() |
||||
{ |
||||
ClosePopup(); |
||||
|
||||
if (BracketSearchResult == null) return; |
||||
|
||||
// verify if we have a open bracket
|
||||
if (this.editor.Document.GetCharAt(BracketSearchResult.OpeningBracketOffset) != '{') |
||||
return; |
||||
|
||||
var line = GetLineText(BracketSearchResult.OpeningBracketOffset); |
||||
if(line == null) return; |
||||
|
||||
control.DefinitionText = line; |
||||
popup.Child = control; |
||||
popup.HorizontalOffset = 70; |
||||
popup.Placement = PlacementMode.Relative; |
||||
popup.PlacementTarget = editor.TextArea; |
||||
popup.IsOpen = true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the line text near the offset.
|
||||
/// </summary>
|
||||
/// <param name="offset">Offset.</param>
|
||||
/// <returns></returns>
|
||||
private string GetLineText(int offset) |
||||
{ |
||||
if (!editor.TextArea.TextView.VisualLinesValid) |
||||
return null; |
||||
|
||||
// get line
|
||||
var documentLine = editor.Document.GetLineByOffset(offset); |
||||
string documentText = editor.Document.Text; |
||||
string lineText = string.Empty; |
||||
int off, length; |
||||
|
||||
do { |
||||
if (documentLine == null || documentLine.IsDeleted) return null; |
||||
off = documentLine.Offset; |
||||
length = documentLine.Length; |
||||
lineText = documentText.Substring(off, length).Trim(); |
||||
|
||||
documentLine = documentLine.PreviousLine; |
||||
} |
||||
while (lineText == "{" || string.IsNullOrEmpty(lineText) || |
||||
lineText.StartsWith("//") || lineText.StartsWith("/*") || |
||||
lineText.StartsWith("*") || lineText.StartsWith("'")); |
||||
|
||||
// check whether the line is visible
|
||||
if (editor.TextArea.TextView.VisualLines[0].StartOffset > off) { |
||||
return this.editor.TextArea.TextView.Document.GetText(off, length); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
private void WorkbenchSingleton_Workbench_ActiveContentChanged(object sender, EventArgs e) |
||||
{ |
||||
ClosePopup(); |
||||
} |
||||
} |
||||
} |
@ -1,55 +1,55 @@
@@ -1,55 +1,55 @@
|
||||
// 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 ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.WpfDesign.Designer.ThumbnailView; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
public class ThumbnailViewPad : AbstractPadContent |
||||
{ |
||||
ContentPresenter contentControl = new ContentPresenter(); |
||||
|
||||
ThumbnailView thumbnailView = new ThumbnailView(); |
||||
|
||||
TextBlock notAvailableTextBlock = new TextBlock { |
||||
Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.OutlinePad.NotAvailable}"), |
||||
TextWrapping = TextWrapping.Wrap |
||||
}; |
||||
|
||||
public ThumbnailViewPad() |
||||
{ |
||||
WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchActiveViewContentChanged; |
||||
WorkbenchActiveViewContentChanged(null, null); |
||||
} |
||||
|
||||
void WorkbenchActiveViewContentChanged(object sender, EventArgs e) |
||||
{ |
||||
WpfViewContent wpfView = WorkbenchSingleton.Workbench.ActiveViewContent as WpfViewContent; |
||||
if (wpfView != null) |
||||
{ |
||||
thumbnailView.DesignSurface = wpfView.DesignSurface; |
||||
contentControl.SetContent(thumbnailView); |
||||
} |
||||
else |
||||
{ |
||||
contentControl.SetContent(notAvailableTextBlock); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get { |
||||
return contentControl; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
// 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 ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.WpfDesign.Designer.ThumbnailView; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
public class ThumbnailViewPad : AbstractPadContent |
||||
{ |
||||
ContentPresenter contentControl = new ContentPresenter(); |
||||
|
||||
ThumbnailView thumbnailView = new ThumbnailView(); |
||||
|
||||
TextBlock notAvailableTextBlock = new TextBlock { |
||||
Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.OutlinePad.NotAvailable}"), |
||||
TextWrapping = TextWrapping.Wrap |
||||
}; |
||||
|
||||
public ThumbnailViewPad() |
||||
{ |
||||
WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchActiveViewContentChanged; |
||||
WorkbenchActiveViewContentChanged(null, null); |
||||
} |
||||
|
||||
void WorkbenchActiveViewContentChanged(object sender, EventArgs e) |
||||
{ |
||||
WpfViewContent wpfView = WorkbenchSingleton.Workbench.ActiveViewContent as WpfViewContent; |
||||
if (wpfView != null) |
||||
{ |
||||
thumbnailView.DesignSurface = wpfView.DesignSurface; |
||||
contentControl.SetContent(thumbnailView); |
||||
} |
||||
else |
||||
{ |
||||
contentControl.SetContent(notAvailableTextBlock); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get { |
||||
return contentControl; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,158 +1,158 @@
@@ -1,158 +1,158 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.WpfDesign.AddIn</RootNamespace> |
||||
<AssemblyName>ICSharpCode.WpfDesign.AddIn</AssemblyName> |
||||
<OutputPath>..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile> |
||||
</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<Optimize>False</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="PresentationCore" /> |
||||
<Reference Include="PresentationFramework" /> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xaml"> |
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="WindowsBase" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Resource Include="Images\Icons.32x32.Error.png" /> |
||||
<None Include="WpfDesign.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\AbstractEventHandlerService.cs" /> |
||||
<Compile Include="Src\Commands\CutCopyPaste.cs" /> |
||||
<Compile Include="Src\Commands\Pads.cs" /> |
||||
<Compile Include="Src\Commands\Remove.cs" /> |
||||
<Compile Include="Src\Commands\UndoRedo.cs" /> |
||||
<Compile Include="Src\Commands\ViewXaml.cs" /> |
||||
<Compile Include="Src\SharpDevelopTranslations.cs" /> |
||||
<Compile Include="Src\ThumbnailViewPad.cs" /> |
||||
<Compile Include="Src\CSharpEventHandlerService.cs" /> |
||||
<Compile Include="Src\FileUriContext.cs" /> |
||||
<Compile Include="Src\IdeChooseClassService.cs" /> |
||||
<Compile Include="Src\ImageSourceEditor\ChooseImageDialog.xaml.cs"> |
||||
<DependentUpon>ChooseImageDialog.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\ImageSourceEditor\ImageSourceEditor.xaml.cs"> |
||||
<DependentUpon>ImageSourceEditor.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\MyTypeFinder.cs" /> |
||||
<Compile Include="Src\ObjectEditor.xaml.cs"> |
||||
<DependentUpon>ObjectEditor.xaml</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\OutlineViewPad.cs" /> |
||||
<Compile Include="Src\ProjectTools.cs" /> |
||||
<Compile Include="Src\PropertyDescriptionService.cs" /> |
||||
<Compile Include="Src\WpfAndWinFormsTopLevelWindowService.cs" /> |
||||
<Compile Include="Src\WpfDisplayBinding.cs" /> |
||||
<Compile Include="Src\WpfDocumentError.xaml.cs"> |
||||
<DependentUpon>WpfDocumentError.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\WpfSideTabItem.cs" /> |
||||
<Compile Include="Src\WpfToolbox.cs" /> |
||||
<Compile Include="Src\WpfViewContent.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Src\WpfDocumentError.xaml" /> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj"> |
||||
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project> |
||||
<Name>ICSharpCode.Core.Presentation</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj"> |
||||
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> |
||||
<Name>ICSharpCode.Core.WinForms</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj"> |
||||
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Widgets</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\FormsDesigner\Project\FormsDesigner.csproj"> |
||||
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project> |
||||
<Name>FormsDesigner</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj"> |
||||
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project> |
||||
<Name>WpfDesign.Designer</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj"> |
||||
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project> |
||||
<Name>WpfDesign.XamlDom</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\WpfDesign\Project\WpfDesign.csproj"> |
||||
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project> |
||||
<Name>WpfDesign</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<Page Include="Src\ImageSourceEditor\ChooseImageDialog.xaml" /> |
||||
<Page Include="Src\ImageSourceEditor\ImageSourceEditor.xaml" /> |
||||
<Page Include="Src\ObjectEditor.xaml" /> |
||||
</ItemGroup> |
||||
<ItemGroup /> |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.WpfDesign.AddIn</RootNamespace> |
||||
<AssemblyName>ICSharpCode.WpfDesign.AddIn</AssemblyName> |
||||
<OutputPath>..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile> |
||||
</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<Optimize>False</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="PresentationCore" /> |
||||
<Reference Include="PresentationFramework" /> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xaml"> |
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="WindowsBase" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Resource Include="Images\Icons.32x32.Error.png" /> |
||||
<None Include="WpfDesign.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\AbstractEventHandlerService.cs" /> |
||||
<Compile Include="Src\Commands\CutCopyPaste.cs" /> |
||||
<Compile Include="Src\Commands\Pads.cs" /> |
||||
<Compile Include="Src\Commands\Remove.cs" /> |
||||
<Compile Include="Src\Commands\UndoRedo.cs" /> |
||||
<Compile Include="Src\Commands\ViewXaml.cs" /> |
||||
<Compile Include="Src\SharpDevelopTranslations.cs" /> |
||||
<Compile Include="Src\ThumbnailViewPad.cs" /> |
||||
<Compile Include="Src\CSharpEventHandlerService.cs" /> |
||||
<Compile Include="Src\FileUriContext.cs" /> |
||||
<Compile Include="Src\IdeChooseClassService.cs" /> |
||||
<Compile Include="Src\ImageSourceEditor\ChooseImageDialog.xaml.cs"> |
||||
<DependentUpon>ChooseImageDialog.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\ImageSourceEditor\ImageSourceEditor.xaml.cs"> |
||||
<DependentUpon>ImageSourceEditor.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\MyTypeFinder.cs" /> |
||||
<Compile Include="Src\ObjectEditor.xaml.cs"> |
||||
<DependentUpon>ObjectEditor.xaml</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\OutlineViewPad.cs" /> |
||||
<Compile Include="Src\ProjectTools.cs" /> |
||||
<Compile Include="Src\PropertyDescriptionService.cs" /> |
||||
<Compile Include="Src\WpfAndWinFormsTopLevelWindowService.cs" /> |
||||
<Compile Include="Src\WpfDisplayBinding.cs" /> |
||||
<Compile Include="Src\WpfDocumentError.xaml.cs"> |
||||
<DependentUpon>WpfDocumentError.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\WpfSideTabItem.cs" /> |
||||
<Compile Include="Src\WpfToolbox.cs" /> |
||||
<Compile Include="Src\WpfViewContent.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Src\WpfDocumentError.xaml" /> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj"> |
||||
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project> |
||||
<Name>ICSharpCode.Core.Presentation</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj"> |
||||
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> |
||||
<Name>ICSharpCode.Core.WinForms</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj"> |
||||
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Widgets</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\FormsDesigner\Project\FormsDesigner.csproj"> |
||||
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project> |
||||
<Name>FormsDesigner</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj"> |
||||
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project> |
||||
<Name>WpfDesign.Designer</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj"> |
||||
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project> |
||||
<Name>WpfDesign.XamlDom</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\WpfDesign\Project\WpfDesign.csproj"> |
||||
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project> |
||||
<Name>WpfDesign</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<Page Include="Src\ImageSourceEditor\ChooseImageDialog.xaml" /> |
||||
<Page Include="Src\ImageSourceEditor\ImageSourceEditor.xaml" /> |
||||
<Page Include="Src\ObjectEditor.xaml" /> |
||||
</ItemGroup> |
||||
<ItemGroup /> |
||||
</Project> |
@ -1,328 +1,328 @@
@@ -1,328 +1,328 @@
|
||||
// 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.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Collections.ObjectModel; |
||||
using System.Threading; |
||||
using System.Globalization; |
||||
using ICSharpCode.WpfDesign.PropertyGrid; |
||||
using System.Windows.Threading; |
||||
using System.Diagnostics; |
||||
using System.Windows.Media; |
||||
using System.Windows; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid |
||||
{ |
||||
public class PropertyGrid : INotifyPropertyChanged |
||||
{ |
||||
public PropertyGrid() |
||||
{ |
||||
Categories = new CategoriesCollection(); |
||||
Categories.Add(specialCategory); |
||||
Categories.Add(popularCategory); |
||||
Categories.Add(otherCategory); |
||||
Categories.Add(attachedCategory); |
||||
|
||||
Events = new PropertyNodeCollection(); |
||||
} |
||||
|
||||
Category specialCategory = new Category("Special"); |
||||
Category popularCategory = new Category("Popular"); |
||||
Category otherCategory = new Category("Other"); |
||||
Category attachedCategory = new Category("Attached"); |
||||
|
||||
Dictionary<MemberDescriptor, PropertyNode> nodeFromDescriptor = new Dictionary<MemberDescriptor, PropertyNode>(); |
||||
|
||||
public CategoriesCollection Categories { get; private set; } |
||||
public PropertyNodeCollection Events { get; private set; } |
||||
|
||||
private PropertyGridGroupMode _groupMode; |
||||
|
||||
public PropertyGridGroupMode GroupMode |
||||
{ |
||||
get { return _groupMode; } |
||||
set |
||||
{ |
||||
if (_groupMode != value) |
||||
{ |
||||
_groupMode = value; |
||||
|
||||
RaisePropertyChanged("GroupMode"); |
||||
|
||||
Reload(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
PropertyGridTab currentTab; |
||||
|
||||
public PropertyGridTab CurrentTab { |
||||
get { |
||||
return currentTab; |
||||
} |
||||
set { |
||||
currentTab = value; |
||||
RaisePropertyChanged("CurrentTab"); |
||||
RaisePropertyChanged("NameBackground"); |
||||
} |
||||
} |
||||
|
||||
string filter; |
||||
|
||||
public string Filter { |
||||
get { |
||||
return filter; |
||||
} |
||||
set { |
||||
filter = value; |
||||
Reload(); |
||||
RaisePropertyChanged("Filter"); |
||||
} |
||||
} |
||||
|
||||
DesignItem singleItem; |
||||
|
||||
public DesignItem SingleItem { |
||||
get { |
||||
return singleItem; |
||||
} |
||||
private set { |
||||
if (singleItem != null) { |
||||
singleItem.NameChanged -= singleItem_NameChanged; |
||||
} |
||||
singleItem = value; |
||||
if (singleItem != null) { |
||||
singleItem.NameChanged += singleItem_NameChanged; |
||||
} |
||||
RaisePropertyChanged("SingleItem"); |
||||
RaisePropertyChanged("Name"); |
||||
RaisePropertyChanged("IsNameEnabled"); |
||||
IsNameCorrect = true; |
||||
} |
||||
} |
||||
|
||||
void singleItem_NameChanged(object sender, EventArgs e) |
||||
{ |
||||
RaisePropertyChanged("Name"); |
||||
} |
||||
|
||||
public string OldName { |
||||
get; private set; |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
if (SingleItem != null) { |
||||
return SingleItem.Name; |
||||
} |
||||
return null; |
||||
} |
||||
set { |
||||
if (SingleItem != null) { |
||||
try { |
||||
if (string.IsNullOrEmpty(value)) { |
||||
OldName = null; |
||||
SingleItem.Name = null; |
||||
} else { |
||||
OldName = SingleItem.Name; |
||||
SingleItem.Name = value; |
||||
} |
||||
IsNameCorrect = true; |
||||
} catch { |
||||
IsNameCorrect = false; |
||||
} |
||||
RaisePropertyChanged("Name"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
bool isNameCorrect = true; |
||||
|
||||
public bool IsNameCorrect { |
||||
get { |
||||
return isNameCorrect; |
||||
} |
||||
set { |
||||
isNameCorrect = value; |
||||
RaisePropertyChanged("IsNameCorrect"); |
||||
} |
||||
} |
||||
|
||||
public bool IsNameEnabled { |
||||
get { |
||||
return SingleItem != null; |
||||
} |
||||
} |
||||
|
||||
IEnumerable<DesignItem> selectedItems; |
||||
|
||||
public IEnumerable<DesignItem> SelectedItems { |
||||
get { |
||||
return selectedItems; |
||||
} |
||||
set { |
||||
selectedItems = value; |
||||
RaisePropertyChanged("SelectedItems"); |
||||
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action( |
||||
delegate { |
||||
Reload(); |
||||
})); |
||||
} |
||||
} |
||||
|
||||
public void ClearFilter() |
||||
{ |
||||
Filter = null; |
||||
} |
||||
|
||||
void Reload() |
||||
{ |
||||
Clear(); |
||||
|
||||
if (SelectedItems == null || SelectedItems.Count() == 0) return; |
||||
if (SelectedItems.Count() == 1) SingleItem = SelectedItems.First(); |
||||
|
||||
foreach (var md in GetDescriptors()) { |
||||
if (PassesFilter(md.Name)) |
||||
AddNode(md); |
||||
} |
||||
} |
||||
|
||||
void Clear() |
||||
{ |
||||
foreach (var c in Categories) { |
||||
c.IsVisible = false; |
||||
foreach (var p in c.Properties) { |
||||
p.IsVisible = false; |
||||
} |
||||
} |
||||
|
||||
foreach (var e in Events) { |
||||
e.IsVisible = false; |
||||
} |
||||
|
||||
SingleItem = null; |
||||
} |
||||
|
||||
List<MemberDescriptor> GetDescriptors() |
||||
{ |
||||
List<MemberDescriptor> list = new List<MemberDescriptor>(); |
||||
|
||||
if (SelectedItems.Count() == 1) { |
||||
foreach (MemberDescriptor d in TypeHelper.GetAvailableProperties(SingleItem.Component)) { |
||||
list.Add(d); |
||||
} |
||||
foreach (MemberDescriptor d in TypeHelper.GetAvailableEvents(SingleItem.ComponentType)) { |
||||
list.Add(d); |
||||
} |
||||
} else { |
||||
foreach (MemberDescriptor d in TypeHelper.GetCommonAvailableProperties(SelectedItems.Select(t => t.Component))) { |
||||
list.Add(d); |
||||
} |
||||
} |
||||
|
||||
return list; |
||||
} |
||||
|
||||
bool PassesFilter(string name) |
||||
{ |
||||
if (string.IsNullOrEmpty(Filter)) return true; |
||||
for (int i = 0; i < name.Length; i++) { |
||||
if (i == 0 || char.IsUpper(name[i])) { |
||||
if (string.Compare(name, i, Filter, 0, Filter.Length, true) == 0) { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void AddNode(MemberDescriptor md) |
||||
{ |
||||
var designProperties = SelectedItems.Select(item => item.Properties.GetProperty(md)).ToArray(); |
||||
if (!Metadata.IsBrowsable(designProperties[0])) return; |
||||
|
||||
PropertyNode node; |
||||
if (nodeFromDescriptor.TryGetValue(md, out node)) { |
||||
node.Load(designProperties); |
||||
} else { |
||||
node = new PropertyNode(); |
||||
node.Load(designProperties); |
||||
if (node.IsEvent) { |
||||
Events.AddSorted(node); |
||||
} else { |
||||
var cat = PickCategory(node); |
||||
cat.Properties.AddSorted(node); |
||||
node.Category = cat; |
||||
} |
||||
nodeFromDescriptor[md] = node; |
||||
} |
||||
node.IsVisible = true; |
||||
if (node.Category != null) |
||||
node.Category.IsVisible = true; |
||||
} |
||||
|
||||
Category PickCategory(PropertyNode node) |
||||
{ |
||||
if (Metadata.IsPopularProperty(node.FirstProperty)) return popularCategory; |
||||
if (node.FirstProperty.IsAttachedDependencyProperty()) return attachedCategory; |
||||
var typeName = node.FirstProperty.DeclaringType.FullName; |
||||
if (typeName.StartsWith("System.Windows.") || typeName.StartsWith("ICSharpCode.WpfDesign.Designer.Controls.")) |
||||
return otherCategory; |
||||
return specialCategory; |
||||
} |
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void RaisePropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
//class CategoryNameComparer : IComparer<string>
|
||||
//{
|
||||
// public static CategoryNameComparer Instance = new CategoryNameComparer();
|
||||
|
||||
// public int Compare(string x, string y)
|
||||
// {
|
||||
// int i1 = Array.IndexOf(Metadata.CategoryOrder, x);
|
||||
// if (i1 == -1) i1 = int.MaxValue;
|
||||
// int i2 = Array.IndexOf(Metadata.CategoryOrder, y);
|
||||
// if (i2 == -1) i2 = int.MaxValue;
|
||||
// if (i1 == i2) return x.CompareTo(y);
|
||||
// return i1.CompareTo(i2);
|
||||
// }
|
||||
//}
|
||||
} |
||||
|
||||
public class CategoriesCollection : SortedObservableCollection<Category, string> |
||||
{ |
||||
public CategoriesCollection() |
||||
: base(n => n.Name) |
||||
{ |
||||
} |
||||
} |
||||
|
||||
public enum PropertyGridGroupMode |
||||
{ |
||||
GroupByPopularCategorys, |
||||
GroupByCategorys, |
||||
Ungrouped, |
||||
} |
||||
|
||||
public enum PropertyGridTab |
||||
{ |
||||
Properties, |
||||
Events |
||||
} |
||||
} |
||||
// 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.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Collections.ObjectModel; |
||||
using System.Threading; |
||||
using System.Globalization; |
||||
using ICSharpCode.WpfDesign.PropertyGrid; |
||||
using System.Windows.Threading; |
||||
using System.Diagnostics; |
||||
using System.Windows.Media; |
||||
using System.Windows; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid |
||||
{ |
||||
public class PropertyGrid : INotifyPropertyChanged |
||||
{ |
||||
public PropertyGrid() |
||||
{ |
||||
Categories = new CategoriesCollection(); |
||||
Categories.Add(specialCategory); |
||||
Categories.Add(popularCategory); |
||||
Categories.Add(otherCategory); |
||||
Categories.Add(attachedCategory); |
||||
|
||||
Events = new PropertyNodeCollection(); |
||||
} |
||||
|
||||
Category specialCategory = new Category("Special"); |
||||
Category popularCategory = new Category("Popular"); |
||||
Category otherCategory = new Category("Other"); |
||||
Category attachedCategory = new Category("Attached"); |
||||
|
||||
Dictionary<MemberDescriptor, PropertyNode> nodeFromDescriptor = new Dictionary<MemberDescriptor, PropertyNode>(); |
||||
|
||||
public CategoriesCollection Categories { get; private set; } |
||||
public PropertyNodeCollection Events { get; private set; } |
||||
|
||||
private PropertyGridGroupMode _groupMode; |
||||
|
||||
public PropertyGridGroupMode GroupMode |
||||
{ |
||||
get { return _groupMode; } |
||||
set |
||||
{ |
||||
if (_groupMode != value) |
||||
{ |
||||
_groupMode = value; |
||||
|
||||
RaisePropertyChanged("GroupMode"); |
||||
|
||||
Reload(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
PropertyGridTab currentTab; |
||||
|
||||
public PropertyGridTab CurrentTab { |
||||
get { |
||||
return currentTab; |
||||
} |
||||
set { |
||||
currentTab = value; |
||||
RaisePropertyChanged("CurrentTab"); |
||||
RaisePropertyChanged("NameBackground"); |
||||
} |
||||
} |
||||
|
||||
string filter; |
||||
|
||||
public string Filter { |
||||
get { |
||||
return filter; |
||||
} |
||||
set { |
||||
filter = value; |
||||
Reload(); |
||||
RaisePropertyChanged("Filter"); |
||||
} |
||||
} |
||||
|
||||
DesignItem singleItem; |
||||
|
||||
public DesignItem SingleItem { |
||||
get { |
||||
return singleItem; |
||||
} |
||||
private set { |
||||
if (singleItem != null) { |
||||
singleItem.NameChanged -= singleItem_NameChanged; |
||||
} |
||||
singleItem = value; |
||||
if (singleItem != null) { |
||||
singleItem.NameChanged += singleItem_NameChanged; |
||||
} |
||||
RaisePropertyChanged("SingleItem"); |
||||
RaisePropertyChanged("Name"); |
||||
RaisePropertyChanged("IsNameEnabled"); |
||||
IsNameCorrect = true; |
||||
} |
||||
} |
||||
|
||||
void singleItem_NameChanged(object sender, EventArgs e) |
||||
{ |
||||
RaisePropertyChanged("Name"); |
||||
} |
||||
|
||||
public string OldName { |
||||
get; private set; |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
if (SingleItem != null) { |
||||
return SingleItem.Name; |
||||
} |
||||
return null; |
||||
} |
||||
set { |
||||
if (SingleItem != null) { |
||||
try { |
||||
if (string.IsNullOrEmpty(value)) { |
||||
OldName = null; |
||||
SingleItem.Name = null; |
||||
} else { |
||||
OldName = SingleItem.Name; |
||||
SingleItem.Name = value; |
||||
} |
||||
IsNameCorrect = true; |
||||
} catch { |
||||
IsNameCorrect = false; |
||||
} |
||||
RaisePropertyChanged("Name"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
bool isNameCorrect = true; |
||||
|
||||
public bool IsNameCorrect { |
||||
get { |
||||
return isNameCorrect; |
||||
} |
||||
set { |
||||
isNameCorrect = value; |
||||
RaisePropertyChanged("IsNameCorrect"); |
||||
} |
||||
} |
||||
|
||||
public bool IsNameEnabled { |
||||
get { |
||||
return SingleItem != null; |
||||
} |
||||
} |
||||
|
||||
IEnumerable<DesignItem> selectedItems; |
||||
|
||||
public IEnumerable<DesignItem> SelectedItems { |
||||
get { |
||||
return selectedItems; |
||||
} |
||||
set { |
||||
selectedItems = value; |
||||
RaisePropertyChanged("SelectedItems"); |
||||
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action( |
||||
delegate { |
||||
Reload(); |
||||
})); |
||||
} |
||||
} |
||||
|
||||
public void ClearFilter() |
||||
{ |
||||
Filter = null; |
||||
} |
||||
|
||||
void Reload() |
||||
{ |
||||
Clear(); |
||||
|
||||
if (SelectedItems == null || SelectedItems.Count() == 0) return; |
||||
if (SelectedItems.Count() == 1) SingleItem = SelectedItems.First(); |
||||
|
||||
foreach (var md in GetDescriptors()) { |
||||
if (PassesFilter(md.Name)) |
||||
AddNode(md); |
||||
} |
||||
} |
||||
|
||||
void Clear() |
||||
{ |
||||
foreach (var c in Categories) { |
||||
c.IsVisible = false; |
||||
foreach (var p in c.Properties) { |
||||
p.IsVisible = false; |
||||
} |
||||
} |
||||
|
||||
foreach (var e in Events) { |
||||
e.IsVisible = false; |
||||
} |
||||
|
||||
SingleItem = null; |
||||
} |
||||
|
||||
List<MemberDescriptor> GetDescriptors() |
||||
{ |
||||
List<MemberDescriptor> list = new List<MemberDescriptor>(); |
||||
|
||||
if (SelectedItems.Count() == 1) { |
||||
foreach (MemberDescriptor d in TypeHelper.GetAvailableProperties(SingleItem.Component)) { |
||||
list.Add(d); |
||||
} |
||||
foreach (MemberDescriptor d in TypeHelper.GetAvailableEvents(SingleItem.ComponentType)) { |
||||
list.Add(d); |
||||
} |
||||
} else { |
||||
foreach (MemberDescriptor d in TypeHelper.GetCommonAvailableProperties(SelectedItems.Select(t => t.Component))) { |
||||
list.Add(d); |
||||
} |
||||
} |
||||
|
||||
return list; |
||||
} |
||||
|
||||
bool PassesFilter(string name) |
||||
{ |
||||
if (string.IsNullOrEmpty(Filter)) return true; |
||||
for (int i = 0; i < name.Length; i++) { |
||||
if (i == 0 || char.IsUpper(name[i])) { |
||||
if (string.Compare(name, i, Filter, 0, Filter.Length, true) == 0) { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void AddNode(MemberDescriptor md) |
||||
{ |
||||
var designProperties = SelectedItems.Select(item => item.Properties.GetProperty(md)).ToArray(); |
||||
if (!Metadata.IsBrowsable(designProperties[0])) return; |
||||
|
||||
PropertyNode node; |
||||
if (nodeFromDescriptor.TryGetValue(md, out node)) { |
||||
node.Load(designProperties); |
||||
} else { |
||||
node = new PropertyNode(); |
||||
node.Load(designProperties); |
||||
if (node.IsEvent) { |
||||
Events.AddSorted(node); |
||||
} else { |
||||
var cat = PickCategory(node); |
||||
cat.Properties.AddSorted(node); |
||||
node.Category = cat; |
||||
} |
||||
nodeFromDescriptor[md] = node; |
||||
} |
||||
node.IsVisible = true; |
||||
if (node.Category != null) |
||||
node.Category.IsVisible = true; |
||||
} |
||||
|
||||
Category PickCategory(PropertyNode node) |
||||
{ |
||||
if (Metadata.IsPopularProperty(node.FirstProperty)) return popularCategory; |
||||
if (node.FirstProperty.IsAttachedDependencyProperty()) return attachedCategory; |
||||
var typeName = node.FirstProperty.DeclaringType.FullName; |
||||
if (typeName.StartsWith("System.Windows.") || typeName.StartsWith("ICSharpCode.WpfDesign.Designer.Controls.")) |
||||
return otherCategory; |
||||
return specialCategory; |
||||
} |
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void RaisePropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
//class CategoryNameComparer : IComparer<string>
|
||||
//{
|
||||
// public static CategoryNameComparer Instance = new CategoryNameComparer();
|
||||
|
||||
// public int Compare(string x, string y)
|
||||
// {
|
||||
// int i1 = Array.IndexOf(Metadata.CategoryOrder, x);
|
||||
// if (i1 == -1) i1 = int.MaxValue;
|
||||
// int i2 = Array.IndexOf(Metadata.CategoryOrder, y);
|
||||
// if (i2 == -1) i2 = int.MaxValue;
|
||||
// if (i1 == i2) return x.CompareTo(y);
|
||||
// return i1.CompareTo(i2);
|
||||
// }
|
||||
//}
|
||||
} |
||||
|
||||
public class CategoriesCollection : SortedObservableCollection<Category, string> |
||||
{ |
||||
public CategoriesCollection() |
||||
: base(n => n.Name) |
||||
{ |
||||
} |
||||
} |
||||
|
||||
public enum PropertyGridGroupMode |
||||
{ |
||||
GroupByPopularCategorys, |
||||
GroupByCategorys, |
||||
Ungrouped, |
||||
} |
||||
|
||||
public enum PropertyGridTab |
||||
{ |
||||
Properties, |
||||
Events |
||||
} |
||||
} |
||||
|
@ -1,79 +1,79 @@
@@ -1,79 +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.Diagnostics; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom |
||||
{ |
||||
/// <summary>
|
||||
/// Static methods to help with <see cref="System.Windows.Markup.INameScope"/> operations on Xaml elements.
|
||||
/// </summary>
|
||||
public static class NameScopeHelper |
||||
{ |
||||
/// <summary>
|
||||
/// Finds the XAML namescope for the specified object and uses it to unregister the old name and then register the new name.
|
||||
/// </summary>
|
||||
/// <param name="namedObject">The object where the name was changed.</param>
|
||||
/// <param name="oldName">The old name.</param>
|
||||
/// <param name="newName">The new name.</param>
|
||||
internal static void NameChanged(XamlObject namedObject, string oldName, string newName) |
||||
{ |
||||
var obj = namedObject; |
||||
while (obj != null) { |
||||
var nameScope = GetNameScopeFromObject(obj.Instance); |
||||
if (nameScope != null) { |
||||
if (oldName != null) { |
||||
try { |
||||
nameScope.UnregisterName(oldName); |
||||
} catch (Exception x) { |
||||
Debug.WriteLine(x.Message); |
||||
} |
||||
} |
||||
if (newName != null) { |
||||
nameScope.RegisterName(newName, namedObject.Instance); |
||||
|
||||
try{ |
||||
var prp = namedObject.ElementType.GetProperty(namedObject.RuntimeNameProperty); |
||||
if (prp != null) |
||||
prp.SetValue(namedObject.Instance, newName, null); |
||||
} catch (Exception x) { |
||||
Debug.WriteLine(x.Message); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
obj = obj.ParentObject; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the XAML namescope for the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to get the XAML namescope for.</param>
|
||||
/// <returns>A XAML namescope, as an <see cref="INameScope"/> instance.</returns>
|
||||
public static INameScope GetNameScopeFromObject(object obj) |
||||
{ |
||||
var nameScope = obj as INameScope; |
||||
if (nameScope == null) { |
||||
var depObj = obj as DependencyObject; |
||||
if (depObj != null) |
||||
nameScope = NameScope.GetNameScope(depObj); |
||||
} |
||||
|
||||
return nameScope; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="NameScope.NameScopeProperty"/> if the object is a <see cref="DependencyObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to clear the <see cref="NameScope.NameScopeProperty"/> on.</param>
|
||||
public static void ClearNameScopeProperty(object obj) |
||||
{ |
||||
var depObj = obj as DependencyObject; |
||||
if (depObj != null) |
||||
depObj.ClearValue(NameScope.NameScopeProperty); |
||||
} |
||||
} |
||||
} |
||||
// 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.Diagnostics; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom |
||||
{ |
||||
/// <summary>
|
||||
/// Static methods to help with <see cref="System.Windows.Markup.INameScope"/> operations on Xaml elements.
|
||||
/// </summary>
|
||||
public static class NameScopeHelper |
||||
{ |
||||
/// <summary>
|
||||
/// Finds the XAML namescope for the specified object and uses it to unregister the old name and then register the new name.
|
||||
/// </summary>
|
||||
/// <param name="namedObject">The object where the name was changed.</param>
|
||||
/// <param name="oldName">The old name.</param>
|
||||
/// <param name="newName">The new name.</param>
|
||||
internal static void NameChanged(XamlObject namedObject, string oldName, string newName) |
||||
{ |
||||
var obj = namedObject; |
||||
while (obj != null) { |
||||
var nameScope = GetNameScopeFromObject(obj.Instance); |
||||
if (nameScope != null) { |
||||
if (oldName != null) { |
||||
try { |
||||
nameScope.UnregisterName(oldName); |
||||
} catch (Exception x) { |
||||
Debug.WriteLine(x.Message); |
||||
} |
||||
} |
||||
if (newName != null) { |
||||
nameScope.RegisterName(newName, namedObject.Instance); |
||||
|
||||
try{ |
||||
var prp = namedObject.ElementType.GetProperty(namedObject.RuntimeNameProperty); |
||||
if (prp != null) |
||||
prp.SetValue(namedObject.Instance, newName, null); |
||||
} catch (Exception x) { |
||||
Debug.WriteLine(x.Message); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
obj = obj.ParentObject; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the XAML namescope for the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to get the XAML namescope for.</param>
|
||||
/// <returns>A XAML namescope, as an <see cref="INameScope"/> instance.</returns>
|
||||
public static INameScope GetNameScopeFromObject(object obj) |
||||
{ |
||||
var nameScope = obj as INameScope; |
||||
if (nameScope == null) { |
||||
var depObj = obj as DependencyObject; |
||||
if (depObj != null) |
||||
nameScope = NameScope.GetNameScope(depObj); |
||||
} |
||||
|
||||
return nameScope; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="NameScope.NameScopeProperty"/> if the object is a <see cref="DependencyObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to clear the <see cref="NameScope.NameScopeProperty"/> on.</param>
|
||||
public static void ClearNameScopeProperty(object obj) |
||||
{ |
||||
var depObj = obj as DependencyObject; |
||||
if (depObj != null) |
||||
depObj.ClearValue(NameScope.NameScopeProperty); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,491 +1,491 @@
@@ -1,491 +1,491 @@
|
||||
// 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.Diagnostics; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Xml; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom |
||||
{ |
||||
/// <summary>
|
||||
/// Describes a property on a <see cref="XamlObject"/>.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("XamlProperty: {PropertyName}")] |
||||
public sealed class XamlProperty |
||||
{ |
||||
XamlObject parentObject; |
||||
internal readonly XamlPropertyInfo propertyInfo; |
||||
XamlPropertyValue propertyValue; |
||||
|
||||
CollectionElementsCollection collectionElements; |
||||
bool isCollection; |
||||
bool isResources; |
||||
|
||||
static readonly IList<XamlPropertyValue> emptyCollectionElementsArray = new XamlPropertyValue[0]; |
||||
|
||||
// for use by parser only
|
||||
internal XamlProperty(XamlObject parentObject, XamlPropertyInfo propertyInfo, XamlPropertyValue propertyValue) |
||||
: this(parentObject, propertyInfo) |
||||
{ |
||||
PossiblyNameChanged(null, propertyValue); |
||||
|
||||
this.propertyValue = propertyValue; |
||||
if (propertyValue != null) { |
||||
propertyValue.ParentProperty = this; |
||||
} |
||||
|
||||
UpdateValueOnInstance(); |
||||
} |
||||
|
||||
internal XamlProperty(XamlObject parentObject, XamlPropertyInfo propertyInfo) |
||||
{ |
||||
this.parentObject = parentObject; |
||||
this.propertyInfo = propertyInfo; |
||||
|
||||
if (propertyInfo.IsCollection) { |
||||
isCollection = true; |
||||
collectionElements = new CollectionElementsCollection(this); |
||||
|
||||
if (propertyInfo.Name.Equals(XamlConstants.ResourcesPropertyName, StringComparison.Ordinal) && |
||||
propertyInfo.ReturnType == typeof(ResourceDictionary)) { |
||||
isResources = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the parent object for which this property was declared.
|
||||
/// </summary>
|
||||
public XamlObject ParentObject { |
||||
get { return parentObject; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the property name.
|
||||
/// </summary>
|
||||
public string PropertyName { |
||||
get { return propertyInfo.Name; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the type the property is declared on.
|
||||
/// </summary>
|
||||
public Type PropertyTargetType { |
||||
get { return propertyInfo.TargetType; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property is an attached property.
|
||||
/// </summary>
|
||||
public bool IsAttached { |
||||
get { return propertyInfo.IsAttached; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property is an event.
|
||||
/// </summary>
|
||||
public bool IsEvent { |
||||
get { return propertyInfo.IsEvent; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the return type of the property.
|
||||
/// </summary>
|
||||
public Type ReturnType { |
||||
get { return propertyInfo.ReturnType; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the type converter used to convert property values to/from string.
|
||||
/// </summary>
|
||||
public TypeConverter TypeConverter { |
||||
get { return propertyInfo.TypeConverter; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the category of the property.
|
||||
/// </summary>
|
||||
public string Category { |
||||
get { return propertyInfo.Category; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the property. Can be null if the property is a collection property.
|
||||
/// </summary>
|
||||
public XamlPropertyValue PropertyValue { |
||||
get { return propertyValue; } |
||||
set { SetPropertyValue(value); } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
|
||||
/// </summary>
|
||||
public bool IsResources { |
||||
get { return isResources; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the property is a collection property.
|
||||
/// </summary>
|
||||
public bool IsCollection { |
||||
get { return isCollection; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the collection elements of the property. Is empty if the property is not a collection.
|
||||
/// </summary>
|
||||
public IList<XamlPropertyValue> CollectionElements { |
||||
get { return collectionElements ?? emptyCollectionElementsArray; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the property is set.
|
||||
/// </summary>
|
||||
public bool IsSet { |
||||
get { return propertyValue != null || |
||||
_propertyElement != null; // collection
|
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Occurs when the value of the IsSet property has changed.
|
||||
/// </summary>
|
||||
public event EventHandler IsSetChanged; |
||||
|
||||
/// <summary>
|
||||
/// Occurs when the value of the property has changed.
|
||||
/// </summary>
|
||||
public event EventHandler ValueChanged; |
||||
|
||||
/// <summary>
|
||||
/// Occurs when MarkupExtension evaluated PropertyValue dosn't changed but ValueOnInstance does.
|
||||
/// </summary>
|
||||
public event EventHandler ValueOnInstanceChanged; |
||||
|
||||
void SetPropertyValue(XamlPropertyValue value) |
||||
{ |
||||
// Binding...
|
||||
//if (IsCollection) {
|
||||
// throw new InvalidOperationException("Cannot set the value of collection properties.");
|
||||
//}
|
||||
|
||||
bool wasSet = this.IsSet; |
||||
|
||||
PossiblyNameChanged(propertyValue, value); |
||||
|
||||
//reset expression
|
||||
var xamlObject = propertyValue as XamlObject; |
||||
if (xamlObject != null && xamlObject.IsMarkupExtension) |
||||
propertyInfo.ResetValue(parentObject.Instance); |
||||
|
||||
ResetInternal(); |
||||
|
||||
propertyValue = value; |
||||
propertyValue.ParentProperty = this; |
||||
propertyValue.AddNodeTo(this); |
||||
UpdateValueOnInstance(); |
||||
|
||||
ParentObject.OnPropertyChanged(this); |
||||
|
||||
if (!wasSet) { |
||||
if (IsSetChanged != null) { |
||||
IsSetChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
if (ValueChanged != null) { |
||||
ValueChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
internal void UpdateValueOnInstance() |
||||
{ |
||||
if (PropertyValue != null) { |
||||
try { |
||||
ValueOnInstance = PropertyValue.GetValueFor(propertyInfo); |
||||
} |
||||
catch { |
||||
Debug.WriteLine("UpdateValueOnInstance() failed"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Resets the properties value.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
if (IsSet) { |
||||
|
||||
propertyInfo.ResetValue(parentObject.Instance); |
||||
ResetInternal(); |
||||
|
||||
ParentObject.OnPropertyChanged(this); |
||||
|
||||
if (IsSetChanged != null) { |
||||
IsSetChanged(this, EventArgs.Empty); |
||||
} |
||||
if (ValueChanged != null) { |
||||
ValueChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ResetInternal() |
||||
{ |
||||
if (propertyValue != null) { |
||||
propertyValue.RemoveNodeFromParent(); |
||||
propertyValue.ParentProperty = null; |
||||
propertyValue = null; |
||||
} |
||||
if (_propertyElement != null) { |
||||
_propertyElement.ParentNode.RemoveChild(_propertyElement); |
||||
_propertyElement = null; |
||||
} |
||||
} |
||||
|
||||
XmlElement _propertyElement; |
||||
|
||||
internal void ParserSetPropertyElement(XmlElement propertyElement) |
||||
{ |
||||
XmlElement oldPropertyElement = _propertyElement; |
||||
if (oldPropertyElement == propertyElement) return; |
||||
|
||||
_propertyElement = propertyElement; |
||||
|
||||
if (oldPropertyElement != null && IsCollection) { |
||||
Debug.WriteLine("Property element for " + this.PropertyName + " already exists, merging.."); |
||||
foreach (XamlPropertyValue val in this.collectionElements) { |
||||
val.RemoveNodeFromParent(); |
||||
val.AddNodeTo(this); |
||||
} |
||||
oldPropertyElement.ParentNode.RemoveChild(oldPropertyElement); |
||||
} |
||||
} |
||||
|
||||
bool IsFirstChildResources(XamlObject obj) |
||||
{ |
||||
return obj.XmlElement.FirstChild != null && |
||||
obj.XmlElement.FirstChild.Name.EndsWith("." + XamlConstants.ResourcesPropertyName) && |
||||
obj.Properties.Where((prop) => prop.IsResources).FirstOrDefault() != null; |
||||
} |
||||
|
||||
XmlElement CreatePropertyElement() |
||||
{ |
||||
string ns = parentObject.OwnerDocument.GetNamespaceFor(parentObject.ElementType); |
||||
return parentObject.OwnerDocument.XmlDocument.CreateElement( |
||||
parentObject.OwnerDocument.GetPrefixForNamespace(ns), |
||||
parentObject.ElementType.Name + "." + this.PropertyName, |
||||
ns |
||||
); |
||||
} |
||||
|
||||
internal void AddChildNodeToProperty(XmlNode newChildNode) |
||||
{ |
||||
if (this.IsCollection) { |
||||
// this is the default collection
|
||||
InsertNodeInCollection(newChildNode, collectionElements.Count); |
||||
return; |
||||
} |
||||
if (_propertyElement == null) { |
||||
if (PropertyName == parentObject.ContentPropertyName) { |
||||
if (IsFirstChildResources(parentObject)) { |
||||
// Resources element should always be first
|
||||
parentObject.XmlElement.InsertAfter(newChildNode, parentObject.XmlElement.FirstChild); |
||||
} |
||||
else |
||||
parentObject.XmlElement.InsertBefore(newChildNode, parentObject.XmlElement.FirstChild); |
||||
return; |
||||
} |
||||
_propertyElement = CreatePropertyElement(); |
||||
|
||||
if (IsFirstChildResources(parentObject)) { |
||||
// Resources element should always be first
|
||||
parentObject.XmlElement.InsertAfter(_propertyElement, parentObject.XmlElement.FirstChild); |
||||
} |
||||
else |
||||
parentObject.XmlElement.InsertBefore(_propertyElement, parentObject.XmlElement.FirstChild); |
||||
} |
||||
_propertyElement.AppendChild(newChildNode); |
||||
} |
||||
|
||||
internal void InsertNodeInCollection(XmlNode newChildNode, int index) |
||||
{ |
||||
Debug.Assert(index >= 0 && index <= collectionElements.Count); |
||||
XmlElement collection = _propertyElement; |
||||
if (collection == null) { |
||||
if (collectionElements.Count == 0 && this.PropertyName != this.ParentObject.ContentPropertyName) { |
||||
// we have to create the collection element
|
||||
_propertyElement = CreatePropertyElement(); |
||||
|
||||
if (this.IsResources) { |
||||
parentObject.XmlElement.PrependChild(_propertyElement); |
||||
} else { |
||||
parentObject.XmlElement.AppendChild(_propertyElement); |
||||
} |
||||
|
||||
collection = _propertyElement; |
||||
} else { |
||||
// this is the default collection
|
||||
collection = parentObject.XmlElement; |
||||
} |
||||
} |
||||
if (collectionElements.Count == 0) { |
||||
// collection is empty -> we may insert anywhere
|
||||
collection.AppendChild(newChildNode); |
||||
} else if (index == collectionElements.Count) { |
||||
// insert after last element in collection
|
||||
collection.InsertAfter(newChildNode, collectionElements[collectionElements.Count - 1].GetNodeForCollection()); |
||||
} else { |
||||
// insert before specified index
|
||||
collection.InsertBefore(newChildNode, collectionElements[index].GetNodeForCollection()); |
||||
} |
||||
} |
||||
|
||||
internal XmlAttribute SetAttribute(string value) |
||||
{ |
||||
string name; |
||||
var element = ParentObject.XmlElement; |
||||
|
||||
if (IsAttached) |
||||
{ |
||||
if (PropertyTargetType == typeof (DesignTimeProperties) || PropertyTargetType == typeof (MarkupCompatibilityProperties)) |
||||
name = PropertyName; |
||||
else |
||||
name = PropertyTargetType.Name + "." + PropertyName; |
||||
|
||||
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType); |
||||
string prefix = element.GetPrefixOfNamespace(ns); |
||||
|
||||
if (String.IsNullOrEmpty(prefix)) { |
||||
prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns); |
||||
} |
||||
|
||||
if (!string.IsNullOrEmpty(prefix)) { |
||||
element.SetAttribute(name, ns, value); |
||||
return element.GetAttributeNode(name, ns); |
||||
} |
||||
} else { |
||||
name = PropertyName; |
||||
} |
||||
|
||||
element.SetAttribute(name, string.Empty, value); |
||||
return element.GetAttributeNode(name); |
||||
} |
||||
|
||||
internal string GetNameForMarkupExtension() |
||||
{ |
||||
if (IsAttached) { |
||||
string name = PropertyTargetType.Name + "." + PropertyName; |
||||
|
||||
var element = ParentObject.XmlElement; |
||||
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType); |
||||
var prefix = element.GetPrefixOfNamespace(ns); |
||||
if (string.IsNullOrEmpty(prefix)) |
||||
return name; |
||||
else |
||||
return prefix + ":" + name; |
||||
} else |
||||
return PropertyName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// used internally by the XamlParser.
|
||||
/// Add a collection element that already is part of the XML DOM.
|
||||
/// </summary>
|
||||
internal void ParserAddCollectionElement(XmlElement collectionPropertyElement, XamlPropertyValue val) |
||||
{ |
||||
if (collectionPropertyElement != null && _propertyElement == null) { |
||||
ParserSetPropertyElement(collectionPropertyElement); |
||||
} |
||||
collectionElements.AddInternal(val); |
||||
val.ParentProperty = this; |
||||
if (collectionPropertyElement != _propertyElement) { |
||||
val.RemoveNodeFromParent(); |
||||
val.AddNodeTo(this); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the value of the property on the instance without updating the XAML document.
|
||||
/// </summary>
|
||||
public object ValueOnInstance { |
||||
get { |
||||
if (IsEvent) { |
||||
if (propertyValue != null) |
||||
return propertyValue.GetValueFor(null); |
||||
else |
||||
return null; |
||||
} else { |
||||
return propertyInfo.GetValue(parentObject.Instance); |
||||
} |
||||
} |
||||
set { |
||||
propertyInfo.SetValue(parentObject.Instance, value); |
||||
if (ValueOnInstanceChanged != null) |
||||
ValueOnInstanceChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property is considered "advanced" and should be hidden by default in a property grid.
|
||||
/// </summary>
|
||||
public bool IsAdvanced { |
||||
get { return propertyInfo.IsAdvanced; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the dependency property.
|
||||
/// </summary>
|
||||
public DependencyProperty DependencyProperty { |
||||
get { |
||||
return propertyInfo.DependencyProperty; |
||||
} |
||||
} |
||||
|
||||
void PossiblyNameChanged(XamlPropertyValue oldValue, XamlPropertyValue newValue) |
||||
{ |
||||
if (ParentObject.RuntimeNameProperty != null && PropertyName == ParentObject.RuntimeNameProperty) { |
||||
|
||||
if (!String.IsNullOrEmpty(ParentObject.GetXamlAttribute("Name"))) { |
||||
throw new XamlLoadException("The property 'Name' is set more than once."); |
||||
} |
||||
|
||||
string oldName = null; |
||||
string newName = null; |
||||
|
||||
var oldTextValue = oldValue as XamlTextValue; |
||||
if (oldTextValue != null) oldName = oldTextValue.Text; |
||||
|
||||
var newTextValue = newValue as XamlTextValue; |
||||
if (newTextValue != null) newName = newTextValue.Text; |
||||
|
||||
NameScopeHelper.NameChanged(ParentObject, oldName, newName); |
||||
} |
||||
} |
||||
|
||||
/*public bool IsAttributeSyntax { |
||||
get { |
||||
return attribute != null; |
||||
} |
||||
} |
||||
|
||||
public bool IsElementSyntax { |
||||
get { |
||||
return element != null; |
||||
} |
||||
} |
||||
|
||||
public bool IsImplicitDefaultProperty { |
||||
get { |
||||
return attribute == null && element == null; |
||||
} |
||||
}*/ |
||||
} |
||||
} |
||||
// 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.Diagnostics; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Xml; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom |
||||
{ |
||||
/// <summary>
|
||||
/// Describes a property on a <see cref="XamlObject"/>.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("XamlProperty: {PropertyName}")] |
||||
public sealed class XamlProperty |
||||
{ |
||||
XamlObject parentObject; |
||||
internal readonly XamlPropertyInfo propertyInfo; |
||||
XamlPropertyValue propertyValue; |
||||
|
||||
CollectionElementsCollection collectionElements; |
||||
bool isCollection; |
||||
bool isResources; |
||||
|
||||
static readonly IList<XamlPropertyValue> emptyCollectionElementsArray = new XamlPropertyValue[0]; |
||||
|
||||
// for use by parser only
|
||||
internal XamlProperty(XamlObject parentObject, XamlPropertyInfo propertyInfo, XamlPropertyValue propertyValue) |
||||
: this(parentObject, propertyInfo) |
||||
{ |
||||
PossiblyNameChanged(null, propertyValue); |
||||
|
||||
this.propertyValue = propertyValue; |
||||
if (propertyValue != null) { |
||||
propertyValue.ParentProperty = this; |
||||
} |
||||
|
||||
UpdateValueOnInstance(); |
||||
} |
||||
|
||||
internal XamlProperty(XamlObject parentObject, XamlPropertyInfo propertyInfo) |
||||
{ |
||||
this.parentObject = parentObject; |
||||
this.propertyInfo = propertyInfo; |
||||
|
||||
if (propertyInfo.IsCollection) { |
||||
isCollection = true; |
||||
collectionElements = new CollectionElementsCollection(this); |
||||
|
||||
if (propertyInfo.Name.Equals(XamlConstants.ResourcesPropertyName, StringComparison.Ordinal) && |
||||
propertyInfo.ReturnType == typeof(ResourceDictionary)) { |
||||
isResources = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the parent object for which this property was declared.
|
||||
/// </summary>
|
||||
public XamlObject ParentObject { |
||||
get { return parentObject; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the property name.
|
||||
/// </summary>
|
||||
public string PropertyName { |
||||
get { return propertyInfo.Name; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the type the property is declared on.
|
||||
/// </summary>
|
||||
public Type PropertyTargetType { |
||||
get { return propertyInfo.TargetType; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property is an attached property.
|
||||
/// </summary>
|
||||
public bool IsAttached { |
||||
get { return propertyInfo.IsAttached; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property is an event.
|
||||
/// </summary>
|
||||
public bool IsEvent { |
||||
get { return propertyInfo.IsEvent; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the return type of the property.
|
||||
/// </summary>
|
||||
public Type ReturnType { |
||||
get { return propertyInfo.ReturnType; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the type converter used to convert property values to/from string.
|
||||
/// </summary>
|
||||
public TypeConverter TypeConverter { |
||||
get { return propertyInfo.TypeConverter; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the category of the property.
|
||||
/// </summary>
|
||||
public string Category { |
||||
get { return propertyInfo.Category; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the property. Can be null if the property is a collection property.
|
||||
/// </summary>
|
||||
public XamlPropertyValue PropertyValue { |
||||
get { return propertyValue; } |
||||
set { SetPropertyValue(value); } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
|
||||
/// </summary>
|
||||
public bool IsResources { |
||||
get { return isResources; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the property is a collection property.
|
||||
/// </summary>
|
||||
public bool IsCollection { |
||||
get { return isCollection; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the collection elements of the property. Is empty if the property is not a collection.
|
||||
/// </summary>
|
||||
public IList<XamlPropertyValue> CollectionElements { |
||||
get { return collectionElements ?? emptyCollectionElementsArray; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the property is set.
|
||||
/// </summary>
|
||||
public bool IsSet { |
||||
get { return propertyValue != null || |
||||
_propertyElement != null; // collection
|
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Occurs when the value of the IsSet property has changed.
|
||||
/// </summary>
|
||||
public event EventHandler IsSetChanged; |
||||
|
||||
/// <summary>
|
||||
/// Occurs when the value of the property has changed.
|
||||
/// </summary>
|
||||
public event EventHandler ValueChanged; |
||||
|
||||
/// <summary>
|
||||
/// Occurs when MarkupExtension evaluated PropertyValue dosn't changed but ValueOnInstance does.
|
||||
/// </summary>
|
||||
public event EventHandler ValueOnInstanceChanged; |
||||
|
||||
void SetPropertyValue(XamlPropertyValue value) |
||||
{ |
||||
// Binding...
|
||||
//if (IsCollection) {
|
||||
// throw new InvalidOperationException("Cannot set the value of collection properties.");
|
||||
//}
|
||||
|
||||
bool wasSet = this.IsSet; |
||||
|
||||
PossiblyNameChanged(propertyValue, value); |
||||
|
||||
//reset expression
|
||||
var xamlObject = propertyValue as XamlObject; |
||||
if (xamlObject != null && xamlObject.IsMarkupExtension) |
||||
propertyInfo.ResetValue(parentObject.Instance); |
||||
|
||||
ResetInternal(); |
||||
|
||||
propertyValue = value; |
||||
propertyValue.ParentProperty = this; |
||||
propertyValue.AddNodeTo(this); |
||||
UpdateValueOnInstance(); |
||||
|
||||
ParentObject.OnPropertyChanged(this); |
||||
|
||||
if (!wasSet) { |
||||
if (IsSetChanged != null) { |
||||
IsSetChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
if (ValueChanged != null) { |
||||
ValueChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
internal void UpdateValueOnInstance() |
||||
{ |
||||
if (PropertyValue != null) { |
||||
try { |
||||
ValueOnInstance = PropertyValue.GetValueFor(propertyInfo); |
||||
} |
||||
catch { |
||||
Debug.WriteLine("UpdateValueOnInstance() failed"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Resets the properties value.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
if (IsSet) { |
||||
|
||||
propertyInfo.ResetValue(parentObject.Instance); |
||||
ResetInternal(); |
||||
|
||||
ParentObject.OnPropertyChanged(this); |
||||
|
||||
if (IsSetChanged != null) { |
||||
IsSetChanged(this, EventArgs.Empty); |
||||
} |
||||
if (ValueChanged != null) { |
||||
ValueChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ResetInternal() |
||||
{ |
||||
if (propertyValue != null) { |
||||
propertyValue.RemoveNodeFromParent(); |
||||
propertyValue.ParentProperty = null; |
||||
propertyValue = null; |
||||
} |
||||
if (_propertyElement != null) { |
||||
_propertyElement.ParentNode.RemoveChild(_propertyElement); |
||||
_propertyElement = null; |
||||
} |
||||
} |
||||
|
||||
XmlElement _propertyElement; |
||||
|
||||
internal void ParserSetPropertyElement(XmlElement propertyElement) |
||||
{ |
||||
XmlElement oldPropertyElement = _propertyElement; |
||||
if (oldPropertyElement == propertyElement) return; |
||||
|
||||
_propertyElement = propertyElement; |
||||
|
||||
if (oldPropertyElement != null && IsCollection) { |
||||
Debug.WriteLine("Property element for " + this.PropertyName + " already exists, merging.."); |
||||
foreach (XamlPropertyValue val in this.collectionElements) { |
||||
val.RemoveNodeFromParent(); |
||||
val.AddNodeTo(this); |
||||
} |
||||
oldPropertyElement.ParentNode.RemoveChild(oldPropertyElement); |
||||
} |
||||
} |
||||
|
||||
bool IsFirstChildResources(XamlObject obj) |
||||
{ |
||||
return obj.XmlElement.FirstChild != null && |
||||
obj.XmlElement.FirstChild.Name.EndsWith("." + XamlConstants.ResourcesPropertyName) && |
||||
obj.Properties.Where((prop) => prop.IsResources).FirstOrDefault() != null; |
||||
} |
||||
|
||||
XmlElement CreatePropertyElement() |
||||
{ |
||||
string ns = parentObject.OwnerDocument.GetNamespaceFor(parentObject.ElementType); |
||||
return parentObject.OwnerDocument.XmlDocument.CreateElement( |
||||
parentObject.OwnerDocument.GetPrefixForNamespace(ns), |
||||
parentObject.ElementType.Name + "." + this.PropertyName, |
||||
ns |
||||
); |
||||
} |
||||
|
||||
internal void AddChildNodeToProperty(XmlNode newChildNode) |
||||
{ |
||||
if (this.IsCollection) { |
||||
// this is the default collection
|
||||
InsertNodeInCollection(newChildNode, collectionElements.Count); |
||||
return; |
||||
} |
||||
if (_propertyElement == null) { |
||||
if (PropertyName == parentObject.ContentPropertyName) { |
||||
if (IsFirstChildResources(parentObject)) { |
||||
// Resources element should always be first
|
||||
parentObject.XmlElement.InsertAfter(newChildNode, parentObject.XmlElement.FirstChild); |
||||
} |
||||
else |
||||
parentObject.XmlElement.InsertBefore(newChildNode, parentObject.XmlElement.FirstChild); |
||||
return; |
||||
} |
||||
_propertyElement = CreatePropertyElement(); |
||||
|
||||
if (IsFirstChildResources(parentObject)) { |
||||
// Resources element should always be first
|
||||
parentObject.XmlElement.InsertAfter(_propertyElement, parentObject.XmlElement.FirstChild); |
||||
} |
||||
else |
||||
parentObject.XmlElement.InsertBefore(_propertyElement, parentObject.XmlElement.FirstChild); |
||||
} |
||||
_propertyElement.AppendChild(newChildNode); |
||||
} |
||||
|
||||
internal void InsertNodeInCollection(XmlNode newChildNode, int index) |
||||
{ |
||||
Debug.Assert(index >= 0 && index <= collectionElements.Count); |
||||
XmlElement collection = _propertyElement; |
||||
if (collection == null) { |
||||
if (collectionElements.Count == 0 && this.PropertyName != this.ParentObject.ContentPropertyName) { |
||||
// we have to create the collection element
|
||||
_propertyElement = CreatePropertyElement(); |
||||
|
||||
if (this.IsResources) { |
||||
parentObject.XmlElement.PrependChild(_propertyElement); |
||||
} else { |
||||
parentObject.XmlElement.AppendChild(_propertyElement); |
||||
} |
||||
|
||||
collection = _propertyElement; |
||||
} else { |
||||
// this is the default collection
|
||||
collection = parentObject.XmlElement; |
||||
} |
||||
} |
||||
if (collectionElements.Count == 0) { |
||||
// collection is empty -> we may insert anywhere
|
||||
collection.AppendChild(newChildNode); |
||||
} else if (index == collectionElements.Count) { |
||||
// insert after last element in collection
|
||||
collection.InsertAfter(newChildNode, collectionElements[collectionElements.Count - 1].GetNodeForCollection()); |
||||
} else { |
||||
// insert before specified index
|
||||
collection.InsertBefore(newChildNode, collectionElements[index].GetNodeForCollection()); |
||||
} |
||||
} |
||||
|
||||
internal XmlAttribute SetAttribute(string value) |
||||
{ |
||||
string name; |
||||
var element = ParentObject.XmlElement; |
||||
|
||||
if (IsAttached) |
||||
{ |
||||
if (PropertyTargetType == typeof (DesignTimeProperties) || PropertyTargetType == typeof (MarkupCompatibilityProperties)) |
||||
name = PropertyName; |
||||
else |
||||
name = PropertyTargetType.Name + "." + PropertyName; |
||||
|
||||
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType); |
||||
string prefix = element.GetPrefixOfNamespace(ns); |
||||
|
||||
if (String.IsNullOrEmpty(prefix)) { |
||||
prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns); |
||||
} |
||||
|
||||
if (!string.IsNullOrEmpty(prefix)) { |
||||
element.SetAttribute(name, ns, value); |
||||
return element.GetAttributeNode(name, ns); |
||||
} |
||||
} else { |
||||
name = PropertyName; |
||||
} |
||||
|
||||
element.SetAttribute(name, string.Empty, value); |
||||
return element.GetAttributeNode(name); |
||||
} |
||||
|
||||
internal string GetNameForMarkupExtension() |
||||
{ |
||||
if (IsAttached) { |
||||
string name = PropertyTargetType.Name + "." + PropertyName; |
||||
|
||||
var element = ParentObject.XmlElement; |
||||
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType); |
||||
var prefix = element.GetPrefixOfNamespace(ns); |
||||
if (string.IsNullOrEmpty(prefix)) |
||||
return name; |
||||
else |
||||
return prefix + ":" + name; |
||||
} else |
||||
return PropertyName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// used internally by the XamlParser.
|
||||
/// Add a collection element that already is part of the XML DOM.
|
||||
/// </summary>
|
||||
internal void ParserAddCollectionElement(XmlElement collectionPropertyElement, XamlPropertyValue val) |
||||
{ |
||||
if (collectionPropertyElement != null && _propertyElement == null) { |
||||
ParserSetPropertyElement(collectionPropertyElement); |
||||
} |
||||
collectionElements.AddInternal(val); |
||||
val.ParentProperty = this; |
||||
if (collectionPropertyElement != _propertyElement) { |
||||
val.RemoveNodeFromParent(); |
||||
val.AddNodeTo(this); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the value of the property on the instance without updating the XAML document.
|
||||
/// </summary>
|
||||
public object ValueOnInstance { |
||||
get { |
||||
if (IsEvent) { |
||||
if (propertyValue != null) |
||||
return propertyValue.GetValueFor(null); |
||||
else |
||||
return null; |
||||
} else { |
||||
return propertyInfo.GetValue(parentObject.Instance); |
||||
} |
||||
} |
||||
set { |
||||
propertyInfo.SetValue(parentObject.Instance, value); |
||||
if (ValueOnInstanceChanged != null) |
||||
ValueOnInstanceChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property is considered "advanced" and should be hidden by default in a property grid.
|
||||
/// </summary>
|
||||
public bool IsAdvanced { |
||||
get { return propertyInfo.IsAdvanced; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the dependency property.
|
||||
/// </summary>
|
||||
public DependencyProperty DependencyProperty { |
||||
get { |
||||
return propertyInfo.DependencyProperty; |
||||
} |
||||
} |
||||
|
||||
void PossiblyNameChanged(XamlPropertyValue oldValue, XamlPropertyValue newValue) |
||||
{ |
||||
if (ParentObject.RuntimeNameProperty != null && PropertyName == ParentObject.RuntimeNameProperty) { |
||||
|
||||
if (!String.IsNullOrEmpty(ParentObject.GetXamlAttribute("Name"))) { |
||||
throw new XamlLoadException("The property 'Name' is set more than once."); |
||||
} |
||||
|
||||
string oldName = null; |
||||
string newName = null; |
||||
|
||||
var oldTextValue = oldValue as XamlTextValue; |
||||
if (oldTextValue != null) oldName = oldTextValue.Text; |
||||
|
||||
var newTextValue = newValue as XamlTextValue; |
||||
if (newTextValue != null) newName = newTextValue.Text; |
||||
|
||||
NameScopeHelper.NameChanged(ParentObject, oldName, newName); |
||||
} |
||||
} |
||||
|
||||
/*public bool IsAttributeSyntax { |
||||
get { |
||||
return attribute != null; |
||||
} |
||||
} |
||||
|
||||
public bool IsElementSyntax { |
||||
get { |
||||
return element != null; |
||||
} |
||||
} |
||||
|
||||
public bool IsImplicitDefaultProperty { |
||||
get { |
||||
return attribute == null && element == null; |
||||
} |
||||
}*/ |
||||
} |
||||
} |
||||
|
@ -1,420 +1,420 @@
@@ -1,420 +1,420 @@
|
||||
// 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.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Collections.ObjectModel; |
||||
using System.Windows.Data; |
||||
using System.Windows.Media; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.PropertyGrid |
||||
{ |
||||
/// <summary>
|
||||
/// View-Model class for the property grid.
|
||||
/// </summary>
|
||||
public class PropertyNode : INotifyPropertyChanged |
||||
{ |
||||
static object Unset = new object(); |
||||
|
||||
/// <summary>
|
||||
/// Gets the properties that are presented by this node.
|
||||
/// This might be multiple properties if multiple controls are selected.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<DesignItemProperty> Properties { get; private set; } |
||||
|
||||
bool raiseEvents = true; |
||||
bool hasStringConverter; |
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the property.
|
||||
/// </summary>
|
||||
public string Name |
||||
{ |
||||
get |
||||
{ |
||||
var dp = FirstProperty.DependencyProperty; |
||||
if (dp != null) |
||||
{ |
||||
var dpd = DependencyPropertyDescriptor.FromProperty(dp, FirstProperty.DesignItem.ComponentType); |
||||
if (dpd.IsAttached) |
||||
{ |
||||
// Will return the attached property name in the form of <DeclaringType>.<PropertyName>
|
||||
return dpd.Name; |
||||
} |
||||
} |
||||
|
||||
return FirstProperty.Name; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property node represents an event.
|
||||
/// </summary>
|
||||
public bool IsEvent { get { return FirstProperty.IsEvent; } } |
||||
|
||||
/// <summary>
|
||||
/// Gets the design context associated with this set of properties.
|
||||
/// </summary>
|
||||
public DesignContext Context { get { return FirstProperty.DesignItem.Context; } } |
||||
|
||||
/// <summary>
|
||||
/// Gets the service container associated with this set of properties.
|
||||
/// </summary>
|
||||
public ServiceContainer Services { get { return FirstProperty.DesignItem.Services; } } |
||||
|
||||
/// <summary>
|
||||
/// Gets the editor control that edits this property.
|
||||
/// </summary>
|
||||
public FrameworkElement Editor { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the first property (equivalent to Properties[0])
|
||||
/// </summary>
|
||||
public DesignItemProperty FirstProperty { get { return Properties[0]; } } |
||||
|
||||
/// <summary>
|
||||
/// For nested property nodes, gets the parent node.
|
||||
/// </summary>
|
||||
public PropertyNode Parent { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// For nested property nodes, gets the level of this node.
|
||||
/// </summary>
|
||||
public int Level { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the category of this node.
|
||||
/// </summary>
|
||||
public Category Category { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of child nodes.
|
||||
/// </summary>
|
||||
public ObservableCollection<PropertyNode> Children { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of advanced child nodes (not visible by default).
|
||||
/// </summary>
|
||||
public ObservableCollection<PropertyNode> MoreChildren { get; private set; } |
||||
|
||||
bool isExpanded; |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this property node is currently expanded.
|
||||
/// </summary>
|
||||
public bool IsExpanded { |
||||
get { |
||||
return isExpanded; |
||||
} |
||||
set { |
||||
isExpanded = value; |
||||
UpdateChildren(); |
||||
RaisePropertyChanged("IsExpanded"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this property node has children.
|
||||
/// </summary>
|
||||
public bool HasChildren { |
||||
get { return Children.Count > 0 || MoreChildren.Count > 0; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the description object using the IPropertyDescriptionService.
|
||||
/// </summary>
|
||||
public object Description { |
||||
get { |
||||
IPropertyDescriptionService s = Services.GetService<IPropertyDescriptionService>(); |
||||
if (s != null) { |
||||
return s.GetDescription(FirstProperty); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the value of this property.
|
||||
/// </summary>
|
||||
public object Value { |
||||
get { |
||||
if (IsAmbiguous) return null; |
||||
var result = FirstProperty.ValueOnInstance; |
||||
if (result == DependencyProperty.UnsetValue) return null; |
||||
return result; |
||||
} |
||||
set { |
||||
SetValueCore(value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the value of this property in string form
|
||||
/// </summary>
|
||||
public string ValueString { |
||||
get { |
||||
if (ValueItem == null || ValueItem.Component is MarkupExtension) { |
||||
if (Value == null) return null; |
||||
if (hasStringConverter) { |
||||
return FirstProperty.TypeConverter.ConvertToInvariantString(Value); |
||||
} |
||||
return "(" + Value.GetType().Name + ")"; |
||||
} |
||||
return "(" + ValueItem.ComponentType.Name + ")"; |
||||
} |
||||
set { |
||||
// make sure we only catch specific exceptions
|
||||
// and/or show the error message to the user
|
||||
//try {
|
||||
Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value); |
||||
//} catch {
|
||||
// OnValueOnInstanceChanged();
|
||||
//}
|
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the property node is enabled for editing.
|
||||
/// </summary>
|
||||
public bool IsEnabled { |
||||
get { |
||||
return ValueItem == null && hasStringConverter; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this property was set locally.
|
||||
/// </summary>
|
||||
public bool IsSet { |
||||
get { |
||||
foreach (var p in Properties) { |
||||
if (p.IsSet) return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the name.
|
||||
/// Depends on the type of the value (binding/resource/etc.)
|
||||
/// </summary>
|
||||
public Brush NameForeground { |
||||
get { |
||||
if (ValueItem != null) { |
||||
object component = ValueItem.Component; |
||||
if (component is BindingBase) |
||||
return Brushes.DarkGoldenrod; |
||||
if (component is StaticResourceExtension || component is DynamicResourceExtension) |
||||
return Brushes.DarkGreen; |
||||
} |
||||
return SystemColors.WindowTextBrush; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the DesignItem that owns the property (= the DesignItem that is currently selected).
|
||||
/// Returns null if multiple DesignItems are selected.
|
||||
/// </summary>
|
||||
public DesignItem ValueItem { |
||||
get { |
||||
if (Properties.Count == 1) { |
||||
return FirstProperty.Value; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the property value is ambiguous (multiple controls having different values are selected).
|
||||
/// </summary>
|
||||
public bool IsAmbiguous { |
||||
get { |
||||
foreach (var p in Properties) { |
||||
if (!object.Equals(p.ValueOnInstance, FirstProperty.ValueOnInstance)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool isVisible; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether the property is visible.
|
||||
/// </summary>
|
||||
public bool IsVisible { |
||||
get { |
||||
return isVisible; |
||||
} |
||||
set { |
||||
isVisible = value; |
||||
RaisePropertyChanged("IsVisible"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether resetting the property is possible.
|
||||
/// </summary>
|
||||
public bool CanReset { |
||||
get { return IsSet; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Resets the property.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
SetValueCore(Unset); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Replaces the value of this node with a new binding.
|
||||
/// </summary>
|
||||
public void CreateBinding() |
||||
{ |
||||
Value = new Binding(); |
||||
IsExpanded = true; |
||||
} |
||||
|
||||
void SetValueCore(object value) |
||||
{ |
||||
raiseEvents = false; |
||||
if (value == Unset) { |
||||
foreach (var p in Properties) { |
||||
p.Reset(); |
||||
} |
||||
} else { |
||||
foreach (var p in Properties) { |
||||
p.SetValue(value); |
||||
} |
||||
} |
||||
raiseEvents = true; |
||||
OnValueChanged(); |
||||
} |
||||
|
||||
void OnValueChanged() |
||||
{ |
||||
RaisePropertyChanged("IsSet"); |
||||
RaisePropertyChanged("Value"); |
||||
RaisePropertyChanged("ValueString"); |
||||
RaisePropertyChanged("IsAmbiguous"); |
||||
RaisePropertyChanged("FontWeight"); |
||||
RaisePropertyChanged("IsEnabled"); |
||||
RaisePropertyChanged("NameForeground"); |
||||
|
||||
UpdateChildren(); |
||||
} |
||||
|
||||
void OnValueOnInstanceChanged() |
||||
{ |
||||
RaisePropertyChanged("Value"); |
||||
RaisePropertyChanged("ValueString"); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a new PropertyNode instance.
|
||||
/// </summary>
|
||||
public PropertyNode() |
||||
{ |
||||
Children = new ObservableCollection<PropertyNode>(); |
||||
MoreChildren = new ObservableCollection<PropertyNode>(); |
||||
} |
||||
|
||||
PropertyNode(DesignItemProperty[] properties, PropertyNode parent) : this() |
||||
{ |
||||
this.Parent = parent; |
||||
this.Level = parent == null ? 0 : parent.Level + 1; |
||||
Load(properties); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes this property node with the specified properties.
|
||||
/// </summary>
|
||||
public void Load(DesignItemProperty[] properties) |
||||
{ |
||||
if (this.Properties != null) { |
||||
// detach events from old properties
|
||||
foreach (var property in this.Properties) { |
||||
property.ValueChanged -= new EventHandler(property_ValueChanged); |
||||
property.ValueOnInstanceChanged -= new EventHandler(property_ValueOnInstanceChanged); |
||||
} |
||||
} |
||||
|
||||
this.Properties = new ReadOnlyCollection<DesignItemProperty>(properties); |
||||
|
||||
if (Editor == null) |
||||
Editor = EditorManager.CreateEditor(FirstProperty); |
||||
|
||||
foreach (var property in properties) { |
||||
property.ValueChanged += new EventHandler(property_ValueChanged); |
||||
property.ValueOnInstanceChanged += new EventHandler(property_ValueOnInstanceChanged); |
||||
} |
||||
|
||||
hasStringConverter = |
||||
FirstProperty.TypeConverter.CanConvertFrom(typeof(string)) && |
||||
FirstProperty.TypeConverter.CanConvertTo(typeof(string)); |
||||
|
||||
OnValueChanged(); |
||||
} |
||||
|
||||
void property_ValueOnInstanceChanged(object sender, EventArgs e) |
||||
{ |
||||
if (raiseEvents) OnValueOnInstanceChanged(); |
||||
} |
||||
|
||||
void property_ValueChanged(object sender, EventArgs e) |
||||
{ |
||||
if (raiseEvents) OnValueChanged(); |
||||
} |
||||
|
||||
void UpdateChildren() |
||||
{ |
||||
Children.Clear(); |
||||
MoreChildren.Clear(); |
||||
|
||||
if (Parent == null || Parent.IsExpanded) { |
||||
if (ValueItem != null) { |
||||
var list = TypeHelper.GetAvailableProperties(ValueItem.Component) |
||||
.OrderBy(d => d.Name) |
||||
.Select(d => new PropertyNode(new[] { ValueItem.Properties.GetProperty(d) }, this)); |
||||
|
||||
foreach (var node in list) { |
||||
if (Metadata.IsBrowsable(node.FirstProperty)) { |
||||
node.IsVisible = true; |
||||
if (Metadata.IsPopularProperty(node.FirstProperty)) { |
||||
Children.Add(node); |
||||
} else { |
||||
MoreChildren.Add(node); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
RaisePropertyChanged("HasChildren"); |
||||
} |
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a property has changed. Used to support WPF data binding.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void RaisePropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
// 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.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Collections.ObjectModel; |
||||
using System.Windows.Data; |
||||
using System.Windows.Media; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.PropertyGrid |
||||
{ |
||||
/// <summary>
|
||||
/// View-Model class for the property grid.
|
||||
/// </summary>
|
||||
public class PropertyNode : INotifyPropertyChanged |
||||
{ |
||||
static object Unset = new object(); |
||||
|
||||
/// <summary>
|
||||
/// Gets the properties that are presented by this node.
|
||||
/// This might be multiple properties if multiple controls are selected.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<DesignItemProperty> Properties { get; private set; } |
||||
|
||||
bool raiseEvents = true; |
||||
bool hasStringConverter; |
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the property.
|
||||
/// </summary>
|
||||
public string Name |
||||
{ |
||||
get |
||||
{ |
||||
var dp = FirstProperty.DependencyProperty; |
||||
if (dp != null) |
||||
{ |
||||
var dpd = DependencyPropertyDescriptor.FromProperty(dp, FirstProperty.DesignItem.ComponentType); |
||||
if (dpd.IsAttached) |
||||
{ |
||||
// Will return the attached property name in the form of <DeclaringType>.<PropertyName>
|
||||
return dpd.Name; |
||||
} |
||||
} |
||||
|
||||
return FirstProperty.Name; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if this property node represents an event.
|
||||
/// </summary>
|
||||
public bool IsEvent { get { return FirstProperty.IsEvent; } } |
||||
|
||||
/// <summary>
|
||||
/// Gets the design context associated with this set of properties.
|
||||
/// </summary>
|
||||
public DesignContext Context { get { return FirstProperty.DesignItem.Context; } } |
||||
|
||||
/// <summary>
|
||||
/// Gets the service container associated with this set of properties.
|
||||
/// </summary>
|
||||
public ServiceContainer Services { get { return FirstProperty.DesignItem.Services; } } |
||||
|
||||
/// <summary>
|
||||
/// Gets the editor control that edits this property.
|
||||
/// </summary>
|
||||
public FrameworkElement Editor { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the first property (equivalent to Properties[0])
|
||||
/// </summary>
|
||||
public DesignItemProperty FirstProperty { get { return Properties[0]; } } |
||||
|
||||
/// <summary>
|
||||
/// For nested property nodes, gets the parent node.
|
||||
/// </summary>
|
||||
public PropertyNode Parent { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// For nested property nodes, gets the level of this node.
|
||||
/// </summary>
|
||||
public int Level { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the category of this node.
|
||||
/// </summary>
|
||||
public Category Category { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of child nodes.
|
||||
/// </summary>
|
||||
public ObservableCollection<PropertyNode> Children { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of advanced child nodes (not visible by default).
|
||||
/// </summary>
|
||||
public ObservableCollection<PropertyNode> MoreChildren { get; private set; } |
||||
|
||||
bool isExpanded; |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this property node is currently expanded.
|
||||
/// </summary>
|
||||
public bool IsExpanded { |
||||
get { |
||||
return isExpanded; |
||||
} |
||||
set { |
||||
isExpanded = value; |
||||
UpdateChildren(); |
||||
RaisePropertyChanged("IsExpanded"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this property node has children.
|
||||
/// </summary>
|
||||
public bool HasChildren { |
||||
get { return Children.Count > 0 || MoreChildren.Count > 0; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the description object using the IPropertyDescriptionService.
|
||||
/// </summary>
|
||||
public object Description { |
||||
get { |
||||
IPropertyDescriptionService s = Services.GetService<IPropertyDescriptionService>(); |
||||
if (s != null) { |
||||
return s.GetDescription(FirstProperty); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the value of this property.
|
||||
/// </summary>
|
||||
public object Value { |
||||
get { |
||||
if (IsAmbiguous) return null; |
||||
var result = FirstProperty.ValueOnInstance; |
||||
if (result == DependencyProperty.UnsetValue) return null; |
||||
return result; |
||||
} |
||||
set { |
||||
SetValueCore(value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the value of this property in string form
|
||||
/// </summary>
|
||||
public string ValueString { |
||||
get { |
||||
if (ValueItem == null || ValueItem.Component is MarkupExtension) { |
||||
if (Value == null) return null; |
||||
if (hasStringConverter) { |
||||
return FirstProperty.TypeConverter.ConvertToInvariantString(Value); |
||||
} |
||||
return "(" + Value.GetType().Name + ")"; |
||||
} |
||||
return "(" + ValueItem.ComponentType.Name + ")"; |
||||
} |
||||
set { |
||||
// make sure we only catch specific exceptions
|
||||
// and/or show the error message to the user
|
||||
//try {
|
||||
Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value); |
||||
//} catch {
|
||||
// OnValueOnInstanceChanged();
|
||||
//}
|
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the property node is enabled for editing.
|
||||
/// </summary>
|
||||
public bool IsEnabled { |
||||
get { |
||||
return ValueItem == null && hasStringConverter; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this property was set locally.
|
||||
/// </summary>
|
||||
public bool IsSet { |
||||
get { |
||||
foreach (var p in Properties) { |
||||
if (p.IsSet) return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the name.
|
||||
/// Depends on the type of the value (binding/resource/etc.)
|
||||
/// </summary>
|
||||
public Brush NameForeground { |
||||
get { |
||||
if (ValueItem != null) { |
||||
object component = ValueItem.Component; |
||||
if (component is BindingBase) |
||||
return Brushes.DarkGoldenrod; |
||||
if (component is StaticResourceExtension || component is DynamicResourceExtension) |
||||
return Brushes.DarkGreen; |
||||
} |
||||
return SystemColors.WindowTextBrush; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the DesignItem that owns the property (= the DesignItem that is currently selected).
|
||||
/// Returns null if multiple DesignItems are selected.
|
||||
/// </summary>
|
||||
public DesignItem ValueItem { |
||||
get { |
||||
if (Properties.Count == 1) { |
||||
return FirstProperty.Value; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the property value is ambiguous (multiple controls having different values are selected).
|
||||
/// </summary>
|
||||
public bool IsAmbiguous { |
||||
get { |
||||
foreach (var p in Properties) { |
||||
if (!object.Equals(p.ValueOnInstance, FirstProperty.ValueOnInstance)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool isVisible; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether the property is visible.
|
||||
/// </summary>
|
||||
public bool IsVisible { |
||||
get { |
||||
return isVisible; |
||||
} |
||||
set { |
||||
isVisible = value; |
||||
RaisePropertyChanged("IsVisible"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether resetting the property is possible.
|
||||
/// </summary>
|
||||
public bool CanReset { |
||||
get { return IsSet; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Resets the property.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
SetValueCore(Unset); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Replaces the value of this node with a new binding.
|
||||
/// </summary>
|
||||
public void CreateBinding() |
||||
{ |
||||
Value = new Binding(); |
||||
IsExpanded = true; |
||||
} |
||||
|
||||
void SetValueCore(object value) |
||||
{ |
||||
raiseEvents = false; |
||||
if (value == Unset) { |
||||
foreach (var p in Properties) { |
||||
p.Reset(); |
||||
} |
||||
} else { |
||||
foreach (var p in Properties) { |
||||
p.SetValue(value); |
||||
} |
||||
} |
||||
raiseEvents = true; |
||||
OnValueChanged(); |
||||
} |
||||
|
||||
void OnValueChanged() |
||||
{ |
||||
RaisePropertyChanged("IsSet"); |
||||
RaisePropertyChanged("Value"); |
||||
RaisePropertyChanged("ValueString"); |
||||
RaisePropertyChanged("IsAmbiguous"); |
||||
RaisePropertyChanged("FontWeight"); |
||||
RaisePropertyChanged("IsEnabled"); |
||||
RaisePropertyChanged("NameForeground"); |
||||
|
||||
UpdateChildren(); |
||||
} |
||||
|
||||
void OnValueOnInstanceChanged() |
||||
{ |
||||
RaisePropertyChanged("Value"); |
||||
RaisePropertyChanged("ValueString"); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a new PropertyNode instance.
|
||||
/// </summary>
|
||||
public PropertyNode() |
||||
{ |
||||
Children = new ObservableCollection<PropertyNode>(); |
||||
MoreChildren = new ObservableCollection<PropertyNode>(); |
||||
} |
||||
|
||||
PropertyNode(DesignItemProperty[] properties, PropertyNode parent) : this() |
||||
{ |
||||
this.Parent = parent; |
||||
this.Level = parent == null ? 0 : parent.Level + 1; |
||||
Load(properties); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes this property node with the specified properties.
|
||||
/// </summary>
|
||||
public void Load(DesignItemProperty[] properties) |
||||
{ |
||||
if (this.Properties != null) { |
||||
// detach events from old properties
|
||||
foreach (var property in this.Properties) { |
||||
property.ValueChanged -= new EventHandler(property_ValueChanged); |
||||
property.ValueOnInstanceChanged -= new EventHandler(property_ValueOnInstanceChanged); |
||||
} |
||||
} |
||||
|
||||
this.Properties = new ReadOnlyCollection<DesignItemProperty>(properties); |
||||
|
||||
if (Editor == null) |
||||
Editor = EditorManager.CreateEditor(FirstProperty); |
||||
|
||||
foreach (var property in properties) { |
||||
property.ValueChanged += new EventHandler(property_ValueChanged); |
||||
property.ValueOnInstanceChanged += new EventHandler(property_ValueOnInstanceChanged); |
||||
} |
||||
|
||||
hasStringConverter = |
||||
FirstProperty.TypeConverter.CanConvertFrom(typeof(string)) && |
||||
FirstProperty.TypeConverter.CanConvertTo(typeof(string)); |
||||
|
||||
OnValueChanged(); |
||||
} |
||||
|
||||
void property_ValueOnInstanceChanged(object sender, EventArgs e) |
||||
{ |
||||
if (raiseEvents) OnValueOnInstanceChanged(); |
||||
} |
||||
|
||||
void property_ValueChanged(object sender, EventArgs e) |
||||
{ |
||||
if (raiseEvents) OnValueChanged(); |
||||
} |
||||
|
||||
void UpdateChildren() |
||||
{ |
||||
Children.Clear(); |
||||
MoreChildren.Clear(); |
||||
|
||||
if (Parent == null || Parent.IsExpanded) { |
||||
if (ValueItem != null) { |
||||
var list = TypeHelper.GetAvailableProperties(ValueItem.Component) |
||||
.OrderBy(d => d.Name) |
||||
.Select(d => new PropertyNode(new[] { ValueItem.Properties.GetProperty(d) }, this)); |
||||
|
||||
foreach (var node in list) { |
||||
if (Metadata.IsBrowsable(node.FirstProperty)) { |
||||
node.IsVisible = true; |
||||
if (Metadata.IsPopularProperty(node.FirstProperty)) { |
||||
Children.Add(node); |
||||
} else { |
||||
MoreChildren.Add(node); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
RaisePropertyChanged("HasChildren"); |
||||
} |
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a property has changed. Used to support WPF data binding.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void RaisePropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
|
@ -1,52 +1,52 @@
@@ -1,52 +1,52 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Editor |
||||
{ |
||||
/// <summary>
|
||||
/// Allows language specific search for matching brackets.
|
||||
/// </summary>
|
||||
public interface IBracketSearcher |
||||
{ |
||||
/// <summary>
|
||||
/// Searches for a matching bracket from the given offset to the start of the document.
|
||||
/// </summary>
|
||||
/// <returns>A BracketSearchResult that contains the positions and lengths of the brackets. Return null if there is nothing to highlight.</returns>
|
||||
BracketSearchResult SearchBracket(IDocument document, int offset); |
||||
} |
||||
|
||||
public class DefaultBracketSearcher : IBracketSearcher |
||||
{ |
||||
public static readonly DefaultBracketSearcher DefaultInstance = new DefaultBracketSearcher(); |
||||
|
||||
public BracketSearchResult SearchBracket(IDocument document, int offset) |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Describes a pair of matching brackets found by IBracketSearcher.
|
||||
/// </summary>
|
||||
public class BracketSearchResult |
||||
{ |
||||
public int OpeningBracketOffset { get; private set; } |
||||
|
||||
public int OpeningBracketLength { get; private set; } |
||||
|
||||
public int ClosingBracketOffset { get; private set; } |
||||
|
||||
public int ClosingBracketLength { get; private set; } |
||||
|
||||
public BracketSearchResult(int openingBracketOffset, int openingBracketLength, |
||||
int closingBracketOffset, int closingBracketLength) |
||||
{ |
||||
this.OpeningBracketOffset = openingBracketOffset; |
||||
this.OpeningBracketLength = openingBracketLength; |
||||
this.ClosingBracketOffset = closingBracketOffset; |
||||
this.ClosingBracketLength = closingBracketLength; |
||||
} |
||||
} |
||||
} |
||||
// 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; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Editor |
||||
{ |
||||
/// <summary>
|
||||
/// Allows language specific search for matching brackets.
|
||||
/// </summary>
|
||||
public interface IBracketSearcher |
||||
{ |
||||
/// <summary>
|
||||
/// Searches for a matching bracket from the given offset to the start of the document.
|
||||
/// </summary>
|
||||
/// <returns>A BracketSearchResult that contains the positions and lengths of the brackets. Return null if there is nothing to highlight.</returns>
|
||||
BracketSearchResult SearchBracket(IDocument document, int offset); |
||||
} |
||||
|
||||
public class DefaultBracketSearcher : IBracketSearcher |
||||
{ |
||||
public static readonly DefaultBracketSearcher DefaultInstance = new DefaultBracketSearcher(); |
||||
|
||||
public BracketSearchResult SearchBracket(IDocument document, int offset) |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Describes a pair of matching brackets found by IBracketSearcher.
|
||||
/// </summary>
|
||||
public class BracketSearchResult |
||||
{ |
||||
public int OpeningBracketOffset { get; private set; } |
||||
|
||||
public int OpeningBracketLength { get; private set; } |
||||
|
||||
public int ClosingBracketOffset { get; private set; } |
||||
|
||||
public int ClosingBracketLength { get; private set; } |
||||
|
||||
public BracketSearchResult(int openingBracketOffset, int openingBracketLength, |
||||
int closingBracketOffset, int closingBracketLength) |
||||
{ |
||||
this.OpeningBracketOffset = openingBracketOffset; |
||||
this.OpeningBracketLength = openingBracketLength; |
||||
this.ClosingBracketOffset = closingBracketOffset; |
||||
this.ClosingBracketLength = closingBracketLength; |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue