private void OnDeletePath(object o, EventArgs args)
 {
     IPathObject pathObject = (IPathObject) application.CurrentTilemap;
     if (pathObject.Path != null) {
         Command command = new PropertyChangeCommand("Removed path of Tilemap " + application.CurrentTilemap.Name + " (" + application.CurrentTilemap.Layer + ")",
                                 FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Path")),
                                 application.CurrentTilemap,
                                 null);
         command.Do();
         UndoManager.AddCommand(command);
     }
 }
    private void OnComboBoxChanged(object o, EventArgs args)
    {
        try {
            ComboBoxEntry comboBox = (ComboBoxEntry)o;
            string s = comboBox.ActiveText;

            // strip off comments from licenseTemplateTexts
            if (s == "non-redistributable (forbid sharing and modification of this level)") s = s.Substring(0, s.IndexOf(" ("));
            if (s == "GPL 2+ / CC-by-sa 3.0 (allow sharing and modification of this level)") s = s.Substring(0, s.IndexOf(" ("));

            if (s != (string) Field.GetValue(Object)) {	//no change => no undo item
                PropertyChangeCommand command = new PropertyChangeCommand(
                    "Changed value of " + Field.Name,
                    Field,
                    Object,
                    s);
                command.Do();
                UndoManager.AddCommand(command);
            }
        } catch (Exception e) {
            ErrorDialog.Exception(e);
        }
    }
    protected void OnOk(object o, EventArgs args)
    {
        try {
            PropertyChangeCommand command = new PropertyChangeCommand(
                "Changed value of " + field.Name,
                field,
                object_,
                scriptEditor.Buffer.Text);
            command.Do();
            UndoManager.AddCommand(command);
        } catch(Exception e) {
            ErrorDialog.Exception(e);
        }

        field.Changed -= OnFieldChanged;
        scriptDialog.Hide();
    }
    private void OnChooseColor(object sender, EventArgs args)
    {
        Drawing.Color col = new Drawing.Color();
        col.Red = ((float) colorButton.Color.Red) / 65535f;
        col.Blue = ((float) colorButton.Color.Blue) / 65535f;
        col.Green = ((float) colorButton.Color.Green) / 65535f;
        col.Alpha = 1f;
        if (useAlpha)
            col.Alpha = ((float) colorButton.Alpha) / 65535f;

        if (col != (Drawing.Color) Field.GetValue(Object)) {
            PropertyChangeCommand command = new PropertyChangeCommand(
                "Changed value of " + Field.Name,
                Field,
                Object,
                col);
            command.Do();
            UndoManager.AddCommand(command);
            //Console.WriteLine("ChooseColorWidget change col r{0},g{1},b{2},a{3}", col.Red, col.Green, col.Blue, col.Alpha);
            //Console.WriteLine("ChooseColorWidget change gtk color r{0},g{1},b{2},a{3}", colorButton.Color.Red, colorButton.Color.Green, colorButton.Color.Blue, colorButton.Alpha);
        }
    }
 private void OnDeletePath(object o, EventArgs args)
 {
     IPathObject pathObject = (IPathObject) selectedObjects[0];
     if (pathObject.Path != null) {
         Command command = new PropertyChangeCommand("Removed path from " + selectedObjects[0],
                                 LispReader.FieldOrProperty.Lookup(typeof(IPathObject).GetProperty("Path")),
                                 selectedObjects[0],
                                 null);
         command.Do();
         UndoManager.AddCommand(command);
     }
 }
 private void OnComboBoxChanged(object o, EventArgs args)
 {
     try {
         ComboBox comboBox = (ComboBox)o;
         string newText = comboBox.ActiveText;
         string oldText = (string) Field.GetValue(Object);
         if (newText != oldText) {
             PropertyChangeCommand command = new PropertyChangeCommand(
                 "Changed value of " + Field.Name,
                 Field,
                 Object,
                 newText);
             command.Do();
             UndoManager.AddCommand(command);
         }
     } catch (Exception e) {
         ErrorDialog.Exception(e);
     }
 }
 public void DeleteCurrentPath()
 {
     SetToolSelect();
     Command command = new PropertyChangeCommand("Deleted path from " + iPathToEdit.GetType().ToString(),
                         FieldOrProperty.Lookup(iPathToEdit.GetType().GetProperty("Path")), iPathToEdit, null);
     command.Do();
     UndoManager.AddCommand(command);
 }
 private void OnEntryChangeDone(object o, FocusOutEventArgs args)
 {
     try {
         Entry entry = (Entry) o;
         if ((string)Field.GetValue(Object) == entry.Text) return;
         PropertyChangeCommand command = new PropertyChangeCommand(
             "Changed value of " + Field.Name,
             Field,
             Object,
             entry.Text);
         command.Do();
         UndoManager.AddCommand(command);
     } catch (Exception e) {
         ErrorDialog.Exception(e);
         string val = (string) Field.GetValue(Object);
         if (val != null)
             entry.Text = val;
     }
 }