Example #1
0
            public override void Draw(CGRect rect)
            {
                UIView       head = ((WalkingDead)Superview).head;
                UIBezierPath path = new UIBezierPath();

                path.LineCapStyle = CGLineCap.Round;
                CGRect headFrame = head.Frame;

                if (!MovingRight)
                {
                    rect.X -= 20;
                    path.MoveTo(new CGPoint(rect.GetMidX() + 20, headFrame.GetMaxY() + 10));
                    path.AddLineTo(new CGPoint(rect.GetMidX() + 20 + rect.Size.Width / 6, headFrame.GetMaxY() + 10));
                    path.AddLineTo(new CGPoint(rect.GetMidX() + 20 + rect.Size.Width / 6 + 10, headFrame.GetMaxY() + 10 + 20));
                }
                else
                {
                    path.MoveTo(new CGPoint(rect.GetMidX() - 20, headFrame.GetMaxY() + 10));
                    path.AddLineTo(new CGPoint(rect.GetMidX() - 20 - rect.Size.Width / 6, headFrame.GetMaxY() + 10));
                    path.AddLineTo(new CGPoint(rect.GetMidX() - 20 - rect.Size.Width / 6 - 10, headFrame.GetMaxY() + 10 + 20));
                }
                UIColor.Black.SetStroke();
                path.LineWidth = 12;
                path.Stroke();

                UIColor.White.SetStroke();
                path.LineWidth = 8;
                path.Stroke();
            }
        private UIBezierPath PathForRect(CGRect rect, nfloat arrowOffset)
        {
            if (rect == CGRect.Empty)
            {
                return(null);
            }
            rect = new CGRect(CGPoint.Empty, rect.Size);              // ensure origin is CGPointZero

            // Create rounded rect
            CGRect roundedRect = rect;
            var    size        = roundedRect.Size;

            size.Height     -= ArrowLength;
            roundedRect.Size = size;
            var popUpPath = UIBezierPath.FromRoundedRect(roundedRect, cornerRadius);

            // Create arrow path
            nfloat  maxX      = roundedRect.GetMaxX();        // prevent arrow from extending beyond this point
            nfloat  arrowTipX = rect.GetMidX() + arrowOffset;
            CGPoint tip       = new CGPoint(arrowTipX, rect.GetMaxY());

            nfloat arrowLength = roundedRect.Height / 2.0f;
            nfloat x           = arrowLength * NMath.Tan(45.0f * NMath.PI / 180);    // x = half the length of the base of the arrow

            var arrowPath = new UIBezierPath();

            arrowPath.MoveTo(tip);
            arrowPath.AddLineTo(new CGPoint(NMath.Max(arrowTipX - x, 0), roundedRect.GetMaxY() - arrowLength));
            arrowPath.AddLineTo(new CGPoint(NMath.Min(arrowTipX + x, maxX), roundedRect.GetMaxY() - arrowLength));
            arrowPath.ClosePath();

            popUpPath.AppendPath(arrowPath);

            return(popUpPath);
        }
        public override void DrawFooterForPage(nint index, CGRect footerRect)
        {
            base.DrawFooterForPage(index, footerRect);

            UIFont footerFont = UIFont.SystemFontOfSize(FOOTER_FONT_SIZE);

            //Draw Print date
            NSString dateStr  = new NSString(PAGE_FOOTER_DATE_STR + DateTime.Now.ToString("dd MMM yyyy "));
            CGSize   dateSize = dateStr.StringSize(footerFont);
            CGPoint  point    = new CGPoint(CONTENT_LEFT_RIGHT_MARGIN, footerRect.GetMaxY() - dateSize.Height - FOOTER_BOTTOM_PADDING);

            dateStr.DrawString(point, footerFont);

            //Draw "© 2015 LexisNexis" in the horizontal center of footer
            NSString copyrightStr  = new NSString(PAGE_FOOTER_COPYRIGHT);
            CGSize   copyrightSize = copyrightStr.StringSize(footerFont);

            point = new CGPoint(footerRect.GetMaxX() / 2 - copyrightSize.Width / 2, footerRect.GetMaxY() - copyrightSize.Height - FOOTER_BOTTOM_PADDING);
            copyrightStr.DrawString(point, footerFont);

            //Draw page num in the footer
            NSString pageNumStr  = new NSString(PAGE_FOOTER_PAGE_INFO + (index + 1));
            CGSize   pageNumSize = pageNumStr.StringSize(footerFont);

            point = new CGPoint(footerRect.GetMaxX() - pageNumSize.Width - CONTENT_LEFT_RIGHT_MARGIN, footerRect.GetMaxY() - pageNumSize.Height - FOOTER_BOTTOM_PADDING);
            pageNumStr.DrawString(point, footerFont);
        }
        /// <summary>
        /// Constrains the bounds rect.
        /// </summary>
        /// <returns>The bounds rect.</returns>
        /// <param name="proposedBounds">Proposed bounds.</param>
        public override CoreGraphics.CGRect ConstrainBoundsRect(CoreGraphics.CGRect proposedBounds)
        {
            // Anything to process
            if (DocumentView == null)
            {
                return(base.ConstrainBoundsRect(proposedBounds));
            }

            // Get new bounds and insets
            var newClipBoundsRect = base.ConstrainBoundsRect(proposedBounds);
            var insets            = ConvertContentInsetsToProposedBoundsSize(newClipBoundsRect.Size);

            // Get the insets in terms of the view geometry edges
            var minYInset = IsFlipped ? insets.Top : insets.Bottom;
            var maxYInset = IsFlipped ? insets.Bottom : insets.Top;
            var minXInset = insets.Left;
            var maxXInset = insets.Right;

            // Get and outset the `documentView`'s frame by the scaled contentInsets.
            var documentFrame       = DocumentView.Frame;
            var outsetDocumentFrame = new CGRect(documentFrame.GetMinX() - minXInset,
                                                 documentFrame.GetMinY() - minYInset,
                                                 (documentFrame.Width + (minXInset + maxXInset)),
                                                 (documentFrame.Height + (minYInset + maxYInset)));

            if (newClipBoundsRect.Width > outsetDocumentFrame.Width)
            {
                newClipBoundsRect.X = outsetDocumentFrame.GetMinX() - (newClipBoundsRect.Width - outsetDocumentFrame.Width) / 2.0f;
            }
            else if (newClipBoundsRect.Width < outsetDocumentFrame.Width)
            {
                if (newClipBoundsRect.GetMaxX() > outsetDocumentFrame.GetMaxX())
                {
                    newClipBoundsRect.X = outsetDocumentFrame.GetMaxX() - newClipBoundsRect.Width;
                }
                else if (newClipBoundsRect.GetMinX() < outsetDocumentFrame.GetMinX())
                {
                    newClipBoundsRect.X = outsetDocumentFrame.GetMinX();
                }
            }

            if (newClipBoundsRect.Height > outsetDocumentFrame.Height)
            {
                newClipBoundsRect.Y = outsetDocumentFrame.GetMinY() - (newClipBoundsRect.Height - outsetDocumentFrame.Height) / 2.0f;
            }
            else if (newClipBoundsRect.Height < outsetDocumentFrame.Height)
            {
                if (newClipBoundsRect.GetMaxY() > outsetDocumentFrame.GetMaxY())
                {
                    newClipBoundsRect.Y = outsetDocumentFrame.GetMaxY() - newClipBoundsRect.Height;
                }
                else if (newClipBoundsRect.GetMinY() < outsetDocumentFrame.GetMinY())
                {
                    newClipBoundsRect.Y = outsetDocumentFrame.GetMinY();
                }
            }

            return(BackingAlignedRect(newClipBoundsRect, NSAlignmentOptions.AllEdgesNearest));
        }
