示例#1
0
        private void GVGraphView_MouseDown(object sender, MouseEventArgs e)
        {
            StopTextEdit();

            p_context.mouseDownPoint.X = e.X;
            p_context.mouseDownPoint.Y = e.Y;
            p_context.mouseMovePoint   = p_context.mouseDownPoint;

            p_context.logDownPoint = p_context.ConvertClientToLogical(e.X, e.Y);
            p_context.logMovePoint = p_context.logDownPoint;

            p_context.mouseState = GVGraphViewMouseState.Down;

            // find if some object is clicked
            p_context.MovedObject   = null;
            p_context.ActiveTracker = FindActiveTracker(p_context.mouseDownPoint);
            if (p_context.ActiveTracker != null)
            {
                p_context.ActiveTracker.OnTouchBegin(p_context);
            }
            else
            {
                p_context.downObject = Graph.Objects.FindObjectContainingClientPoint(p_context.mouseDownPoint);
                if (p_context.downObject != null)
                {
                    GVGraphObject go = p_context.downObject;
                    p_context.downObjectHotPointOffset.X = e.X - go.X;
                    p_context.downObjectHotPointOffset.Y = e.Y - go.Y;
                }
            }

            Invalidate();
        }
示例#2
0
 private void GVGraphView_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (Graph != null && GraphDelegate != null)
     {
         GVGraphObject go = Graph.Objects.FindObjectContainingClientPoint(new PointF(e.X, e.Y));
         GraphDelegate.OnObjectDoubleClick(p_context, go);
     }
 }
示例#3
0
        public GVGraphObject Add(GVGraphObject entity)
        {
            entity.Id = GetNextId();
            entity.X  = 0;
            entity.Y  = GetMaxY() + 120;
            Objects.Add(entity);

            return(entity);
        }
示例#4
0
 public virtual void setReference(int tag, object obj)
 {
     switch (tag)
     {
     case 14:
         ParentObject = (GVGraphObject)obj;
         break;
     }
 }
示例#5
0
        public List <GVGraphConnection> FindTargeted(GVGraphObject oid)
        {
            List <GVGraphConnection> list = new List <GVGraphConnection>();

            foreach (GVGraphConnection gv in this)
            {
                if (gv.Target == oid)
                {
                    list.Add(gv);
                }
            }
            return(list);
        }
示例#6
0
        public GVGraphObject FindObjectContainingClientPoint(float cX, float cY)
        {
            GVGraphObject start = null;
            GVGraphObject end   = this;

            do
            {
                start = end;
                end   = start.Objects.FindObjectContainingClientPoint(cX, cY);
            }while (end != null);

            return(start);
        }
示例#7
0
        public void ResetPoints()
        {
            mouseDownPoint = PointF.Empty;
            mouseMovePoint = PointF.Empty;
            mouseUpPoint   = PointF.Empty;

            logDownPoint = PointF.Empty;
            logMovePoint = PointF.Empty;
            logUpPoint   = PointF.Empty;

            mouseState = GVGraphViewMouseState.None;

            downObject = null;
            downObjectHotPointOffset = PointF.Empty;
            TrackedObject            = null;

            upObject      = null;
            ActiveTracker = null;
        }
示例#8
0
        private void GVGraphView_MouseMove(object sender, MouseEventArgs e)
        {
            if (p_context.mouseState != GVGraphViewMouseState.None)
            {
                p_context.mouseMovePoint.X = e.X;
                p_context.mouseMovePoint.Y = e.Y;

                p_context.logMovePoint = p_context.ConvertClientToLogical(e.X, e.Y);

                p_context.TrackedObject = p_graph.Objects.FindObjectContainingClientPoint(p_context.mouseMovePoint);

                // test if we should transfer to MOVING status
                if (p_context.mouseState == GVGraphViewMouseState.Down)
                {
                    float diff = Math.Abs(e.X - p_context.mouseDownPoint.X) + Math.Abs(e.Y + p_context.mouseDownPoint.Y);
                    if (diff >= 6)
                    {
                        p_context.mouseState = GVGraphViewMouseState.Moved;
                    }
                }

                if (p_context.mouseState == GVGraphViewMouseState.Moved)
                {
                    if (p_context.ActiveTracker != null)
                    {
                        p_context.ActiveTracker.OnTrack(p_context);
                    }
                    else if (p_context.MovedObject == null)
                    {
                        // move whole diagram
                        p_context.DiagramTempOffset.X = e.X - p_context.mouseDownPoint.X;
                        p_context.DiagramTempOffset.Y = e.Y - p_context.mouseDownPoint.Y;
                    }
                }


                Invalidate();
            }

            if (p_context.mouseState == GVGraphViewMouseState.None)
            {
                if (OnItemHover != null)
                {
                    p_context.mouseMovePoint.X = e.X;
                    p_context.mouseMovePoint.Y = e.Y;

                    GeneralEventArgs args = new GeneralEventArgs();
                    GVGraphObject    go   = Graph.Objects.FindObjectContainingClientPoint(p_context.mouseMovePoint);
                    if (go != null)
                    {
                        args.UserInfo["object"] = go;
                    }
                    else
                    {
                        GVTrackerBase tb = FindActiveTracker(p_context.mouseMovePoint);
                        if (tb != null)
                        {
                            args.UserInfo["tracker"] = tb;
                        }
                    }
                    OnItemHover(this, args);
                }
            }
        }