Browse Source
- node UI Control reuse between subsequent graphs for better performance - styled "+" buttons git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4690 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
19 changed files with 186 additions and 218 deletions
@ -1,26 +0,0 @@
@@ -1,26 +0,0 @@
|
||||
<UserControl x:Class="Debugger.AddIn.Visualizers.Graph.Drawing.NodeControl" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:dropShadow="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"> |
||||
<dropShadow:SystemDropShadowChrome> |
||||
<Border Name="border1" BorderBrush="Black" BorderThickness="1" Padding="04,04,04,04" |
||||
Canvas.Left="20" Canvas.Top="20"> |
||||
<Border.Background> |
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> |
||||
<GradientStop Color="#ddeeff" Offset="0.0" /> |
||||
<GradientStop Color="White" Offset="0.4" /> |
||||
<GradientStop Color="White" Offset="0.8" /> |
||||
</LinearGradientBrush> |
||||
</Border.Background> |
||||
<Grid Name="propertyGrid"> |
||||
<Grid.RowDefinitions> |
||||
</Grid.RowDefinitions> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto" /> |
||||
<ColumnDefinition Width="Auto" /> |
||||
<ColumnDefinition Width="Auto" /> |
||||
</Grid.ColumnDefinitions> |
||||
</Grid> |
||||
</Border> |
||||
</dropShadow:SystemDropShadowChrome> |
||||
</UserControl> |
@ -1,154 +0,0 @@
@@ -1,154 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
using Debugger.AddIn.Visualizers.Graph.Layout; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using System.Windows.Media.Imaging; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Shapes; |
||||
using Debugger.AddIn.Visualizers.Graph; |
||||
|
||||
namespace Debugger.AddIn.Visualizers.Graph.Drawing |
||||
{ |
||||
/// <summary>
|
||||
/// UserControl used to display Positione.
|
||||
/// </summary>
|
||||
public partial class NodeControl : UserControl |
||||
{ |
||||
/// <summary>
|
||||
/// Creates new NodeControl displaying PositionedNode.
|
||||
/// </summary>
|
||||
/*public NodeControl() : this() |
||||
{ |
||||
//this.GraphNode = graphNode;
|
||||
}*/ |
||||
|
||||
/// <summary>
|
||||
/// Creates new NodeControl displaying PositionedNode.
|
||||
/// </summary>
|
||||
public NodeControl() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
public event EventHandler<PositionedPropertyEventArgs> PropertyExpanded; |
||||
public event EventHandler<PositionedPropertyEventArgs> PropertyCollapsed; |
||||
|
||||
private PositionedGraphNode node; |
||||
/// <summary>
|
||||
/// ObjectNode that this control displays.
|
||||
/// </summary>
|
||||
public PositionedGraphNode GraphNode |
||||
{ |
||||
get |
||||
{ |
||||
return node; |
||||
} |
||||
private set |
||||
{ |
||||
this.node = value; |
||||
} |
||||
} |
||||
|
||||
public void AddProperty(PositionedNodeProperty property) |
||||
{ |
||||
int nRow = propertyGrid.RowDefinitions.Count; |
||||
|
||||
var row = new RowDefinition(); |
||||
propertyGrid.RowDefinitions.Add(row); |
||||
|
||||
if (!property.IsAtomic && !property.IsNull) |
||||
{ |
||||
Button btnExpandCollapse = new Button(); |
||||
btnExpandCollapse.Tag = property; |
||||
btnExpandCollapse.Content = property.IsPropertyExpanded ? "-" : "+"; |
||||
btnExpandCollapse.Width = 20; |
||||
propertyGrid.Children.Add(btnExpandCollapse); |
||||
Grid.SetRow(btnExpandCollapse, nRow); |
||||
Grid.SetColumn(btnExpandCollapse, 0); |
||||
btnExpandCollapse.Click += new RoutedEventHandler(btnExpandCollapse_Click); |
||||
} |
||||
|
||||
TextBlock txtName = createTextBlock(property.Name); |
||||
propertyGrid.Children.Add(txtName); |
||||
Grid.SetRow(txtName, nRow); |
||||
Grid.SetColumn(txtName, 1); |
||||
|
||||
TextBlock txtValue = createTextBlock(property.Value); |
||||
propertyGrid.Children.Add(txtValue); |
||||
Grid.SetRow(txtValue, nRow); |
||||
Grid.SetColumn(txtValue, 2); |
||||
} |
||||
|
||||
/*public void Measure() |
||||
{ |
||||
this.Measure(); |
||||
|
||||
int nRow = 0; |
||||
// dynamically create TextBlocks and insert them to the 2-column propertyGrid
|
||||
foreach (var property in node.Properties) |
||||
{ |
||||
|
||||
|
||||
nRow++; |
||||
} |
||||
}*/ |
||||
|
||||
void btnExpandCollapse_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
Button buttonClicked = ((Button)sender); |
||||
var property = (PositionedNodeProperty)buttonClicked.Tag; |
||||
|
||||
property.IsPropertyExpanded = !property.IsPropertyExpanded; |
||||
buttonClicked.Content = property.IsPropertyExpanded ? "-" : "+"; |
||||
if (property.IsPropertyExpanded) |
||||
{ |
||||
OnPropertyExpanded(property); |
||||
} |
||||
else |
||||
{ |
||||
OnPropertyCollapsed(property); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates TextBlock with given text.
|
||||
/// </summary>
|
||||
private TextBlock createTextBlock(string text) |
||||
{ |
||||
TextBlock newTextblock = new TextBlock(); |
||||
newTextblock.Text = text; |
||||
newTextblock.Padding = new Thickness(4); |
||||
return newTextblock; |
||||
} |
||||
|
||||
#region event helpers
|
||||
protected virtual void OnPropertyExpanded(PositionedNodeProperty property) |
||||
{ |
||||
if (this.PropertyExpanded != null) |
||||
{ |
||||
this.PropertyExpanded(this, new PositionedPropertyEventArgs(property)); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnPropertyCollapsed(PositionedNodeProperty property) |
||||
{ |
||||
if (this.PropertyCollapsed != null) |
||||
{ |
||||
this.PropertyCollapsed(this, new PositionedPropertyEventArgs(property)); |
||||
} |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
> |
||||
<Style TargetType="{x:Type ToggleButton}"> |
||||
<Setter Property="Focusable" |
||||
Value="False"/> |
||||
<Setter Property="Width" |
||||
Value="19"/> |
||||
<Setter Property="Height" |
||||
Value="13"/> |
||||
<Setter Property="Template"> |
||||
<Setter.Value> |
||||
<ControlTemplate TargetType="{x:Type ToggleButton}"> |
||||
<Border Width="19" |
||||
Height="13" |
||||
Background="Transparent"> |
||||
<Border Width="9" |
||||
Height="9" |
||||
BorderThickness="1" |
||||
BorderBrush="#FF7898B5" |
||||
CornerRadius="1" |
||||
SnapsToDevicePixels="true"> |
||||
<Border.Background> |
||||
<LinearGradientBrush StartPoint="0,0" |
||||
EndPoint="1,1"> |
||||
<LinearGradientBrush.GradientStops> |
||||
<GradientStop Color="White" |
||||
Offset=".2"/> |
||||
<GradientStop Color="#FFC0B7A6" |
||||
Offset="1"/> |
||||
</LinearGradientBrush.GradientStops> |
||||
</LinearGradientBrush> |
||||
</Border.Background> |
||||
<Path x:Name="ExpandPath" |
||||
Margin="1,1,1,1" |
||||
Fill="Black" |
||||
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/> |
||||
</Border> |
||||
</Border> |
||||
<ControlTemplate.Triggers> |
||||
<Trigger Property="IsChecked" |
||||
Value="True"> |
||||
<Setter Property="Data" |
||||
TargetName="ExpandPath" |
||||
Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/> |
||||
</Trigger> |
||||
</ControlTemplate.Triggers> |
||||
</ControlTemplate> |
||||
</Setter.Value> |
||||
</Setter> |
||||
</Style> |
||||
</ResourceDictionary> |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
using Debugger.AddIn.Visualizers.Graph.Drawing; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
namespace Debugger.AddIn.Visualizers.Graph |
||||
{ |
||||
/// <summary>
|
||||
/// Description of NodeControlCache.
|
||||
/// </summary>
|
||||
public class NodeControlCache |
||||
{ |
||||
public static readonly NodeControlCache Instance = new NodeControlCache(); |
||||
|
||||
private Stack<PositionedGraphNodeControl> controls; |
||||
private int controlsReturned = 0; |
||||
|
||||
private NodeControlCache() |
||||
{ |
||||
Clear(); |
||||
} |
||||
|
||||
public void ReturnForReuse(PositionedGraphNodeControl controlToReuse) |
||||
{ |
||||
controls.Push(controlToReuse); |
||||
} |
||||
|
||||
public PositionedGraphNodeControl GetNodeControl() |
||||
{ |
||||
return new PositionedGraphNodeControl(); |
||||
var control = controls.Count == 0 ? new PositionedGraphNodeControl() : controls.Pop(); |
||||
control.Init(); |
||||
//control.InvalidateVisual();
|
||||
controlsReturned++; |
||||
return control; |
||||
} |
||||
|
||||
public void Clear() |
||||
{ |
||||
controls = new Stack<PositionedGraphNodeControl>(); |
||||
controlsReturned = 0; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue