Exemplo n.º 1
0
        /// <summary>
        /// Removes an item from the selection.
        /// </summary>
        /// <param name="item">Item to be removed from the selection.</param>
        /// <param name="bNotify">True to notify of this selection change. False otherwise.</param>
        public void RemoveFromSelection(ISelectable item, bool bNotify)
        {
            if (CurrentSelection.Contains(item))
            {
                CurrentSelection.Remove(item);
            }
            item.IsSelected = false;

            if (bNotify)
            {
                Notify();
            }
        }
Exemplo n.º 2
0
 private void Control_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button.HasFlag(MouseButtons.Left))
     {
         InitializeSelectionMode();
     }
     else if (e.Button == MouseButtons.Right &&
              CurrentSelection != null &&
              !CurrentSelection.Contains(ActiveGridTile))
     {
         CurrentSelection = null;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds an item to selection.
        /// </summary>
        /// <param name="item">Item to add to selection.</param>
        /// <param name="bNotify">True to notify of this selection change. False otherwise.</param>
        public void AddToSelection(ISelectable item, bool bNotify)
        {
            if (item is ISelectable)
            {
                if (!CurrentSelection.Contains(item))
                {
                    CurrentSelection.Add(item);
                }
                item.IsSelected = true;
            }

            if (bNotify)
            {
                Notify();
            }
        }
Exemplo n.º 4
0
        private void MouseServiceOnMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                MouseRightDownMoveTranslationPositionLast = e.Location;
            }

            if (e.Button == MouseButtons.Left)
            {
                StartSelectionRectangle       = false;
                MouseLeftDownMovePositionLast = RenderingEngine.TranslatedMousePosition;
                MouseLeftDownPositionLast     = RenderingEngine.TranslatedMousePosition;

                if (!StartDrag)
                {
                    Input  = null;
                    Output = null;

                    var mouseOverItems       = RenderingEngine.CurrentProject.Items.Where(x => x.IsMouseOver).ToList();
                    var mouseOverConnections = RenderingEngine.CurrentProject.Connections.Where(x => x.IsMouseOver).ToList();

                    if (mouseOverItems.Count == 0 && mouseOverConnections.Count == 0)
                    {
                        DeselectAll();
                    }

                    if (mouseOverItems.Count > 0)
                    {
                        foreach (var selectedItem in mouseOverItems)
                        {
                            if (!CurrentSelection.Contains(selectedItem))
                            {
                                DeselectAll();
                                CurrentSelection.Add(selectedItem);
                            }
                            selectedItem.IsSelected = true;

                            List <InputOutputBase> inputOutputs = new List <InputOutputBase>();

                            inputOutputs.AddRange(selectedItem.Inputs);
                            inputOutputs.AddRange(selectedItem.Outputs);

                            var mouseOverInputOutput = inputOutputs.FirstOrDefault(x => x.IsMouseOver);

                            if (mouseOverInputOutput != null)
                            {
                                if (mouseOverInputOutput is InputBase)
                                {
                                    Input = new InputOutputSelector(selectedItem, mouseOverInputOutput);
                                }
                                if (mouseOverInputOutput is OutputBase)
                                {
                                    Output = new InputOutputSelector(selectedItem, mouseOverInputOutput);
                                }
                            }
                        }
                    }

                    if (mouseOverConnections.Count > 0)
                    {
                        foreach (var selectedItem in mouseOverConnections)
                        {
                            if (!CurrentSelectionConnection.Contains(selectedItem))
                            {
                                DeselectAll();
                                CurrentSelectionConnection.Add(selectedItem);
                            }
                            selectedItem.IsSelected = true;
                        }
                    }
                }

                if (!SelectedItemsAvailable)
                {
                    StartSelectionRectangle = true;
                    SelectionRectangleStart = e.Location;
                }
                StartDrag = true;
            }

            if (e.Button == MouseButtons.Middle)
            {
                MouseMiddleDownMovePositionLast = e.Location;
            }
        }