public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            UnpackDefinitionID(source);

            // unpacking common attributes
            BackgroundImageCrop   = (CropStrategy)(source[DefAgentFieldID.BackgroundCropStrategy].AsNumber() ?? 0);
            SizeToBackgroundImage = source[DefAgentFieldID.BlockSizeToBackground].AsBoolean() ?? false;

            // unpacking visuals
            FieldList stateData = source[DefAgentFieldID.DataPerComponentState] as FieldList;

            if (stateData != null)
            {
                // set paint styles
                Foreground = new PaintStyle(stateData, DefAgentFieldID.ForegroundPaintStyle);
                Background = new PaintStyle(stateData, DefAgentFieldID.BackgroundPaintStyle);

                // font reference
                Font = stateData[DefAgentFieldID.FontReference].AsShort() ?? 0;
            }

            // rendering hints for the block
            UnpackBlockHints(source);

            // done
            IsUnpacked = true;
        }
        public override void Restore(Stream str)
        {
            base.Restore(str);

            if (str.ReadByte() == 0)
            {
                // background
                if (str.ReadBool())
                {
                    PaintStyle bg = new PaintStyle();
                    bg.Restore(str);

                    Background = bg;
                }
                else
                {
                    Background = null;
                }

                // other settings
                IsZoomEnabled      = str.ReadBool();
                IsScrollEnabled    = str.ReadBool();
                IsAnimationEnabled = str.ReadBool();
                ShowUserLocation   = str.ReadBool();
                Mode = (WaveMapMode)str.ReadShort();
            }
        }
        public void Restore(Stream str)
        {
            if (str.ReadByte() == 0)
            {
                if (str.ReadByte() == 1)
                {
                    Font = str.ReadShort();
                }
                else
                {
                    Font = null;
                }

                if (str.ReadByte() == 1)
                {
                    PaintStyle fg = new PaintStyle();
                    fg.Restore(str);

                    Foreground = fg;
                }
                else
                {
                    Foreground = null;
                }

                if (str.ReadByte() == 1)
                {
                    PaintStyle fg = new PaintStyle();
                    fg.Restore(str);

                    Background = fg;
                }
                else
                {
                    Background = null;
                }

                if (str.ReadByte() == 1)
                {
                    SlotIndex = str.ReadShort();
                }
                else
                {
                    SlotIndex = null;
                }
            }
        }
Example #4
0
        public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            UnpackDefinitionID(source);

            // unpack paint styles
            Foreground = new PaintStyle(source, DefAgentFieldID.ForegroundPaintStyle);
            Background = new PaintStyle(source, DefAgentFieldID.BackgroundPaintStyle);

            // font
            Font = source[DefAgentFieldID.FontReference].AsShort() ?? 0;

            BlockSelectionMode = (GridSelectionMode)(source[DefAgentFieldID.SelectionMode].AsByte() ?? (byte)GridSelectionMode.Cell);
            DefaultSlotDefaultPaletteEntryIndex = source[DefAgentFieldID.DefaultSlotDefaultPaletteEntry].AsShort() ?? -1;

            MinimumColumnWidthPercent = source[DefAgentFieldID.MinimumColumnWidth].AsByte() ?? 20;
            MaximumColumnWidthPercent = source[DefAgentFieldID.MaximumColumnWidth].AsByte() ?? 50;

            Spacing = source[DefAgentFieldID.Spacing].AsShort() ?? 0;

            AreColumnsHeadersFocusable = source[DefAgentFieldID.ColumnsHeadersFocusable].AsBoolean() ?? false;
            AreRowHeadersFocusable     = source[DefAgentFieldID.RowHeadersFocusable].AsBoolean() ?? false;

            KeepColumnHeadersVisible = source[DefAgentFieldID.KeepColumnsHeadersVisible].AsBoolean() ?? false;
            KeepRowHeadersVisible    = source[DefAgentFieldID.KeepRowHeadersVisible].AsBoolean() ?? false;

            // scroll indication
            HorizontalScrollIndicationType = (ScrollIndication)(source[DefAgentFieldID.HorizontalScrollIndicationType].AsByte() ?? (byte)ScrollIndication.Bar);
            VerticalScrollIndicationType   = (ScrollIndication)(source[DefAgentFieldID.VerticalScrollIndicationType].AsByte() ?? (byte)ScrollIndication.Bar);

            UnpackMarginsAndPadding(source);

            ForceContentsToGridWidth = source[DefAgentFieldID.ForceContentToWidth].AsBoolean() ?? false;

            UnpackBlockHints(source);

            // done
            IsUnpacked = true;
        }
