Exemple #1
0
        public static string GetValue(Stripes strip, Color color)
        {
            int col = Array.IndexOf(StripColors, color);

            if (col == -1)
            {
                return(null);
            }

            switch (strip)
            {
            case Stripes.Digit1: return(Digit1[col]);

            case Stripes.Digit2: return(Digit2[col]);

            case Stripes.Digit3: return(Digit3[col]);

            case Stripes.Multiplier: return(Multiplier[col]);

            case Stripes.Tolerance: return(Tolerance[col]);

            case Stripes.TRC: return(TRC[col]);

            default: return(null);
            }
        }
        public override void Restore(Stream str)
        {
            base.Restore(str);

            if (str.ReadByte() == 0)
            {
                NumberOfFullyVisibleChildrenInHorizontalMode = str.ReadInteger();
                ScrollIndicationType  = (ScrollIndication)str.ReadShort();
                ScrollBarSize         = str.ReadInteger();
                FocusPositionOffset   = str.ReadInteger();
                BlockFocusPosition    = (FocusPosition)str.ReadByte();
                BlockFocusBehaviour   = (FocusBehaviour)str.ReadByte();
                InsertFromTheTop      = str.ReadBool();
                TickerPauseTimeOnItem = str.ReadInteger();
                BlockTickerSpeed      = (TickerSpeed)str.ReadByte();
                TickerDirection       = (TickerFlowDirection)str.ReadByte();
                TicksPerUnit          = str.ReadInteger();
                PixelsPerUnit         = str.ReadInteger();
                AllowAutoScroll       = str.ReadBool();
                FixedScrolling        = str.ReadBool();
                FixedScrollingSize    = str.ReadInteger();
                FixedScrollingJumps   = str.ReadInteger();
                Spacing = str.ReadInteger();
                MaximumNumberOfChildren = str.ReadInteger();

                short numberOfStripes = str.ReadShort();

                if (numberOfStripes > 0)
                {
                    for (int i = 0; i < numberOfStripes; i++)
                    {
                        Stripes.Add(str.ReadShort());
                    }
                }

                Paginate   = str.ReadBool();
                IsFloating = str.ReadBool();
            }
        }
        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;
        }