Пример #1
0
        /// <summary>
        /// Respond to a canvas item component being selected. ComponentID is the ID
        /// of the actual component under the mouse cursor.
        /// </summary>
        /// <param name="item">The item that raised this select</param>
        /// <param name="component">The component selected</param>
        internal void HandleSelect(CanvasItem item, CanvasElementBase component)
        {
            if (component == null || component.ID == ActionID.None)
            {
                if (AllowSelection)
                {
                    Focus();

                    int selectedItem = Controls.IndexOf(item);
                    if (selectedItem != _selectedItemIndex)
                    {
                        SelectItem(selectedItem, true);
                    }
                }
            }
            if (CanvasItemAction != null)
            {
                CanvasItemAction(this, new CanvasItemArgs
                {
                    Item    = (component != null) ? component.ID : ActionID.None,
                    Tag     = (component != null) ? component.Tag : null,
                    Control = item
                });
            }
        }
Пример #2
0
        /// <summary>
        /// Handle mouse hover over an item to display a tooltip.
        /// </summary>
        protected override void OnMouseHover(EventArgs e)
        {
            base.OnMouseHover(e);
            CanvasElementBase item = CanvasItemLayout.ItemFromPosition(_lastMousePosition);

            if (item != null && item.HasToolTip)
            {
                _tooltip.Show(item.ToolTipString, this, _lastMousePosition.X + 16, _lastMousePosition.Y, 2500);
            }
        }
Пример #3
0
        /// <summary>
        /// Handle mouse movement to set the cursor.
        /// </summary>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                if (_dragBoxFromMouseDown != Rectangle.Empty && !_dragBoxFromMouseDown.Contains(e.X, e.Y))
                {
                    // OK - it is definitely a drag so handle it as such.
                    DoDragDrop(this, DragDropEffects.All | DragDropEffects.Link);
                    return;
                }
            }

            base.OnMouseMove(e);
            CanvasElementBase item = CanvasItemLayout.ItemFromPosition(e.Location);

            Cursor             = (item != null && item.ID != ActionID.None) ? Cursors.Hand : Cursors.Default;
            _lastMousePosition = e.Location;
        }
Пример #4
0
 /// <summary>
 /// Raises an event on a component in the canvas item. The event is passed up to the
 /// parent canvas to notify the owner.
 /// </summary>
 /// <param name="item">The item that raised the event</param>
 public void RaiseEvent(CanvasElementBase item)
 {
     _view.HandleSelect(this, item);
 }
Пример #5
0
        /// <summary>
        /// Respond to a canvas item component being selected. ComponentID is the ID
        /// of the actual component under the mouse cursor.
        /// </summary>
        /// <param name="item">The item that raised this select</param>
        /// <param name="component">The component selected</param>
        internal void HandleSelect(CanvasItem item, CanvasElementBase component)
        {
            if (component == null || component.ID == ActionID.None)
            {
                if (AllowSelection)
                {
                    Focus();

                    int selectedItem = Controls.IndexOf(item);
                    if (selectedItem != _selectedItemIndex)
                    {
                        SelectItem(selectedItem, true);
                    }
                }
            }
            if (CanvasItemAction != null)
            {
                CanvasItemAction(this, new CanvasItemArgs
                {
                    Item = (component != null) ? component.ID : ActionID.None,
                    Tag = (component != null) ? component.Tag : null,
                    Control = item
                });
            }
        }
Пример #6
0
 /// <summary>
 /// Add a new component and advance forward on the current line.
 /// </summary>
 public void Add(CanvasElementBase newElement)
 {
     _components.Add(newElement);
     newElement.Add(this, _clientBounds, Position);
     Forward(newElement.Width, newElement.Height);
 }
Пример #7
0
 /// <summary>
 /// Raises an event on a component in the canvas item. The event is passed up to the
 /// parent canvas to notify the owner.
 /// </summary>
 /// <param name="item">The item that raised the event</param>
 public void RaiseEvent(CanvasElementBase item)
 {
     _view.HandleSelect(this, item);
 }
Пример #8
0
 /// <summary>
 /// Add a new component and advance forward on the current line.
 /// </summary>
 public void Add(CanvasElementBase newElement)
 {
     _components.Add(newElement);
     newElement.Add(this, _clientBounds, Position);
     Forward(newElement.Width, newElement.Height);
 }