Exemple #1
0
 /// <summary>
 /// SetLineHandler
 /// </summary>
 /// <param name="node"></param>
 internal void SetCreateLineHandler(PPathwayEntity node)
 {
     Handle handle = toolButtonArrow.Handle;
     SetEventHandler(handle);
     CreateReactionMouseHandler handler = (CreateReactionMouseHandler)handle.EventHandler;
     handler.StartNode = node;
 }
        /// <summary>
        /// Called when the mouse is down on the canvas.
        /// </summary>
        /// <param name="sender">UserControl.</param>
        /// <param name="e">PInputEventArgs</param>
        public override void OnMouseDown(object sender, PInputEventArgs e)
        {
            base.OnMouseDown(sender, e);

            CanvasControl canvas = m_con.Canvas;
            PPathwayEntity newNode = canvas.GetPickedEntity(e.Position);
            // Set start node.
            if (newNode == null)
            {
                ResetStartNode();
                m_con.Menu.ResetEventHandler();
                return;
            }
            else if(m_start == null)
            {
                SetStartNode(newNode);
                return;
            }
            if ((m_start is PPathwayVariable && newNode is PPathwayVariable)
                || (m_start is PPathwayProcess && newNode is PPathwayProcess)
                || m_start is PPathwayVariable && newNode is PPathwayAlias
                || m_start is PPathwayAlias && newNode is PPathwayAlias
                || m_start is PPathwayAlias && newNode is PPathwayVariable)
            {
                SetStartNode(newNode);
                return;
            }

            // Create edge.
            // hide EdgeHandle
            canvas.LineHandler.SetLineVisibility(false);

            // Set object.
            int coef = 0;
            PPathwayProcess process;
            PPathwayVariable variable;
            //
            if (m_start is PPathwayAlias)
            {
                m_start = ((PPathwayAlias)m_start).Variable;
            }
            if (newNode is PPathwayAlias)
            {
                newNode = ((PPathwayAlias)newNode).Variable;
            }
            //
            if (newNode is PPathwayProcess)
            {
                process = (PPathwayProcess)newNode;
                variable = (PPathwayVariable)m_start;
                coef = -1;
            }
            else
            {
                process = (PPathwayProcess)m_start;
                variable = (PPathwayVariable)newNode;
                coef = 1;
            }

            // Create Edge.
            Mode mode = m_con.Menu.Handle.Mode;
            if (mode == Mode.CreateConstant)
            {
                this.CreateEdge(process, variable, RefChangeType.SingleDir, 0);
            }
            else if (mode == Mode.CreateOneWayReaction)
            {
                this.CreateEdge(process, variable, RefChangeType.SingleDir, coef);
            }
            else if (mode == Mode.CreateMutualReaction)
            {
                this.CreateEdge(process, variable, RefChangeType.BiDir, 0);
            }
            ResetStartNode();
        }
 /// <summary>
 /// Reset node to be connected to normal state.
 /// </summary>
 public void ResetStartNode()
 {
     if (m_start != null)
         m_start.RefreshView();
     m_start = null;
 }
 /// <summary>
 /// Add node, which is to be connected
 /// </summary>
 /// <param name="obj">node which is to be connected</param>
 public void SetStartNode(PPathwayEntity obj)
 {
     m_start = obj;
 }
Exemple #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private static string CreateSVGProperties(PPathwayEntity entity)
        {
            string svgObj = "";
            float margin = 2f;
            PPathwayProperties properties = entity.Property;
            if (!properties.Visible)
                return svgObj;

            foreach (PPathwayProperty property in entity.Property.Properties)
            {
                if (!property.Visible)
                    continue;
                string pen = BrushManager.ParseBrushToString(Brushes.Black);
                string fill = BrushManager.ParseBrushToString(property.Brush);
                svgObj += SVGUtil.Rectangle(property.Rect, pen, fill);
                svgObj += SVGUtil.Line(new PointF(property.value.X, property.value.Y), new PointF(property.value.X, property.value.Y + property.Height), pen, "1");
                svgObj += SVGUtil.Text(new PointF(property.label.X + margin, property.label.Y + SVGUtil.SVG_FONT_SIZE + margin), property.Label, pen, "", SVGUtil.SVG_FONT_SIZE);
                svgObj += SVGUtil.Text(new PointF(property.value.X + margin, property.value.Y + SVGUtil.SVG_FONT_SIZE + margin), property.Value, pen, "", SVGUtil.SVG_FONT_SIZE);
            }
            return svgObj;
        }