Exemplo n.º 1
0
 private void OnLeftClick(object sender, MouseEventArgs e)
 {
     if (!string.IsNullOrEmpty(_flowChartCtlBasic.RefStateMachine.LockText))
     {
         return;
     }
     if (!EditMode)
     {
         EditMode = true;
     }
     else
     {
         SMContainerPanel panel = sender as SMContainerPanel;
         CurrentSel = null;
         if (_emptyFlowSpot && panel != null && !PreventEdit)
         {
             if (Control.ModifierKeys != Keys.Control)
             {
                 new NewItemForm(this, PixelToGridSnap(panel.PointToClient(MousePosition))).ShowDialog();
             }
             else
             {
                 if (!_draging)
                 {
                     ShowContextMenu(null, PixelToGridSnap(panel.PointToClient(MousePosition)));
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            _isCropping = false;
//            System.Diagnostics.Debug.WriteLine(string.Format("FlowChart MouseMove"));
            if (onMouseMove != null)
            {
                //              System.Diagnostics.Debug.WriteLine(string.Format("Fire FlowChart MouseMove event"));
                onMouseMove(this, e);
                return;
            }

            SMContainerPanel panel = sender as SMContainerPanel;

            if (panel == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (Control.ModifierKeys != Keys.Control)
                {
                    if (_emptyFlowSpot)
                    {
                        // turn off New Flow Item readiness
                        panel.Cursor   = Cursors.Hand;
                        _emptyFlowSpot = false;
                    }
                    if (!_lastMousePos.IsEmpty)
                    {
                        // Dragging
                        Point newPos     = _flowChartCtlBasic.PointToClient(MousePosition);
                        Point deltaMoved = newPos;

                        deltaMoved.Offset(-_lastMousePos.X, -_lastMousePos.Y);
                        panel.Top    += deltaMoved.Y;
                        panel.Left   += deltaMoved.X;
                        _lastMousePos = newPos;

                        ////Cropping
                        //this.Refresh();
                        //_cropWidth = Math.Abs(e.X - _cropX);
                        //_cropHeight = Math.Abs(e.Y - _cropY);

                        //_oCropX = Math.Min(_cropX, e.X);
                        //_oCropY = Math.Min(_cropY, e.Y);

                        //this.CreateGraphics().DrawRectangle(_cropPen, _oCropX, _oCropY, _cropWidth, _cropHeight);
                        //_isCropping = true;
                    }
                }
                else
                {
                    if (_selectedCtrlList != null)
                    {
                        _draging = true;
                        if (_selectedCtrlList != null && _selectedCtrlList.Count > 0)
                        {
                            foreach (SMCtlBase smCtrl in _selectedCtrlList)
                            {
                                try
                                {
                                    smCtrl.OnMouseMove(null, e);
                                }
                                catch { }
                                finally { }
                            }
                        }
                    }
                    else
                    {
                        //Cropping
                        //this.Refresh();
                        if (_g != null)
                        {
                            _g.Clear(Color.FromArgb(255, 236, 233, 216));
                            _g.Dispose();
                            _g = null;
                        }

                        _g = this.CreateGraphics();
                        _g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                        _g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;


                        _cropWidth  = Math.Abs(e.X - _cropX);
                        _cropHeight = Math.Abs(e.Y - _cropY);

                        _oCropX = Math.Min(_cropX, e.X);
                        _oCropY = Math.Min(_cropY, e.Y);

                        _g.DrawRectangle(_cropPen, _oCropX, _oCropY, _cropWidth, _cropHeight);
                        _isCropping = true;
                    }
                }
            }
            else if (EditMode)
            {
                if (e.Button == MouseButtons.Right)
                {
                    if (!_lastMousePos.IsEmpty)
                    {
                        // Dragging
                        Point newPos     = _flowChartCtlBasic.PointToClient(MousePosition);
                        Point deltaMoved = newPos;

                        deltaMoved.Offset(-_lastMousePos.X, -_lastMousePos.Y);

                        if (Math.Abs(deltaMoved.X) > GridToPixelX(1.0f))
                        {
                            // Change in X
                            if (deltaMoved.X > 0)
                            {
                                _flowContainer.MoveAll(new PointF(1f, 0f));
                            }
                            else
                            {
                                _flowContainer.MoveAll(new PointF(-1f, 0f));
                            }
                            _lastMousePos = newPos;
                            Redraw();
                        }
                        else if (Math.Abs(deltaMoved.Y) > GridToPixelY(1.0f))
                        {
                            // Chang in Y
                            if (deltaMoved.Y > 0)
                            {
                                _flowContainer.MoveAll(new PointF(0f, 1f));
                            }
                            else
                            {
                                _flowContainer.MoveAll(new PointF(0f, -1f));
                            }
                            _lastMousePos = newPos;
                            Redraw();
                        }
                    }
                }

                else
                {
                    // If over an empty space, show
                    PointF gridPos = PixelToGrid(panel.PointToClient(MousePosition));
                    double x       = gridPos.X - (int)gridPos.X;
                    double y       = gridPos.Y - (int)gridPos.Y;

                    if (x < 0.7 && x > 0.3 && y < 0.6 && y > 0.4)
                    {
                        _emptyFlowSpot = true;
                        panel.Cursor   = _flowItemCursor;
                    }
                    else
                    {
                        _emptyFlowSpot = false;
                        panel.Cursor   = Cursors.Default;
                    }
                }
            }
        }