public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers) { if (button == 1) { IGameObject gameObject = CreateObjectAt(MousePos); // switch back to object edit mode when shift was not pressed if ((Modifiers & ModifierType.ShiftMask) == 0) { ObjectSelectTool editor = new ObjectSelectTool(application, application.CurrentSector); if (gameObject is IObject) { editor.MakeActive((IObject)gameObject); } application.SetTool(editor); } } else //cancel creation by other buttons { application.SetToolObjects(); } if (UpdateMousePos(mousePos)) { Redraw(); } }
private void CommandPaste() { if (CommandCanPaste()) { ObjectSelectionClipboard clip = ObjectSelectionClipboard.CopyFromClipboard(Layer.Level.Project); if (clip == null) { return; } ObjectSelectTool tool = _currentTool as ObjectSelectTool; if (tool == null) { SetCurrentTool(NewSelectTool()); } _selectionManager.ClearSelection(); CenterObjectsInViewport(clip.Objects); Command command = new ObjectAddCommand(Layer, clip.Objects, _selectionManager); LayerContext.History.Execute(command); foreach (ObjectInstance inst in clip.Objects) { //Layer.AddObject(inst); _selectionManager.AddObjectToSelection(inst); } } }
private ObjectSelectTool NewSelectTool() { Treefrog.Framework.Imaging.Size gridSize = new Treefrog.Framework.Imaging.Size(Layer.GridWidth, Layer.GridHeight); ObjectSelectTool tool = new ObjectSelectTool(LayerContext, Layer, gridSize, _selectionManager); tool.BindObjectSourceController(_objectController); return(tool); }
private void OnButtonPress(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1) { application.SetToolObjects(); Vector MousePos = new Vector((float)args.Event.X, (float)args.Event.Y); int?objectNr = GetObjectNrByPosition(MousePos); int selected; if (!objectNr.HasValue) { return; } else { selected = (int)objectNr; } if (selected < gameObjectTypes.Count) { if (SelectedObjectNr != selected) { SelectedObjectNr = selected; if (application.CurrentSector != null) { Type type = gameObjectTypes[selected]; Sprite Icon = gameObjectSprites[selected]; if (type != null) { ITool editor = new ObjectCreationTool(application, application.CurrentSector, type, Icon); application.SetTool(editor); application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name + "\""); } else { ITool editor = new ObjectSelectTool(application, application.CurrentSector); application.SetTool(editor); application.PrintStatus("ObjectListWidget: none selected "); } } QueueDraw(); } } } }
private void SetCurrentTool(PointerTool tool) { ObjectSelectTool objTool = _currentTool as ObjectSelectTool; if (objTool != null) { objTool.Cancel(); _selectionManager.ClearSelection(); _commandManager.RemoveCommandSubscriber(objTool); } _currentTool = tool; objTool = _currentTool as ObjectSelectTool; if (objTool != null && objTool.CommandManager != null) { _commandManager.AddCommandSubscriber(objTool); } }
protected ToolState(ObjectSelectTool tool) { Tool = tool; }
public SelectionTimeoutToolState(ObjectSelectTool tool) : base(tool) { }
public SelectionStandbyToolState(ObjectSelectTool tool) : base(tool) { }
public SelectionRotatingToolState(ObjectSelectTool tool, ObjectInstance hitObject) : base(tool) { HitObject = hitObject; InitialPosition = hitObject.Position; InitialCenter = hitObject.ImageBounds.Center; InitialAngle = hitObject.Rotation; float radius = Tool.MaxBoundingDiagonal(HitObject) / 2 + 5; Annot = new CircleAnnot(HitObject.ImageBounds.Center, radius); Annot.Outline = Outline; Annot.OutlineGlow = OutlineGlow; Tool._annots.Add(Annot); }
public SelectionMovingToolState(ObjectSelectTool tool) : base(tool) { }
public SelectionAreaToolState(ObjectSelectTool tool) : base(tool) { }
public ReleaseToolState(ObjectSelectTool tool) : base(tool) { }
private void OnButtonPress(object o, ButtonPressEventArgs args) { if(args.Event.Button == 1) { application.SetToolObjects(); Vector MousePos = new Vector((float) args.Event.X, (float) args.Event.Y); int? objectNr = GetObjectNrByPosition(MousePos); int selected; if (!objectNr.HasValue) { return ; } else { selected = (int)objectNr; } if( selected < gameObjectTypes.Count ){ if( SelectedObjectNr != selected ){ SelectedObjectNr = selected; if( application.CurrentSector != null ) { Type type = gameObjectTypes[selected]; Sprite Icon = gameObjectSprites[selected]; if(type != null) { ITool editor = new ObjectCreationTool(application, application.CurrentSector, type, Icon); application.SetTool(editor); application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name +"\""); } else { ITool editor = new ObjectSelectTool(application, application.CurrentSector); application.SetTool(editor); application.PrintStatus("ObjectListWidget: none selected "); } } QueueDraw(); } } } }
public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers) { if (button == 1){ IGameObject gameObject = CreateObjectAt(MousePos); // switch back to object edit mode when shift was not pressed if((Modifiers & ModifierType.ShiftMask) == 0) { ObjectSelectTool editor = new ObjectSelectTool(application, application.CurrentSector); if(gameObject is IObject) { editor.MakeActive((IObject) gameObject); } application.SetTool(editor); } } else { //cancel creation by other buttons application.SetToolObjects(); } if (UpdateMousePos(mousePos)) Redraw(); }