コード例 #1
0
        // Normally we wouldn't do this in the pattern but the originator itself
        // can't be found without project-wide knowledge...so we have to do some type-specific
        // logic.
        ElementSave GetWhatToApplyTo(UndoObject undoObject)
        {
            object      parentAsObject      = undoObject.Parent;
            ElementSave parentAsElementSave = parentAsObject as ElementSave;

            return(parentAsElementSave);

            //if (undoObject.StateSave != null)
            //{
            //    if (parentAsElementSave != null)
            //    {
            //        // for now we will just assume the default state
            //        return parentAsElementSave.DefaultState;
            //    }
            //}
            //if (undoObject.Instances != null)
            //{
            //    if (parentAsElementSave != null)
            //    {
            //        return parentAsElementSave.Instances;
            //    }
            //}

            //return null;
        }
コード例 #2
0
ファイル: UndoObject.cs プロジェクト: jiailiuyan/Gum
        public static UndoObject CreateUndoObject(StateSave objectToSave, List<InstanceSave> instances, object parent)
        {
            StateSave cloned = FileManager.CloneSaveObject(objectToSave);
            List<InstanceSave> instancesCloned = null;
            if (instances != null)
            {
                instancesCloned = new List<InstanceSave>();
                foreach (var instance in instances)
                {
                    instancesCloned.Add(instance); // no need to clone this, I don't think
                }
            }
            UndoObject undoObject = new UndoObject(
                cloned,
                instancesCloned,
                parent);

            return undoObject;
        }
コード例 #3
0
        public static UndoObject CreateUndoObject(StateSave objectToSave, List <InstanceSave> instances, object parent)
        {
            StateSave           cloned          = FileManager.CloneSaveObject(objectToSave);
            List <InstanceSave> instancesCloned = null;

            if (instances != null)
            {
                instancesCloned = new List <InstanceSave>();
                foreach (var instance in instances)
                {
                    instancesCloned.Add(instance); // no need to clone this, I don't think
                }
            }
            UndoObject undoObject = new UndoObject(
                cloned,
                instancesCloned,
                parent);

            return(undoObject);
        }
コード例 #4
0
ファイル: UndoManager.cs プロジェクト: jiailiuyan/Gum
        // Normally we wouldn't do this in the pattern but the originator itself
        // can't be found without project-wide knowledge...so we have to do some type-specific
        // logic.
        ElementSave GetWhatToApplyTo(UndoObject undoObject)
        {
            object parentAsObject = undoObject.Parent;
            ElementSave parentAsElementSave = parentAsObject as ElementSave;
            return parentAsElementSave;

            //if (undoObject.StateSave != null)
            //{
            //    if (parentAsElementSave != null)
            //    {
            //        // for now we will just assume the default state
            //        return parentAsElementSave.DefaultState;
            //    }
            //}
            //if (undoObject.Instances != null)
            //{
            //    if (parentAsElementSave != null)
            //    {
            //        return parentAsElementSave.Instances;
            //    }
            //}

            //return null;
        }