コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
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));
        }
コード例 #4
0
        public static float MaxDistance(this MaterialShowcase _materialShowcase, CGPoint _fromPoint, CGRect _toRect)
        {
            var tl = _materialShowcase.Distance(_fromPoint, new CGPoint(_toRect.GetMinX(), _toRect.GetMinY()));
            var tr = _materialShowcase.Distance(_fromPoint, new CGPoint(_toRect.GetMaxX(), _toRect.GetMinY()));
            var bl = _materialShowcase.Distance(_fromPoint, new CGPoint(_toRect.GetMinX(), _toRect.GetMaxY()));
            var br = _materialShowcase.Distance(_fromPoint, new CGPoint(_toRect.GetMaxX(), _toRect.GetMaxY()));

            return(Math.Max(tl, Math.Max(tr, Math.Max(bl, br))));
        }
コード例 #5
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))));
        }
コード例 #6
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;
 }
コード例 #7
0
ファイル: DividerView.cs プロジェクト: Zebra/iFactr-iOS
        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);
            }
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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();
        }
コード例 #13
0
        void LayoutButtonBars()
        {
            nfloat nextX  = 0;
            nfloat y      = 0;
            nfloat height = AwesomeBar.ToolbarWidgetHeight;

            if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark)
            {
                y       = 2;
                height += 2;
            }
            else
            {
                height += 5;
                y       = -1;
            }

            foreach (ButtonBar bar in buttonBars)
            {
                var frame = new CGRect(nextX, y, extraPadding + (bar.SegmentCount * SegmentWidth), height);
                bar.Frame = frame;

                nextX = frame.GetMaxX() + buttonBarSpacing;
            }

            SetFrameSize(new CGSize(nextX - buttonBarSpacing, height));

            if (SizeChanged != null)
            {
                SizeChanged(this, EventArgs.Empty);
            }
        }
コード例 #14
0
		public override void DrawRect(CGRect dirtyRect)
		{
			CGRect nameRect = CGRect.Empty;
			CGRect raiseRect = CGRect.Empty;
			raiseRect.Size = nameRect.Size = new CGSize(0.0f, lineHeight);

			nameRect.Location = new CGPoint(pageRect.Location.X, nameRect.Location.X);
			nameRect.Size = new CGSize(200.0f, nameRect.Size.Height);
			raiseRect.Location = new CGPoint(nameRect.GetMaxX(), raiseRect.Location.Y);
			raiseRect.Size = new CGSize(100.0f, raiseRect.Size.Height);

			nuint emptyRows = 2;
			for (nuint i = 0; i < employeeLinesPerPage; i++) {
				nuint index = (currentPage * employeeLinesPerPage) + i;
				if (index >= people.Count) {
					emptyRows = totalLinesPerPage - i;
					break;
				}
				Person p = people.GetItem<Person>(index);

				// Draw index and name
				nameRect.Location = new CGPoint(nameRect.Location.X, pageRect.Location.Y + (i * lineHeight));
				NSString nameString = new NSString(String.Format("{0:D2}: {1}", index+1, p.Name));
				nameString.DrawInRect(nameRect, attributes);

				raiseRect.Location = new CGPoint(raiseRect.Location.X, nameRect.Location.Y);
				NSString raiseString = new NSString(String.Format("{0:P1}", p.ExpectedRaise));
				raiseString.DrawInRect(raiseRect, attributes);
			}
			NSString printPageNumber = new NSString(String.Format("Page {0}", currentPage + 1));
			printPageNumber.DrawInRect(new CGRect(nameRect.Location.X, nameRect.Location.Y + nameRect.Size.Height * emptyRows, 200.0f, nameRect.Size.Height), attributes);

		}
コード例 #15
0
        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);
        }
コード例 #16
0
        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;
        }
コード例 #17
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);
        }
コード例 #18
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);
        }
