+ Fixed edge labels display for self looped edges [WPF, METRO]

+ Added new property EdgeLabelControl::DisplayForSelfLoopedEdges which is self explaining [WPF, METRO]
This commit is contained in:
Alexander Smirnov 2015-03-31 16:56:15 +03:00
Родитель ffbb199e28
Коммит 866525e8db
4 изменённых файлов: 82 добавлений и 1 удалений

Просмотреть файл

@ -10,6 +10,8 @@
+ Added VertexControl::GetCenterPosition() method to get vertex center position instead the default top-left [WPF, METRO]
+ Added new showcase example: Templates/Graph editor [WPF]
+ Added new option GraphArea::LogicCoreChangeAction which defines what action will be taken on LogicCore property change. You can rebuild graph now. [WPF, METRO]
+ Fixed edge labels display for self looped edges [WPF, METRO]
+ Added new property EdgeLabelControl::DisplayForSelfLoopedEdges which is self explaining [WPF, METRO]
+ Fixed annoying data binding error in ZoomControl slider binding [METRO, WPF]
+ Fixed ZoomControl unresponsivness after startup (prev needed to change zoom/translation first to work fine) [WPF,METRO]
+ Fixed ZoomControl::Zoom property bug on empty content window resize [WPF, METRO]

Просмотреть файл

@ -84,6 +84,7 @@
<!--EDGE LABLE CONTROL -->
<Style TargetType="{x:Type gxl:EdgeLabelControl}">
<Setter Property="DisplayForSelfLoopedEdges" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type gxl:EdgeLabelControl}">

Просмотреть файл

@ -13,6 +13,26 @@ namespace GraphX
internal Rect LastKnownRectSize;
#region Common part
public static readonly DependencyProperty DisplayForSelfLoopedEdgesProperty = DependencyProperty.Register("DisplayForSelfLoopedEdges",
typeof(bool),
typeof(EdgeLabelControl),
new UIPropertyMetadata(false));
/// <summary>
/// Gets or sets if label should be visible for self looped edge
/// </summary>
public bool DisplayForSelfLoopedEdges
{
get
{
return (bool)GetValue(DisplayForSelfLoopedEdgesProperty);
}
set
{
SetValue(DisplayForSelfLoopedEdgesProperty, value);
}
}
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle",
typeof(double),
typeof(EdgeLabelControl),
@ -48,6 +68,7 @@ namespace GraphX
public void Show()
{
if (EdgeControl.IsSelfLooped && !DisplayForSelfLoopedEdges) return;
Visibility = Visibility.Visible;
}
@ -64,8 +85,13 @@ namespace GraphX
LayoutUpdated += EdgeLabelControl_LayoutUpdated;
HorizontalAlignment = HorizontalAlignment.Left;
VerticalAlignment = VerticalAlignment.Top;
this.Initialized += EdgeLabelControl_Initialized;
}
void EdgeLabelControl_Initialized(object sender, EventArgs e)
{
if (EdgeControl.IsSelfLooped && !DisplayForSelfLoopedEdges) Hide();
else Show();
}
void EdgeLabelControl_LayoutUpdated(object sender, EventArgs e)
@ -101,6 +127,18 @@ namespace GraphX
Debug.WriteLine("EdgeLabelControl_LayoutUpdated() -> Got empty edgecontrol!");
return;
}
//if hidden
if (Visibility != Visibility.Visible) return;
if(EdgeControl.IsSelfLooped)
{
var idesiredSize = DesiredSize;
var pt = EdgeControl.Source.GetCenterPosition();
pt.Offset(-idesiredSize.Width / 2, (EdgeControl.Source.DesiredSize.Height * .5) + 2 + (idesiredSize.Height * .5));
LastKnownRectSize = new Rect(pt.X, pt.Y, idesiredSize.Width, idesiredSize.Height);
Arrange(LastKnownRectSize);
return;
}
var p1 = EdgeControl.SourceConnectionPoint.GetValueOrDefault();
var p2 = EdgeControl.TargetConnectionPoint.GetValueOrDefault();

Просмотреть файл

@ -14,6 +14,25 @@ namespace GraphX.Controls
public class EdgeLabelControl : ContentControl, IEdgeLabelControl
{
public static readonly DependencyProperty DisplayForSelfLoopedEdgesProperty = DependencyProperty.Register("DisplayForSelfLoopedEdges",
typeof(bool),
typeof(EdgeLabelControl),
new PropertyMetadata(false));
/// <summary>
/// Gets or sets if label should be visible for self looped edge
/// </summary>
public bool DisplayForSelfLoopedEdges
{
get
{
return (bool)GetValue(DisplayForSelfLoopedEdgesProperty);
}
set
{
SetValue(DisplayForSelfLoopedEdgesProperty, value);
}
}
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle",
typeof(double),
typeof(EdgeLabelControl),
@ -59,6 +78,7 @@ namespace GraphX.Controls
public void Show()
{
if (EdgeControl.IsSelfLooped && !DisplayForSelfLoopedEdges) return;
Visibility = Visibility.Visible;
}
@ -85,6 +105,13 @@ namespace GraphX.Controls
LayoutUpdated += EdgeLabelControl_LayoutUpdated;
HorizontalAlignment = HorizontalAlignment.Left;
VerticalAlignment = VerticalAlignment.Top;
Loaded += EdgeLabelControl_Loaded;
}
void EdgeLabelControl_Loaded(object sender, RoutedEventArgs e)
{
if (EdgeControl.IsSelfLooped && !DisplayForSelfLoopedEdges) Hide();
else Show();
}
void EdgeLabelControl_LayoutUpdated(object sender, object e)
@ -128,6 +155,19 @@ namespace GraphX.Controls
return;
}
//if hidden
if (Visibility != Visibility.Visible) return;
if (EdgeControl.IsSelfLooped)
{
var idesiredSize = DesiredSize;
var pt = EdgeControl.Source.GetCenterPosition();
pt = pt.Offset(-idesiredSize.Width / 2, (EdgeControl.Source.DesiredSize.Height * .5) + 2 + (idesiredSize.Height * .5));
LastKnownRectSize = new Rect(pt.X, pt.Y, idesiredSize.Width, idesiredSize.Height);
Arrange(LastKnownRectSize);
return;
}
var p1 = EdgeControl.SourceConnectionPoint.GetValueOrDefault();
var p2 = EdgeControl.TargetConnectionPoint.GetValueOrDefault();