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