Example #5
0
        public override CoreGraphics.CGRect ConstrainBoundsRect(CGRect proposedBounds)
        {
            if (DocumentView == null)
            {
                return(base.ConstrainBoundsRect(proposedBounds));
            }

            CGRect newClipBoundsRect = base.ConstrainBoundsRect(proposedBounds);

            NSEdgeInsets insets = ConvertetContentInsetsToProposedBoundsSize(newClipBoundsRect.Size);

            nfloat minYInset = IsFlipped ? insets.Top : insets.Bottom;
            nfloat maxYInset = IsFlipped ? insets.Bottom : insets.Top;
            nfloat minXInset = insets.Left;
            nfloat maxXInset = insets.Right;

            CGRect documentFrame = DocumentView.Frame;

            CGRect outsetDocumentFrame = new CGRect(
                documentFrame.GetMinX() - minXInset,
                documentFrame.GetMinY() - minYInset,
                documentFrame.Width + (minXInset + maxXInset),
                documentFrame.Height + (minYInset + maxYInset));

            if (newClipBoundsRect.Width > outsetDocumentFrame.Width)
            {
                newClipBoundsRect.X = outsetDocumentFrame.GetMinX() - (newClipBoundsRect.Width - outsetDocumentFrame.Width) / 2.0f;
            }
            else if (newClipBoundsRect.Width < outsetDocumentFrame.Width)
            {
                if (newClipBoundsRect.GetMaxX() > outsetDocumentFrame.GetMaxX())
                {
                    newClipBoundsRect.X = outsetDocumentFrame.GetMaxX() - newClipBoundsRect.Width;
                }
                else if (newClipBoundsRect.GetMinX() < outsetDocumentFrame.GetMinX())
                {
                    newClipBoundsRect.X = outsetDocumentFrame.GetMinX();
                }
            }

            if (newClipBoundsRect.Height > outsetDocumentFrame.Height)
            {
                newClipBoundsRect.Y = outsetDocumentFrame.GetMinY() - (newClipBoundsRect.Height - outsetDocumentFrame.Height) / 2.0f;
            }
            else if (newClipBoundsRect.Height < outsetDocumentFrame.Height)
            {
                if (newClipBoundsRect.GetMaxY() > outsetDocumentFrame.GetMaxY())
                {
                    newClipBoundsRect.Y = outsetDocumentFrame.GetMaxY() - newClipBoundsRect.Height;
                }
                else if (newClipBoundsRect.GetMinY() < outsetDocumentFrame.GetMinY())
                {
                    newClipBoundsRect.Y = outsetDocumentFrame.GetMinY();
                }
            }

            return(BackingAlignedRect(newClipBoundsRect, NSAlignmentOptions.AllEdgesNearest));
        }
        public static CGPoint DrawBarText(CGRect Bounds, CGSize size, nfloat stepInBar)
        {
            var x = Bounds.GetMidX() - size.Width / 2;
            var y = Bounds.GetMaxY() - Bounds.GetMaxY() / 4 - stepInBar - Bounds.GetMaxY() / 30 - size.Height / 2;

            var rect = new CGPoint(x, y);

            return(rect);
        }
Example #7
0
        public static float MaxDistance(CGPoint point, CGRect rect)
        {
            var tl = Distance(point, new CGPoint(x: rect.GetMinX(), y: rect.GetMinY()));
            var tr = Distance(point, new CGPoint(x: rect.GetMaxX(), y: rect.GetMinY()));
            var bl = Distance(point, new CGPoint(x: rect.GetMinX(), y: rect.GetMaxY()));
            var br = Distance(point, new CGPoint(x: rect.GetMaxX(), y: rect.GetMaxY()));

            return(Math.Max(tl, Math.Max(tr, Math.Max(bl, br))));
        }
Example #8
0
 public TrackedPolyRect(CGRect cgRect, UIColor color, TrackedPolyRectStyle style = TrackedPolyRectStyle.Solid)
 {
     this.topLeft     = new CGPoint(cgRect.GetMinX(), cgRect.GetMaxY());
     this.topRight    = new CGPoint(cgRect.GetMaxX(), cgRect.GetMaxY());
     this.bottomLeft  = new CGPoint(cgRect.GetMinX(), cgRect.GetMinY());
     this.bottomRight = new CGPoint(cgRect.GetMaxX(), cgRect.GetMinY());
     this.Color       = color;
     this.Style       = style;
 }
        public override void ViewWillAppear(bool animated)
        {
            CGRect frame = View.Frame;

            frame      = new CGRect(frame.X, frame.Y, frame.Size.Height + 20, frame.Size.Width);
            View.Frame = frame;

            frame = View.Frame;

            var backGround = new UIImageView(UIImage.FromBundle("background.png"));

            backGround.Alpha = 0.34f;
            View.AddSubview(backGround);

            var miniPadFrame = new CGRect(350, 50, 0, 0);

            miniPadView = new MiniPadView(miniPadFrame);
            View.AddSubview(miniPadView);

            var meterFrame = new CGRect(miniPadView.Frame.GetMaxX(), miniPadFrame.Y, 200, miniPadView.Frame.Size.Height);

            meterView = new ZombieMeter(meterFrame);
            View.AddSubview(meterView);

            var statusFrame = new CGRect(100, frame.Size.Height - 350, frame.Size.Width - 100, 100);

            statusView = new StatusView(statusFrame);
            View.AddSubview(statusView);
            statusView.Status = "Loading";

            var buttonsFrame = new CGRect(100, statusFrame.GetMaxY() + 20, frame.Size.Width - 100, 230);

            buttonsView = new ButtonCollectionView(buttonsFrame)
            {
                ShouldGroupAccessibilityChildren = true
            };
            buttonsView.ButtonSelectedEvent += ButtonSelected;
            buttonsView.ButtonDraggedEvent  += ButtonDragged;
            buttonsView.ButtonFinishedEvent += ButtonFinished;
            View.AddSubview(buttonsView);

            var questionFrame = new CGRect(10, statusFrame.GetMaxY() + 110, 80, 80);
            var questionView  = new SymbolMarkView(questionFrame)
            {
                AccessibilityLabel = "Help"
            };

            questionView.TouchUpInside += (s, e) => questionPressed();
            View.AddSubview(questionView);
            questionView.Symbol = "?";

            meterView.ZombieLevel = 0;
            goForthZombies();
            NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("voiceOverFinished:"), null, null);
        }
