Exemple #1
0
        public void UndoProperties(int undoLevel)
        {
            InternalDebug.Assert(undoLevel <= propertyUndoStackTop);

            for (var i = propertyUndoStackTop - 1; i >= undoLevel; i--)
            {
                if (propertyUndoStack[i].IsFlags)
                {
                    flagProperties = propertyUndoStack[i].flags.flags;
                }
                else if (propertyUndoStack[i].IsDistinctFlags)
                {
                    distinctFlagProperties = propertyUndoStack[i].flags.flags;
                }
                else if (propertyUndoStack[i].IsDistinctMask1)
                {
                    distinctPropertyMask.Set1(propertyUndoStack[i].bits.bits);
                }
                else if (propertyUndoStack[i].IsDistinctMask2)
                {
                    distinctPropertyMask.Set2(propertyUndoStack[i].bits.bits);
                }
                else
                {
                    if (propertyUndoStack[i].property.Value.IsNull)
                    {
                        propertyMask.Clear(propertyUndoStack[i].property.Id);
                    }
                    else
                    {
                        properties[(int)(propertyUndoStack[i].property.Id - PropertyBitMask.FirstNonFlag)] = propertyUndoStack[i].property.Value;
                        propertyMask.Set(propertyUndoStack[i].property.Id);
                    }
                }
            }

            propertyUndoStackTop = undoLevel;
        }
Exemple #2
0
        public int ApplyProperties(FlagProperties flagProperties, Property[] propList, FlagProperties flagInheritanceMask, PropertyBitMask propertyInheritanceMask)
        {
            int undoStackPosition = this.propertyUndoStackTop;

            FlagProperties allInheritedFlagProperties = this.flagProperties & flagInheritanceMask;

            FlagProperties newEffectiveFlagProperties = allInheritedFlagProperties | flagProperties;

            if (newEffectiveFlagProperties != this.flagProperties)
            {
                this.PushUndoEntry(PropertyUndoEntry.FlagPropertiesFakeId, this.flagProperties);
                this.flagProperties = newEffectiveFlagProperties;
            }


            FlagProperties overridenFlagsPropertiesMask = allInheritedFlagProperties ^ flagProperties;

            FlagProperties newDistinctFlagProperties = (flagProperties & overridenFlagsPropertiesMask) | (flagProperties & ~allInheritedFlagProperties);

            if (newDistinctFlagProperties != this.distinctFlagProperties)
            {
                this.PushUndoEntry(PropertyUndoEntry.DistinctFlagPropertiesFakeId, this.distinctFlagProperties);
                this.distinctFlagProperties = newDistinctFlagProperties;
            }

            PropertyBitMask maskedOutProperties = this.propertyMask & ~propertyInheritanceMask;

            foreach (PropertyId propId in maskedOutProperties)
            {
                this.PushUndoEntry(propId, this.properties[(int)(propId - PropertyBitMask.FirstNonFlag)]);
            }

            PropertyBitMask newDistinctPropertyMask = PropertyBitMask.AllOff;

            this.propertyMask &= propertyInheritanceMask;

            if (propList != null)
            {
                foreach (Property prop in propList)
                {
                    if (this.propertyMask.IsSet(prop.Id))
                    {
                        if (this.properties[(int)(prop.Id - PropertyBitMask.FirstNonFlag)] != prop.Value)
                        {
                            this.PushUndoEntry(prop.Id, this.properties[(int)(prop.Id - PropertyBitMask.FirstNonFlag)]);

                            if (prop.Value.IsNull)
                            {
                                this.propertyMask.Clear(prop.Id);
                            }
                            else
                            {
                                this.properties[(int)(prop.Id - PropertyBitMask.FirstNonFlag)] = prop.Value;
                                newDistinctPropertyMask.Set(prop.Id);
                            }
                        }
                    }
                    else if (!prop.Value.IsNull)
                    {
                        if (!maskedOutProperties.IsSet(prop.Id))
                        {
                            this.PushUndoEntry(prop.Id, PropertyValue.Null);
                        }

                        this.properties[(int)(prop.Id - PropertyBitMask.FirstNonFlag)] = prop.Value;

                        this.propertyMask.Set(prop.Id);

                        newDistinctPropertyMask.Set(prop.Id);
                    }
                }
            }

            if (newDistinctPropertyMask != this.distinctPropertyMask)
            {
                this.PushUndoEntry(this.distinctPropertyMask);
                this.distinctPropertyMask = newDistinctPropertyMask;
            }

            return(undoStackPosition);
        }
        public int ApplyProperties(FlagProperties flagProperties, Property[] propList, FlagProperties flagInheritanceMask, PropertyBitMask propertyInheritanceMask)
        {
            int            result = this.propertyUndoStackTop;
            FlagProperties x      = this.flagProperties & flagInheritanceMask;
            FlagProperties x2     = x | flagProperties;

            if (x2 != this.flagProperties)
            {
                this.PushUndoEntry(PropertyId.MaxValue, this.flagProperties);
                this.flagProperties = x2;
            }
            FlagProperties y  = x ^ flagProperties;
            FlagProperties x3 = (flagProperties & y) | (flagProperties & ~x);

            if (x3 != this.distinctFlagProperties)
            {
                this.PushUndoEntry((PropertyId)74, this.distinctFlagProperties);
                this.distinctFlagProperties = x3;
            }
            PropertyBitMask propertyBitMask = this.propertyMask & ~propertyInheritanceMask;

            foreach (PropertyId propertyId in propertyBitMask)
            {
                this.PushUndoEntry(propertyId, this.properties[(int)(propertyId - PropertyId.FontColor)]);
            }
            PropertyBitMask allOff = PropertyBitMask.AllOff;

            this.propertyMask &= propertyInheritanceMask;
            if (propList != null)
            {
                foreach (Property property in propList)
                {
                    if (this.propertyMask.IsSet(property.Id))
                    {
                        if (this.properties[(int)(property.Id - PropertyId.FontColor)] != property.Value)
                        {
                            this.PushUndoEntry(property.Id, this.properties[(int)(property.Id - PropertyId.FontColor)]);
                            if (property.Value.IsNull)
                            {
                                this.propertyMask.Clear(property.Id);
                            }
                            else
                            {
                                this.properties[(int)(property.Id - PropertyId.FontColor)] = property.Value;
                                allOff.Set(property.Id);
                            }
                        }
                    }
                    else if (!property.Value.IsNull)
                    {
                        if (!propertyBitMask.IsSet(property.Id))
                        {
                            this.PushUndoEntry(property.Id, PropertyValue.Null);
                        }
                        this.properties[(int)(property.Id - PropertyId.FontColor)] = property.Value;
                        this.propertyMask.Set(property.Id);
                        allOff.Set(property.Id);
                    }
                }
            }
            if (allOff != this.distinctPropertyMask)
            {
                this.PushUndoEntry(this.distinctPropertyMask);
                this.distinctPropertyMask = allOff;
            }
            return(result);
        }