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(); }
private void _storeAndSetCurrentLayoutActionAndCursor(Cursor newCursor, layoutActions newAction) { layoutStateHistory.layoutCursor = Cursor; layoutStateHistory.layoutActionState = this.currentLayoutAction.ToString(); this.currentLayoutAction = newAction; Cursor = newCursor; }
void _layoutArea_MouseUp(object sender, MouseEventArgs e) { if (_selectedItem != null) { List<placeableItem> selectedItems = _getSelectedItems(); foreach (placeableItem selectedItem in selectedItems) { if (selectedItem.itemType == placeableItem.itemTypes.image) { selectedItem.mouseUp(); //((baseImage)selectedItem).mouseUp(_autoFitImages); } else { selectedItem.mouseUp(); } } } currentLayoutAction = layoutActions.none; //_groupingBoxResize = false; _layoutArea.Refresh(); }
private void _setCurrentLayoutActionAndCursor() { this.currentLayoutAction = (layoutActions)Enum.Parse(typeof(layoutActions), layoutStateHistory.layoutActionState); Cursor = layoutStateHistory.layoutCursor; }