Example #10
0
        public override void Draw(CGRect rect)
        {
            if (SplitViewController.DividerStyle == MGSplitViewDividerStyle.Thin)
            {
                base.Draw(rect);
            }
            else if (SplitViewController.DividerStyle == MGSplitViewDividerStyle.PaneSplitter)
            {
                // Draw gradient background.
                CGRect       bounds     = Bounds;
                CGColorSpace rgb        = CGColorSpace.CreateDeviceRGB();
                nfloat[]     locations  = { 0, 1 };
                nfloat[]     components = { 0.988f, 0.988f, 0.988f, 1.0f,              // light
                                            0.875f,     0.875f, 0.875f, 1.0f };        // dark
                CGGradient   gradient = new CGGradient(rgb, components, locations);
                CGContext    context = UIGraphics.GetCurrentContext();
                CGPoint      start, end;
                if (SplitViewController.Vertical)
                {
                    // Light left to dark right.
                    start = new CGPoint(bounds.GetMinX(), bounds.GetMidY());
                    end   = new CGPoint(bounds.GetMaxX(), bounds.GetMidY());
                }
                else
                {
                    // Light top to dark bottom.
                    start = new CGPoint(bounds.GetMidX(), bounds.GetMinY());
                    end   = new CGPoint(bounds.GetMidX(), bounds.GetMaxY());
                }
                context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsBeforeStartLocation);

                // Draw borders.
                float borderThickness = 10;
                UIColor.FromWhiteAlpha(0.7f, 1).SetColor();
                CGRect borderRect = bounds;
                if (SplitViewController.Vertical)
                {
                    borderRect.Width = borderThickness;
                    context.FillRect(borderRect);
                    borderRect.X = bounds.GetMaxX() - borderThickness;
                    context.FillRect(borderRect);
                }
                else
                {
                    borderRect.Height = borderThickness;
                    context.FillRect(borderRect);
                    borderRect.Y = bounds.GetMaxY() - borderThickness;
                    context.FillRect(borderRect);
                }

                // Draw grip.
                DrawGripThumbInRect(bounds);
            }
        }
Example #11
0
        public static CGRect RectSimple(CGRect Bounds, nfloat endPoint)
        {
            var x = Bounds.GetMidX() - Bounds.GetMaxX() / 4;
            var y = endPoint;

            var width  = Bounds.GetMaxX() / 2;
            var height = Bounds.GetMaxY() - Bounds.GetMaxY() / 4 - endPoint;

            var rect = new CGRect(x, y, width, height);

            return(rect);
        }
Example #12
0
        public static CGRect RectBar(CGRect Bounds, nfloat stepInBar)
        {
            var x = Bounds.GetMidX() - Bounds.GetMaxX() / 4;
            var y = Bounds.GetMaxY() - Bounds.GetMaxY() / 4 - Bounds.GetMaxY() / 25 - stepInBar;

            var width  = Bounds.GetMaxX() / 2;
            var height = Bounds.GetMaxY() / 20;

            var rect = new CGRect(x, y, width, height);

            return(rect);
        }
Example #13
0
 void DrawBottomBorder(CGContext ctx, CGRect rect)
 {
     if (ViewInfo.BottomBorderThickness <= 0)
     {
         return;
     }
     ctx.SetStrokeColor(ViewInfo.BottomBorderColor.CGColor);
     ctx.SetLineWidth((nfloat)ViewInfo.BottomBorderThickness);
     ctx.BeginPath();
     ctx.MoveTo(rect.GetMinX(), rect.GetMaxY());
     ctx.AddLineToPoint(rect.GetMaxX(), rect.GetMaxY());
     ctx.StrokePath();
 }
Example #14
0
        private void DrawArc(CGContext context, CGRect rect)
        {
            var    radius = rect.GetMaxY() * badgeCornerRoundness;
            var    puffer = new nfloat(Padding(rect));
            var    maxX   = rect.GetMaxX() - puffer;
            var    maxY   = rect.GetMaxY() - puffer;
            var    minX   = rect.GetMinX() + puffer;
            var    minY   = rect.GetMinY() + puffer;
            double pi     = Math.PI;

            context.AddArc(new nfloat(maxX - radius), new nfloat(minY + radius), new nfloat(radius), new nfloat(pi + (pi / 2)), 0, false);
            context.AddArc(new nfloat(maxX - radius), new nfloat(minY - radius), new nfloat(radius), 0, new nfloat(pi / 2), false);
        }
Example #15
0
        private CGPath GetShadowPath(CGRect biggerRect)
        {
            var shadowPath = new UIBezierPath();

            shadowPath.MoveTo(new CGPoint(biggerRect.GetMinX(), biggerRect.GetMinY()));
            shadowPath.AddLineTo(new CGPoint(biggerRect.GetMinX(), biggerRect.GetMaxY()));
            shadowPath.AddLineTo(new CGPoint(biggerRect.GetMaxX(), biggerRect.GetMaxY()));
            shadowPath.AddLineTo(new CGPoint(biggerRect.GetMaxX(), biggerRect.GetMinY()));
            shadowPath.AddLineTo(new CGPoint(biggerRect.GetMinX(), biggerRect.GetMinY()));;
            shadowPath.AppendPath(UIBezierPath.FromRoundedRect(Bounds, RadiusCorner));
            shadowPath.UsesEvenOddFillRule = true;

            return(shadowPath.CGPath);
        }
Example #16
0
        internal static CGPath CreateClippingPath(CGRect rect, float radius)
        {
            var path = new CGPath();

            path.MoveToPoint(rect.GetMinX(), rect.GetMinY());
            path.AddLineToPoint(rect.GetMinX(), rect.GetMaxY() - radius);
            path.AddArcToPoint(rect.GetMinX(), rect.GetMaxY(), rect.GetMinX() + radius, rect.GetMaxY(), radius);
            path.AddLineToPoint(rect.GetMaxX() - radius, rect.GetMaxY());
            path.AddArcToPoint(rect.GetMaxX(), rect.GetMaxY(), rect.GetMaxX(), rect.GetMaxY() - radius, radius);
            path.AddLineToPoint(rect.GetMaxX(), rect.GetMinY());
            path.CloseSubpath();

            return(path);
        }
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);
            var start = new CGPoint(rect.GetMinX(), rect.GetMaxY());
            var end   = new CGPoint(rect.GetMaxX(), rect.GetMaxY());

            var path = new UIBezierPath();

            path.MoveTo(start);
            path.AddLineTo(end);
            path.LineWidth = 2.0f;

            ((EntryLine)Element).BorderColor.ToUIColor().SetStroke();
            path.Stroke();
        }
