Exemple #1
0
        //// Drawing Methods

        public static void DrawArrowSlider(UIColor fillColor, UIColor outlineColor, float outlinePadding, float outlineThickness, nfloat percentFull, CGPoint position, CGSize overallSize)
        {
            outlinePadding = 1.0f;
            // General Declarations
            var context = UIGraphics.GetCurrentContext();

            // Variable Declarations
            var sizeOfFill = new CGSize(percentFull * (overallSize.Width - (overallSize.Height / 2.0f)) + (overallSize.Height / 2.0f), overallSize.Height);

            // Outline Drawing
            CGRect outlineRect = new CGRect(position.X, position.Y, overallSize.Width, overallSize.Height);

            context.SaveState();
            context.ClipToRect(outlineRect);
            context.TranslateCTM(outlineRect.X, outlineRect.Y);

            ArrowSliderStyleKit.DrawArrowOutline(new CGRect(0.0f + (outlineThickness / 2.0f), 0.0f + (outlineThickness / 2.0f), outlineRect.Width - outlineThickness, outlineRect.Height - outlineThickness), outlinePadding, outlineThickness, outlineColor);
            context.RestoreState();


            // Fill Drawing
            CGRect fillRect = new CGRect(position.X + outlineThickness, position.Y, sizeOfFill.Width, sizeOfFill.Height);

            context.SaveState();
            context.ClipToRect(fillRect);
            context.TranslateCTM(fillRect.X, fillRect.Y);

            ArrowSliderStyleKit.DrawArrowFill(new CGRect(0.0f, 0.0f, fillRect.Width, fillRect.Height), outlinePadding, fillColor);
            context.RestoreState();
        }
Exemple #2
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            nfloat filled = _percentFilled;

            if (IsDiscrete)
            {
                filled = _discretePercentFilled;
            }

            nfloat  totalPadding = 2.0f * Padding;
            CGPoint location     = new CGPoint(rect.Location.X + Padding, rect.Location.Y + Padding);

            CGSize size = new CGSize(rect.Size.Width - totalPadding, rect.Size.Height - totalPadding);

            ArrowSliderStyleKit.DrawArrowSlider(Color, Color, Padding, BorderWidth, filled, location, size);
        }