예제 #1
0
    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);
    }
    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);
    }