Example #18
0
		private void ComputeDifferenceBetweenRect (CGRect oldRect, CGRect newRect, Action<CGRect> removedHandler, Action<CGRect> addedHandler)
		{
			if (CGRect.Intersect (newRect, oldRect) != CGRect.Empty) {
				var oldMaxY = oldRect.GetMaxY ();
				var oldMinY = oldRect.GetMinY ();
				var newMaxY = newRect.GetMaxY ();
				var newMinY = newRect.GetMinY ();

				if (newMaxY > oldMaxY) {
					var rectToAdd = new CGRect (newRect.X, oldMaxY, newRect.Size.Width, (newMaxY - oldMaxY));
					addedHandler (rectToAdd);
				}
				if (oldMinY > newMinY) {
					var rectToAdd = new CGRect (newRect.X, newMinY, newRect.Size.Width, (oldMinY - newMinY));
					addedHandler (rectToAdd);
				}
				if (newMaxY < oldMaxY) {
					var rectToRemove = new CGRect (newRect.X, newMaxY, newRect.Size.Width, (oldMaxY - newMaxY));
					removedHandler (rectToRemove);
				}
				if (oldMinY < newMinY) {
					var rectToRemove = new CGRect (newRect.X, oldMinY, newRect.Size.Width, (newMinY - oldMinY));
					removedHandler (rectToRemove);
				}
			} else {
				addedHandler (newRect);
				removedHandler (oldRect);
			}
		}
Example #19
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            if (BorderWidthAll > 0)
            {
                BorderWidth = new UIEdgeInsets(BorderWidthAll, BorderWidthAll, BorderWidthAll, BorderWidthAll);
            }

            if (BorderColorAll != null)
            {
                BorderColorTop = BorderColorBottom = BorderColorLeft = BorderColorRight = BorderColorAll;
            }

            var xMin = rect.GetMinX();
            var xMax = rect.GetMaxX();

            var yMin = rect.GetMinY();
            var yMax = rect.GetMaxY();

            var fWidth  = this.Frame.Size.Width;
            var fHeight = this.Frame.Size.Height;

            var context = UIGraphics.GetCurrentContext();

            DrawBorders(context, xMin, xMax, yMin, yMax, fWidth, fHeight);
        }
Example #20
0
        private void DrawBox(CGContext context, CGRect trect, float fRadius)
        {
            float fWidth  = (float)trect.Width;
            float fHeight = (float)trect.Height;

            if (fRadius > fWidth / 2.0f)
            {
                fRadius = fWidth / 2.0f;
            }
            if (fRadius > fHeight / 2.0f)
            {
                fRadius = fHeight / 2.0f;
            }

            float fMinX = (float)trect.GetMinX();
            float fMidX = (float)trect.GetMidX();
            float fMaxX = (float)trect.GetMaxX();
            float fMinY = (float)trect.GetMinY();
            float fMidY = (float)trect.GetMidY();
            float fMaxY = (float)trect.GetMaxY();

            context.MoveTo(fMinX, fMidY);
            context.AddArcToPoint(fMinX, fMinY, fMidX / 2, fMinY, fRadius);
            context.AddLineToPoint(fMidX - 5, fMinY);
            context.AddLineToPoint(fMidX, fMinY - 5);
            context.AddLineToPoint(fMidX + 5, fMinY);
            context.AddArcToPoint(fMaxX, fMinY, fMaxX, fMidY, fRadius);
            context.AddArcToPoint(fMaxX, fMaxY, fMidX, fMaxY, fRadius);
            context.AddArcToPoint(fMinX, fMaxY, fMinX, fMidY, fRadius);
        }
Example #21
0
 CGRect CGRectFlipped(CGRect rect, CGRect bounds)
 {
     return(new CGRect(rect.GetMinX(),
                       bounds.GetMaxY() - rect.GetMaxY(),
                       rect.Width,
                       rect.Height));
 }
        //Generated with PaintCode 2.2
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            // General Declarations
            var colorSpace = CGColorSpace.CreateDeviceRGB();
            var context = UIGraphics.GetCurrentContext();

            // Color Declarations
            var darkBlue = UIColor.FromRGBA(0.053f, 0.123f, 0.198f, 1.000f);
            var lightBlue = UIColor.FromRGBA(0.191f, 0.619f, 0.845f, 1.000f);

            // Gradient Declarations
            var backgroundGradientColors = new CGColor [] {lightBlue.CGColor, darkBlue.CGColor};
            var backgroundGradientLocations = new nfloat [] {0.0f, 1.0f};
            var backgroundGradient = new CGGradient(colorSpace, backgroundGradientColors, backgroundGradientLocations);

            // Rectangle Drawing
            var rectangleRect = new CGRect(rect.GetMinX() + (float)Math.Floor(rect.Width * -0.12917f + 0.5f), rect.GetMinY() + (float)Math.Floor(rect.Height * 0.00000f + 0.5f), (float)Math.Floor(rect.Width * 1.00000f + 0.5f) - (float)Math.Floor(rect.Width * -0.12917f + 0.5f), (float)Math.Floor(rect.Height * 1.00000f + 0.5f) - (float)Math.Floor(rect.Height * 0.00000f + 0.5f));
            var rectanglePath = UIBezierPath.FromRect(rectangleRect);
            context.SaveState();
            rectanglePath.AddClip();
            context.DrawLinearGradient(backgroundGradient,
                new PointF((float)rectangleRect.GetMidX(), (float)rectangleRect.GetMinY()),
                new PointF((float)rectangleRect.GetMidX(), (float)rectangleRect.GetMaxY()),
                0);
            context.RestoreState();
        }