コード例 #19
0
        private void UpdatePopUpView()
        {
            CGSize popUpViewSize;
            string valueString = DataSource?.Slider(this, this.Value) ?? "";

            if (!string.IsNullOrWhiteSpace(valueString))
            {
                popUpViewSize = PopUpView.PopUpSizeForString(valueString);
            }
            else
            {
                valueString   = numberFormatter.StringFromNumber(this.Value);
                popUpViewSize = CalculatePopUpViewSize();
            }

            // calculate the popUpView frame
            CGRect thumbRect = ThumbRect();
            nfloat thumbW    = thumbRect.Size.Width;
            nfloat thumbH    = thumbRect.Size.Height;

            CGRect popUpRect = thumbRect.Inset((thumbW - popUpViewSize.Width) / 2, (thumbH - popUpViewSize.Height) / 2);

            popUpRect.Y = thumbRect.Y - popUpViewSize.Height;

            // determine if popUpRect extends beyond the frame of the progress view
            // if so adjust frame and set the center offset of the PopUpView's arrow
            nfloat minOffsetX = popUpRect.GetMinX();
            nfloat maxOffsetX = popUpRect.GetMaxX() - this.Bounds.Width;

            nfloat offset = minOffsetX < 0.0f ? minOffsetX : (maxOffsetX > 0.0f ? maxOffsetX : 0.0f);

            popUpRect.X -= offset;

            PopUpView.SetFrame(popUpRect, offset, valueString);
        }
コード例 #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);
        }
コード例 #21
0
        private void DrawAudioMixTracks(CGRect bannerRect, CGRect rowRect, ref float runningTop)
        {
            bannerRect.Y = runningTop;
            CGContext context = UIGraphics.GetCurrentContext();

            context.SetFillColor(1.00f, 1.00f, 1.00f, 1.00f);              // white

            NSString compositionTitle = new NSString("AVAudioMix");

            compositionTitle.DrawString(bannerRect, UIFont.PreferredCaption1);
            runningTop += (float)bannerRect.Height;

            foreach (List <CGPoint> mixTrack in audioMixTracks)
            {
                rowRect.Y = runningTop;

                CGRect rampRect = rowRect;
                rampRect.Width = (float)duration.Seconds * scaledDurationToWidth;
                rampRect       = rampRect.Inset(3f, 3f);

                context.SetFillColor(0.55f, 0.02f, 0.02f, 1.00f);                  // darker red
                context.SetStrokeColor(0.87f, 0.10f, 0.10f, 1.00f);                // brighter red
                context.SetLineWidth(2f);
                context.AddRect(rampRect);
                context.DrawPath(CGPathDrawingMode.FillStroke);

                context.BeginPath();
                context.SetStrokeColor(0.95f, 0.68f, 0.09f, 1.00f);                  // yellow
                context.SetLineWidth(3f);
                bool firstPoint = true;

                foreach (CGPoint pointValue in mixTrack)
                {
                    CGPoint timeVolumePoint = pointValue;
                    CGPoint pointInRow      = new CGPoint();

                    pointInRow.X = rampRect.X + timeVolumePoint.X * scaledDurationToWidth;
                    pointInRow.Y = rampRect.Y + (0.9f - 0.8f * timeVolumePoint.Y) * rampRect.Height;

                    pointInRow.X = (float)Math.Max(pointInRow.X, rampRect.GetMinX());
                    pointInRow.X = (float)Math.Min(pointInRow.X, rampRect.GetMaxX());

                    if (firstPoint)
                    {
                        context.MoveTo(pointInRow.X, pointInRow.Y);
                        firstPoint = false;
                    }
                    else
                    {
                        context.AddLineToPoint(pointInRow.X, pointInRow.Y);
                    }
                }
                context.StrokePath();
                runningTop += (float)rowRect.Height;
            }

            runningTop += GapAfterRows;
        }
