예제 #1
0
        private void MenuDeleteInFlow(object sender, EventArgs e)
        {
            if (_menuItem == null)
            {
                return;
            }
            Flow fl = _menuItem as Flow;

            if (fl != null)
            {
                if (fl._source != null)
                {
                    fl.SetSourcePoint(Middle(fl._source.GetBounds()), false);
                }
            }
            else if (_menuItem is Stock)
            {
                if (((Stock)_menuItem).InFlow != null)
                {
                    ((Stock)_menuItem).InFlow.SetDestPoint(Middle(((Stock)_menuItem).GetBounds()), false);
                }
            }
            pbDashboard.Refresh();
        }
예제 #2
0
        private void pbDashboard_MouseMove(object sender, MouseEventArgs e)
        {
            _mousePoint = new Point(e.X, e.Y);
            if (btnRefference.CheckState == CheckState.Checked)
            {
                //  _DestinationRefferencePt = new Point(e.X, e.Y);
                pbDashboard.Refresh();
            }

            if (this._selectedIndex != -1)
            {
                int dX, dY;
                dX      = e.X - this._X;
                dY      = e.Y - this._Y;
                this._X = e.X;
                this._Y = e.Y;
                if (this._items[this._selectedIndex] is IResizable && this._selectedItem != 0)
                {
                    if (!((IResizable)this._items[this._selectedIndex]).Resize(dX, dY, this._selectedItem))
                    {
                        Cursor.Position = _mousePoint;
                    }
                }
                if (this._items[this._selectedIndex] is Flow)
                {
                    Flow fl = (Flow)this._items[this._selectedIndex];

                    IRenderable itm = getitemex(e.X, e.Y, this._items[this._selectedIndex]);

                    switch (this._selectedItem)
                    {
                    case 2:
                        if (itm != null && itm is Stock && fl._source != itm && ((Stock)itm)._inFlow == null)
                        {
                            if (fl._source == null)
                            {
                                fl.SetDestStock((Stock)itm, false);
                            }
                            else
                            {
                                fl.SetDestPoint(_mousePoint, false);
                            }
                        }
                        else
                        {
                            if (itm == null || fl._destination != itm)
                            {
                                fl.SetDestPoint(_mousePoint, false);
                            }
                        }
                        pbDashboard.Refresh();

                        return;

                    case 0:
                        if (itm != null && itm is Stock && fl._destination != itm && ((Stock)itm)._outFlow == null)
                        {
                            if (fl._destination == null)
                            {
                                fl.SetSourceStock((Stock)itm, false);
                            }
                            else
                            {
                                fl.SetSourcePoint(_mousePoint, false);
                            }
                        }
                        else
                        {
                            if (itm == null || fl._source != itm)
                            {
                                fl.SetSourcePoint(_mousePoint, false);
                            }
                        }
                        pbDashboard.Refresh();

                        return;
                    }
                }
                ((ITransformable)this._items[this._selectedIndex]).Translate(dX, dY, this._selectedItem);
                this.pbDashboard.Refresh();
            }
            else if (this.start != null)
            {
                this.pbDashboard.Refresh();
                Graphics  g      = this.pbDashboard.CreateGraphics();
                Rectangle sRect  = ((ITransformable)start).GetBounds();
                Point     sPoint = new Point(sRect.X + sRect.Width / 2, sRect.Y + sRect.Height / 2);
                g.DrawLine(new Pen(Color.Red), sPoint, new Point(e.X, e.Y));
            }
            else if (this._startPoint != null)
            {
                ITransformable item = (ITransformable)getItem(_mousePoint);
                if (item != null && item is Stock && this._flow._source != item && ((Stock)item)._inFlow == null)
                {
                    this._flow.SetDestStock((Stock)item, true);
                    ((Stock)item)._inFlow = this._flow;
                    this.pbDashboard.Refresh();
                }
                else
                {
                    if (item == null)
                    {
                        this._flow.SetDestPoint(_mousePoint, true);
                        if (this._flow._destination != null)
                        {
                            this._flow._destination._outFlow = null;
                            this._flow._destination          = null;
                        }
                    }
                    else
                    {
                        if (item != this._flow._destination)
                        {
                            this._flow.SetDestPoint(_mousePoint, true);
                        }
                    }
                    this.pbDashboard.Refresh();
                }
            }
            if (this._cursorItem == -1 && btnSelect.CheckState == CheckState.Checked)
            {
                while (true)
                {
                    ITransformable item = getItem(new Point(e.X, e.Y));
                    if (item == null || !(item is IResizable))
                    {
                        break;
                    }

                    int cnt = item.Contains(e.X, e.Y);
                    if (cnt < 1)
                    {
                        break;
                    }
                    this.pbDashboard.Cursor = ((IResizable)item).GetCursor(cnt);
                    return;
                }
                this.pbDashboard.Cursor = Cursors.Default;
                IRenderable it = getItem(new Point(e.X, e.Y)) as IRenderable;
                if (it != null)
                {
                    if (sbLabel1.Tag == it)
                    {
                        return;
                    }
                    sbLabel1.Text = it.GetHint();
                    sbLabel1.Tag  = it;
                }
                else
                {
                    if (sbLabel1.Tag != null)
                    {
                        sbLabel1.Tag  = null;
                        sbLabel1.Text = "";
                    }
                }
            }
            else
            {
                this.pbDashboard.Cursor = Cursors.Default;
            }
        }