Esempio n. 1
0
 public GraphEdge(BinaryReader reader)
 {
     m_type = Factory.ObjectType.GraphEdge;
       m_from = null;
       m_to = null;
       m_loop = reader.ReadBoolean();
 }
        public override object visit(GraphNode node)
        {
            //draw node
              Pen p;
              if (node == m_selected){
            p = new Pen(Brushes.IndianRed,2.5f);
              }
              else
            p = new Pen(Brushes.BlueViolet,1.5f);
              if (node.getRoot() == node)
            p.DashStyle = DashStyle.Dash;
              m_gc.DrawEllipse(p, node.Location.X-node.Width/2, node.Location.Y-node.Height/2, node.Width, node.Height);

              //with its text
              m_gc.DrawString(node.Name, new Font(FontFamily.GenericSerif, 8),
            Brushes.DarkGreen,
            node.Location.X-node.Name.Length*3, node.Location.Y-5);

              //visit edges
              foreach (GraphEdge edge in node.Successors)
              {
            edge.getVisited(this);
              }
              return null;
        }
        public ObjectProperties(GraphNode node)
        {
            //
              // Required for Windows Form Designer support
              //
              InitializeComponent();

              m_properties = new ArrayList();
              m_node = node;
              if (m_node != null){
            getValuesFromNode();
            if (m_properties.Count > 0)
            {
              Properties.SelectedIndex = 0;
              if (((ObjProperty)m_properties[0]).Values.Count > 0)
              {
            Value.SelectedIndex = 0;
            if (((ObjValue)(((ObjProperty)m_properties[0]).Values[0])).Responses.Count > 0)
            {
              Response.SelectedIndex = 0;
              Opcode code = ((ObjResponse)((ObjValue)(((ObjProperty)m_properties[0]).Values[0])).Responses[0]).Operation;
              responseType.SelectedIndex = (int)code;
            }
              }
            }
              }
        }
 public GraphDrawVisitor(Graphics graph, GraphNode selection)
 {
     //
     // TODO: Add constructor logic here
     //
       m_gc = graph;
       m_selected = selection;
 }
 public override object visit(GraphNode node)
 {
     m_nodes.Add(node);
       foreach (GraphEdge edge in node.Successors)
       {
     edge.getVisited(this);
       }
       return null;
 }
Esempio n. 6
0
 public GraphEdge(GraphNode from, GraphNode to)
 {
     m_type = Factory.ObjectType.GraphEdge;
       m_from = from;
       m_to = to;
       if (to.Successors.Count > 0 && to.getRoot() == from.getRoot())
     m_loop = true;
       else
     m_loop = false;
 }
 public abstract object visit(GraphNode node);
Esempio n. 8
0
 public static GraphNode getFirstNonLoopingPredecessor(GraphNode node)
 {
     //get the non-looping predecessor
       for (int i = 0; i < node.Predecessors.Count; ++i)
       {
     GraphEdge edge = (GraphEdge)node.Predecessors[i];
     if (!edge.IsLoop)
     {
       return edge.From;
     }
       }
       return null;
 }
 public override object visit(GraphNode node)
 {
     return null;
 }
Esempio n. 10
0
 private void GraphForm_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
       {
     if (m_selection == null)
       return;
     //connect request
     Monitor.Enter(m_graph);
     GraphNodeSelectionVisitor gnsv = new GraphNodeSelectionVisitor(new Point(e.X,e.Y));
     GraphNode target = (GraphNode)m_graph.getVisited(gnsv);
     if (target != null)
     {
       //it was clicked on a node
       m_graph.connect(m_selection, target);
     }
     else{
       m_selection = null;
     }
     Monitor.Exit(m_graph);
       }
       else if (e.Button == MouseButtons.Left)
       {
     GraphNodeSelectionVisitor gnsv = new GraphNodeSelectionVisitor(new Point(e.X,e.Y));
     m_selection = (GraphNode)m_graph.getVisited(gnsv);
     if (m_selection != null)
     {
       //it was clicked on a node
       if (e.Clicks > 1)
       {
     //double click
     if (m_selection.LowerGraph == null)
     {
       m_selection.LowerGraph = m_gen_graph();
     }
     m_selection.LowerGraph.Parent = m_graph;
     m_graph = m_selection.LowerGraph;
     string tmp = graph_level.Text.Substring(6);
     int level = Convert.ToInt32(tmp);
     graph_level.Text = "level "+Convert.ToString(level+1);
     //m_selection.Name = "dc";
       }
       m_left_down = true;
     }
     else
     {
       m_click = new Point(e.X, e.Y);
       NodeMenu.Show(this, m_click);
     }
       }
       Invalidate();
 }
Esempio n. 11
0
 public abstract object visit(GraphNode node);
Esempio n. 12
0
 public void addUnconnectedNode(GraphNode node)
 {
     m_roots.Add(node);
       m_leafs.Add(node);
 }
Esempio n. 13
0
 //public virtual GraphNode newNode(Point p){
 //  return new GraphNode(p);
 //}
 public virtual GraphEdge newEdge(GraphNode from, GraphNode to)
 {
     return new GraphEdge(from, to);
 }
Esempio n. 14
0
 public void connect(GraphNode from, GraphNode to)
 {
     GraphEdge edge = newEdge(from, to);
       addEdge(edge);
 }