コード例 #1
0
        public override XmlElement WriteObject(ObjectWrapper wrapper)
        {
            Wrapper.Widget ww = wrapper as Wrapper.Widget;

            // If the object is already registered, skip it (just create a dummy object)
            if (allowMarkers && ww != null && undoManager.IsRegistered(ww) && !ww.RequiresUndoStatusUpdate)
            {
                XmlElement marker = XmlDocument.CreateElement("widget");
                marker.SetAttribute("unchanged_marker", "yes");
                return(marker);
            }

            // Don't allow markers in indirect children, since those are not checked
            // when creating the diff
            bool oldAllow = allowMarkers;

            allowMarkers = false;
            XmlElement elem = base.WriteObject(wrapper);

            allowMarkers = oldAllow;

            if (ww != null)
            {
                ww.RequiresUndoStatusUpdate = false;
            }

            // Register the object, so it is correctly bound to this xml element
            if (undoManager.IsRegistered(wrapper))
            {
                undoManager.UnregisterObject(wrapper);
            }
            undoManager.RegisterObject(wrapper, elem);

            return(elem);
        }
コード例 #2
0
        public void Dispose()
        {
            if (Count == 0)
            {
                return;
            }

            if (Count == 1)
            {
                // The change events fired here may generate changes in other
                // objects. Those changes will also be included in the transaction.
                // So, the ChangeEventPending array may grow while calling NotifyChanged,
                // and that's ok.

                for (int n = 0; n < ChangeEventPending.Count; n++)
                {
                    ((ObjectWrapper)ChangeEventPending[n]).FireObjectChangedEvent();
                }

                // Remove from the list the widgets that have been disposed. It means that
                // they have been deleted. That change will be recorded by their parents.
                // Remove as well wrappers that are not registered, since there won't be
                // status information for them.
                for (int n = 0; n < ChangeEventPending.Count; n++)
                {
                    ObjectWrapper w = (ObjectWrapper)ChangeEventPending[n];
                    if (w.IsDisposed || !undoManager.IsRegistered(w))
                    {
                        ChangeEventPending.RemoveAt(n);
                        n--;
                    }
                }

                ObjectWrapper[] obs = (ObjectWrapper[])ChangeEventPending.ToArray(typeof(ObjectWrapper));
                ChangeEventPending.Clear();
                Count = 0;

                if (!delayed)
                {
                    undoManager.NotifyUndoCheckpoint(obs);
                }
                delayed = false;
            }
            else
            {
                Count--;
            }
        }