Exemplo n.º 1
0
 /// <summary>
 /// Reset selected line
 /// </summary>
 public void ResetSelectedLine()
 {
     m_selectedLine = null;
     SetLineVisibility(false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Select this line on this canvas.
        /// </summary>
        /// <param name="line"></param>
        public void AddSelectedLine(PPathwayEdge line)
        {
            if (line == null)
                return;
            m_selectedLine = line;

            // Prepare line handles
            m_lineHandle4V.Offset = PointF.Empty;
            m_lineHandle4P.Offset = PointF.Empty;

            m_lineHandle4V.OffsetX = m_selectedLine.VarPoint.X;
            m_lineHandle4V.OffsetY = m_selectedLine.VarPoint.Y;

            m_lineHandle4P.OffsetX = m_selectedLine.ProPoint.X;
            m_lineHandle4P.OffsetY = m_selectedLine.ProPoint.Y;

            // Create Reconnect line
            m_edge4reconnect.SetEdge(LINE_BRUSH, m_edge4reconnect.EdgeWidth);
            m_edge4reconnect.Info.Direction = m_selectedLine.Info.Direction;
            m_edge4reconnect.Info.LineType = m_selectedLine.Info.LineType;
            m_edge4reconnect.VarPoint = m_selectedLine.VarPoint;
            m_edge4reconnect.ProPoint = m_selectedLine.ProPoint;
            m_edge4reconnect.PIndex = m_selectedLine.PIndex;
            m_edge4reconnect.VIndex = m_selectedLine.VIndex;
            m_edge4reconnect.DrawLine();

            SetLineVisibility(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="canvas"></param>
        public EdgeHandler(CanvasControl canvas)
        {
            this.m_canvas = canvas;
            this.m_con = canvas.Control;

            // Prepare line handles
            m_lineHandle4V = new EdgeHandle();
            m_lineHandle4V.ComponentType = EcellObject.VARIABLE;
            m_lineHandle4V.MouseDrag += new PInputEventHandler(LineHandle_MouseDrag);
            m_lineHandle4V.MouseUp += new PInputEventHandler(LineHandle_MouseUp);

            m_lineHandle4P = new EdgeHandle();
            m_lineHandle4P.ComponentType = EcellObject.PROCESS;
            m_lineHandle4P.MouseDrag += new PInputEventHandler(LineHandle_MouseDrag);
            m_lineHandle4P.MouseUp += new PInputEventHandler(LineHandle_MouseUp);

            m_edge4reconnect = new PPathwayEdge(m_canvas);
            m_edge4reconnect.SetEdge(LINE_BRUSH, 2);
            m_edge4reconnect.Pickable = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// create edge by using the information of element.
        /// </summary>
        public void SetEdges()
        {
            // Error Check
            if (base.m_canvas == null || m_ecellObj == null || m_layer == null)
                return;
            EcellProcess process = (EcellProcess)m_ecellObj;
            if (process.ReferenceList == null)
                return;

            try
            {
                List<EcellReference> list = process.ReferenceList;
                float width = m_canvas.Control.Animation.EdgeWidth;
                Brush brush = m_canvas.Control.Animation.EdgeBrush;
                // Create EdgeInfo
                List<EdgeInfo> infos = CreateEdgeInfos(process.Key, list);

                // Delete edges.
                List<PPathwayEdge> edges = new List<PPathwayEdge>();
                foreach (PPathwayEdge edge in m_edges)
                {
                    bool exist = false;
                    EdgeInfo temp = null;
                    foreach (EdgeInfo info in infos)
                    {
                        if (edge.Info.VariableKey != info.VariableKey)
                            continue;
                        // Check existing edge.
                        exist = true;
                        temp = info;
                        edge.EdgeWidth = width;
                        edge.Info.Direction = info.Direction;
                        edge.Info.LineType = info.LineType;
                        //
                        edge.Refresh();
                        edges.Add(edge);
                        break;
                    }
                    // Delete
                    if (!exist)
                    {
                        edge.RemoveFromParent();
                        edge.Dispose();
                        continue;
                    }
                    //
                    infos.Remove(temp);
                    int index = m_layer.IndexOfChild(edge);
                    if (index < 0)
                        m_layer.AddChild(edge);
                }
                m_edges.Clear();
                m_edges = edges;

                // Create edge.
                foreach (EdgeInfo info in infos)
                {
                    PPathwayVariable var = base.m_canvas.Variables[info.VariableKey];
                    PPathwayEdge edge = new PPathwayEdge(m_canvas, info, this, var);
                    edge.EdgeWidth = width;
                    edge.EdgeBrush = brush;
                    edge.Selected = this.Selected || var.Selected;
                    edge.Refresh();
                    m_layer.AddChild(edge);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(" target is " + e.TargetSite);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set line menu.
        /// </summary>
        /// <param name="line"></param>
        private void SetLineMenu(PPathwayEdge line)
        {
            EdgeDirection direction = line.Info.Direction;

            toolStripAnotherArrow.Enabled = direction == EdgeDirection.Inward || direction == EdgeDirection.Outward;
            toolStripOneWayArrow.Enabled = direction == EdgeDirection.None || direction == EdgeDirection.Bidirection;
            toolStripBidirArrow.Enabled = direction != EdgeDirection.Bidirection;
            toolStripConstant.Enabled = direction != EdgeDirection.None;
        }
Exemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 private static string CreateSVGLine(PPathwayEdge line)
 {
     string obj = "";
     string brush = BrushManager.ParseBrushToString(line.Brush);
     string width = line.Pen.Width.ToString();
     PointF proPoint = line.ProPoint;
     PointF varPoint = line.VarPoint;
     switch (line.Info.LineType)
     {
         case LineType.Solid:
         case LineType.Unknown:
             obj += SVGUtil.Line(proPoint, varPoint, brush, width);
             break;
         case LineType.Dashed:
             obj += SVGUtil.DashedLine(proPoint, varPoint, brush, width);
             break;
     }
     switch (line.Info.Direction)
     {
         case EdgeDirection.Bidirection:
             obj += SVGUtil.Polygon(PPathwayEdge.GetArrowPoints(proPoint, varPoint), brush, width);
             obj += SVGUtil.Polygon(PPathwayEdge.GetArrowPoints(varPoint, proPoint), brush, width);
             break;
         case EdgeDirection.Inward:
             obj += SVGUtil.Polygon(PPathwayEdge.GetArrowPoints(proPoint, varPoint), brush, width);
             break;
         case EdgeDirection.Outward:
             obj += SVGUtil.Polygon(PPathwayEdge.GetArrowPoints(varPoint, proPoint), brush, width);
             break;
         case EdgeDirection.None:
             break;
     }
     return obj;
 }