private void OnDragDataReceived(object o, DragDataReceivedArgs args) { string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); if (!badguySprites.ContainsKey(data)) { badguySprites.Add(data, CrateSprite(data)); } if (data != "") { if (badguys.Count == 0) { Gtk.Drag.SourceSet(this, Gdk.ModifierType.Button1Mask, source_table, DragAction.Move); } Command command; if (draggedID > NONE) //We were moving { if (SelectedObjectNr > draggedID) { SelectedObjectNr--; } if (SelectedObjectNr == draggedID) { draggedID = NONE; return; } command = new SortedListMoveCommand <string>( "Changed position of badguy \"" + data + "\" in the queue", _object, field, draggedID, SelectedObjectNr); draggedID = NONE; } else //We were adding { command = new SortedListAddCommand <string>( "Added badguy \"" + data + "\" into the queue", _object, field, data, SelectedObjectNr); } command.Do(); UndoManager.AddCommand(command); dragging = false; //update heigth SetSizeRequest(-1, ROW_HEIGHT * ((badguys.Count - 1) / TILES_PER_ROW + 1)); } Gtk.Drag.Finish(args.Context, true, false, args.Time); }
public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers) { if (button == 1) { Path.Node node = FindNodeAt(mousePos); if (node == null) { if ((Modifiers & ModifierType.ControlMask) != 0) { Vector pointOnEdge = new Vector(0, 0); int addNode = FindPath(mousePos, ref pointOnEdge); if (addNode >= 0) { node = new Path.Node(); node.Pos = pointOnEdge; Command command = new SortedListAddCommand <Path.Node>("Added Path node", path, field, node, addNode + 1); command.Do(); UndoManager.AddCommand(command); } } else if (selectedNode == path.Nodes[path.Nodes.Count - 1]) { node = new Path.Node(); // Snap? if (application.SnapToGrid) { mousePos = new Vector((float)((int)mousePos.X / 32) * 32, (float)((int)mousePos.Y / 32) * 32); } node.Pos = mousePos; Command command = new SortedListAddCommand <Path.Node>("Added Path node", path, field, node); command.Do(); UndoManager.AddCommand(command); } else if (selectedNode == path.Nodes[0]) { node = new Path.Node(); node.Pos = mousePos; Command command = new SortedListAddCommand <Path.Node>("Added Path node", path, field, node, 0); command.Do(); UndoManager.AddCommand(command); } } if (node != selectedNode) { selectedNode = node; Redraw(); } if (selectedNode != null) { application.EditProperties(selectedNode, "Path Node"); dragging = true; pressPoint = mousePos; originalPos = selectedNode.Pos; } } else if (button == 3) { if (dragging) { dragging = false; selectedNode.Pos = originalPos; Redraw(); } else { Path.Node node = FindNodeAt(mousePos); if (node != null) //if we have clicked on a node.. { selectedNode = node; //..make that node active } PopupMenu(button); } } }
public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers) { if(button == 1) { Path.Node node = FindNodeAt(mousePos); if(node == null) { if((Modifiers & ModifierType.ControlMask) != 0) { Vector pointOnEdge = new Vector(0, 0); int addNode = FindPath(mousePos, ref pointOnEdge); if(addNode >= 0) { node = new Path.Node(); node.Pos = pointOnEdge; Command command = new SortedListAddCommand<Path.Node>("Added Path node", path, field, node, addNode+1); command.Do(); UndoManager.AddCommand(command); } } else if(selectedNode == path.Nodes[path.Nodes.Count - 1]) { node = new Path.Node(); // Snap? if( application.SnapToGrid ) { mousePos = new Vector((float) ((int)mousePos.X / 32) * 32, (float) ((int)mousePos.Y / 32) * 32); } node.Pos = mousePos; Command command = new SortedListAddCommand<Path.Node>("Added Path node", path, field, node); command.Do(); UndoManager.AddCommand(command); } else if(selectedNode == path.Nodes[0]) { node = new Path.Node(); node.Pos = mousePos; Command command = new SortedListAddCommand<Path.Node>("Added Path node", path, field, node, 0); command.Do(); UndoManager.AddCommand(command); } } if(node != selectedNode) { selectedNode = node; Redraw(); } if(selectedNode != null) { application.EditProperties(selectedNode, "Path Node"); dragging = true; pressPoint = mousePos; originalPos = selectedNode.Pos; } } else if(button == 3) { if(dragging) { dragging = false; selectedNode.Pos = originalPos; Redraw(); } else { Path.Node node = FindNodeAt(mousePos); if (node != null) //if we have clicked on a node.. selectedNode = node; //..make that node active PopupMenu(button); } } }
private void OnDragDataReceived(object o, DragDataReceivedArgs args) { string data = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data); if(!badguySprites.ContainsKey(data)) { badguySprites.Add(data, CrateSprite(data)); } if (data != ""){ if (badguys.Count == 0) Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask, source_table, DragAction.Move); Command command; if (draggedID > NONE){ //We were moving if (SelectedObjectNr > draggedID) SelectedObjectNr--; if (SelectedObjectNr == draggedID) { draggedID = NONE; return; } command = new SortedListMoveCommand<string>( "Changed position of badguy \"" + data + "\" in the queue", _object, field , draggedID, SelectedObjectNr); draggedID = NONE; } else //We were adding command = new SortedListAddCommand<string>( "Added badguy \"" + data + "\" into the queue", _object, field, data, SelectedObjectNr); command.Do(); UndoManager.AddCommand(command); dragging = false; //update heigth SetSizeRequest( -1, ROW_HEIGHT * ((badguys.Count - 1) / TILES_PER_ROW + 1)); } Gtk.Drag.Finish (args.Context, true, false, args.Time); }