Exemplo n.º 1
0
    //------------------------------------------------------------------------------------//
    //---------------------------------- METHODS -----------------------------------------//
    //------------------------------------------------------------------------------------//

    public static Color GetConcreteColor(BarColor key)
    {
        Color fetchedColor;

        if (_barColorToConcrete.TryGetValue(key, out fetchedColor))
        {
            return(fetchedColor);
        }

        // No color
        return(Color.clear);
    }
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            float width    = ActualPosition.Width;
            float height   = ActualPosition.Height;
            float barWidth = BarWidth.Value();

            if (barWidth == 0)
            {
                barWidth = 0.001f;
            }


            float availableWidth = width - barWidth;

            float percentage = Value.Value() / MaxValue.Value();

            float sliderHeight = SliderHeight.Value();

            if (sliderHeight == 0)
            {
                sliderHeight = 0.001f;
            }

            float sliderTop = (height / 2f) - (sliderHeight / 2f);

            FloatRectangle sliderRect = new FloatRectangle(0 + ActualPosition.X, sliderTop + ActualPosition.Y, width, sliderHeight);
            FloatRectangle barRect    = new FloatRectangle(availableWidth * percentage + ActualPosition.X, ActualPosition.Y, barWidth, height);

            if (SliderTexture.HasValue())
            {
                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture(SliderTexture.Value(), true), screen.Translate(sliderRect).Value.ToRectangle, Color.White);
                }
            }
            else
            {
                spriteBatch.DrawSolidRectangle(screen.Translate(sliderRect).Value, SliderColor.Value().Value *opacity, clip);
            }

            if (BarTexture.HasValue())
            {
                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture(BarTexture.Value(), true), screen.Translate(barRect).Value.ToRectangle, Color.White);
                }
            }
            else
            {
                spriteBatch.DrawSolidRectangle(screen.Translate(barRect).Value, BarColor.Value().Value *opacity, clip);
            }
        }
Exemplo n.º 3
0
    public void SetBarColor(BarColor barGraphColor)
    {
        switch (barGraphColor)
        {
        case BarColor.Red:
            BarModel.GetComponent <MeshRenderer>().material = Red;
            break;

        case BarColor.Grey:
            BarModel.GetComponent <MeshRenderer>().material = Grey;
            break;

        case BarColor.LightGrey:
            BarModel.GetComponent <MeshRenderer>().material = LightGrey;
            break;

        default:
            break;
        }
    }
Exemplo n.º 4
0
        public void Start()
        {
            if (OnInitialGraphCompleted == null)
            {
                OnInitialGraphCompleted = new UnityEvent();
            }

            if (OnBarPointerDown == null)
            {
                OnBarPointerDown = new OnBarPointerDownEvent();
            }

            if (OnBarPointerUp == null)
            {
                OnBarPointerUp = new OnBarPointerUpEvent();
            }

            if (OnBarHoverEnter == null)
            {
                OnBarHoverEnter = new OnBarHoverEnterEvent();
            }

            if (OnBarHoverExit == null)
            {
                OnBarHoverExit = new OnBarHoverExitEvent();
            }



            if (graphAnimation == AnimatioType.animationWithGradient)
            {
                barColorProperty = BarColor.HeightWiseGradient;
            }

            if (barColorProperty == BarColor.HeightWiseGradient)
            {
                gredientStartColor = HeightWiseGradient.Evaluate(0);
            }

            //Debug.Log("BarScaleFactor " + barScaleFactor);
        }
Exemplo n.º 5
0
        protected override void OnPaintSurface(SKPaintSurfaceEventArgs e)
        {
            base.OnPaintSurface(e);
            var canvas = e.Surface.Canvas;

            canvas.Clear();

            int width  = e.Info.Width;
            int height = e.Info.Height;

            SKPaint backPaint = new SKPaint
            {
                Style = SKPaintStyle.Fill,
                Color = SKColors.WhiteSmoke,
            };

            canvas.DrawRect(new SKRect(0, 0, width, height), backPaint);

            canvas.Save();

            canvas.Translate(width / 2, height / 2);
            canvas.Scale(Math.Min(width / 210f, height / 520f));

            var rect = new SKRect(-100, -100, 100, 100);

            // Add a buffer for the rectangle
            rect.Inflate(-10, -10);

            var bgColorPaint = new SKPaint
            {
                Color       = BGColor.ToSKColor(),
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                StrokeWidth = 0
            };


            var barColorPaint = new SKPaint
            {
                Color       = BarColor.ToSKColor(),
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                StrokeWidth = 0
            };

            var frameColorPaint = new SKPaint
            {
                Color       = FrameColor.ToSKColor(),
                IsAntialias = true,
                Style       = SKPaintStyle.Stroke,
                StrokeWidth = 2
            };

            var skrect      = new SKRect(0, 0, PGWidth, PGHeight);
            var skRoundRect = new SKRoundRect(skrect, PGHeight / 2, PGHeight / 2);

            canvas.DrawRoundRect(0, 0, PGWidth, PGHeight, PGHeight / 2, PGHeight / 2, bgColorPaint);
            canvas.DrawRoundRect(skRoundRect, frameColorPaint);
            canvas.ClipRoundRect(skRoundRect, SKClipOperation.Intersect);

            if (StartColor != Color.Default && EndColor != Color.Default)
            {
                barColorPaint.Shader = SKShader.CreateLinearGradient(
                    new SKPoint(skrect.Left, skrect.Bottom),
                    new SKPoint(skrect.Right, skrect.Top),
                    new SKColor[] { StartColor.ToSKColor(), EndColor.ToSKColor() },
                    new float[] { 0, 1 },
                    SKShaderTileMode.Repeat);
            }
            canvas.DrawRoundRect(0, 0, PGWidth * Progress / 100, PGHeight, PGWidth / 2, 0, barColorPaint);

            canvas.Restore();
        }
Exemplo n.º 6
0
 public BarAttribute(int staticMaxValue, BarColor color = BarColor.Red)
 {
     _usingStaticMaxValue = true;
     this.staticMaxValue  = staticMaxValue;
     this.color           = color;
 }
Exemplo n.º 7
0
 public BarAttribute(string maxValueName = null, BarColor color = BarColor.Red)
 {
     this.maxValueName = maxValueName;
     this.color        = color;
 }
Exemplo n.º 8
0
 public BarAttribute(double maxValue, BarColor color = BarColor.Red)
 {
     _usingStaticMaxValue = true;
     this.staticMaxValue  = (float)maxValue;
     this.color           = color;
 }