|
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using GraphLayout;
namespace TreeContainer
{
public class TreeConnectionsAdorner : Adorner
{
#region Private variables
TreeContainer _tc;
#endregion
#region Constructors
static TreeConnectionsAdorner()
{
}
public TreeConnectionsAdorner(UIElement adornedElement)
: base(adornedElement)
{
_tc = adornedElement as TreeContainer;
IsHitTestVisible = false;
}
#endregion
#region Point Conversion
Point PtFromDPoint(DPoint dpt)
{
return new Point(dpt.X, dpt.Y);
}
#endregion
#region Rendering
protected override void OnRender(DrawingContext drawingContext)
{
List<TreeConnection> lsttcn = _tc.Connections;
if (lsttcn != null)
{
SolidColorBrush brsh = new SolidColorBrush(Colors.Black);
brsh.Opacity = 0.5;
Pen pen = new Pen(brsh, 1.0);
Point ptLast = new Point(0, 0);
bool fHaveLastPoint = false;
base.OnRender(drawingContext);
foreach (TreeConnection tcn in lsttcn)
{
fHaveLastPoint = false;
foreach (DPoint dpt in tcn.LstPt)
{
if (!fHaveLastPoint)
{
ptLast = PtFromDPoint(tcn.LstPt[0]);
fHaveLastPoint = true;
continue;
}
drawingContext.DrawLine(pen, PtFromDPoint(dpt), ptLast);
ptLast = PtFromDPoint(dpt);
}
}
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been doing programming for close to 30 years now. I started with C at Bell Labs and later went to work for Microsoft for many years. I currently am a partner in Suckerpunch LLC where we produce PlayStation games (www.suckerpunch.com).
I am mainly interested in AI, graphics and more mathematical stuff. Dealing with client/server architectures and business software doesn't do that much for me. I love math, computers, hiking, travel, reading, playing piano, fruit jars (yes - I said fruit jars) and photography.