Пример #1
0
 public void AddConnector(Connector connector)
 {
     this.Connectors.Add(connector);
 }
Пример #2
0
        private void drawingCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            bool onDesignItem = false;

            // TODO:  Do something about z-order...

            foreach (DesignItem o in this.DesignItems)
            {
                // update the border to reflect selected state
                //if (o.Selected)
                this.Invalidate(o.Border, false);
                // update the cursor in the DrawingCanvas
                if (o.IsVisible(e.Location))
                {
                    this.Cursor  = o.Cursor;
                    onDesignItem = true;
                    break;
                }
                else
                {
                    this.Cursor = this.defaultCursor;
                }
            }

            if (!onDesignItem)
            {
                foreach (Connector c in this.Connectors)
                {
                    if (c.Selected)
                    {
                        this.Invalidate(c.Region, false);
                    }

                    if (c.IsVisible(e.Location))
                    {
                        bool onCorner = false;
                        foreach (Corner corner in c.Corners)
                        {
                            if (corner.IsVisible(e.Location))
                            {
                                this.Cursor = corner.Cursor;
                                onCorner    = true;
                                break;
                            }
                        }
                        if (!onCorner)
                        {
                            this.Cursor            = c.Cursor;
                            this.selectedConnector = c;
                            break;
                        }
                    }
                    else
                    {
                        this.Cursor            = this.defaultCursor;
                        this.selectedConnector = null;
                    }
                }
            }

            // Start the action!
            foreach (DesignItem o in this.DesignItems)
            {
                if (o.IsDragging)
                {
                    //o.Drag(this, e);
                    o.Drag(e);
                    break;
                }
                else if (o.IsResizing)
                {
                    //o.Resize(this, e);
                    o.Resize(e);
                    break;
                }
            }
            foreach (Connector c in this.Connectors)
            {
                if (c.IsDraggingCorner)
                {
                    c.DraggingCorner(this, e);
                    break;
                }
                if (c.IsDraggingLine)
                {
                    c.DraggingLine(this, e);
                    break;
                }
            }
            if (this.tempConnector != null)
            {
                this.tempConnector.Connecting(this, e);
            }

            this.Invalidate(true);
        }