コード例 #22
0
        public static void DrawArrowOutline(CGRect frameOutline, float outlinePadding, float outlineThickness, UIColor outlineColor)
        {
            // OutlineShape Drawing
            UIBezierPath outlineShapePath = new UIBezierPath();

            outlineShapePath.MoveTo(new CGPoint(frameOutline.GetMinX() + outlinePadding, frameOutline.GetMaxY() - outlinePadding));
            outlineShapePath.AddLineTo(new CGPoint(frameOutline.GetMaxX() - (frameOutline.Height / 2.0f), frameOutline.GetMaxY() - outlinePadding));
            outlineShapePath.AddLineTo(new CGPoint(frameOutline.GetMaxX() - outlinePadding, frameOutline.GetMinY() + 0.50000f * frameOutline.Height));
            outlineShapePath.AddLineTo(new CGPoint(frameOutline.GetMaxX() - (frameOutline.Height / 2.0f), frameOutline.GetMinY() + outlinePadding));
            outlineShapePath.AddLineTo(new CGPoint(frameOutline.GetMinX() + outlinePadding, frameOutline.GetMinY() + outlinePadding));
            outlineShapePath.AddLineTo(new CGPoint(frameOutline.GetMinX() + outlinePadding, frameOutline.GetMaxY() - outlinePadding));
            outlineShapePath.ClosePath();

            outlineColor.SetStroke();

            outlineShapePath.LineWidth = outlineThickness;
            outlineShapePath.Stroke();
        }
コード例 #23
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();
 }
コード例 #24
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);
        }
コード例 #25
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();
        }
コード例 #26
0
        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();
        }
コード例 #27
0
        public override void Draw(CGRect rect)
        {
            // This will always end up 40x40 with the original x,y
            var fabRect = new CGRect(rect.Location, new CGSize(40, 40));

            fabRect = rect;

            base.Draw(fabRect);

            circleLayer = new CAShapeLayer();
            var bp = UIBezierPath.FromOval(fabRect);

            circleLayer.Path      = bp.CGPath;
            circleLayer.FillColor = UIColor.FromRGB(230, 248, 37).CGColor;
            Layer.AddSublayer(circleLayer);

            tintLayer           = new CAShapeLayer();
            tintLayer.Path      = bp.CGPath;
            tintLayer.FillColor = UIColor.FromRGB(168, 181, 27).CGColor;

            // Calculate the X and Y for the cross rectangles
            var xMidPointLow  = fabRect.GetMidX() - 2;
            var xMidPointHigh = fabRect.GetMidX() + 2;
            var xPointLow     = fabRect.GetMinX() + 8;
            var xPointHigh    = fabRect.GetMaxX() - 8;

            var yMidPointLow  = fabRect.GetMidY() - 2;
            var yMidPointHigh = fabRect.GetMidY() + 2;
            var yPointLow     = fabRect.GetMinY() + 8;
            var yPointHigh    = fabRect.GetMaxY() - 8;

            downLayer = new CAShapeLayer();
            var downRect = new CGRect(xMidPointLow, yPointLow, xMidPointHigh - xMidPointLow, yPointHigh - yPointLow);
            var downBp   = UIBezierPath.FromRoundedRect(downRect, 2);

            downLayer.Path      = downBp.CGPath;
            downLayer.FillColor = UIColor.FromRGB(232, 80, 80).CGColor;
            Layer.AddSublayer(downLayer);

            crossLayer = new CAShapeLayer();
            var crossRect = new CGRect(xPointLow, yMidPointLow, xPointHigh - xPointLow, yMidPointHigh - yMidPointLow);
            var crossBp   = UIBezierPath.FromRoundedRect(crossRect, 2);

            crossLayer.Path      = crossBp.CGPath;
            crossLayer.FillColor = UIColor.FromRGB(232, 80, 80).CGColor;
            Layer.AddSublayer(crossLayer);
        }
コード例 #28
0
		void LayoutButtonBars ()
		{
			nfloat nextX = 0;

			foreach (ButtonBar bar in buttonBars) {
				var frame = new CGRect (nextX, 0, extraPadding + (bar.SegmentCount * segmentWidth), AwesomeBar.ToolbarWidgetHeight);
				bar.Frame = frame;

				nextX = frame.GetMaxX () + buttonBarSpacing;
			}

			SetFrameSize (new CGSize (nextX - buttonBarSpacing, AwesomeBar.ToolbarWidgetHeight));

			if (SizeChanged != null) {
				SizeChanged (this, EventArgs.Empty);
			}
		}
