Esempio n. 1
0
        private void panel2_MouseUp(object sender, MouseEventArgs e)
        {
            int     H          = 0;
            int     W          = 0;
            GObject GContainer = new GObject();
            GObject GToDrag    = new GObject();

            GToDrag = GNetwork.GObjects[CurrObjDragIndx];
            double   d1     = 0;
            double   d2     = 0;
            TimeSpan DTDrag = new TimeSpan();

            DTDrag = DateTime.Now.Subtract(Tdown);
            if ((Dragging == true) && (DTDrag.Milliseconds > DragTimeMin))
            {
                //如果拖动的是线,并且有容器
                if ((GNetwork.GObjects[CurrObjDragIndx].Type == "Line") &&
                    (GNetwork.FindContainerObject(e.X, e.Y, ref GContainer, true) > -1))
                {
                    //
                    //    What is the point of the line to link ?
                    //    The nearest to (Xdown,Ydown)
                    //
                    d1 = CommFnc.distance(Xdown, Ydown, GToDrag.x1, GToDrag.y1);
                    d2 = CommFnc.distance(Xdown, Ydown, GToDrag.x2, GToDrag.y2);
                    if (d1 <= d2)
                    {
                        GToDrag.x1   = (GContainer.x1 + GContainer.x2) / 2;
                        GToDrag.y1   = (GContainer.y1 + GContainer.y2) / 2;
                        GToDrag.Lnk1 = GContainer.Name;
                    }
                    else
                    {
                        GToDrag.x2   = (GContainer.x1 + GContainer.x2) / 2;
                        GToDrag.y2   = (GContainer.y1 + GContainer.y2) / 2;
                        GToDrag.Lnk2 = GContainer.Name;
                    }
                }
                else
                {
                    W          = GToDrag.x2 - GToDrag.x1;
                    H          = GToDrag.y2 - GToDrag.y1;
                    GToDrag.x1 = e.X;
                    GToDrag.y1 = e.Y;
                    GToDrag.x2 = e.X + W;
                    GToDrag.y2 = e.Y + H;
                    GNetwork.AdjustLinkedTo(GToDrag.Name);
                }
                Cursor.Current = Cursors.Default;
                Dragging       = false;



                //this.panel2.Refresh();

                ReDrawAll();

                //this.Refresh();
            }
        }
Esempio n. 2
0
        private void panel2_MouseDown(object sender, MouseEventArgs e)
        {
            Xdown = e.X;
            Ydown = e.Y;
            Tdown = DateTime.Now;
            GObject GContainer = new GObject();
            int     Container  = GNetwork.FindContainerObject(Xdown, Ydown, ref GContainer, false);

            //如果有容器,就允许拖动!!
            if (Container > -1)
            {
                Dragging        = true;
                Cursor.Current  = Cursors.Hand;
                CurrObjDragIndx = Container;
            }
            else
            {
                // Click out of all objects
            }
        }
Esempio n. 3
0
        private void panel2_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Xdown = e.X;
            Ydown = e.Y;
            //Tdown = DateTime.Now;
            GObject GContainer = new GObject();
            int     Container  = GNetwork.FindContainerObject(Xdown, Ydown, ref GContainer, false);

            //如果有容器,就允许拖动!!
            if (Container > -1)
            {
                //Dragging = true;
                //Cursor.Current = Cursors.Hand;
                //CurrObjDragIndx = Container;

                this.toolTip1.SetToolTip(this.panel2, GContainer.AddInfo);
                //this.toolTip1.ShowAlways = true;
                //this.toolTip1.Show(this);
            }
            else
            {
                // Click out of all objects
            }
        }