Example #5
0
        public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            UnpackDefinitionID(source);

            // unpacking common attributes
            Background = new PaintStyle(source, DefAgentFieldID.BackgroundPaintStyle);
            UnpackMarginsAndPadding(source);

            // rendering hints for the block
            UnpackBlockHints(source);

            // done
            IsUnpacked = true;
        }
Example #6
0
        public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            Foreground = new PaintStyle(source, DefAgentFieldID.ForegroundPaintStyle);
            Background = new PaintStyle(source, DefAgentFieldID.BackgroundPaintStyle);
            Font       = source[DefAgentFieldID.FontReference].AsShort() ?? 0;

            Crop = (CropStrategy)(source[DefAgentFieldID.CropStrategy].AsNumber() ?? 0);

            MarginLeft   = source[DefAgentFieldID.LeftMargin2].AsShort() ?? 0;
            MarginTop    = source[DefAgentFieldID.TopMargin2].AsShort() ?? 0;
            MarginRight  = source[DefAgentFieldID.RightMargin].AsShort() ?? 0;
            MarginBottom = source[DefAgentFieldID.BottomMargin].AsShort() ?? 0;

            // done
            IsUnpacked = true;
        }
Example #7
0
        public void Restore(Stream str)
        {
            if (str.ReadByte() == 0)
            {
                IsUnpacked = str.ReadBool();
                Font       = str.ReadShort();

                if (str.ReadByte() == 1)
                {
                    PaintStyle fg = new PaintStyle();
                    fg.Restore(str);

                    Foreground = fg;
                }
                else
                {
                    Foreground = null;
                }

                if (str.ReadByte() == 1)
                {
                    PaintStyle bg = new PaintStyle();
                    bg.Restore(str);

                    Background = bg;
                }
                else
                {
                    Background = null;
                }

                Crop = (CropStrategy)str.ReadShort();

                MarginLeft   = str.ReadInteger();
                MarginTop    = str.ReadInteger();
                MarginRight  = str.ReadInteger();
                MarginBottom = str.ReadInteger();
            }
        }
        public override void Restore(Stream str)
        {
            base.Restore(str);

            if (str.ReadByte() == 0)
            {
                // background
                if (str.ReadBool())
                {
                    PaintStyle bg = new PaintStyle();
                    bg.Restore(str);

                    Background = bg;
                }
                else
                {
                    Background = null;
                }

                // first focus
                FirstFocus = str.ReadShort();

                // margins
                MarginLeft   = str.ReadInteger();
                MarginTop    = str.ReadInteger();
                MarginRight  = str.ReadInteger();
                MarginBottom = str.ReadInteger();

                // paddings
                PaddingLeft   = str.ReadInteger();
                PaddingTop    = str.ReadInteger();
                PaddingRight  = str.ReadInteger();
                PaddingBottom = str.ReadInteger();

                // other things
                IsHorizontal          = str.ReadBool();
                EnforceRadioBehaviour = str.ReadBool();
            }
        }
