コード例 #1
0
ファイル: placeableItem.cs プロジェクト: ctwoolsey/layoutApp
 public void selectItem(Point mousePoint, Boolean groupSelect)
 {
     
     if (groupSelect)
     {
         _windowSelected = true;
         _itemSelected = false;
         _groupSelect = true;
     
     }
     else
     {
         if (Control.ModifierKeys == Keys.Alt)
         {
             _itemSelected = true;
             _windowSelected = false;
             _groupSelect = false;
         }
         else
         {
             //window has already been selected so set it up to resize
             if (((_windowSelected == true) || (_itemSelected)) && (this._groupSelect == false))
             {
                 Cursor grabCursor;
                 using (var memoryStream = new MemoryStream(Properties.Resources.Grabbed15_19))
                 {
                     grabCursor = new Cursor(memoryStream);
                 }
                 
                 if (_windowSelected)
                 {
                     if (_windowBox.direction != resizeSelectBox.resizeDirection.none)
                     {
                         _resizeDirection = _windowBox.direction;
                         _resizing = true;
                     }
                     else
                     {
                         _parent.Cursor = grabCursor;
                     }
                 }
                 if (_itemSelected)
                 {
                     if (_itemBox.direction != resizeSelectBox.resizeDirection.none)
                     {
                         _resizeDirection = _itemBox.direction;
                         _resizing = true;
                     }
                     else
                     {
                         _parent.Cursor = grabCursor;
                     }
                 }
             }
             else
             {
                 if (this._windowSelected == false)
                 {
                     this._windowSelected = true;
                     this._itemSelected = false;
                     this._groupSelect = false;
                 }
             }
         }
     }
     _mouseClickOffsetToWindow = new Point(mousePoint.X - _windowLocation.X, mousePoint.Y - _windowLocation.Y);
     if (_itemSelected)
         _mouseClickOffsetToWindow = new Point(mousePoint.X - _itemLocation.X, mousePoint.Y - _itemLocation.Y);
 }
コード例 #2
0
        void _layoutArea_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDownPosition = e.Location;

            if ((_showGroupingBox) && (_GroupingBox.hover(e.Location)))
            {
                this.currentLayoutAction = layoutActions.groupResize;
                //_groupingBoxResize = true;
                _groupingBoxResizeDirection = _GroupingBox.direction;
            }

            placeableItem previousSelectedItem = null;

            if (!_showGroupingBox)
            {
                if (_selectedItem != null)
                    previousSelectedItem = _selectedItem;
            }
           

            List<placeableItem> containingItems = new List<placeableItem>();
          
            foreach (placeableItem placedItem in _pageMatFrame.placedItems)
            {
                if (placedItem.contains(new Point(e.X, e.Y)))
                    containingItems.Add(placedItem);
            }
            if (containingItems.Count > 1)
            {
                containingItems.Sort(new zComparer());  //images can overlap, but the mouse click should only go to the top level image/graphic
            }
            if (containingItems.Count > 0)  //if this is not true than nothing was selected
            {
                _selectedItem = containingItems[0];
                if (Control.MouseButtons == System.Windows.Forms.MouseButtons.Right)
                {
                    //?????? should I put this here
                    _showGroupingBox = false;
                    /*if (_selectedItem.selected == false)
                    {
                        _unselectAll();
                        _selectedItem.selectItem(e, false);
                    }*/
                    if (_selectedItem.selected)
                        this.showContextMenu(_layoutArea.PointToScreen(e.Location));
                }
                else
                {
                   
                    if (Control.ModifierKeys == Keys.Control)
                    {
                        //selecting more than one image
                        /*
                     
                         * is selected image already selected? then un-select it
                         * else -> select the image and add it to a list of selected images
                 
                         * 
                         * need to check if a single items is group selected and if it is then change it so it is not if only one is left
                        */
                        if (_selectedItem.selected)
                        {
                            _showGroupingBox = false;
                            _selectedItem.unselectItem();
                            List<placeableItem> selectedItems = _getSelectedItems();
                            if (selectedItems.Count == 1)
                            {
                                _selectedItem = selectedItems[0];
                                _selectedItem.selectItem(e, false);
                            }
                        }
                        else
                        {
                            //if a previous item is selected then change the previous item to a group select
                            if ((previousSelectedItem != null) && (previousSelectedItem != _selectedItem))
                            {
                                if (previousSelectedItem.selected)
                                    previousSelectedItem.selectItem(e, true);
                                    
                            }
                            if (previousSelectedItem == null) // only one item is being control clicked
                            {
                                _showGroupingBox = false;
                                _selectedItem.selectItem(e, false); 
                            }
                            else
                            {
                                _selectedItem.selectItem(e, true);
                                _showGroupingBox = true;
                                _createGroupingBox();
                            }
                        }
                    } //end CNTL Modifier Key
                    else //not adding images via CNTL Modifier
                    {
                        if (_selectedItem.groupSelect == false)
                        {
                            _showGroupingBox = false;
                            if ((previousSelectedItem != null) && (previousSelectedItem != _selectedItem))
                            {
                                previousSelectedItem.unselectItem();
                            }
                            if (Control.ModifierKeys == Keys.Alt)
                            {

                            }
                            _selectedItem.selectItem(e, false);
                        }
                        else 
                        {
                            _showGroupingBox = true;
                            _updateGroupSelectedMousePosition(e);
                        }
                    }
                } //end not right click
            }
            else //the click was not on any image
            {
                if ((_GroupingBox != null) && (_groupingRectangle.Contains(e.Location)))
                {
                    _showGroupingBox = true;
                    _updateGroupSelectedMousePosition(e);
                }
                else
                {
                    _showGroupingBox = false;
                    _GroupingBox = null;
                    List<placeableItem> selectedItems = _getSelectedItems();
                    foreach (placeableItem selectedItem in selectedItems)
                    {
                        selectedItem.unselectItem();
                    }

                    _selectedItem = null;
                }
            }
            this.Refresh();
        }
