Esempio n. 1
1
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="part"></param>
        /// <param name="change">bit field with what is changed</param>
        /// 
        public UndoState(SceneObjectPart part, ObjectChangeType change)
        {
            data = new ObjectChangeData();
            data.change = change;
            creationtime = DateTime.UtcNow;

            if (part.ParentGroup.RootPart == part)
            {
                if ((change & ObjectChangeType.Position) != 0)
                    data.position = part.ParentGroup.AbsolutePosition;
                if ((change & ObjectChangeType.Rotation) != 0)
                    data.rotation = part.RotationOffset;
                if ((change & ObjectChangeType.Scale) != 0)
                    data.scale = part.Shape.Scale;
            }
            else
            {
                if ((change & ObjectChangeType.Position) != 0)
                    data.position = part.OffsetPosition;
                if ((change & ObjectChangeType.Rotation) != 0)
                    data.rotation = part.RotationOffset;
                if ((change & ObjectChangeType.Scale) != 0)
                    data.scale = part.Shape.Scale;
            }
        }
Esempio n. 2
0
        private static void ObjectChanged(uint serial, ObjectChangeType changeType, bool isStatusUpdate)
        {
            objectCallbacks.InvokeAsync(new ObjectChangedEventArgs(serial, changeType, isStatusUpdate));

            if (changeType == ObjectChangeType.ItemUpdated || changeType == ObjectChangeType.Removed)
            {
                ObjectChangeType subChange = (changeType == ObjectChangeType.Removed) ? ObjectChangeType.SubItemRemoved : ObjectChangeType.SubItemUpdated;

                RealItem item = World.FindRealItem(serial);
                if (item != null)
                {
                    do
                    {
                        RealObject obj = World.FindRealObject(item.Container);

                        if (obj != null)
                        {
                            objectCallbacks.InvokeAsync(new ObjectChangedEventArgs(obj.Serial, serial, subChange));
                        }

                        item = obj as RealItem;
                    }while (item != null);
                }
            }
        }
Esempio n. 3
0
 public ObjectChangedEventArgs(Serial serial, ObjectChangeType type, bool isStatusUpdate)
 {
     this.serial         = serial;
     this.type           = type;
     this.itemSerial     = Serial.Invalid;
     this.isStatusUpdate = isStatusUpdate;
 }
        /// <summary>
        /// adds a new state undo to part or its group, with changes indicated by what bits
        /// </summary>
        /// <param name="part"></param>
        /// <param name="change">bit field with what is changed</param>

        public void StoreUndo(SceneObjectPart part, ObjectChangeType change)
        {
            lock (m_undo)
            {
                UndoState last;

                if (m_redo.Count > 0) // last code seems to clear redo on every new undo
                {
                    m_redo.Clear();
                }

                if (m_undo.Count > 0)
                {
                    // check expired entry
                    last = m_undo.First.Value;
                    if (last != null && last.checkExpire())
                    {
                        m_undo.Clear();
                    }
                    else
                    {
                        // see if we actually have a change
                        if (last != null)
                        {
                            if (last.Compare(part, change))
                            {
                                return;
                            }
                        }
                    }
                }

                // limite size
                while (m_undo.Count >= size)
                {
                    m_undo.RemoveLast();
                }

                UndoState nUndo = new UndoState(part, change);
                m_undo.AddFirst(nUndo);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="part"></param>
        /// <param name="change">bit field with what is changed</param>
        ///
        public UndoState(SceneObjectPart part, ObjectChangeType change)
        {
            data         = new ObjectChangeData();
            data.change  = change;
            creationtime = DateTime.UtcNow;
            SceneObjectGroup sog = part.ParentGroup;

            if (sog.RootPart == part)
            {
                if ((change & ObjectChangeType.Position) != 0)
                {
                    data.position = sog.IsAttachment ? part.AttachedPos : sog.AbsolutePosition;
                }
                if ((change & ObjectChangeType.Rotation) != 0)
                {
                    data.rotation = part.RotationOffset;
                }
                if ((change & ObjectChangeType.Scale) != 0)
                {
                    data.scale = part.Shape.Scale;
                }
            }
            else
            {
                if ((change & ObjectChangeType.Position) != 0)
                {
                    data.position = part.OffsetPosition;
                }
                if ((change & ObjectChangeType.Rotation) != 0)
                {
                    data.rotation = part.RotationOffset;
                }
                if ((change & ObjectChangeType.Scale) != 0)
                {
                    data.scale = part.Shape.Scale;
                }
            }
        }
        /// <summary>
        /// Compare the relevant state in the given part to this state.
        /// </summary>
        /// <param name="part"></param>
        /// <returns>true what fiels and related data are equal, False otherwise.</returns>
        ///
        public bool Compare(SceneObjectPart part, ObjectChangeType change)
        {
            if (data.change != change) // if diferent targets, then they are diferent
            {
                return(false);
            }

            if (part != null)
            {
                if (part.ParentID == 0)
                {
                    if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition)
                    {
                        return(false);
                    }
                }
                else
                {
                    if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition)
                    {
                        return(false);
                    }
                }

                if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset)
                {
                    return(false);
                }
                if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale)
                {
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Esempio n. 7
0
        public void StoreUndoState(ObjectChangeType change)
        {
            if (m_UndoRedo == null)
                m_UndoRedo = new UndoRedoState(5);

            lock (m_UndoRedo)
            {
                if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better  - undo is in progress, or suspended
                {
                    m_UndoRedo.StoreUndo(this, change);
                }
            }
        }
 public SpecializedObjectChangedEventWaiter(Serial serial, ObjectChangeType changes)
     : base(serial)
 {
     this.changes = changes;
 }
Esempio n. 9
0
        /// <summary>
        /// adds a new state undo to part or its group, with changes indicated by what bits
        /// </summary>
        /// <param name="part"></param>
        /// <param name="change">bit field with what is changed</param>

        public void StoreUndo(SceneObjectPart part, ObjectChangeType change)
        {
            lock (m_undo)
            {
                UndoState last;

                if (m_redo.Count > 0) // last code seems to clear redo on every new undo
                {
                    m_redo.Clear();
                }

                if (m_undo.Count > 0)
                {
                    // check expired entry
                    last = m_undo.First.Value;
                    if (last != null && last.checkExpire())
                        m_undo.Clear();
                    else
                    {
                        // see if we actually have a change
                        if (last != null)
                        {
                            if (last.Compare(part, change))
                                return;
                        }
                    }
                }

                // limite size
                while (m_undo.Count >= size)
                    m_undo.RemoveLast();

                UndoState nUndo = new UndoState(part, change);
                m_undo.AddFirst(nUndo);
            }
        }
 public SpecializedObjectChangedEventWaiter(Serial serial, ObjectChangeType changes)
     : base(serial)
 {
     this.changes = changes;
 }
Esempio n. 11
0
 private static void ObjectChanged(uint serial, ObjectChangeType changeType)
 {
     ObjectChanged(serial, changeType, false);
 }
Esempio n. 12
0
        /// <summary>
        /// Compare the relevant state in the given part to this state.
        /// </summary>
        /// <param name="part"></param>
        /// <returns>true what fiels and related data are equal, False otherwise.</returns>
        /// 
        public bool Compare(SceneObjectPart part, ObjectChangeType change)    
        {
            if (data.change != change) // if diferent targets, then they are diferent
                return false;

            if (part != null)
            {
                if (part.ParentID == 0)
                {
                    if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition)
                        return false;
                }
                else
                {
                    if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition)
                        return false;
                }

                if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset)
                    return false;
                if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale)
                    return false;
                return true;

            }
            return false;
        }