Example #9
0
        public override void Restore(Stream str)
        {
            base.Restore(str);

            if (str.ReadByte() == 0)
            {
                Font = str.ReadShort();

                if (str.ReadByte() == 1)
                {
                    PaintStyle fg = new PaintStyle();
                    fg.Restore(str);

                    Foreground = fg;
                }
                else
                {
                    Foreground = null;
                }

                BlockSelectionMode = (GridSelectionMode)str.ReadByte();
                DefaultSlotDefaultPaletteEntryIndex = str.ReadShort();

                MinimumColumnWidthPercent = str.ReadInteger();
                MaximumColumnWidthPercent = str.ReadInteger();

                AreColumnsHeadersFocusable = str.ReadBool();
                AreRowHeadersFocusable     = str.ReadBool();
                KeepColumnHeadersVisible   = str.ReadBool();
                KeepRowHeadersVisible      = str.ReadBool();
                ForceContentsToGridWidth   = str.ReadBool();

                Spacing = str.ReadShort();
                HorizontalScrollIndicationType = (ScrollIndication)str.ReadShort();
                VerticalScrollIndicationType   = (ScrollIndication)str.ReadShort();
            }
        }
        public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            UnpackDefinitionID(source);

            Background = new PaintStyle(source, DefAgentFieldID.BackgroundPaintStyle);
            FirstFocus = source[DefAgentFieldID.FirstFocus].AsByte() ?? (short)-1;

            if (FirstFocus == -1)
            {
                FirstFocus = 0;
            }

            BackgroundImageCrop = (CropStrategy)(source[DefAgentFieldID.BackgroundCropStrategy].AsNumber() ?? 0);

            UIFlowDirection fd = (UIFlowDirection)(source[DefAgentFieldID.FlowDirection].AsByte() ?? (byte)UIFlowDirection.Down);

            IsHorizontal = (fd == UIFlowDirection.Right);

            List <Int16Field> rs = source.GetItems <Int16Field>(DefAgentFieldID.RelativeSize);

            foreach (Int16Field field in rs)
            {
                SizeRatios.Add(field.Data);
            }

            UnpackMarginsAndPadding(source);
            UnpackBlockHints(source);

            // done
            IsUnpacked = true;
        }