Example #23
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            if (BorderWidthAll > 0)
            {
                BorderWidth = new UIEdgeInsets(BorderWidthAll, BorderWidthAll, BorderWidthAll, BorderWidthAll);
            }

            if (BorderColorAll != null)
            {
                BorderColorTop = BorderColorBottom = BorderColorLeft = BorderColorRight = BorderColorAll;
            }

            var xMin = rect.GetMinX();
            var xMax = rect.GetMaxX();

            var yMin = rect.GetMinY();
            var yMax = rect.GetMaxY();

            var fWidth = this.Frame.Size.Width;
            var fHeight = this.Frame.Size.Height;

            var context = UIGraphics.GetCurrentContext();

            if (context != null)
                DrawBorders(context, xMin, xMax, yMin, yMax, fWidth, fHeight);
        }
        void MoveJaguarPrintToPresentedPosition(bool presentedPosition)
        {
            CGSize horizontalJaguarSize = jaguarPrintImageH.Size;
            CGSize verticalJaguarSize   = jaguarPrintImageV.Size;
            CGRect frameOfView          = FrameOfPresentedViewInContainerView;
            CGRect containerFrame       = ContainerView.Frame;

            CGRect topFrame, bottomFrame, leftFrame, rightFrame;

            topFrame        = bottomFrame = leftFrame = rightFrame = CGRect.Empty;
            topFrame.Height = bottomFrame.Height = horizontalJaguarSize.Height;
            topFrame.Width  = bottomFrame.Width = frameOfView.Width;

            leftFrame.Width  = rightFrame.Width = verticalJaguarSize.Width;
            leftFrame.Height = rightFrame.Height = frameOfView.Height;

            topFrame.X    = frameOfView.X;
            bottomFrame.X = frameOfView.X;

            leftFrame.Y  = frameOfView.Y;
            rightFrame.Y = frameOfView.Y;

            CGRect frameToAlignAround = presentedPosition ? frameOfView : containerFrame;

            topFrame.Y    = frameToAlignAround.GetMinY() - horizontalJaguarSize.Height;
            bottomFrame.Y = frameToAlignAround.GetMaxY();
            leftFrame.X   = frameToAlignAround.GetMinX() - verticalJaguarSize.Width;
            rightFrame.X  = frameToAlignAround.GetMaxX();

            topJaguarPrintImageView.Frame    = topFrame;
            bottomJaguarPrintImageView.Frame = bottomFrame;
            leftJaguarPrintImageView.Frame   = leftFrame;
            rightJaguarPrintImageView.Frame  = rightFrame;
        }
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);
            var startingPoint = new CGPoint(x: rect.GetMinX(), y: rect.GetMaxY() - 10);
            var endingPoint   = new CGPoint(x: rect.GetMaxX(), y: rect.GetMaxY() - 10);

            CGContext context = UIGraphics.GetCurrentContext();

            context.SetLineWidth(1);
            UIColor.Clear.SetFill();
            UIColor.FromRGB(177, 177, 177).SetStroke();
            var currentPath = new CGPath();

            currentPath.AddLines(new CGPoint[] { startingPoint, endingPoint });
            context.AddPath(currentPath);
            context.DrawPath(CGPathDrawingMode.Stroke);
            context.SaveState();
        }
Example #26
0
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            CGRect lottieRect = new CGRect(0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height * 0.3);

            this.lottieLogo.Frame   = lottieRect;
            this.lottieButton.Frame = lottieRect;

            this.tableView.Frame = new CGRect(0, lottieRect.GetMaxY(), lottieRect.Width, this.View.Bounds.Size.Height - lottieRect.GetMaxY());
        }
		public override void ViewWillAppear (bool animated)
		{
			CGRect frame = View.Frame;

			var backGround = new UIImageView (UIImage.FromBundle ("background.png"));
			backGround.Alpha = 0.34f;
			View.AddSubview (backGround);

			var miniPadFrame = new CGRect (350, 50, 0, 0);
			miniPadView = new MiniPadView (miniPadFrame);
			View.AddSubview (miniPadView);

			var meterFrame = new CGRect (miniPadView.Frame.GetMaxX (), miniPadFrame.Y, 200, miniPadView.Frame.Size.Height);
			meterView = new ZombieMeter (meterFrame);
			View.AddSubview (meterView);

			var statusFrame = new CGRect (100, frame.Size.Height - 350, frame.Size.Width - 100, 100);
			statusView = new StatusView (statusFrame);
			View.AddSubview (statusView);
			statusView.Status = "Loading";

			var buttonsFrame = new CGRect (100, statusFrame.GetMaxY () + 20, frame.Size.Width - 100, 230);
			buttonsView = new ButtonCollectionView (buttonsFrame) {
				ShouldGroupAccessibilityChildren = true
			};
			buttonsView.ButtonSelectedEvent += ButtonSelected;
			buttonsView.ButtonDraggedEvent += ButtonDragged;
			buttonsView.ButtonFinishedEvent += ButtonFinished;
			View.AddSubview (buttonsView);

			var questionFrame = new CGRect (10, statusFrame.GetMaxY () + 110, 80, 80);
			var questionView = new SymbolMarkView (questionFrame) {
				AccessibilityLabel = "Help"
			};
			questionView.TouchUpInside += (s, e) => questionPressed ();
			View.AddSubview (questionView);
			questionView.Symbol = "?";

			meterView.ZombieLevel = 0;
			goForthZombies ();
			NSNotificationCenter.DefaultCenter.AddObserver (this, new Selector ("voiceOverFinished:"), null, null);
		}
Example #28
0
            public override void Draw(CGRect rect)
            {
                UIView       body      = ((WalkingDead)Superview).body;
                CGRect       bodyFrame = body.Frame;
                float        legWidth  = (float)rect.Size.Width / 3;
                UIBezierPath path      = UIBezierPath.FromRoundedRect(new CGRect(20, bodyFrame.GetMaxY() - 5, legWidth, rect.Size.Height * .25f), UIRectCorner.TopRight | UIRectCorner.BottomRight, new CGSize(3, 3));

                path.LineWidth = 2;
                UIColor.White.SetFill();
                path.Fill();
                path.Stroke();
            }
Example #29
0
            public override void DrawInContext(CoreGraphics.CGContext ctx)
            {
                CGRect       rect       = this.BoundsRect();
                CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();

                nfloat [] colors = new nfloat[] {
                    0.42f, 0.66f, 0.31f, 1.0f,
                    0.95f, 0.76f, 0.20f, 1.0f,
                    0.80f, 0.25f, 0.15f, 1.0f
                };

                CGGradient gradient = new CGGradient(colorSpace, colors, null);

                nuint tickSpaces  = this.Axis.MajorTickCount - 1;
                nuint pointsCount = 5;

                if (this.Chart.Frame.Size.Height < this.Chart.Frame.Size.Width)
                {
                    pointsCount = 3;
                }

                nfloat diameter           = 8;
                nfloat spaceHeight        = rect.Size.Height / tickSpaces;
                nfloat spacing            = (spaceHeight - (pointsCount * diameter)) / (pointsCount + 1);
                nuint  allPointsCount     = pointsCount * tickSpaces;
                CGPath multipleCirclePath = new CGPath();
                double y = rect.GetMinY() + diameter / 2.0f + spacing;

                for (uint i = 1; i <= allPointsCount; i++)
                {
                    CGPoint center = new CGPoint(rect.GetMidX(), y);
                    CGPath  path   = new CGPath();
                    path.AddArc(center.X, center.Y, (nfloat)diameter / 2.0f, 0, (nfloat)Math.PI * 2, true);
                    multipleCirclePath.AddPath(path);
                    y += spacing + diameter;
                    if (i % pointsCount == 0)
                    {
                        y += spacing;
                    }
                }

                ctx.SaveState();
                ctx.AddPath(multipleCirclePath);
                ctx.Clip();
                CGPoint startPoint = new CGPoint(rect.GetMidX(), rect.GetMinY());
                CGPoint endPoint   = new CGPoint(rect.GetMidX(), rect.GetMaxY());

                ctx.DrawLinearGradient(gradient, startPoint, endPoint, 0);
                ctx.RestoreState();

                base.DrawInContext(ctx);
            }