コード例 #29
0
        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();
        }
コード例 #30
0
        void LayoutButtonBars()
        {
            nfloat nextX = 0;

            foreach (ButtonBar bar in buttonBars)
            {
                var frame = new CGRect(nextX, 0, extraPadding + (bar.SegmentCount * segmentWidth), AwesomeBar.ToolbarWidgetHeight);
                bar.Frame = frame;

                nextX = frame.GetMaxX() + buttonBarSpacing;
            }

            SetFrameSize(new CGSize(nextX - buttonBarSpacing, AwesomeBar.ToolbarWidgetHeight));

            if (SizeChanged != null)
            {
                SizeChanged(this, EventArgs.Empty);
            }
        }
コード例 #31
0
ファイル: EasyTipView.cs プロジェクト: zjmsky/EasyTipView
        private void AdjustFrame(ref CGRect frame, CGRect superview)
        {
            if (frame.X < 0)
            {
                frame.X = 0;
            }
            else if (frame.GetMaxX() > superview.Width)
            {
                frame.X = superview.Width - frame.Width;
            }

            if (frame.Y < 0)
            {
                frame.Y = 0;
            }
            else if (frame.GetMaxY() > superview.GetMaxY())
            {
                frame.Y = superview.Height - frame.Height;
            }
        }
コード例 #32
0
        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);
                    }
                }
            }
        }
コード例 #33
0
        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);
                    }
                }
            }
        }
コード例 #34
0
        public override void Draw(CGRect frame)
        {
            var context = UIGraphics.GetCurrentContext();
            var expression = 377.0f - percentage;

            // coverView Drawing
            var coverViewPath =
                UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 5.0f, frame.GetMinY() + 4.0f, frame.Width - 10.0f,
                    frame.Height - 10.0f));
            UIColor.FromRGB(21, 169, 254).SetFill();
            coverViewPath.Fill();

            // completedView Drawing
            context.SaveState();
            context.SaveState();
            context.TranslateCTM(frame.GetMaxX() - 65.0f, frame.GetMinY() + 64.0f);
            context.RotateCTM(-90.0f*NMath.PI/180.0f);

            var completedViewRect = new CGRect(-60.0f, -60.0f, 120.0f, 120.0f);
            var completedViewPath = new UIBezierPath();
            completedViewPath.AddArc(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()),
                completedViewRect.Width/2.0f, -360.0f*NMath.PI/180,
                -(expression - 17.0f)*NMath.PI/180.0f, true);
            completedViewPath.AddLineTo(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()));
            completedViewPath.ClosePath();

            UIColor.FromRGB(247, 247, 247).SetFill();
            completedViewPath.Fill();
            context.RestoreState();

            // backgroundView Drawing
            var backgroundViewPath =
                UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 12.0f, frame.GetMinY() + 11.0f, frame.Width - 24.0f,
                    frame.Height - 24.0f));
            UIColor.FromRGB(21, 169, 254).SetFill();
            backgroundViewPath.Fill();
        }
コード例 #35
0
		void LayoutButtonBars ()
		{
			nfloat nextX = 0;
			nfloat y = 0;
			nfloat height = AwesomeBar.ToolbarWidgetHeight;

			if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark) {
				y = 2;
				height += 2;
			} else {
				height += 5;
				y = -1;
			}

			foreach (ButtonBar bar in buttonBars) {
				var frame = new CGRect (nextX, y, extraPadding + (bar.SegmentCount * segmentWidth), height);
				bar.Frame = frame;

				nextX = frame.GetMaxX () + buttonBarSpacing;
			}

			SetFrameSize (new CGSize (nextX - buttonBarSpacing, height));

			if (SizeChanged != null) {
				SizeChanged (this, EventArgs.Empty);
			}
		}
コード例 #36
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 ();
			}

		}
コード例 #37
0
ファイル: UIBarButtonItem.cs プロジェクト: Jurabek/Restaurant
 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);
 }
コード例 #38
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);
		}