public override void UserInteractionDuringCreation( ) { int lastItemIndex = _properties.WorldPoints.Count - 1; Vector2 mouseWorldPos = MouseStatus.WorldPosition; //_properties.WorldPoints[ lastItemIndex ] = mouseWorldPos ; //_properties.LocalPoints[ lastItemIndex ] = _properties.WorldPoints[0] - mouseWorldPos ; //} if (MouseStatus.IsNewLeftMouseButtonClick( )) { addWorldPoint(mouseWorldPos); WhenUpdatedByUi( ); } if (MouseStatus.IsNewMiddleMouseButtonClick( )) { _editorMode = ItemEditorMode.Created; PreviewEndedReadyForCreation(this, EventArgs.Empty); } if (KeyboardStatus.IsNewKeyPress(Keys.Back)) { if (_properties.WorldPoints.Count > 1) { int lastItem = lastItemIndex; _properties.WorldPoints.RemoveAt(lastItem); _properties.LocalPoints.RemoveAt(lastItem); WhenUpdatedByUi( ); } } }
public void Update( ) { //get item under mouse cursor var model = ObjectFactory.GetInstance <IModel>( ); ItemEditor item = _canvas.ItemUnderMouse; bool controlButtonPressed = KeyboardStatus.IsKeyDown(Keys.LeftControl); if (item != null) { _mainForm.SetToolStripStatusLabel1(item.ItemProperties.Name); item.OnMouseOver(MouseStatus.WorldPosition); if (controlButtonPressed) { _mainForm.SetCursorForCanvas(_cursorDuplicate); } } else { _mainForm.SetToolStripStatusLabel1(string.Empty); } if (item != _lastItem && _lastItem != null) { _lastItem.OnMouseOut( ); } _lastItem = item; IEnumerable <ITreeItem> editors = selectedEditors( ).ToList( ); if (MouseStatus.IsNewLeftMouseButtonClick() || KeyboardStatus.IsNewKeyPress(Keys.D1)) { if (item != null) { item.OnMouseButtonDown(MouseStatus.WorldPosition); } if (controlButtonPressed && item != null) { _canvas.StartCopyingSelectedItems( ); } else if (KeyboardStatus.IsKeyDown(Keys.LeftShift) && item != null) { model.ToggleSelectionOnItem(item); } else if (editors.Contains(item)) { _canvas.StartMovingSelectedItems( ); } else if (!selectedEditors().Contains(item)) { if (item != null) { _model.SelectEditor(item); _canvas.StartMovingSelectedItems( ); } else { _canvas.CreateSelectionRectangle( ); } } } //MIDDLE MOUSE BUTTON CLICK bool anyEditorsSelected = editors.Any(); if (MouseStatus.IsNewMiddleMouseButtonClick( ) || KeyboardStatus.IsNewKeyPress(Keys.D2)) { if (item != null) { item.OnMouseOut( ); } if (controlButtonPressed) { _canvas.StartMovingCamera( ); } else { if (anyEditorsSelected) { _canvas.StartRotatingItems( ); } } } //RIGHT MOUSE BUTTON CLICK if (MouseStatus.IsNewRightMouseButtonClick( ) || KeyboardStatus.IsNewKeyPress(Keys.D3)) { if (item != null) { item.OnMouseOut( ); } if (anyEditorsSelected) { _canvas.StartScalingSelectedItems( ); } } selectedEditors( ).ForEach(e => e.HandleKeyPressWhenFocused()); }