Example #30
0
        public override void Draw(CGRect rect)
        {
            CGContext ctx = UIGraphics.GetCurrentContext();

            if (ViewInfo.LeftBorderThickness > 0)
            {
                ctx.SetStrokeColor(ViewInfo.LeftBorderColor.CGColor);
                ctx.SetLineWidth((nfloat)ViewInfo.LeftBorderThickness);
                ctx.BeginPath();
                ctx.MoveTo(rect.GetMinX(), rect.GetMinY());
                ctx.AddLineToPoint(rect.GetMinX(), rect.GetMaxY());
                ctx.StrokePath();
            }
            if (ViewInfo.BottomBorderThickness > 0)
            {
                ctx.SetStrokeColor(ViewInfo.BottomBorderColor.CGColor);
                ctx.SetLineWidth((nfloat)ViewInfo.BottomBorderThickness);
                ctx.BeginPath();
                ctx.MoveTo(rect.GetMinX(), rect.GetMaxY());
                ctx.AddLineToPoint(rect.GetMaxX(), rect.GetMaxY());
                ctx.StrokePath();
            }
        }
Example #31
0
        public override void Draw(CGRect rect)
        {
            var path = new UIBezierPath();

            path.LineWidth    = LineWidth;
            path.LineCapStyle = CGLineCap.Round;


            var iconFrame = new CGRect(
                x: (rect.Width - IconSize) / 2.0,
                y: (rect.Height - IconSize) / 2.0,
                width: IconSize,
                height: IconSize
                );

            path.MoveTo(iconFrame.Location);
            path.AddLineTo(new CGPoint(iconFrame.GetMaxX(), iconFrame.GetMaxY()));
            path.MoveTo(new CGPoint(iconFrame.GetMaxX(), iconFrame.GetMinY()));
            path.AddLineTo(new CGPoint(iconFrame.GetMinX(), iconFrame.GetMaxY()));

            LineColor.SetStroke();
            path.Stroke();
        }
Example #32
0
        public static UIEdgeInsets TPKeyboardAvoiding_contentInsetForKeyboard(this UIScrollView scrollView)
        {
            //TPKeyboardAvoidingState state = KeyboardAvoidingState();
            if (State == null)
            {
                State = new TPKeyboardAvoidingState();
            }

            UIEdgeInsets newInset     = scrollView.ContentInset;
            CGRect       keyboardRect = State.keyboardRect;

            newInset.Bottom = (nfloat)(keyboardRect.Size.Height - Math.Max((keyboardRect.GetMaxY() - scrollView.Bounds.GetMaxY()), 0));
            return(newInset);
        }
Example #33
0
        public static void DrawArrowFill(CGRect frameFill, float outlinePadding, UIColor fillColor)
        {
            // FillShape Drawing
            UIBezierPath fillShapePath = new UIBezierPath();

            fillShapePath.MoveTo(new CGPoint(frameFill.GetMinX() + outlinePadding, frameFill.GetMaxY() - outlinePadding));
            fillShapePath.AddLineTo(new CGPoint(frameFill.GetMaxX() - (frameFill.Height / 2.0f), frameFill.GetMaxY() - outlinePadding));
            fillShapePath.AddLineTo(new CGPoint(frameFill.GetMaxX() - outlinePadding, frameFill.GetMinY() + 0.50000f * frameFill.Height));
            fillShapePath.AddLineTo(new CGPoint(frameFill.GetMaxX() - (frameFill.Height / 2.0f), frameFill.GetMinY() + outlinePadding));
            fillShapePath.AddLineTo(new CGPoint(frameFill.GetMinX() + outlinePadding, frameFill.GetMinY() + outlinePadding));
            fillShapePath.AddLineTo(new CGPoint(frameFill.GetMinX() + outlinePadding, frameFill.GetMaxY() - outlinePadding));
            fillShapePath.ClosePath();
            fillColor.SetFill();
            fillShapePath.Fill();
        }
        public override void Draw(CGRect rect)
        {
            using (var context = UIGraphics.GetCurrentContext ()) {

                // get the scale from the context by getting the current transform matrix, then asking for
                // its "a" component, which is one of the two scale components. We could also ask for "d".
                // This assumes (safely) that the view is being scaled equally in both dimensions.
                var scale = context.GetCTM ().xx;
                CATiledLayer tiledLayer = (CATiledLayer)this.Layer;
                var tileSize = tiledLayer.TileSize;

                // Even at scales lower than 100%, we are drawing into a rect in the coordinate system of the full
                // image. One tile at 50% covers the width (in original image coordinates) of two tiles at 100%.
                // So at 50% we need to stretch our tiles to double the width and height; at 25% we need to stretch
                // them to quadruple the width and height; and so on.
                // (Note that this means that we are drawing very blurry images as the scale gets low. At 12.5%,
                // our lowest scale, we are stretching about 6 small tiles to fill the entire original image area.
                // But this is okay, because the big blurry image we're drawing here will be scaled way down before
                // it is displayed.)
                tileSize.Width /= scale;
                tileSize.Height /= scale;

                // calculate the rows and columns of tiles that intersect the rect we have been asked to draw
                int firstCol = (int)Math.Floor (rect.GetMinX () / tileSize.Width);
                int lastCol = (int)Math.Floor ((rect.GetMaxX () - 1) / tileSize.Width);
                int firstRow = (int)Math.Floor (rect.GetMinY () / tileSize.Height);
                int lastRow = (int)Math.Floor ((rect.GetMaxY () - 1) / tileSize.Height);

                for (int row = firstRow; row <= lastRow; row++) {
                    for (int col = firstCol; col <= lastCol; col++) {

                        UIImage tile = TileForScale ((float)scale, row, col);
                        var tileRect = new CGRect (tileSize.Width * col, tileSize.Height * row, tileSize.Width, tileSize.Height);
                        // if the tile would stick outside of our bounds, we need to truncate it so as to avoid
                        // stretching out the partial tiles at the right and bottom edges
                        tileRect.Intersect (this.Bounds);
                        tile.Draw (tileRect);
                    }
                }
            }
        }
