Beispiel #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);
                    }
                }
            }
        }
Beispiel #2
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);
            }
        }