public void ChangeTool(Guid toolGuid) { _currMapPlugin = (Plugins.IMapPlugin)tools[toolGuid]; if (SelectedPluginChanged != null) SelectedPluginChanged(new ToolEventArgs(_currMapPlugin)); _currMapPlugin.GetButton().Checked = true; }
private void toolchanged(object sender, EventArgs e) { ToolButton tb = (ToolButton)sender; if (!tb.Checked) { return; } _currMapPlugin = (Plugins.IMapPlugin)tools[tb.guid]; if (SelectedPluginChanged != null) { SelectedPluginChanged(new ToolEventArgs(_currMapPlugin)); } }
protected override void OnMouseUp(MouseEventArgs e) { if (!live || ParentMap.IsBrush) { return; } mdown = false; if (bDragging) { Cursor = Cursors.Default; Capture = false; bDragging = false; if (bSliding) { bSliding = bSlidingLeft = bSlidingRight = bSlidingDown = bSlidingUp = false; slideTimer.Enabled = false; } } if (bDraggingTool) { setupMapCursorLocation(ref currMapEventInfo.end, e.X, e.Y); currMapDragTool.MouseUp(currMapEventInfo); bDraggingTool = false; if (currMapEventInfo.bDirty) { Invalidate(); } currMapEventInfo.bDirty = false; } ParentMap.bUpdating = false; currMapPlugin = null; currMapTool = null; currMapDragTool = null; }
private void toolchanged(object sender, EventArgs e) { ToolButton tb = (ToolButton)sender; if(!tb.Checked) return; _currMapPlugin = (Plugins.IMapPlugin)tools[tb.guid]; if(SelectedPluginChanged != null) SelectedPluginChanged(new ToolEventArgs(_currMapPlugin)); }
public ToolEventArgs(Plugins.IMapPlugin imp) { selectedPlugin=imp; }
protected override void OnMouseUp(MouseEventArgs e) { if (!live || ParentMap.IsBrush) return; mdown = false; if (bDragging) { Cursor = Cursors.Default; Capture = false; bDragging = false; if (bSliding) { bSliding = bSlidingLeft = bSlidingRight = bSlidingDown = bSlidingUp = false; slideTimer.Enabled = false; } } if (bDraggingTool) { setupMapCursorLocation(ref currMapEventInfo.end, e.X, e.Y); currMapDragTool.MouseUp(currMapEventInfo); bDraggingTool = false; if (currMapEventInfo.bDirty) Invalidate(); currMapEventInfo.bDirty = false; } ParentMap.bUpdating = false; currMapPlugin = null; currMapTool = null; currMapDragTool = null; }
protected override void OnMouseDown(MouseEventArgs e) { if (!live || ParentMap.IsBrush) return; mdown = true; if (Global.editedLayer.type == LayerType.Entity) { if (Global.SelectedEntity != null) { Global.SelectedEntity.TileX = Global.MapCursorLocation.X; Global.SelectedEntity.TileY = Global.MapCursorLocation.Y; } return; } currMapPlugin = Global.toolPalette.currMapPlugin; if (currMapPlugin == null) return; //get the tool to be used currMapTool = currMapPlugin.getTool( e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, ((Control.ModifierKeys & Keys.Shift) != 0), ((Control.ModifierKeys & Keys.Control) != 0), ((Control.ModifierKeys & Keys.Alt) != 0) ); if (currMapTool == null) return; //ensure that the tool to be used works with the current edited layer MapLayer ml = null; foreach (LayerType t in currMapTool.layerTypes) { if (t == Global.editedLayer.type) ml = Global.editedLayer; } if (ml == null) { currMapTool = null; return; } Capture = true; bDragging = true; ParentMap.bUpdating = true; //setup eventinfo currMapEventInfo = new Plugins.MapEventInfo(); //currMapEventInfo.invalidateEvent += new EventHandler(invalidateEvent); currMapEventInfo.editedMap = ParentMap; currMapEventInfo.editedLayer = ml; currMapEventInfo.editedLayerIndex = ParentMap.Layers.IndexOf(ml); currMapEventInfo.lb = ((e.Button & MouseButtons.Left) > 0); currMapEventInfo.rb = ((e.Button & MouseButtons.Right) > 0); currMapEventInfo.opManager = Global.opManager; setupMapCursorLocation(ref currMapEventInfo.start, e.X, e.Y); setupMapCursorLocation(ref currMapEventInfo.current, e.X, e.Y); setupMapCursorLocation(ref currMapEventInfo.previous, e.X, e.Y); currMapEventInfo.bDirty = false; if (currMapTool is Plugins.IMapDragTool) { bDraggingTool = true; currMapDragTool = (Plugins.IMapDragTool)currMapTool; currMapDragTool.MouseDown(currMapEventInfo); currMapDragTool.MouseMove(currMapEventInfo); if (currMapDragTool is Plugins.IMapDragTileTool) ((Plugins.IMapDragTileTool)currMapDragTool).MouseMoveTile(currMapEventInfo); } if (currMapTool is Plugins.IMapClickTool) { ((Plugins.IMapClickTool)currMapTool).MouseClick(currMapEventInfo); } if (currMapEventInfo.bDirty) Invalidate(); currMapEventInfo.bDirty = false; }
public ToolEventArgs(Plugins.IMapPlugin imp) { selectedPlugin = imp; }
public void registerPlugin(Plugins.IMapPlugin mapPlugin, Guid guid) { tools[guid] = mapPlugin; }
public void registerButton(ToolButton tb, Plugins.IMapPlugin mapPlugin) { tb.guid = mapPlugin.guid; tools[mapPlugin.guid] = mapPlugin; tb.CheckedChanged += new EventHandler(toolchanged); }
protected override void OnMouseDown(MouseEventArgs e) { if (!live || ParentMap.IsBrush) { return; } mdown = true; if (Global.editedLayer.type == LayerType.Entity) { if (Global.SelectedEntity != null) { Global.SelectedEntity.TileX = Global.MapCursorLocation.X; Global.SelectedEntity.TileY = Global.MapCursorLocation.Y; } return; } currMapPlugin = Global.toolPalette.currMapPlugin; if (currMapPlugin == null) { return; } //get the tool to be used currMapTool = currMapPlugin.getTool( e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, ((Control.ModifierKeys & Keys.Shift) != 0), ((Control.ModifierKeys & Keys.Control) != 0), ((Control.ModifierKeys & Keys.Alt) != 0) ); if (currMapTool == null) { return; } //ensure that the tool to be used works with the current edited layer MapLayer ml = null; foreach (LayerType t in currMapTool.layerTypes) { if (t == Global.editedLayer.type) { ml = Global.editedLayer; } } if (ml == null) { currMapTool = null; return; } Capture = true; bDragging = true; ParentMap.bUpdating = true; //setup eventinfo currMapEventInfo = new Plugins.MapEventInfo(); //currMapEventInfo.invalidateEvent += new EventHandler(invalidateEvent); currMapEventInfo.editedMap = ParentMap; currMapEventInfo.editedLayer = ml; currMapEventInfo.editedLayerIndex = ParentMap.Layers.IndexOf(ml); currMapEventInfo.lb = ((e.Button & MouseButtons.Left) > 0); currMapEventInfo.rb = ((e.Button & MouseButtons.Right) > 0); currMapEventInfo.opManager = Global.opManager; setupMapCursorLocation(ref currMapEventInfo.start, e.X, e.Y); setupMapCursorLocation(ref currMapEventInfo.current, e.X, e.Y); setupMapCursorLocation(ref currMapEventInfo.previous, e.X, e.Y); currMapEventInfo.bDirty = false; if (currMapTool is Plugins.IMapDragTool) { bDraggingTool = true; currMapDragTool = (Plugins.IMapDragTool)currMapTool; currMapDragTool.MouseDown(currMapEventInfo); currMapDragTool.MouseMove(currMapEventInfo); if (currMapDragTool is Plugins.IMapDragTileTool) { ((Plugins.IMapDragTileTool)currMapDragTool).MouseMoveTile(currMapEventInfo); } } if (currMapTool is Plugins.IMapClickTool) { ((Plugins.IMapClickTool)currMapTool).MouseClick(currMapEventInfo); } if (currMapEventInfo.bDirty) { Invalidate(); } currMapEventInfo.bDirty = false; }