Example #35
0
 private void drawArc(CGContext context, CGRect rect)
 {
     var radius = rect.GetMaxY() * badgeCornerRoundness;
     var puffer = new nfloat(Padding(rect));
     var maxX = rect.GetMaxX() - puffer;
     var maxY = rect.GetMaxY() - puffer;
     var minX = rect.GetMinX() + puffer;
     var minY = rect.GetMinY() + puffer;
     double pi = Math.PI;
     context.AddArc(new nfloat(maxX - radius), new nfloat(minY + radius), new nfloat(radius), new nfloat(pi + (pi / 2)), 0, false);
     context.AddArc(new nfloat(maxX - radius), new nfloat(minY - radius), new nfloat(radius), 0, new nfloat(pi / 2), false);
 }
		static void ComputeDifferenceBetweenRect (CGRect oldRect, CGRect newRect, Action<CGRect> removedHandler, Action<CGRect> addedHandler)
		{
			if (!oldRect.IntersectsWith (newRect)) {
				addedHandler (newRect);
				removedHandler (oldRect);
			} else {
				nfloat oldMaxY = oldRect.GetMaxY ();
				nfloat oldMinY = oldRect.GetMinY ();
				nfloat newMaxY = newRect.GetMaxY ();
				nfloat newMinY = newRect.GetMinY ();

				if (newMaxY > oldMaxY) {
					var rectToAdd = new CGRect (newRect.X, oldMaxY, newRect.Width, newMaxY - oldMaxY);
					addedHandler(rectToAdd);
				}

				if (oldMinY > newMinY) {
					var rectToAdd = new CGRect (newRect.X, newMinY, newRect.Width, oldMinY - newMinY);
					addedHandler(rectToAdd);
				}

				if (newMaxY < oldMaxY) {
					var rectToRemove = new CGRect (newRect.X, newMaxY, newRect.Width, oldMaxY - newMaxY);
					removedHandler(rectToRemove);
				}

				if (oldMinY < newMinY) {
					var rectToRemove = new CGRect (newRect.X, oldMinY, newRect.Width, newMinY - oldMinY);
					removedHandler(rectToRemove);
				}
			}
		}
Example #37
0
		public override void Draw (CGRect rect)
		{
			base.Draw (rect);


			_highTemps = null;
			_lowTemps = null;

			_hourlyTemps = null;


			if (Forecasts.Count == 0 || Hourly.Count == 0) return;


			graphRect = new CGRect (rect.X + padding, rect.Y + padding, rect.Width - (padding * 2), rect.Height - (padding * 2));


			var days = Hourly.GroupBy (h => h.FCTTIME.mday).Select (g => g.First ().FCTTIME.weekday_name_abbrev).ToList ();

			var dayCount = hourly ? days.Count : Forecasts.Count;


			var xAxisScale = (graphRect.Width + padding / 2) / dayCount;

			inset = xAxisScale / 2;


			var highest = (nfloat)(hourly ? HourlyTemps.Max () : HighTemps.Max ());
			var lowest = (nfloat)(hourly ? HourlyTemps.Min () : LowTemps.Min ());


			scaleHigh = NMath.Round (highest, MidpointRounding.AwayFromZero);
			scaleLow = lowest < 0 ? NMath.Round (lowest, MidpointRounding.AwayFromZero) : NMath.Round (lowest);

			var rangePadding = Settings.UomTemperature.IsImperial () ? scalePadding : (scalePadding / 2);


			scaleHigh += rangePadding;
			scaleLow -= rangePadding;

			scaleRange = scaleHigh - scaleLow;


			var scaleIncrement = scaleRange / dividerCount;

			scaleX = (graphRect.Width - inset) / (hourly ? HourlyTemps.Count : Forecasts.Count);
			scaleY = graphRect.Height / dividerCount;


			nfloat x, y;


			using (CGContext ctx = UIGraphics.GetCurrentContext ()) {

				// Draw x and y axis
				using (UIColor color = UIColor.White) {

					color.SetStroke ();
					ctx.SetLineWidth (1);

					using (CGPath p = new CGPath ()) {

						p.MoveToPoint (graphRect.GetMinX (), graphRect.GetMaxY ());

						p.AddLines (new [] {
							new CGPoint (graphRect.GetMinX (), graphRect.GetMinY ()),
							new CGPoint (graphRect.GetMinX (), graphRect.GetMaxY ()),
							new CGPoint (graphRect.GetMaxX (), graphRect.GetMaxY ())
						});

						ctx.AddPath (p);
						ctx.DrawPath (CGPathDrawingMode.Stroke);
					}
				}


				// Draw horizontal gridlines
				using (UIColor color = UIColor.Black.ColorWithAlpha (0.08f)) {

					for (int i = 1; i < dividerCount; i += 2) {

						y = (i + 1) * scaleY;

						color.SetFill ();
						ctx.FillRect (new CGRect (graphRect.GetMinX (), graphRect.GetMaxY () - y, graphRect.Width, scaleY));
						ctx.StrokePath ();
					}
				}



				drawLines ();


				// Draw y-axis labels

				nfloat yStep = scaleLow;

				ctx.SaveState ();
				ctx.TranslateCTM (0, rect.Height);
				ctx.ScaleCTM (1, -1);


				for (int i = 0; i <= dividerCount; i++) {

					y = padding + (i * scaleY);

					var step = NMath.Round (yStep).ToString ();

					drawLabel (ctx, rect, y, padding - 6, UITextAlignment.Right, step, false, true);

					yStep += scaleIncrement;
				}


				// Draw x-axis labels
				for (int i = 0; i < dayCount; i++) {

					x = padding + (i * xAxisScale);

					drawLabel (ctx, rect, padding - 6, x, UITextAlignment.Left, hourly ? days [i] : Forecasts [i]?.date?.weekday_short, false);
				}

				ctx.RestoreState ();
			}

		}
		private void ComputeDifferenceBetweenRect (CGRect oldRect, CGRect newRect, Action<CGRect> removedHandler, Action<CGRect> addedHandler)
		{
			if (CGRect.Intersect (newRect, oldRect) != CGRect.Empty) {
				var oldMaxY = oldRect.GetMaxY ();
				var oldMinY = oldRect.GetMinY ();
				var newMaxY = newRect.GetMaxY ();
				var newMinY = newRect.GetMinY ();

				if (newMaxY > oldMaxY) {
					var rectToAdd = new CGRect (newRect.X, oldMaxY, newRect.Size.Width, (newMaxY - oldMaxY));
					addedHandler (rectToAdd);
				}
				if (oldMinY > newMinY) {
					var rectToAdd = new CGRect (newRect.X, newMinY, newRect.Size.Width, (oldMinY - newMinY));
					addedHandler (rectToAdd);
				}
				if (newMaxY < oldMaxY) {
					var rectToRemove = new CGRect (newRect.X, newMaxY, newRect.Size.Width, (oldMaxY - newMaxY));
					removedHandler (rectToRemove);
				}
				if (oldMinY < newMinY) {
					var rectToRemove = new CGRect (newRect.X, oldMinY, newRect.Size.Width, (newMinY - oldMinY));
					removedHandler (rectToRemove);
				}
			} else {
				addedHandler (newRect);
				removedHandler (oldRect);
			}
		}