Esempio n. 13
0
        private static void ObjectChanged(uint serial, ObjectChangeType changeType, bool isStatusUpdate)
        {
            objectCallbacks.InvokeAsync(new ObjectChangedEventArgs(serial, changeType, isStatusUpdate));

            if (changeType == ObjectChangeType.ItemUpdated || changeType == ObjectChangeType.Removed) {
                ObjectChangeType subChange = (changeType == ObjectChangeType.Removed) ? ObjectChangeType.SubItemRemoved : ObjectChangeType.SubItemUpdated;

                RealItem item = World.FindRealItem(serial);
                if (item != null) {
                    do {
                        RealObject obj = World.FindRealObject(item.Container);

                        if (obj != null)
                            objectCallbacks.InvokeAsync(new ObjectChangedEventArgs(obj.Serial, serial, subChange));

                        item = obj as RealItem;
                    }
                    while (item != null);
                }
            }
        }
 public SpecializedObjectChangedEventWaiter(Serial serial, ObjectChangeType changes, TestEventArgsDelegate eventTest)
     : base(serial, eventTest)
 {
     this.changes = changes;
 }
Esempio n. 15
0
        public void ObjectStoredNotification(IInformationObject informationObject, ObjectChangeType changeType)
        {
            IIndexedDocument iDoc = informationObject as IIndexedDocument;
            if (iDoc != null && _owner != null)
            {
                VirtualOwner owner = VirtualOwner.FigureOwner(informationObject);
                if (owner.IsEqualOwner(_owner))
                {
                    IndexedIDInfos.Add(informationObject.RelativeLocation);
                }
            }

            if (trackedDomainNames.Contains(informationObject.SemanticDomainName) == false)
                return;
            string changeTypeValue;
            switch (changeType)
            {
                case ObjectChangeType.D_Deleted:
                    changeTypeValue = "D";
                    break;
                case ObjectChangeType.M_Modified:
                    changeTypeValue = "M";
                    break;
                case ObjectChangeType.N_New:
                    changeTypeValue = "N";
                    break;
                default:
                    throw new NotSupportedException("ChangeType handling not implemented: " + changeType.ToString());

            }
            string changedIDInfo = changeTypeValue + ":" + informationObject.ID;
            ChangedIDInfos.Add(changedIDInfo);
        }
Esempio n. 16
0
        /// <summary>
        /// 标记对象为变更。
        /// </summary>
        /// <typeparam name="T">扩展的对象类型</typeparam>
        /// <param name="obj">一个可扩展的对象类的实例对象。</param>
        /// <param name="changeType">对象变更类型枚举。</param>
        /// <returns>修改后的对象实例。</returns>
        /// <exception cref="System.ArgumentNullException">[ObjectExtendibleExtensions].[SetChange{{0}}].obj.With(typeof(T).FullName)</exception>
        public static ObjectExtendible <T> SetChange <T>(this ObjectExtendible <T> obj, ObjectChangeType changeType)
        {
            if (ReferenceEquals(obj, null))
            {
                throw new ArgumentNullException("[ObjectExtendibleExtensions].[SetChange<{0}>].obj".With(typeof(T).FullName));
            }

            obj.Tag["Change"] = changeType.ToString();
            return(obj);
        }
Esempio n. 17
0
 public ObjectChangedEventArgs(Serial serial, Serial itemSerial, ObjectChangeType type)
 {
     this.serial     = serial;
     this.type       = type;
     this.itemSerial = itemSerial;
 }
 public SpecializedObjectChangedEventWaiter(Serial serial, ObjectChangeType changes, TestEventArgsDelegate eventTest)
     : base(serial, eventTest)
 {
     this.changes = changes;
 }
Esempio n. 19
0
 private static void ObjectChanged(uint serial, ObjectChangeType changeType)
 {
     ObjectChanged(serial, changeType, false);
 }