Ejemplo n.º 1
0
        public override void Restore(Stream str)
        {
            base.Restore(str);

            if (str.ReadByte() == 0)
            {
                Flow        = (UIFlowDirection)str.ReadShort();
                ColumnCount = (byte)str.ReadByte();
                RowCount    = (byte)str.ReadByte();

                short numberOfRelSizes = str.ReadShort();

                if (numberOfRelSizes > 0)
                {
                    RelativeSizes = new short[numberOfRelSizes];

                    for (int i = 0; i < numberOfRelSizes; i++)
                    {
                        RelativeSizes[i] = str.ReadShort();
                    }
                }
                else
                {
                    RelativeSizes = null;
                }

                short numberOfStretches = str.ReadShort();

                if (numberOfStretches > 0)
                {
                    StretchWeights = new short[numberOfStretches];

                    for (int i = 0; i < numberOfStretches; i++)
                    {
                        StretchWeights[i] = str.ReadShort();
                    }
                }
                else
                {
                    StretchWeights = null;
                }

                Spacing = str.ReadShort();

                int numberOfLayoutItems = str.ReadInteger();

                if (numberOfLayoutItems > 0)
                {
                    for (int i = 0; i < numberOfLayoutItems; i++)
                    {
                        TableLayoutItemInfo layoutItem = new TableLayoutItemInfo();
                        layoutItem.Restore(str);

                        LayoutItems.Add(layoutItem);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
 internal UIWindow(UIDispatcher dispatcher)
     : base(dispatcher)
 {
     _flowDirection    = UI.UIFlowDirection.TopToBottom;
     _handle           = CreateHandle(this, Service.ClassAtom);
     _readingDirection = UI.UIReadingDirection.LeftToRight;
Ejemplo n.º 5
0
        public TableLayoutTemplate(FieldList source)
            : this()
        {
            Flow = (UIFlowDirection)(source[DefAgentFieldID.FlowDirection].AsByte() ?? 0);

            ColumnCount = source[DefAgentFieldID.NumberOfColumns].AsByte() ?? 0;
            RowCount    = source[DefAgentFieldID.NumberOfRows].AsByte() ?? 0;

            // relative sizes
            RelativeSizes = new short[ColumnCount];
            List <Int16Field> sizes = source.GetItems <Int16Field>(DefAgentFieldID.RelativeSize);

            for (int i = 0; i < sizes.Count; i++)
            {
                RelativeSizes[i] = sizes[i].Data;
            }

            // stretch weights
            StretchWeights = new short[RowCount];
            List <Int16Field> weights = source.GetItems <Int16Field>(DefAgentFieldID.StretchWeight);

            for (int i = 0; i < weights.Count; i++)
            {
                StretchWeights[i] = weights[i].Data;
            }

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

            // layout items
            List <FieldList> layoutItems = source.GetItems <FieldList>(DefAgentFieldID.LayoutItem);

            foreach (FieldList item in layoutItems)
            {
                TableLayoutItemInfo li = new TableLayoutItemInfo();

                // compulsory bits
                li.SlotX    = item[DefAgentFieldID.XPosition].AsShort() ?? 0;
                li.SlotY    = item[DefAgentFieldID.YPosition].AsShort() ?? 0;
                li.SlotXEnd = (short)((item[DefAgentFieldID.Width].AsShort() ?? 0) + li.SlotX - 1);
                li.SlotYEnd = (short)((item[DefAgentFieldID.Height].AsShort() ?? 0) + li.SlotY - 1);

                li.CropStrategy = (CropStrategy)(item[DefAgentFieldID.CropStrategy].AsNumber() ?? 0);

                // optional bits
                li.LeftMargin   = item[DefAgentFieldID.LeftMargin2].AsShort() ?? 0;
                li.TopMargin    = item[DefAgentFieldID.TopMargin2].AsShort() ?? 0;
                li.RightMargin  = item[DefAgentFieldID.RightMargin].AsShort() ?? 0;
                li.BottomMargin = item[DefAgentFieldID.BottomMargin].AsShort() ?? 0;

                li.LeftPadding   = item[DefAgentFieldID.LeftPadding2].AsShort() ?? 0;
                li.TopPadding    = item[DefAgentFieldID.TopPadding2].AsShort() ?? 0;
                li.RightPadding  = item[DefAgentFieldID.RightPadding].AsShort() ?? 0;
                li.BottomPadding = item[DefAgentFieldID.BottomPadding].AsShort() ?? 0;

                li.MaximumChars = item[DefAgentFieldID.MaximumChars].AsShort() ?? 0;
                li.MaximumLines = item[DefAgentFieldID.MaximumLines].AsShort() ?? 0;
                li.MinimumLines = item[DefAgentFieldID.MinimumLines].AsShort() ?? 0;

                LayoutItems.Add(li);
            }
        }