public void ClearCurrentEditor( ) { if( _currentEditor != null ) { _currentEditor.PreviewEndedReadyForCreation -= ( s, e ) => _whenEntityReadyToBeAdded( ) ; } _currentEditor = null ; }
public void AddEditor(ItemEditor editor) { var possibleDuplicate = allEditors( ).FirstOrDefault(e => e.Name == editor.Name); if (possibleDuplicate != null) { throw new InvalidOperationException( @"Cannot add editor '{0}' into layer '{1}' as an editor of the same name exists in layer '{2}'.".FormatWith( editor.Name, editor.ParentLayer.Name, possibleDuplicate.ParentLayer.Name)); } if (allEditors().Any(e => e == editor)) { throw new InvalidOperationException( @"Cannot add editor '{0}' into layer '{1}' as the same editor has already been added.".FormatWith( editor.Name, editor.ParentLayer.Name)); } editor.ParentLayer.AddEditor(editor); ActiveLayer = editor.ParentLayer; }
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() ); }
public void AddEditorToSelection( ItemEditor editor ) { Level.SelectEditor( editor ) ; tryFire( ( ) => SelectionChanged, Level.SelectedEditors ) ; }
public void SelectEditor( ItemEditor editor ) { Level.ClearSelectedEditors( ) ; setActiveLayerIfItsDifferent( editor.ParentLayer ) ; Level.SelectEditor( editor ) ; tryFire( ( ) => SelectionChanged, editor ) ; }
public void ToggleSelectionOnItem( ItemEditor item ) { item.ToggleSelection( ) ; tryFire( ( ) => SelectionChanged, Level.SelectedEditors ) ; }
public void MoveItemToLayer( ItemEditor itemToMove, LayerEditor layer, ItemEditor itemToMoveNewItemUnder ) { int insertPosition = itemToMoveNewItemUnder == null ? 0 : layer.Items.IndexOf( itemToMoveNewItemUnder ) ; itemToMove.ParentLayer.Items.Remove( itemToMove ) ; layer.Items.Insert( insertPosition, itemToMove ) ; itemToMove.ParentLayer = layer ; }
public void NotifyChanged( ItemEditor item ) { tryFire( ( ) => ItemChanged, item ) ; }
public void MoveEditorDown( ItemEditor editor ) { _memento.Record(@"Move editor down'{0}'".FormatWith(editor.Name), () => { int index = editor.ParentLayer.Items.IndexOf( editor ) ; editor.ParentLayer.Items[ index ] = editor.ParentLayer.Items[ index + 1 ] ; editor.ParentLayer.Items[ index + 1 ] = editor ; }); SelectEditor( editor ) ; tryFire( ( ) => ItemsRearrangedInLayer, editor ) ; }
public void MoveEditorUp( ItemEditor i ) { _memento.Record(@"Move editor up '{0}'".FormatWith(i.Name), () => { int index = i.ParentLayer.Items.IndexOf( i ) ; i.ParentLayer.Items[ index ] = i.ParentLayer.Items[ index - 1 ] ; i.ParentLayer.Items[ index - 1 ] = i ; }); SelectEditor( i ) ; tryFire( ( ) => ItemsRearrangedInLayer, i ) ; }
public void AddEditor( ItemEditor editor ) { _memento.Record(@"Add Item '{0}'".FormatWith(editor.ItemProperties.Name), () => { Level.AddEditor( editor ) ; tryFire( ( ) => ItemsAddedOrRemoved, editor ) ; }); }
public void AddEditor( ItemEditor editor ) { var possibleDuplicate = allEditors( ).FirstOrDefault( e => e.Name == editor.Name ) ; if (possibleDuplicate!=null) { throw new InvalidOperationException( @"Cannot add editor '{0}' into layer '{1}' as an editor of the same name exists in layer '{2}'.".FormatWith( editor.Name, editor.ParentLayer.Name, possibleDuplicate.ParentLayer.Name ) ) ; } if (allEditors().Any(e => e == editor ) ) { throw new InvalidOperationException( @"Cannot add editor '{0}' into layer '{1}' as the same editor has already been added.".FormatWith( editor.Name, editor.ParentLayer.Name ) ) ; } editor.ParentLayer.AddEditor( editor ); ActiveLayer = editor.ParentLayer ; }
public void NotifyChanged(ItemEditor item) { tryFire(() => ItemChanged, item); }
public void ToggleSelectionOnItem(ItemEditor item) { item.ToggleSelection( ); tryFire(() => SelectionChanged, Level.SelectedEditors); }
public void AddEditorToSelection(ItemEditor editor) { Level.SelectEditor(editor); tryFire(() => SelectionChanged, Level.SelectedEditors); }
public void AddNewItemAtMouse( ItemEditor newEditor ) { int nextNumber = _model.Level.GetNextItemNumber(); newEditor.SetPosition( MouseStatus.WorldPosition ); newEditor.ItemProperties.Id = _model.Level.GenerateId(nextNumber); newEditor.ItemProperties.Name = @"{0}_{1}".FormatWith(newEditor.NameSeed, nextNumber); newEditor.ParentLayer = _model.ActiveLayer ; _model.AddEditor(newEditor); }
public void SelectEditor( ItemEditor editor ) { LayerEditor parentLayer = editor.ParentLayer ; editor.IsSelected = true ; ActiveLayer = parentLayer ; }