Example #11
0
        public void Unpack(FieldList source)
        {
            if (source == null)
            {
                return;
            }

            UnpackDefinitionID(source);

            Background = new PaintStyle(source, DefAgentFieldID.BackgroundPaintStyle);

            UIFlowDirection fd = (UIFlowDirection)(source[DefAgentFieldID.FlowDirection].AsByte() ?? (byte)UIFlowDirection.Down);

            IsHorizontal = (fd == UIFlowDirection.Right);

            BackgroundImageCrop   = (CropStrategy)(source[DefAgentFieldID.BackgroundCropStrategy].AsNumber() ?? 0);
            SizeToBackgroundImage = source[DefAgentFieldID.BlockSizeToBackground].AsBoolean() ?? false;
            ScrollableBackground  = source[DefAgentFieldID.BackgroundScrollable].AsBoolean() ?? false;

            NumberOfFullyVisibleChildrenInHorizontalMode = source[DefAgentFieldID.VisibleChildren].AsShort() ?? 4;

            AllowAutoScroll       = source.GetItemCount(DefAgentFieldID.AllowAutoscroll) > 0;
            EnforceRadioBehaviour = source.GetItemCount(DefAgentFieldID.EnforceRadio) > 0;

            ScrollIndicationType = (ScrollIndication)(source[DefAgentFieldID.ScrollIndicationType].AsByte() ?? (byte)ScrollIndication.Bar);

            Spacing = source[DefAgentFieldID.Spacing].AsShort() ?? 0;

            UnpackMarginsAndPadding(source);

            BlockFocusBehaviour = (FocusBehaviour)(source[DefAgentFieldID.FocusBehaviour].AsByte() ?? (byte)FocusBehaviour.Normal);
            BlockFocusPosition  = (FocusPosition)(source[DefAgentFieldID.FocusPosition].AsByte() ?? (byte)FocusPosition.Free);

            MaximumNumberOfChildren = source[DefAgentFieldID.MaximumChildren].AsShort() ?? DefaultMaximumNumberOfChildren;

            InsertFromTheTop = !(source[DefAgentFieldID.FromBottom].AsBoolean() ?? false);

            BlockTickerSpeed = (TickerSpeed)(source[DefAgentFieldID.TickerSpeed].AsByte() ?? (byte)TickerSpeed.Medium);

            switch (BlockTickerSpeed)
            {
            case TickerSpeed.Slow:
                TicksPerUnit  = 1;
                PixelsPerUnit = 1;
                break;

            case TickerSpeed.Medium:
            default:
                TicksPerUnit  = 0;
                PixelsPerUnit = 1;
                break;

            case TickerSpeed.Fast:
                TicksPerUnit  = 0;
                PixelsPerUnit = 2;
                break;
            }

            TickerDirection = (TickerFlowDirection)(source[DefAgentFieldID.TickerDirection].AsByte() ?? (byte)TickerFlowDirection.Forwards);

            TickerItemPause tickerPauseSetting = (TickerItemPause)(source[DefAgentFieldID.PauseBetweenItem].AsByte() ?? (byte)TickerItemPause.None);

            switch (tickerPauseSetting)
            {
            case TickerItemPause.Long:
                TickerPauseTimeOnItem = 300;
                break;

            case TickerItemPause.Medium:
                TickerPauseTimeOnItem = 150;
                break;

            case TickerItemPause.Short:
                TickerPauseTimeOnItem = 50;
                break;

            case TickerItemPause.None:
            default:
                TickerPauseTimeOnItem = 0;
                break;
            }

            Paginate = source[DefAgentFieldID.UsePagination].AsBoolean() ?? false;

            // get list of striping palette references
            FieldList stripes = source[DefAgentFieldID.StripeStyles] as FieldList;

            if (stripes != null)
            {
                List <Int16Field> stripesData = source.GetItems <Int16Field>(DefAgentFieldID.PaletteEntryIndex);

                foreach (Int16Field field in stripesData)
                {
                    Stripes.Add(field.Data);
                }
            }

            IsFloating = source[DefAgentFieldID.FloatBehaviour].AsBoolean() ?? false;

            UnpackBlockHints(source);

            // done
            IsUnpacked = true;
        }
Example #12
0
        public void Restore(Stream str)
        {
            if (str.ReadByte() == 0)
            {
                if (str.ReadByte() == 1)
                {
                    ComponentFont = str.ReadShort();
                }
                else
                {
                    ComponentFont = null;
                }

                if (str.ReadByte() == 1)
                {
                    PaintStyle fg = new PaintStyle();
                    fg.Restore(str);

                    ComponentForeground = fg;
                }
                else
                {
                    ComponentForeground = null;
                }

                if (str.ReadByte() == 1)
                {
                    PaintStyle bg = new PaintStyle();
                    bg.Restore(str);

                    ComponentBackground = bg;
                }
                else
                {
                    ComponentBackground = null;
                }

                MarginLeft   = str.ReadInteger();
                MarginTop    = str.ReadInteger();
                MarginRight  = str.ReadInteger();
                MarginBottom = str.ReadInteger();

                PaddingLeft   = str.ReadInteger();
                PaddingTop    = str.ReadInteger();
                PaddingRight  = str.ReadInteger();
                PaddingBottom = str.ReadInteger();

                int slotInfoCount = str.ReadInteger();

                if (slotInfoCount > 0)
                {
                    for (int i = 0; i < slotInfoCount; i++)
                    {
                        SlotData slot = new SlotData();
                        slot.Restore(str);

                        SlotInfo.Add(slot);
                    }
                }

                LayoutTemplate = CacheHelper.UnpackFromStream(str) as LayoutTemplateBase;
            }
        }