Commits

Mark Heath  committed 7a48503

for clarity, now Node is called NodeControl

  • Participants
  • Parent commits b78f85c

Comments (0)

Files changed (7)

File GraphPad/GraphPad.csproj

     <Compile Include="Logic\GraphRenderer.cs" />
     <Compile Include="Logic\NodeInfo.cs" />
     <Compile Include="Logic\RelationshipType.cs" />
-    <Compile Include="Node.xaml.cs">
-      <DependentUpon>Node.xaml</DependentUpon>
+    <Compile Include="NodeControl.xaml.cs">
+      <DependentUpon>NodeControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Logic\Tokenizer.cs" />
     <Page Include="MainWindow.xaml">
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Page Include="Node.xaml">
+    <Page Include="NodeControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>

File GraphPad/Logic/GraphRenderer.cs

     class GraphRenderer
     {
         private Canvas canvas;
-        private Dictionary<string, Node> nodes;
+        private Dictionary<string, NodeControl> nodes;
         private const double nodePadding = 10.0;
 
         public GraphRenderer(Canvas canvas)
         {
             this.canvas = canvas;
-            this.nodes = new Dictionary<string, Node>();
+            this.nodes = new Dictionary<string, NodeControl>();
         }
 
         public void Render(Graph graph)
             return line;
         }
 
-        private static Point GetNodeMidpoint(Node node)
+        private static Point GetNodeMidpoint(NodeControl node)
         {
             var radius = node.Width / 2;
             return new Point((double)node.GetValue(Canvas.LeftProperty) + radius, (double)node.GetValue(Canvas.TopProperty) + radius);
         }
 
-        private static Node CreateNode(double left, double top, string name)
+        private static NodeControl CreateNode(double left, double top, string name)
         {
-            var node = new Node();
+            var node = new NodeControl();
             node.SetValue(Canvas.LeftProperty, left);
             node.SetValue(Canvas.TopProperty, top);
             node.NodeName = name;

File GraphPad/MainWindow.xaml.cs

             RecreateGraph();
         }
 
-        private Dictionary<string, Node> nodes = new Dictionary<string, Node>();
+        private Dictionary<string, NodeControl> nodes = new Dictionary<string, NodeControl>();
 
         private void RecreateGraph()
         {

File GraphPad/Node.xaml

-<UserControl x:Class="GraphPad.Node"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             mc:Ignorable="d" 
-             Width="40" Height="40"
-             d:DesignHeight="40" d:DesignWidth="40">
-    <Grid ToolTip="This is a node">
-        <Ellipse Stroke="Black" StrokeThickness="2" x:Name="ellipse" Fill="White" />
-        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Text="A" FontSize="20" x:Name="nodeNameTextBlock" />
-    </Grid>
-</UserControl>

File GraphPad/Node.xaml.cs

-using System;
-using System.Collections.Generic;
-using System.Linq;
-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 System.ComponentModel;
-
-namespace GraphPad
-{
-    /// <summary>
-    /// Interaction logic for Node.xaml
-    /// </summary>
-    public partial class Node : UserControl
-    {
-        private List<Node> connections = new List<Node>();
-        
-        public Node()
-        {
-            InitializeComponent();
-        }
-
-        public List<Node> Connections
-        {
-            get { return connections; }
-        }
-
-        public string NodeName
-        {
-            get { return (string)GetValue(NodeNameProperty); }
-            set { SetValue(NodeNameProperty, value); }
-        }
-
-        // Using a DependencyProperty as the backing store for NodeName.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty NodeNameProperty =
-            DependencyProperty.Register("NodeName", typeof(string), typeof(Node), new UIPropertyMetadata("A", new PropertyChangedCallback(OnNodeNameChanged)));
-
-        private static void OnNodeNameChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
-        {
-            var node = (Node)sender;
-            node.nodeNameTextBlock.Text = (string)args.NewValue;
-        }
-
-    }
-}

File GraphPad/NodeControl.xaml

+<UserControl x:Class="GraphPad.NodeControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             mc:Ignorable="d" 
+             Width="40" Height="40"
+             d:DesignHeight="40" d:DesignWidth="40">
+    <Grid ToolTip="This is a node">
+        <Ellipse Stroke="Black" StrokeThickness="2" x:Name="ellipse" Fill="White" />
+        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Text="A" FontSize="20" x:Name="nodeNameTextBlock" />
+    </Grid>
+</UserControl>

File GraphPad/NodeControl.xaml.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+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 System.ComponentModel;
+
+namespace GraphPad
+{
+    /// <summary>
+    /// Interaction logic for Node.xaml
+    /// </summary>
+    public partial class NodeControl : UserControl
+    {
+        private List<NodeControl> connections = new List<NodeControl>();
+        
+        public NodeControl()
+        {
+            InitializeComponent();
+        }
+
+        public List<NodeControl> Connections
+        {
+            get { return connections; }
+        }
+
+        public string NodeName
+        {
+            get { return (string)GetValue(NodeNameProperty); }
+            set { SetValue(NodeNameProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for NodeName.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty NodeNameProperty =
+            DependencyProperty.Register("NodeName", typeof(string), typeof(NodeControl), new UIPropertyMetadata("A", new PropertyChangedCallback(OnNodeNameChanged)));
+
+        private static void OnNodeNameChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
+        {
+            var node = (NodeControl)sender;
+            node.nodeNameTextBlock.Text = (string)args.NewValue;
+        }
+
+    }
+}