Hi,
I have a custom Node:UIElement and a custom view class which contains a collection of Nodes.
When I try to add Nodes in XAML, they don't show up, even though when I step through I can see they exist in the HattenView's collection. If I add a button control to the XAML inside the view, it shows up.
I've been looking at this for so long now and just can't seem to figure out why these notes aren't showing.
<Grid Name="HattenContentGrid" >
<MyPresentation:HattenView x:Name="GSM" >
<MyPresentation:HattenView.Nodes>
<MyPresentation:Node Name="UNREG2G" Bounds="20,35,150,80" Text="UNREGISTERED"
TextAlignment="Center" ClipToBounds="True"
TextBrush="LavenderBlush" FontSize="15" Shape="RoundRect" Opacity="0.0"
Image="{StaticResource UNREG2G}" ImageAlign="Fit" />
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using Logic.Itsa;
namespace Presentation.MyPresentation
{
public class HattenNodeCollection
{
private List<Node> _nodes;
public List<Node> Nodes
{
get { return _nodes; }
set { _nodes = value; }
}
}
public class Node : UIElement
{
public HattenView HattenView { get; set; }
public string Name { get; set; }
public string Tag { get; set; }
public string Text { get; set; }
public int StrokeThickness { get; set; }
public bool Visible { get; set; }
public Rect Bounds { get; set; }
public Brush TextBrush { get; set; }
public Brush Brush { get; set; }
public string Shape { get; set; }
public DrawingImage Image { get; set; }
public ImageAlign ImageAlign { get; set; }
public TextAlignment TextAlignment { get; set; }
public Double FontSize { get; set; }
public HattenNodeVisual VisualObject { get; set; }
//public HattenNodeVisual.HandlesStyle HandlesStyle { get; set; }
public Brush Stroke
{
get;
set;
}
//public void ZBottom()
//{
// if (HattenView != null)
// {
// HattenView.ZBottom(this);
// Repaint();
// }
//}
protected void Repaint()
{
// //if (diagram != null && !diagram.NowLoading)
// // diagram.Invalidate(GetRepaintRect(false));
// Repaint(false);
}
///// <summary>
///// Repaints the specified region of the diagram.
///// </summary>
//public virtual void Repaint(bool includeConnected)
//{
// if (diagram != null && !diagram.NowLoading)
// diagram.Invalidate(invalidRect);
// Utilities.InvalidateVisual(this);
// if (UIElement != this)
// Utilities.InvalidateVisual(UIElement);
// Utilities.InvalidateVisual(adorner);
// include the group objects rectangles in the update area
// if (includeConnected && subordinateGroup != null)
// subordinateGroup.Repaint();
//}
public void Render(DrawingContext dc) { OnRender(dc);}
protected override void OnRender(DrawingContext dc)
{
dc.DrawImage(this.Image, this.Bounds);
dc.DrawRectangle(null, null, Bounds);
}
}
public class NodeAdapter : Node
{
}
}
protected override void OnRender(DrawingContext drawingContext)
{
//double x = 0, y = 0;
foreach (Node n in Nodes)
{
n.Render(drawingContext);
n.MouseEnter += UIElement_OnMouseEnter;
}
}