コード例 #3
0
        public void selectItem(Point mousePoint, Boolean groupSelect)
        {
            _mouseClickOffset = new Point(mousePoint.X - this.location.X, mousePoint.Y - this.location.Y);

            if (groupSelect)
            {
                _selected = true;
                _groupSelect = true;
            
            }
            else
            {
                if (Control.ModifierKeys == Keys.Alt)
                {
                    _showContainedItem = true;
                    _selected = true;
                    _groupSelect = false;
                }
                else
                {
                    if ((this._selected == true) && (this._groupSelect == false))
                    {
                        _mouseClickOffset = new Point(mousePoint.X - this.location.X, mousePoint.Y - this.location.Y);
                        if (_resizeBox.direction != resizeSelectBox.resizeDirection.none)
                        {
                            _resizeDirection = _resizeBox.direction;
                            _resizing = true;
                        }
                    }
                    else
                    {
                        if (this._selected == false)
                        {
                            this._selected = true;
                            this._groupSelect = false;
                        }
                    }
                }
            }
        }
コード例 #4
0
 public void selectItem(MouseEventArgs e, Boolean groupSelect)
 {
     if (groupSelect)
     {
         _selected = true;
         _groupSelect = true;
        // this.showResizeBox = false;
        _mouseClickOffset = new Point(e.X - this.location.X, e.Y - this.location.Y);
     }
     else
     {
         if ((this._selected == true) && (this._groupSelect == false))//(this.showResizeBox == true))
         {
             _mouseClickOffset = new Point(e.X - this.location.X, e.Y - this.location.Y);
             if (_resizeBox.direction != resizeSelectBox.resizeDirection.none)
             {
                 _resizeDirection = _resizeBox.direction;
                 _resizing = true;
             }
         }
         else
         {
             if (this._selected == false)
             {
                 this._selected = true;
                 this._groupSelect = false;
             }
             
            // this.showResizeBox = true;
             _mouseClickOffset = new Point(e.X - this.location.X, e.Y - this.location.Y);
         }
     }
 }
コード例 #5
0
ファイル: baseLayoutArea.cs プロジェクト: ctwoolsey/layoutApp
        void _designArea_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDownPosition = e.Location;
            placeableItem clickedItem = _getClickedOnItem();
            Console.WriteLine("mouse down");
            if ((e.Button == System.Windows.Forms.MouseButtons.Right) && (Control.ModifierKeys == Keys.None))
            {
                if (((_showGroupingBox) && (_GroupingBox.hover(mouseDownPosition))) || ((clickedItem != null) && (clickedItem.selected)))
                    this.showContextMenu(_designArea.PointToScreen(e.Location));
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if ((Control.ModifierKeys == Keys.Control) && (clickedItem != null))
                {
                    if (clickedItem.selected)
                        _removeFromSelectedItems(clickedItem);
                    else
                        _addToSelectedItems(clickedItem);       
                }

                if (clickedItem != null)
                {
                    if (Control.ModifierKeys == Keys.Alt)
                    {
                        _unselectAll();
                        _addToSelectedItems(clickedItem);
                    }

                    if ((clickedItem.selected == false) && (Control.ModifierKeys == Keys.None))
                    {
                        _unselectAll();
                        _addToSelectedItems(clickedItem);
                    }
                    else
                    {
                        if (clickedItem.selected)
                        {
                            if ((Control.ModifierKeys == Keys.None) || (Control.ModifierKeys == Keys.Shift))
                            {
                                _storeAndSetCurrentLayoutActionAndCursor(clickedItem.resizeHoverCursor(mouseDownPosition), layoutActions.itemMoveResize);
                                clickedItem.selectItem(mouseDownPosition, false);
                            }
                        }
                    }
                }

                if ((clickedItem == null) && ((_showGroupingBox == false) || ((_showGroupingBox == true) && (!_GroupingBox.contains(mouseDownPosition)))))
                {
                    _unselectAll();
                    _createGroupingBox(true);
                }

                if ((_showGroupingBox) && (_GroupingBox.hover(mouseDownPosition)))
                {
                    _storeAndSetCurrentLayoutActionAndCursor(_GroupingBox.getCursor(), layoutActions.groupResize);
                    _groupingBoxResizeDirection = _GroupingBox.direction;
                }
                else
                {
                    if ((_showGroupingBox) && (_GroupingBox.contains(mouseDownPosition)))
                    {
                        _storeAndSetCurrentLayoutActionAndCursor(Cursors.Default, layoutActions.groupMove);
                        _createGroupingBox(true);
                    }
                }
            }

            _designArea.Refresh();

          
        }