Beispiel #1
0
 public StyleSet(PaletteEntryType sd)
     : base(PaletteEntryType.StyleSet)
 {
     // if this is not a normal styleset, but instead a "system dialog" one
     // let's remember save that extra bit of data
     SecondaryEntryType = sd;
 }
Beispiel #2
0
        public PaintStyle(FieldList source, Enum sourceID)
            : this()
        {
            if ((source != null) && (sourceID != null))
            {
                PaletteEntryType pst = (PaletteEntryType)(source[sourceID].AsByte() ?? (byte)PaletteEntryType.Inherited);

                switch (pst)
                {
                case PaletteEntryType.Inherited:
                default:
                    StyleType = PaletteEntryType.Inherited;
                    break;

                case PaletteEntryType.DoNotPaint:
                    StyleType = PaletteEntryType.DoNotPaint;
                    break;

                case PaletteEntryType.Colour:
                {
                    StyleType = PaletteEntryType.Colour;

                    Int32Field field = source.GetNextItemAfter <Int32Field>(sourceID, DefAgentFieldID.PaintStyleData);

                    if (field != null)
                    {
                        Data = field.Data;
                    }

                    break;
                }

                case PaletteEntryType.PaletteReference:
                {
                    StyleType = PaletteEntryType.PaletteReference;

                    Int32Field field = source.GetNextItemAfter <Int32Field>(sourceID, DefAgentFieldID.PaintStyleData);

                    if (field != null)
                    {
                        Data = field.Data;
                    }

                    break;
                }
                }
            }
        }
Beispiel #3
0
 public PaletteEntryBase(PaletteEntryType et)
 {
     EntryType = et;
 }
Beispiel #4
0
 public PaintStyle(PaletteEntryType st, int?data)
     : this()
 {
     StyleType = st;
     Data      = data;
 }
Beispiel #5
0
        public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            UnpackDefinitionID(source);

            if (source.GetItemCount(DefAgentFieldID.PaletteEntryIndex) > 0)
            {
                int paletteSize = source[DefAgentFieldID.PaletteSize].AsShort() ?? 0;

                if (paletteSize > 0)
                {
                    // create internal array
                    entries = new PaletteEntryBase[paletteSize];

                    // add entries
                    IEnumerator <IFieldBase> enumerator = source.GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryIndex)
                        {
                            int entryIndex = enumerator.Current.AsShort() ?? -1;

                            if (entryIndex != -1)
                            {
                                enumerator.MoveNext();

                                if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryType)
                                {
                                    PaletteEntryType entryType = (PaletteEntryType)(enumerator.Current.AsByte() ?? 0);
                                    PaletteEntryBase newEntry  = null;

                                    switch (entryType)
                                    {
                                    case PaletteEntryType.Undefined:
                                    default:
                                        break;

                                    case PaletteEntryType.Inherited:
                                        newEntry = new InheritedPaletteEntry();
                                        break;

                                    case PaletteEntryType.DoNotPaint:
                                        newEntry = new DoNotPaintPaletteEntry();
                                        break;

                                    case PaletteEntryType.FontReference:
                                    {
                                        enumerator.MoveNext();

                                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryData)
                                        {
                                            int fontDefID = enumerator.Current.AsInteger() ?? -1;

                                            if (fontDefID != -1)
                                            {
                                                newEntry = new FontReferencePaletteEntry(fontDefID);
                                            }
                                        }

                                        break;
                                    }

                                    case PaletteEntryType.Image:
                                    {
                                        break;
                                    }

                                    case PaletteEntryType.Colour:
                                    {
                                        enumerator.MoveNext();

                                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryData)
                                        {
                                            int?argb = enumerator.Current.AsInteger();

                                            if (argb.HasValue)
                                            {
                                                newEntry = new ColourPaletteEntry(argb.Value);
                                            }
                                        }

                                        break;
                                    }

                                    case PaletteEntryType.LinearGradient:
                                    {
                                        enumerator.MoveNext();

                                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryData)
                                        {
                                            FieldList gradientData = enumerator.Current as FieldList;

                                            if (gradientData != null)
                                            {
                                                newEntry = new LinearGradientPaletteEntry(gradientData);
                                            }
                                        }

                                        break;
                                    }

                                    case PaletteEntryType.ColourSequence:
                                    {
                                        enumerator.MoveNext();

                                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryData)
                                        {
                                            FieldList clsData = enumerator.Current as FieldList;

                                            if (clsData != null)
                                            {
                                                newEntry = new ColourSequencePaletteEntry(clsData);
                                            }
                                        }

                                        break;
                                    }

                                    case PaletteEntryType.PaletteReference:
                                    {
                                        enumerator.MoveNext();

                                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryData)
                                        {
                                            int rf = enumerator.Current.AsInteger() ?? -1;

                                            if (rf != -1)
                                            {
                                                newEntry = new PaletteReferencePaletteEntry(rf);
                                            }
                                        }

                                        break;
                                    }

                                    case PaletteEntryType.StyleSet:
                                    case PaletteEntryType.SystemDialogRoot:
                                    case PaletteEntryType.SystemDialogContainer:
                                    case PaletteEntryType.SystemDialogTitle:
                                    case PaletteEntryType.SystemDialogStaticText:
                                    case PaletteEntryType.SystemDialogListEntry:
                                    case PaletteEntryType.SystemDialogMenuBar:
                                    {
                                        enumerator.MoveNext();

                                        if (enumerator.Current.FieldID == (short)DefAgentFieldID.PaletteEntryData)
                                        {
                                            FieldList styleSetData = enumerator.Current as FieldList;

                                            if (styleSetData != null)
                                            {
                                                StyleSet sst = new StyleSet(entryType);
                                                sst.Unpack(styleSetData);

                                                newEntry = sst;
                                            }
                                        }

                                        break;
                                    }
                                    }

                                    if (newEntry != null)
                                    {
                                        entries[entryIndex] = newEntry;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // done
            IsUnpacked = true;
        }