Пример #1
0
        public static UndoState FromObject(object recordFrom)
        {
            UndoState toReturn = new UndoState();
            toReturn.Owner = recordFrom;

            var lateBinder = LateBinder.GetInstance(recordFrom.GetType());

            object result;

            if(lateBinder.TryGetValue(recordFrom, "X", out result))
            {
                toReturn.X = (float)result;
            }
            if (lateBinder.TryGetValue(recordFrom, "Y", out result))
            {
                toReturn.Y = (float)result;
            }
            if (lateBinder.TryGetValue(recordFrom, "Z", out result))
            {
                toReturn.Z = (float)result;
            }

            if (lateBinder.TryGetValue(recordFrom, "ScaleX", out result))
            {
                toReturn.ScaleX = (float)result;
            }
            if (lateBinder.TryGetValue(recordFrom, "ScaleY", out result))
            {
                toReturn.ScaleY = (float)result;
            }

            return toReturn;
        }
Пример #2
0
        public static UndoState FromObject(object recordFrom)
        {
            UndoState toReturn = new UndoState();

            toReturn.Owner = recordFrom;

            var lateBinder = LateBinder.GetInstance(recordFrom.GetType());

            object result;

            if (lateBinder.TryGetValue(recordFrom, "X", out result))
            {
                toReturn.X = (float)result;
            }
            if (lateBinder.TryGetValue(recordFrom, "Y", out result))
            {
                toReturn.Y = (float)result;
            }
            if (lateBinder.TryGetValue(recordFrom, "Z", out result))
            {
                toReturn.Z = (float)result;
            }

            if (lateBinder.TryGetValue(recordFrom, "ScaleX", out result))
            {
                toReturn.ScaleX = (float)result;
            }
            if (lateBinder.TryGetValue(recordFrom, "ScaleY", out result))
            {
                toReturn.ScaleY = (float)result;
            }

            return(toReturn);
        }
Пример #3
0
        public UndoState GetDiff(object compareTo)
        {
            UndoState toReturn       = new UndoState();
            var       lateBinder     = LateBinder.GetInstance(compareTo.GetType());
            object    result         = null;
            bool      foundSomething = false;

            if (X.HasValue && lateBinder.TryGetValue(compareTo, "X", out result) && (float)result != X.Value)
            {
                toReturn.X     = this.X;
                foundSomething = true;
            }
            if (Y.HasValue && lateBinder.TryGetValue(compareTo, "Y", out result) && (float)result != Y.Value)
            {
                toReturn.Y     = this.Y;
                foundSomething = true;
            }
            if (Z.HasValue && lateBinder.TryGetValue(compareTo, "Z", out result) && (float)result != Z)
            {
                toReturn.Z     = this.Z;
                foundSomething = true;
            }

            if (ScaleX.HasValue && lateBinder.TryGetValue(compareTo, "ScaleX", out result) && (float)result != ScaleX)
            {
                toReturn.ScaleX = this.ScaleX;
                foundSomething  = true;
            }
            if (ScaleY.HasValue && lateBinder.TryGetValue(compareTo, "ScaleY", out result) && (float)result != ScaleY)
            {
                toReturn.ScaleY = this.ScaleY;
                foundSomething  = true;
            }

            if (foundSomething)
            {
                toReturn.Owner = compareTo;
                return(toReturn);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        public UndoState GetDiff(object compareTo)
        {
            UndoState toReturn = new UndoState();
            var lateBinder = LateBinder.GetInstance(compareTo.GetType());
            object result = null;
            bool foundSomething = false;
            if (X.HasValue && lateBinder.TryGetValue(compareTo, "X", out result) && (float)result != X.Value)
            {
                toReturn.X = this.X;
                foundSomething = true;
            }
            if (Y.HasValue && lateBinder.TryGetValue(compareTo, "Y", out result) && (float)result != Y.Value)
            {
                toReturn.Y = this.Y;
                foundSomething = true;
            }
            if (Z.HasValue &&  lateBinder.TryGetValue(compareTo, "Z", out result) && (float)result != Z)
            {
                toReturn.Z = this.Z;
                foundSomething = true;
            }

            if (ScaleX.HasValue && lateBinder.TryGetValue(compareTo, "ScaleX", out result) && (float)result != ScaleX)
            {
                toReturn.ScaleX = this.ScaleX;
                foundSomething = true;
            }
            if (ScaleY.HasValue && lateBinder.TryGetValue(compareTo, "ScaleY", out result) && (float)result != ScaleY)
            {
                toReturn.ScaleY = this.ScaleY;
                foundSomething = true;
            }

            if (foundSomething)
            {
                toReturn.Owner = compareTo;
                return toReturn;
            }
            else
            {
                return null;
            }
        }
Пример #5
0
        public void SaveSnapshot(object selectedObject)
        {
            mCurrentSnapshot = UndoState.FromObject(selectedObject);

        }
Пример #6
0
 public void Clear()
 {
     mUndos = new List<UndoState>();
     mCurrentSnapshot = null;
 }
Пример #7
0
 public void SaveSnapshot(object selectedObject)
 {
     mCurrentSnapshot = UndoState.FromObject(selectedObject);
 }
Пример #8
0
 public void Clear()
 {
     mUndos           = new List <UndoState>();
     mCurrentSnapshot = null;
 }