public override void Draw(CGRect frame) { // General Declarations var context = UIGraphics.GetCurrentContext(); // Color Declarations var color4 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var color5 = UIColor.FromRGBA(0.793f, 0.793f, 0.793f, 1.000f); // Shadow Declarations var shadow = new NSShadow(); shadow.ShadowColor = UIColor.Black.ColorWithAlpha(0.28f); shadow.ShadowOffset = new CGSize(3.1f, 3.1f); shadow.ShadowBlurRadius = 5.0f; // Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect( new CGRect(frame.GetMinX() + 10.5f, frame.GetMinY() + 7.5f, frame.Width - 20.0f, 76.0f), 4.0f); context.SaveState(); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor); color4.SetFill(); rectanglePath.Fill(); context.RestoreState(); color5.SetStroke(); rectanglePath.LineWidth = 1.0f; rectanglePath.Stroke(); // Bezier 2 Drawing var bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(frame.GetMinX() + 0.02386f*frame.Width, frame.GetMinY() + 0.50543f*frame.Height)); bezier2Path.AddLineTo(new CGPoint(frame.GetMinX() + 0.97841f*frame.Width, frame.GetMinY() + 0.50543f*frame.Height)); context.SaveState(); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor); color4.SetFill(); bezier2Path.Fill(); context.RestoreState(); color5.SetStroke(); bezier2Path.LineWidth = 1.0f; bezier2Path.Stroke(); }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> private void UpdateUi(ExtendedLabel view) { // Prefer font set through Font property. if (view.Font == Font.Default) { if (view.FontSize > 0) { this.Control.Font = UIFont.FromName(this.Control.Font.Name, (float)view.FontSize); } if (!string.IsNullOrEmpty(view.FontName)) { var fontName = Path.GetFileNameWithoutExtension(view.FontName); var font = UIFont.FromName(fontName, this.Control.Font.PointSize); if (font != null) { this.Control.Font = font; } } #region ======= This is for backward compatability with obsolete attrbute 'FontNameIOS' ======== if (!string.IsNullOrEmpty(view.FontNameIOS)) { var font = UIFont.FromName(view.FontNameIOS, (view.FontSize > 0) ? (float)view.FontSize : 12.0f); if (font != null) { this.Control.Font = font; } } #endregion ====== End of obsolete section ========================================================== } //Do not create attributed string if it is not necesarry //if (!view.IsUnderline && !view.IsStrikeThrough && !view.IsDropShadow) //{ // return; //} var underline = view.IsUnderline ? NSUnderlineStyle.Single : NSUnderlineStyle.None; var strikethrough = view.IsStrikeThrough ? NSUnderlineStyle.Single : NSUnderlineStyle.None; NSShadow dropShadow = null; if (view.IsDropShadow) { dropShadow = new NSShadow { ShadowColor = view.DropShadowColor.ToUIColor(), ShadowBlurRadius = 1.4f, ShadowOffset = new CoreGraphics.CGSize(new CoreGraphics.CGPoint(0.3f, 0.8f)) }; } // For some reason, if we try and convert Color.Default to a UIColor, the resulting color is // either white or transparent. The net result is the ExtendedLabel does not display. // Only setting the control's TextColor if is not Color.Default will prevent this issue. if (view.TextColor != Color.Default) { this.Control.TextColor = view.TextColor.ToUIColor(); } this.Control.AttributedText = new NSMutableAttributedString(view.Text, this.Control.Font, underlineStyle: underline, strikethroughStyle: strikethrough, shadow: dropShadow); ; }
//// Drawing Methods public static void DrawUISwitch(bool inFocus, bool switchOn) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Shadow Declarations var shadow = new NSShadow(); shadow.ShadowColor = CustomControlsStyleKit.ShadowColor; shadow.ShadowOffset = new CGSize(0.1f, 5.1f); shadow.ShadowBlurRadius = 5.0f; //// Variable Declarations var thumbHeight = inFocus ? 85.0f : 65.0f; var thumbY = inFocus ? 6.0f : 16.0f; var thumbColor = inFocus ? CustomControlsStyleKit.InFocusThumbColor : CustomControlsStyleKit.UnFocusedThumbColor; var textColor = inFocus ? CustomControlsStyleKit.InFocusTextColor : CustomControlsStyleKit.UnFocusedTextColor; var gutterColor = switchOn ? (inFocus ? CustomControlsStyleKit.OnColor : CustomControlsStyleKit.OnColorUnFocused) : (inFocus ? CustomControlsStyleKit.OffColor : CustomControlsStyleKit.OffColorUnFocused); var thumbX = switchOn ? 147.0f : 11.0f; var switchOff = !switchOn; //// Gutter Drawing var gutterPath = UIBezierPath.FromRoundedRect(new CGRect(11.0f, 16.0f, 227.0f, 67.0f), 4.0f); gutterColor.SetFill(); gutterPath.Fill(); ////// Gutter Inner Shadow context.SaveState(); context.ClipToRect(gutterPath.Bounds); context.SetShadow(new CGSize(0, 0), 0); context.SetAlpha(shadow.ShadowColor.CGColor.Alpha); context.BeginTransparencyLayer(); { var opaqueShadow = new CGColor(shadow.ShadowColor.CGColor, 1.0f); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, opaqueShadow); context.SetBlendMode(CGBlendMode.SourceOut); context.BeginTransparencyLayer(); context.SetFillColor(opaqueShadow); gutterPath.Fill(); context.EndTransparencyLayer(); } context.EndTransparencyLayer(); context.RestoreState(); CustomControlsStyleKit.BorderColor.SetStroke(); gutterPath.LineWidth = 2.0f; gutterPath.Stroke(); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect(new CGRect(thumbX, thumbY, 91.0f, thumbHeight), 4.0f); context.SaveState(); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor); thumbColor.SetFill(); rectanglePath.Fill(); context.RestoreState(); CustomControlsStyleKit.BorderColor.SetStroke(); rectanglePath.LineWidth = 2.0f; rectanglePath.Stroke(); if (switchOn) { //// OnText Drawing CGRect onTextRect = new CGRect(26.0f, 27.0f, 99.0f, 49.0f); { var textContent = "ON"; textColor.SetFill(); var onTextStyle = new NSMutableParagraphStyle (); onTextStyle.Alignment = UITextAlignment.Center; var onTextFontAttributes = new UIStringAttributes () {Font = UIFont.BoldSystemFontOfSize(27.0f), ForegroundColor = textColor, ParagraphStyle = onTextStyle}; var onTextTextHeight = new NSString(textContent).GetBoundingRect(new CGSize(onTextRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, onTextFontAttributes, null).Height+10; context.SaveState(); context.ClipToRect(onTextRect); new NSString(textContent).DrawString(new CGRect(onTextRect.GetMinX(), onTextRect.GetMinY() + (onTextRect.Height - onTextTextHeight) / 2.0f, onTextRect.Width, onTextTextHeight), UIFont.BoldSystemFontOfSize(27.0f), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); } } if (switchOff) { //// OffText Drawing CGRect offTextRect = new CGRect(123.0f, 27.0f, 99.0f, 49.0f); { var textContent = "OFF"; textColor.SetFill(); var offTextStyle = new NSMutableParagraphStyle (); offTextStyle.Alignment = UITextAlignment.Center; var offTextFontAttributes = new UIStringAttributes () {Font = UIFont.BoldSystemFontOfSize(27.0f), ForegroundColor = textColor, ParagraphStyle = offTextStyle}; var offTextTextHeight = new NSString(textContent).GetBoundingRect(new CGSize(offTextRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, offTextFontAttributes, null).Height+10; context.SaveState(); context.ClipToRect(offTextRect); new NSString(textContent).DrawString(new CGRect(offTextRect.GetMinX(), offTextRect.GetMinY() + (offTextRect.Height - offTextTextHeight) / 2.0f, offTextRect.Width, offTextTextHeight), UIFont.BoldSystemFontOfSize(27.0f), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); } } }
//// Drawing Methods public static void DrawLightMapPoint(float lightColorR, float lightColorG, float lightColorB, float lightColorA, string rank, float fontSize) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var lightBaseColor = UIColor.FromRGBA(0.009f, 0.471f, 0.009f, 1.000f); //// Shadow Declarations var shadow = new NSShadow(); shadow.ShadowColor = UIColor.Black.ColorWithAlpha(0.62f); shadow.ShadowOffset = new CGSize(0.1f, -0.1f); shadow.ShadowBlurRadius = 5.0f; //// Variable Declarations var lightColor = UIColor.FromRGBA(lightColorR, lightColorG, lightColorB, lightColorA); //// LightIcon { //// Oval Drawing var ovalPath = UIBezierPath.FromOval(new CGRect(1.0f, 1.0f, 18.0f, 38.0f)); lightColor.SetFill(); ovalPath.Fill(); ////// Oval Inner Shadow context.SaveState(); context.ClipToRect(ovalPath.Bounds); context.SetShadow(new CGSize(0, 0), 0); context.SetAlpha(shadow.ShadowColor.CGColor.Alpha); context.BeginTransparencyLayer(); { var opaqueShadow = new CGColor(shadow.ShadowColor.CGColor, 1.0f); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, opaqueShadow); context.SetBlendMode(CGBlendMode.SourceOut); context.BeginTransparencyLayer(); context.SetFillColor(opaqueShadow); ovalPath.Fill(); context.EndTransparencyLayer(); } context.EndTransparencyLayer(); context.RestoreState(); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRect(new CGRect(3.0f, 34.0f, 14.0f, 12.0f)); lightBaseColor.SetFill(); rectanglePath.Fill(); ////// Rectangle Inner Shadow context.SaveState(); context.ClipToRect(rectanglePath.Bounds); context.SetShadow(new CGSize(0, 0), 0); context.SetAlpha(shadow.ShadowColor.CGColor.Alpha); context.BeginTransparencyLayer(); { var opaqueShadow = new CGColor(shadow.ShadowColor.CGColor, 1.0f); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, opaqueShadow); context.SetBlendMode(CGBlendMode.SourceOut); context.BeginTransparencyLayer(); context.SetFillColor(opaqueShadow); rectanglePath.Fill(); context.EndTransparencyLayer(); } context.EndTransparencyLayer(); context.RestoreState(); } //// Text Drawing CGRect textRect = new CGRect(0.0f, 8.0f, 20.0f, 23.0f); UIColor.White.SetFill(); var textStyle = new NSMutableParagraphStyle (); textStyle.Alignment = UITextAlignment.Center; var textFontAttributes = new UIStringAttributes () {Font = UIFont.SystemFontOfSize(fontSize), ForegroundColor = UIColor.White, ParagraphStyle = textStyle}; var textTextHeight = new NSString(rank).GetBoundingRect(new CGSize(textRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, textFontAttributes, null).Height; context.SaveState(); context.ClipToRect(textRect); new NSString(rank).DrawString(new CGRect(textRect.GetMinX(), textRect.GetMinY() + (textRect.Height - textTextHeight) / 2.0f, textRect.Width, textTextHeight), UIFont.SystemFontOfSize(fontSize), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); }
public override void Draw(CGRect rect) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var fillColor = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var strokeColor3 = UIColor.FromRGBA(0.716f, 0.716f, 0.716f, 1.000f); var shadowTint2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); var strokeColor4 = UIColor.FromRGBA(0.807f, 0.807f, 0.807f, 1.000f); var fillColor4 = UIColor.FromRGBA(0.969f, 0.969f, 0.969f, 1.000f); var fillColor6 = UIColor.FromRGBA(0.314f, 0.824f, 0.761f, 1.000f); var strokeColor5 = UIColor.FromRGBA(0.855f, 0.855f, 0.855f, 1.000f); //// Shadow Declarations var shadow3 = new NSShadow(); shadow3.ShadowColor = shadowTint2.ColorWithAlpha(shadowTint2.CGColor.Alpha * 0.13f); shadow3.ShadowOffset = new CGSize(1450.1f, 2.1f); shadow3.ShadowBlurRadius = 4.0f; //// Group 5 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 5 var clip5Path = UIBezierPath.FromRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 248.55f, 686.9f, 265.6f)); clip5Path.AddClip(); //// Rectangle 6 Drawing var rectangle6Path = UIBezierPath.FromRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 248.55f, 686.9f, 265.6f)); strokeColor4.SetStroke(); rectangle6Path.LineWidth = 2.0f; rectangle6Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(rect.GetMinX() + 687.41f, rect.GetMinY() + 349.29f)); bezierPath.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 353.29f)); bezierPath.LineCapStyle = CGLineCap.Square; strokeColor3.SetStroke(); bezierPath.LineWidth = 1.0f; bezierPath.Stroke(); //// Group { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip var clipPath = UIBezierPath.FromRect(new CGRect(rect.GetMinX() - 13.0f, rect.GetMinY() - 17.0f, 725.0f, 556.0f)); clipPath.AddClip(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 2.0f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 1444.0f, rect.GetMinY() - 2.0f), new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() - 0.21f), new CGPoint(rect.GetMinX() - 1446.2f, rect.GetMinY() - 2.0f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 765.08f, rect.GetMinY() - 2.0f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() + 2.0f), new CGPoint(rect.GetMinX() - 762.87f, rect.GetMinY() - 2.0f), new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() - 0.21f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() + 509.16f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 765.08f, rect.GetMinY() + 513.16f), new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() + 511.37f), new CGPoint(rect.GetMinX() - 762.88f, rect.GetMinY() + 513.16f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 1444.0f, rect.GetMinY() + 513.16f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 509.16f), new CGPoint(rect.GetMinX() - 1446.21f, rect.GetMinY() + 513.16f), new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 511.37f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 2.0f)); bezier2Path.ClosePath(); bezier2Path.UsesEvenOddFillRule = true; context.SaveState(); context.SetShadow(shadow3.ShadowOffset, shadow3.ShadowBlurRadius, shadow3.ShadowColor.CGColor); fillColor.SetFill(); bezier2Path.Fill(); context.RestoreState(); context.EndTransparencyLayer(); context.RestoreState(); } //// Group 2 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 3 UIBezierPath clip3Path = new UIBezierPath(); clip3Path.MoveTo(new CGPoint(rect.GetMinX() - 15.49f, rect.GetMinY() - 22.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 712.41f, rect.GetMinY() - 22.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 712.41f, rect.GetMinY() + 533.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() - 15.49f, rect.GetMinY() + 533.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() - 15.49f, rect.GetMinY() - 22.5f)); clip3Path.ClosePath(); clip3Path.MoveTo(new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 2.0f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() - 1.5f), new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 0.07f), new CGPoint(rect.GetMinX() + 7.07f, rect.GetMinY() - 1.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() - 1.5f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 2.0f), new CGPoint(rect.GetMinX() + 689.85f, rect.GetMinY() - 1.5f), new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 0.07f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 509.16f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() + 512.66f), new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 511.09f), new CGPoint(rect.GetMinX() + 689.85f, rect.GetMinY() + 512.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() + 512.66f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 509.16f), new CGPoint(rect.GetMinX() + 7.07f, rect.GetMinY() + 512.66f), new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 511.09f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 2.0f)); clip3Path.ClosePath(); clip3Path.MoveTo(new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 2.0f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 509.16f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 511.65f), new CGPoint(rect.GetMinX() + 6.52f, rect.GetMinY() + 513.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() + 513.66f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() + 509.16f), new CGPoint(rect.GetMinX() + 690.4f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() + 511.64f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() + 2.0f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() - 2.5f), new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() - 0.49f), new CGPoint(rect.GetMinX() + 690.4f, rect.GetMinY() - 2.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() - 2.5f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 2.0f), new CGPoint(rect.GetMinX() + 6.52f, rect.GetMinY() - 2.5f), new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() - 0.48f)); clip3Path.ClosePath(); clip3Path.UsesEvenOddFillRule = true; clip3Path.AddClip(); //// Group 3 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 2 var clip2Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 5.0f, rect.GetMinY() - 1.98f, 686.9f, 515.15f), 4.0f); clip2Path.AddClip(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 5.0f, rect.GetMinY() - 1.98f, 686.9f, 515.15f), 4.0f); fillColor.SetFill(); rectangle2Path.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } context.EndTransparencyLayer(); context.RestoreState(); } //// Group 4 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 4 var clip4Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 3.02f, 686.9f, 515.15f), 4.0f); clip4Path.AddClip(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 3.02f, 686.9f, 515.15f), 4.0f); strokeColor4.SetStroke(); rectangle4Path.LineWidth = 2.0f; rectangle4Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier 4 Drawing UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.57f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 690.01f, rect.GetMinY() + 249.06f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.56f), new CGPoint(rect.GetMinX() + 690.01f, rect.GetMinY() + 249.06f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 249.06f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.56f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.73f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.56f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.57f)); bezier4Path.ClosePath(); bezier4Path.MoveTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.57f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 249.06f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.56f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.73f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 249.06f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 261.48f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 501.24f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 690.01f, rect.GetMinY() + 513.66f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 514.16f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 514.16f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 513.99f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.66f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 249.06f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 501.24f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 261.48f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.01f, rect.GetMinY() + 249.06f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.56f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.57f)); bezier4Path.ClosePath(); bezier4Path.MoveTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.66f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 514.16f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.99f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 514.16f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.01f, rect.GetMinY() + 513.66f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.66f)); bezier4Path.ClosePath(); fillColor4.SetFill(); bezier4Path.Fill(); //// Bezier 5 Drawing UIBezierPath bezier5Path = new UIBezierPath(); bezier5Path.MoveTo(new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 513.16f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 690.91f, rect.GetMinY() + 513.16f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 690.91f, rect.GetMinY() + 589.34f)); bezier5Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 686.91f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 690.91f, rect.GetMinY() + 591.55f), new CGPoint(rect.GetMinX() + 689.13f, rect.GetMinY() + 593.34f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 350.63f, rect.GetMinY() + 593.34f)); bezier5Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 342.63f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 348.42f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 344.84f, rect.GetMinY() + 593.34f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 8.01f, rect.GetMinY() + 593.34f)); bezier5Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 589.34f), new CGPoint(rect.GetMinX() + 5.8f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 591.55f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 513.16f)); bezier5Path.ClosePath(); bezier5Path.UsesEvenOddFillRule = true; fillColor6.SetFill(); bezier5Path.Fill(); //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath(); bezier6Path.MoveTo(new CGPoint(rect.GetMinX() + 345.0f, rect.GetMinY() + 110.0f)); bezier6Path.AddLineTo(new CGPoint(rect.GetMinX() + 345.46f, rect.GetMinY() + 4.0f)); bezier6Path.LineCapStyle = CGLineCap.Square; strokeColor5.SetStroke(); bezier6Path.LineWidth = 2.0f; bezier6Path.Stroke(); //// Bezier 7 Drawing UIBezierPath bezier7Path = new UIBezierPath(); bezier7Path.MoveTo(new CGPoint(rect.GetMinX() + 689.01f, rect.GetMinY() + 399.9f)); bezier7Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.01f, rect.GetMinY() + 399.9f)); bezier7Path.LineCapStyle = CGLineCap.Square; strokeColor5.SetStroke(); bezier7Path.LineWidth = 2.0f; bezier7Path.Stroke(); //// Bezier 8 Drawing UIBezierPath bezier8Path = new UIBezierPath(); bezier8Path.MoveTo(new CGPoint(rect.GetMinX() + 688.91f, rect.GetMinY() + 110.25f)); bezier8Path.AddLineTo(new CGPoint(rect.GetMinX() + 6.01f, rect.GetMinY() + 110.25f)); bezier8Path.LineCapStyle = CGLineCap.Square; strokeColor5.SetStroke(); bezier8Path.LineWidth = 2.0f; bezier8Path.Stroke(); }
private void DrawCanvas(CGRect frame, string beerName) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var fillColor = UIColor.FromRGBA(0.500f, 0.500f, 0.500f, 1.000f); var shadowTint = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); var fillColor2 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var strokeColor = UIColor.FromRGBA(0.531f, 0.531f, 0.531f, 1.000f); var textForeground2 = UIColor.FromRGBA(0.408f, 0.408f, 0.408f, 1.000f); //// Shadow Declarations var shadow2 = new NSShadow(); shadow2.ShadowColor = shadowTint.ColorWithAlpha(shadowTint.CGColor.Alpha * 0.3f); shadow2.ShadowOffset = new CGSize(930.1f, -0.1f); shadow2.ShadowBlurRadius = 10.0f; //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect(new CGRect(-921.0f, 9.0f, 395.0f, 418.0f), 8.0f); context.SaveState(); context.SetShadow(shadow2.ShadowOffset, shadow2.ShadowBlurRadius, shadow2.ShadowColor.CGColor); fillColor.SetFill(); rectanglePath.Fill(); context.RestoreState(); //// Group { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 2 UIBezierPath clip2Path = new UIBezierPath(); clip2Path.MoveTo(new CGPoint(-11.5f, -11.5f)); clip2Path.AddLineTo(new CGPoint(424.5f, -11.5f)); clip2Path.AddLineTo(new CGPoint(424.5f, 447.5f)); clip2Path.AddLineTo(new CGPoint(-11.5f, 447.5f)); clip2Path.AddLineTo(new CGPoint(-11.5f, -11.5f)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(9.5f, 17.0f)); clip2Path.AddCurveToPoint(new CGPoint(17.0f, 9.5f), new CGPoint(9.5f, 12.86f), new CGPoint(12.86f, 9.5f)); clip2Path.AddLineTo(new CGPoint(396.0f, 9.5f)); clip2Path.AddCurveToPoint(new CGPoint(403.5f, 17.0f), new CGPoint(400.14f, 9.5f), new CGPoint(403.5f, 12.86f)); clip2Path.AddLineTo(new CGPoint(403.5f, 419.0f)); clip2Path.AddCurveToPoint(new CGPoint(396.0f, 426.5f), new CGPoint(403.5f, 423.14f), new CGPoint(400.14f, 426.5f)); clip2Path.AddLineTo(new CGPoint(17.0f, 426.5f)); clip2Path.AddCurveToPoint(new CGPoint(9.5f, 419.0f), new CGPoint(12.86f, 426.5f), new CGPoint(9.5f, 423.14f)); clip2Path.AddLineTo(new CGPoint(9.5f, 17.0f)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(8.5f, 17.0f)); clip2Path.AddLineTo(new CGPoint(8.5f, 419.0f)); clip2Path.AddCurveToPoint(new CGPoint(17.0f, 427.5f), new CGPoint(8.5f, 423.69f), new CGPoint(12.31f, 427.5f)); clip2Path.AddLineTo(new CGPoint(396.0f, 427.5f)); clip2Path.AddCurveToPoint(new CGPoint(404.5f, 419.0f), new CGPoint(400.69f, 427.5f), new CGPoint(404.5f, 423.69f)); clip2Path.AddLineTo(new CGPoint(404.5f, 17.0f)); clip2Path.AddCurveToPoint(new CGPoint(396.0f, 8.5f), new CGPoint(404.5f, 12.31f), new CGPoint(400.69f, 8.5f)); clip2Path.AddLineTo(new CGPoint(17.0f, 8.5f)); clip2Path.AddCurveToPoint(new CGPoint(8.5f, 17.0f), new CGPoint(12.31f, 8.5f), new CGPoint(8.5f, 12.31f)); clip2Path.ClosePath(); clip2Path.UsesEvenOddFillRule = true; clip2Path.AddClip(); //// Group 2 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip var clipPath = UIBezierPath.FromRoundedRect(new CGRect(9.0f, 9.0f, 395.0f, 418.0f), 8.0f); clipPath.AddClip(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRoundedRect(new CGRect(9.0f, 9.0f, 395.0f, 418.0f), 8.0f); fillColor2.SetFill(); rectangle2Path.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } context.EndTransparencyLayer(); context.RestoreState(); } //// background { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 3 var clip3Path = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX(), frame.GetMinY() + 9.0f, 395.0f, 418.0f), 8.0f); clip3Path.AddClip(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX(), frame.GetMinY() + 9.0f, 395.0f, 418.0f), 8.0f); strokeColor.SetStroke(); rectangle4Path.LineWidth = 2.0f; rectangle4Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// title Drawing CGRect titleRect = new CGRect(frame.GetMinX() + 0.38f, frame.GetMinY() + 19.0f, 394.62f, 41.0f); textForeground2.SetFill(); var titleStyle = new NSMutableParagraphStyle (); titleStyle.Alignment = UITextAlignment.Center; var titleFontAttributes = new UIStringAttributes () {Font = UIFont.FromName("Avenir-Medium", 24.0f), ForegroundColor = textForeground2, ParagraphStyle = titleStyle}; var titleTextHeight = new NSString(beerName).GetBoundingRect(new CGSize(titleRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, titleFontAttributes, null).Height; context.SaveState(); context.ClipToRect(titleRect); new NSString(beerName).DrawString(new CGRect(titleRect.GetMinX(), titleRect.GetMinY() + (titleRect.Height - titleTextHeight) / 2.0f, titleRect.Width, titleTextHeight), UIFont.FromName("Avenir-Medium", 24.0f), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); }