FindObjectByUndoId() 공개 메소드

public FindObjectByUndoId ( string id ) : ObjectWrapper
id string
리턴 ObjectWrapper
        ObjectWrapperUndoRedoChange ApplyDiff(string id, object diff)
        {
//			Console.WriteLine ("** APPLYING DIFF: uid:" + id);
//			PrintPatch (diff);

            ObjectWrapper ww = rootObject.FindObjectByUndoId(id);

            if (ww == null)
            {
                Console.WriteLine("Object with undo id '{0}' not found", id);
                return(null);
            }

            object reverseDiff = ww.ApplyUndoRedoDiff(diff);

            if (reverseDiff != null)
            {
//				Console.WriteLine ("** REVERSE DIFF:");
//				PrintPatch (reverseDiff);

                ObjectWrapperUndoRedoChange change = new ObjectWrapperUndoRedoChange(this, id, reverseDiff);
                return(change);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        // Call this from a DragDrop event to receive the dragged widget
        public static void Drop(Gdk.DragContext ctx, uint time, ObjectWrapper targetWrapper, string dropData)
        {
            if (dropCallback == null)
            {
                Gtk.Widget w = Drop(ctx, (Gtk.Widget)targetWrapper.Wrapped, time);
                targetWrapper.DropObject(dropData, w);
                return;
            }

            Cancel();
            Gtk.Drag.Finish(ctx, true, true, time);

            Gtk.Application.Invoke(delegate
            {
                IProject project = targetWrapper.Project;
                string uid       = targetWrapper.UndoId;
                string tname     = ((Wrapper.Widget)targetWrapper).GetTopLevel().Wrapped.Name;

                // This call may cause the project to be reloaded
                dragWidget = dropCallback();
                if (dragWidget == null)
                {
                    return;
                }

                if (targetWrapper.IsDisposed)
                {
                    // The project has been reloaded. Find the wrapper again.
                    Gtk.Widget twidget = project.GetTopLevel(tname);
                    ObjectWrapper ow   = ObjectWrapper.Lookup(twidget);
                    if (ow != null)
                    {
                        targetWrapper = ow.FindObjectByUndoId(uid);
                    }
                    else
                    {
                        targetWrapper = null;
                    }

                    if (targetWrapper == null)
                    {
                        // Target wrapper not found. Just ignore the drop.
                        return;
                    }
                }

                targetWrapper.DropObject(dropData, dragWidget);
            });
        }