Example #39
0
		public void DisplayPixelBuffer (CVPixelBuffer pixelBuffer)
		{
			DrawTextInCorner (pixelBuffer);
			CVReturn error;

			if (pixelBuffer != null) {
				int frameWidth = (int)pixelBuffer.Width;
				int frameHeight = (int)pixelBuffer.Height;

				if (videoTextureCache == null) {
					Console.WriteLine ("No video texture cache");
					return;
				}

				CleanUpTextures ();
				CVAttachmentMode attachmentMode;
				var colorAttachments = pixelBuffer.GetAttachment <NSString> (CVImageBuffer.YCbCrMatrixKey, out attachmentMode);

				if (colorAttachments == CVImageBuffer.YCbCrMatrix_ITU_R_601_4)
					preferredConversion = colorConversion601;
				else
					preferredConversion = colorConversion709;

				GL.ActiveTexture (TextureUnit.Texture0);
				lumaTexture = videoTextureCache.TextureFromImage (pixelBuffer, true, All.RedExt, frameWidth, frameHeight,
					All.RedExt, DataType.UnsignedByte, 0, out error);

				if (lumaTexture == null)
					Console.WriteLine ("Error at CVOpenGLESTextureCach.TextureFromImage");

				GL.BindTexture (lumaTexture.Target, lumaTexture.Name);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);

				GL.ActiveTexture (TextureUnit.Texture1);
				chromaTexture = videoTextureCache.TextureFromImage (pixelBuffer, true, All.RgExt, frameWidth / 2, frameHeight / 2,
					All.RgExt, DataType.UnsignedByte, 1, out error);

				if (chromaTexture == null)
					Console.WriteLine ("Error at CVOpenGLESTextureCach.TextureFromImage");

				GL.BindTexture (chromaTexture.Target, chromaTexture.Name);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
				GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);

				GL.BindFramebuffer (FramebufferTarget.Framebuffer, frameBufferHandle);
				GL.Viewport (0, 0, backingWidth, backingHeight);
			}

			GL.ClearColor (0f, 0f, 0f, 1f);
			GL.Clear (ClearBufferMask.ColorBufferBit);

			GL.UseProgram (Program);
			GL.Uniform1 (uniforms [(int)UniformIndex.RotationAngle], 0f);
			GL.UniformMatrix3 (uniforms [(int)UniformIndex.ColorConversionMatrix], 1, false, preferredConversion);

			CGRect vertexSamplingRect = AVUtilities.WithAspectRatio (Bounds, PresentationRect);

			var normalizedSamplingSize = new CGSize (0f, 0f);
			var cropScaleAmount = new CGSize (vertexSamplingRect.Width / Bounds.Width, vertexSamplingRect.Height / Bounds.Height);

			if (cropScaleAmount.Width > cropScaleAmount.Height) {
				normalizedSamplingSize.Width = 1f;
				normalizedSamplingSize.Height = cropScaleAmount.Height / cropScaleAmount.Width;
			} else {
				normalizedSamplingSize.Width = 1f;
				normalizedSamplingSize.Height = cropScaleAmount.Width / cropScaleAmount.Height;
			}

			float[] quadVertexData = {
				-1f * (float)normalizedSamplingSize.Width, -1f * (float)normalizedSamplingSize.Height,
				(float)normalizedSamplingSize.Width, -1f * (float)normalizedSamplingSize.Height,
				-1f * (float)normalizedSamplingSize.Width, (float)normalizedSamplingSize.Height,
				(float)normalizedSamplingSize.Width, (float)normalizedSamplingSize.Height,
			};

			GL.VertexAttribPointer ((int)AttributeIndex.Vertex, 2, VertexAttribPointerType.Float, false, 0, quadVertexData);
			GL.EnableVertexAttribArray ((int)AttributeIndex.Vertex);

			var textureSamplingRect = new CGRect (0, 0, 1, 1);
			float[] quadTextureData = {
				(float)textureSamplingRect.GetMinX (), (float)textureSamplingRect.GetMaxY (),
				(float)textureSamplingRect.GetMaxX (), (float)textureSamplingRect.GetMaxY (),
				(float)textureSamplingRect.GetMinX (), (float)textureSamplingRect.GetMinY (),
				(float)textureSamplingRect.GetMaxX (), (float)textureSamplingRect.GetMinY ()
			};

			GL.VertexAttribPointer ((int)AttributeIndex.TextureCoordinates, 2, VertexAttribPointerType.Float, false, 0, quadTextureData);
			GL.EnableVertexAttribArray ((int)AttributeIndex.TextureCoordinates);

			GL.DrawArrays (BeginMode.TriangleStrip, 0, 4);
			GL.BindRenderbuffer (RenderbufferTarget.Renderbuffer, colorBufferHandle);
			context.PresentRenderBuffer ((int)RenderbufferTarget.Renderbuffer);
		}
		static Rects ComputeDifferenceBetweenRect (CGRect oldRect, CGRect newRect)
		{
			if (!oldRect.IntersectsWith (newRect)) {
				return new Rects {
					Added = new CGRect [] { newRect },
					Removed = new CGRect [] { oldRect }
				};
			}

			var oldMaxY = oldRect.GetMaxY ();
			var oldMinY = oldRect.GetMinY ();
			var newMaxY = newRect.GetMaxY ();
			var newMinY = newRect.GetMinY ();

			var added = new List<CGRect> ();
			var removed = new List<CGRect> ();

			if (newMaxY > oldMaxY)
				added.Add (new CGRect (newRect.X, oldMaxY, newRect.Width, newMaxY - oldMaxY));

			if (oldMinY > newMinY)
				added.Add (new CGRect (newRect.X, newMinY, newRect.Width, oldMinY - newMinY));

			if (newMaxY < oldMaxY)
				removed.Add (new CGRect (newRect.X, newMaxY, newRect.Width, oldMaxY - newMaxY));

			if (oldMinY < newMinY)
				removed.Add (new CGRect (newRect.X, oldMinY, newRect.Width, newMinY - oldMinY));

			return new Rects {
				Added = added,
				Removed = removed
			};
		}
Example #41
0
 private double Padding(CGRect rect)
 {
     return rect.GetMaxY() * 0.10;
 }