/// <summary>
        /// Initializes a new instance of the <see cref="Paint.BrushSizeSelector"/> class.
        /// </summary>
        /// <param name='graphicsDisplay'>
        /// Graphics display.
        /// </param>
        /// <param name='brushSizeDefinition'>
        /// Brush size definition - layout of the control.
        /// </param>
        public BrushSizeSelector(IGraphicsDisplay graphicsDisplay, BrushSizeSelectorDefinition brushSizeDefinition)
            : base(brushSizeDefinition.BackgroundColor,
				brushSizeDefinition.BorderColor,
				brushSizeDefinition.BorderWidth,
				graphicsDisplay,
				brushSizeDefinition.Bounds)
        {
            this.brushSizeDefinition = brushSizeDefinition;

            this.color = brushSizeDefinition.StartColor;
            this.BrushSize = brushSizeDefinition.BrushSizeInitial;
            this.gaugeYPosition = Bounds.Y + brushSizeDefinition.GaugeVerticalMargin + this.brushSizeDefinition.BrushSizeMaximum;

            Rectangle gaugeBounds = new Rectangle(
                this.Bounds.X + ((this.Bounds.Width - this.brushSizeDefinition.GaugeWidth) / 2),
                this.gaugeYPosition,
                this.brushSizeDefinition.GaugeWidth,
                this.Bounds.Height - (this.brushSizeDefinition.BrushSizeMaximum + (this.brushSizeDefinition.GaugeVerticalMargin * 2)));

            float startMarkerValue =
                (float)(this.brushSizeDefinition.BrushSizeInitial - this.brushSizeDefinition.BrushSizeMinimum) /
                (float)(this.brushSizeDefinition.BrushSizeMaximum - this.brushSizeDefinition.BrushSizeMinimum);

            this.brushSizeGauge =
                new VerticalGauge(
                    this.BackgroundColor,
                    graphicsDisplay,
                    gaugeBounds,
                    this.brushSizeDefinition.GaugeMarkerWidth,
                    this.brushSizeDefinition.BorderColor,
                    startMarkerValue);

            this.brushSizeGauge.MarkerChanged += brushSizeGauge_MarkerChanged;
        }
Beispiel #2
0
 public VerticalGaugeZoom(VerticalGauge gauge, Texture2D skin, Texture2D scale)
 {
     this.value                  = 0.0f;
     this.gauge                  = gauge;
     this.bounds.width           = (float)Math.Truncate(gauge.GetWidth() * ZOOM);
     this.bounds.height          = (float)Math.Truncate(gauge.GetHeight() / 3.0f);
     this.scale                  = scale;
     this.skin                   = skin;
     this.gaugeSkinBounds.width  = (float)Math.Truncate(gauge.GetWidth() * ZOOM);
     this.gaugeSkinBounds.height = (float)Math.Truncate(gauge.GetHeight() * ZOOM);
     //
     this.skinBounds.width  = this.bounds.width;
     this.skinBounds.height = this.bounds.height;
 }
Beispiel #3
0
            public void AutoLayout()
            {
                Log.Info("autolayout of gauges on screen");

                int LAYOUT_CELL_X  = NanoGauges.configuration.verticalGaugeWidth + Gauges.LAYOUT_GAP;
                int LAYOUT_CELL_Y  = NanoGauges.configuration.verticalGaugeHeight + Gauges.LAYOUT_GAP;
                int LAYOUT_RANGE_X = 3 * LAYOUT_CELL_X / 2;
                int LAYOUT_RANGE_Y = 3 * LAYOUT_CELL_Y / 2;

                List <AbstractGauge> leftToRight = new List <AbstractGauge>();

                foreach (AbstractGauge gauge in gauges.Values)
                {
                    // Autolayout works with vertical gauges only
                    VerticalGauge vgauge = gauge as VerticalGauge;
                    if (vgauge != null)
                    {
                        if (vgauge.IsVisible())
                        {
                            leftToRight.Add(vgauge);
                        }
                    }
                }

                leftToRight.Sort(
                    delegate(AbstractGauge left, AbstractGauge right)
                {
                    if (left.GetY().In(right.GetY(), right.GetY() + right.GetHeight()) ||
                        right.GetY().In(left.GetY(), left.GetY() + left.GetHeight()))
                    {
                        return(left.GetX().CompareTo(right.GetX()));
                    }
                    return(left.GetY().CompareTo(right.GetY()));
                }
                    );

                int x0 = -1;
                int x  = -1;
                int y  = -1;

                Log.Trace("starting autolayout");
                foreach (AbstractGauge gauge in leftToRight)
                {
                    Log.Detail("autolayout for gauge " + gauge.GetWindowId());
                    Log.Trace("LAYOUT " + gauge);
                    if (x < 0)
                    {
                        Log.Trace(" FIRST NEW LINE " + gauge);
                        x  = gauge.GetX();
                        y  = gauge.GetY();
                        x0 = x;
                    }
                    else
                    {
                        // next line?
                        if (gauge.GetY() > y + gauge.GetHeight())
                        {
                            Log.Trace(" NEXT LINE " + gauge);
                            // next line
                            x = x0;
                            // independent column?
                            if (!gauge.GetX().In(x0 - LAYOUT_RANGE_X, x0 + 1 * LAYOUT_RANGE_X))
                            {
                                Log.Trace(" INDEPENDENT COLUMN " + gauge);
                                // yes, indepedent column
                                x0 = x = gauge.GetX();
                            }
                            //
                            // independent line?
                            if (gauge.GetY() > y + 1 * LAYOUT_RANGE_Y)
                            {
                                Log.Trace(" INDEPENDENT LINE " + gauge);
                                // yes
                                y = gauge.GetY();
                            }
                            else
                            {
                                Log.Trace(" NEW LINE " + gauge);
                                // no
                                y += LAYOUT_CELL_Y;
                            }
                        }
                        else
                        {
                            // line continues
                            // independent column?
                            if (gauge.GetX().In(x, x + 1 * LAYOUT_RANGE_X))
                            {
                                Log.Trace(" CONT LINE " + gauge);
                                // no
                                x += LAYOUT_CELL_X;
                            }
                            else
                            {
                                Log.Trace(" CONT LINE GAP " + gauge);
                                // yes, indepedent column
                                x = gauge.GetX();
                                y = gauge.GetY();
                            }
                            // overflow?
                            if (x + gauge.GetWidth() > Screen.width)
                            {
                                Log.Trace(" OVERFLOW " + gauge);
                                x  = x0;
                                y -= LAYOUT_CELL_Y;
                            }
                        }
                        NanoGauges.configuration.SetWindowPosition(gauge, x, y);
                        gauge.SetPosition(x, y);
                    }
                }
                Log.Trace("autolayout finished");
            }