Exemplo n.º 1
0
 public override void Draw(CGRect bounds, CoreGraphics.CGContext context, UIView view)
 {
     if (AutoLoadOnVisible)
     {
         LoadMore();
     }
 }
Exemplo n.º 2
0
		public override void Draw (CoreGraphics.CGRect rect)
		{
			this.stocktext.Font = DataColumn.GridColumn.RecordFont;
			this.stocktext.TextColor = DataColumn.Renderer.DataGrid.GridStyle.GetRecordForegroundColor ();
			this.stocktext.TextAlignment = UITextAlignment.Right;
			base.Draw (rect);
		}
Exemplo n.º 3
0
 // Workaround until this method is available in Xamarin.iOS
 public static CoreGraphics.CGRect InsetRect(CoreGraphics.CGRect rect, UIEdgeInsets insets)
 {
     return new CoreGraphics.CGRect(rect.X + insets.Left,
                            rect.Y + insets.Top,
                            rect.Width - insets.Left - insets.Right,
                            rect.Height - insets.Top - insets.Bottom);
 }
Exemplo n.º 4
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            base.DrawRect (dirtyRect);

            if (grContext != null)
            {
                var sampleCount = grContext.GetRecommendedSampleCount(GRPixelConfig.Rgba8888, 96.0f);

                var desc = new GRBackendRenderTargetDesc
                {
                    Width = (int)Bounds.Width,
                    Height = (int)Bounds.Height,
                    Config = GRPixelConfig.Rgba8888,
                    Origin = GRSurfaceOrigin.TopLeft,
                    SampleCount = sampleCount,
                    StencilBits = 0,
                    RenderTargetHandle = IntPtr.Zero,
                };

                using (var surface = SKSurface.Create (grContext, desc))
                {
                    var skcanvas = surface.Canvas;

                    sample.Method (skcanvas, (int)Bounds.Width, (int)Bounds.Height);

                    skcanvas.Flush ();
                }

                GL.Flush();
            }
        }
Exemplo n.º 5
0
 public NSMyVideoView(CoreGraphics.CGRect rect, NSView view, AVPlayerLayer layer)
     : base(rect)
 {
     AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
     _view = view;
     _layer = layer;
 }
Exemplo n.º 6
0
        public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw(rect);

            var width = rect.Width / 2f - 1f;
            var addedRect = new CoreGraphics.CGRect(0, 0, width, rect.Height);
            var removedRect = new CoreGraphics.CGRect(rect.Width / 2f + 1f, 0, width, rect.Height);

            var context = UIGraphics.GetCurrentContext();
            context.SaveState();
            context.SetFillColor(UIColor.FromRGB(204, 255, 204).CGColor);
            context.AddPath(GraphicsUtil.MakeRoundedRectPath(addedRect, 5));
            context.FillPath();

            context.SetFillColor(UIColor.FromRGB(255, 221, 221).CGColor);
            context.AddPath(GraphicsUtil.MakeRoundedRectPath(removedRect, 5));
            context.FillPath();

            context.RestoreState();

            UIColor.FromRGB(57, 152, 57).SetColor();
            var stringRect = addedRect;
            stringRect.Y += 1f;
            string addedString = (Added == null) ? "-" : "+" + Added.Value;
            new NSString(addedString).DrawString(stringRect, UIFont.SystemFontOfSize(12f), UILineBreakMode.TailTruncation, UITextAlignment.Center);

            UIColor.FromRGB(0xcc, 0x33, 0x33).SetColor();
            stringRect = removedRect;
            stringRect.Y += 1f;
            string removedString = (Removed == null) ? "-" : "-" + Removed.Value;
            new NSString(removedString).DrawString(stringRect, UIFont.SystemFontOfSize(12f), UILineBreakMode.TailTruncation, UITextAlignment.Center);
        }
        public override void DidCropToImage(TOCropViewController cropViewController, 
            UIImage image, CoreGraphics.CGRect cropRect, nint angle)
        {
            var imageBytes = image.AsPNG().ToArray();
            _taskCompletionSource.SetResult(imageBytes);

            cropViewController.DismissViewController(true, null);
        }
Exemplo n.º 8
0
        public override void Draw(CoreGraphics.CGRect rect)
        {
            if (incrementalImage != null)
                incrementalImage.Draw(rect);

            path.Stroke();
            //base.Draw (rect);
        }
Exemplo n.º 9
0
		public override void Draw (CoreGraphics.CGRect rect)
		{
			var b = Bounds; //= {X=0,Y=0,Width=375,Height=667}
			var n = 50;
			var dw = b.Width / (n - 1); //= 7.653061
			for (var i = 0; i < n; i++) {
				var x = i * dw; //= ...321.4286, 329.0816, 336.7347, 344.3878, 352.0408, 359.6939, 367.347, 375
			}
		}
Exemplo n.º 10
0
        public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw (rect);

            using (CGContext g = UIGraphics.GetCurrentContext ()) {
                _radius = (int)( (this.Frame.Width) / 3) - 8;
                DrawGraph(g, this.Frame.GetMidX(), this.Frame.GetMidY());
            };
        }
Exemplo n.º 11
0
 public override void Draw(CoreGraphics.CGRect rect)
 {
     base.Draw (rect);
     if (Scores != null)
         StyleKit.DrawEmotionStatView (rect, Scores.Anger * 100, Scores.Contempt * 100,
             Scores.Disgust * 100, Scores.Fear * 100, Scores.Happiness * 100,
             Scores.Neutral * 100, Scores.Sadness * 100, Scores.Surprise * 100, (int)this.Bounds.Size.Height);
     else
         StyleKit.DrawEmotionStatView(rect, 0, 0, 0, 0, 0, 0, 0, 0, (int)this.Bounds.Size.Height);
 }
Exemplo n.º 12
0
		public override void Draw (CoreGraphics.CGRect rect)
		{
			base.Draw (rect);

			logo.Font = UIFont.FromName("FontAwesome", 168f);
			logo.Text = "\xf110";
			logo.SizeToFit ();

			this.SetNeedsUpdateConstraints ();
		}
Exemplo n.º 13
0
 public override void Draw(CoreGraphics.CGRect rect)
 {
     base.Draw (rect);
     var outer = UIBezierPath.FromOval (rect.Inset(inset, inset));
     Color.SetFill ();
     outer.Fill ();
     Border.SetStroke ();
     outer.LineWidth = inset;
     outer.Stroke ();
 }
        public override void DrawInContext(CoreGraphics.CGContext ctx)
        {
            base.DrawInContext (ctx);

            var knobFrame = CGRect.Inflate(PaintFrame, -2.0f, -2.0f);

            UIBezierPath knobPath = UIBezierPath.FromRoundedRect((CGRect)knobFrame, (nfloat)knobFrame.Height * Slider.Curvaceousness / 2.0f);

            // 1) fill - with a subtle shadow
            ctx.SetShadow(new CGSize(0, 1), 1.0f, UIColor.Gray.CGColor);
            ctx.SetFillColor( Slider.KnobColor.CGColor);
            ctx.AddPath( knobPath.CGPath);
            ctx.FillPath ();

            // 2) outline
            ctx.SetStrokeColor(UIColor.Gray.CGColor);
            ctx.SetLineWidth((nfloat)0.5f);
            ctx.AddPath(knobPath.CGPath);
            ctx.StrokePath ();

            // 3) inner gradient
            var rect = CGRect.Inflate(knobFrame, -2.0f, -2.0f);
            var clipPath = UIBezierPath.FromRoundedRect ((CGRect)rect, (nfloat)rect.Height * Slider.Curvaceousness / 2.0f);

            CGGradient myGradient;
            CGColorSpace myColorspace;

            nfloat[] locations = { 0.0f, 1.0f };
            nfloat[] components = { 0.0f, 0.0f, 0.0f , 0.15f,  // Start color
                0.0f, 0.0f, 0.0f, 0.05f }; // End color

            myColorspace = CGColorSpace.CreateDeviceRGB (); // CGColorSpaceCreateDeviceRGB();
            myGradient = new CGGradient( myColorspace, components, locations);

            CGPoint startPoint = new CGPoint((float)rect.GetMidX(), (float)rect.GetMinY());
            CGPoint endPoint = new CGPoint((float)rect.GetMidX(), (float)rect.GetMaxY());

            ctx.SaveState ();
            ctx.AddPath( clipPath.CGPath);
            ctx.Clip ();
            ctx.DrawLinearGradient( (CGGradient)myGradient, (CGPoint)startPoint, (CGPoint)endPoint, (CGGradientDrawingOptions)0);

            myGradient.Dispose ();
            myColorspace.Dispose();
            ctx.RestoreState();

            // 4) highlight
            if (Highlighted)
            {
                // fill
                ctx.SetFillColor(UIColor.FromWhiteAlpha((nfloat)0.0f, (nfloat)0.1f).CGColor);
                ctx.AddPath( knobPath.CGPath);
                ctx.FillPath();
            }
        }
Exemplo n.º 15
0
        public ImageScrollView(UIView View, nfloat Height, nfloat Width, UIColor BackgroundColor, CoreGraphics.CGSize imageSize)
        {
            this.Height = Height;
            this.Width = Width;
            this.scrollView = new UIScrollView {
                Frame = new CoreGraphics.CGRect (View.Bounds.Top, View.Bounds.Bottom - this.Height, View.Bounds.Width, this.Height),
                BackgroundColor = BackgroundColor
            };
            this.ImageSize = imageSize;

            View.AddSubview (this.scrollView);
        }
Exemplo n.º 16
0
 public override void DrawRect(CoreGraphics.CGRect dirtyRect)
 {
     mPath.RemoveAllPoints();
     CGRect bounds = this.Bounds;
     // Fill view with green
     NSColor.Green.Set();
     NSBezierPath.FillRect(bounds);
     NSColor.White.Set();
     foreach (Oval oval in Ovals) {
         mPath.AppendPathWithOvalInRect(oval.Rect);
     }
     mPath.Stroke();
 }
Exemplo n.º 17
0
        public override void Draw(CoreGraphics.CGRect bounds, CoreGraphics.CGContext context, UIKit.UIView view)
        {
            UIColor.White.SetFill ();
            context.FillRect (bounds);

            if (this.cell == null) {
                this.cell = new CheckPointTableCell ();
                view.AddSubview (cell);
            }
            cell.RenderCheckpointForDetail(this.data);

            view.LayoutIfNeeded ();
        }
        public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw (rect);
            Console.WriteLine ("Draw");

            if (root != null) {
                //start from root and draw lines to the children
                using (var g = UIGraphics.GetCurrentContext ()) {
                    UIColor.Red.SetStroke ();
                    //g.SetStrokeColor (UIColor.Red.CGColor);
                    g.SetLineWidth (2f);

                    drawLinesToChildren (g, root);
                }
            }
        }
		public override void Draw(CoreGraphics.CGRect rect)
		{
			//base.Draw(rect);

			// Elementをキャストしてformsで定義したCustomBoxViewを取得
			var formsBox = (CustomBoxView)Element;

			// iOSの描画はContextを使用
			using (var context = UIGraphics.GetCurrentContext())
			{
				// 吹き出しの設定
				// 色の設定
				context.SetFillColor(formsBox.FillColor.ToCGColor());

				// スタート位置の設定
				context.MoveTo(0, 0);

				// 結ぶ位置の設定
				context.AddLineToPoint(100, 10);
				context.AddLineToPoint(100, 100);

				// 設定した点を繋げる
				context.ClosePath();

				// 描画
				context.DrawPath(CGPathDrawingMode.Fill);

				// 角の丸い四角の設定
				// 角丸の設定
				// widthとheightを比較して小さい方を基準にする
				var minSize = (float)Math.Min(rect.Width, rect.Height);

				var radius = formsBox.Radius;
				// 指定するのは半径なので、minSize / 2以下でなければならない
				if (formsBox.Radius > minSize / 2)
					radius = minSize / 2;

				// パスの取得
				var path = CGPath.FromRoundedRect(rect, radius, radius);

				// コンテキストにパスを追加
				context.AddPath(path);

				// コンテキストを描画
				context.DrawPath(CGPathDrawingMode.Fill);
			}
		}
Exemplo n.º 20
0
		public override void Draw (CoreGraphics.CGRect rect)
		{
			try {
				base.Draw (rect);
				
				var c = UIGraphics.GetCurrentContext ();
				
				var e = new CanvasDrawingEventArgs (
					        new CoreGraphicsGraphics (c, true),
					        Bounds.ToRectangleF ()
				        );
				
				Drawing (this, e);
			} catch (Exception ex) {
				Log.Error (ex);
			}
		}
Exemplo n.º 21
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);
			}
Exemplo n.º 22
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            base.DrawRect (dirtyRect);

            if (onDrawCallback == null)
                return;

            // Just not that sharp using the scale pixel scale only
            // Going going 2x Pixel Scale
            var screenScale = (int)NSScreen.MainScreen.BackingScaleFactor * 2;
            var width = (int)Bounds.Width * screenScale;
            var height = (int)Bounds.Height * screenScale;

            IntPtr buff = System.Runtime.InteropServices.Marshal.AllocCoTaskMem (width * height * 4);
            try {

                using (var surface = SKSurface.Create (width, height, SKColorType.Rgba_8888, SKAlphaType.Premul, buff, width * 4)) {
                    var skcanvas = surface.Canvas;

                    skcanvas.Scale (screenScale, screenScale);

                    onDrawCallback (skcanvas, (int)Bounds.Width, (int)Bounds.Height);
                }

                using (var colorSpace = CoreGraphics.CGColorSpace.CreateDeviceRGB ()) {
                    int hack = ((int)CoreGraphics.CGBitmapFlags.ByteOrderDefault) | ((int)CoreGraphics.CGImageAlphaInfo.PremultipliedLast);
                    using (var bContext = new CoreGraphics.CGBitmapContext (buff, width, height, 8, width * 4, colorSpace, (CoreGraphics.CGImageAlphaInfo) hack)) {
                        using (var image = bContext.ToImage ()) {
                            using (var context = NSGraphicsContext.CurrentContext.GraphicsPort) {
                                context.DrawImage (Bounds, image);
                            }
                        }
                    }
                }
            } finally {
                if (buff != IntPtr.Zero)
                    System.Runtime.InteropServices.Marshal.FreeCoTaskMem (buff);
            }
        }
		public override void DidCropToImage (TOCropViewController cropViewController, UIImage image, CoreGraphics.CGRect cropRect, nint angle)
		{
			DidCrop = true;

			try 
			{
				if (image != null)
					App.CroppedImage = image.AsPNG().ToArray();

			}
			catch (Exception ex) {
				Debug.WriteLine (ex.Message);
			}
			finally
			{
				if (image != null) {
					image.Dispose ();
					image = null;
				}
			}

			parent.DismissViewController (true, App.PopModal);
		}
Exemplo n.º 24
0
		/// <summary>
		/// Draws the specified rect.
		/// </summary>
		/// <param name="rect">The rect.</param>
		public override void Draw(CoreGraphics.CGRect rect)
		{
			base.Draw(rect);


			var height = Bounds.Size.Height;
			//var percentage = (this.Limit - Math.Abs(this.CurrentValue)) / this.Limit;

			var context = UIGraphics.GetCurrentContext();

			context.ClearRect(rect);
			//context.SetFillColor(UIColor.Clear.CGColor);
			//context.FillRect(rect);
			context.SetStrokeColor(StrokeColor.CGColor);
			switch (StrokeType)
			{
				case StrokeType.Dashed:
					context.SetLineDash(0, new nfloat[] { 6, 2 });
					break;
				case StrokeType.Dotted:
					context.SetLineDash(0, new nfloat[] { (nfloat)Thickness, (nfloat)Thickness });
					break;
				default:

					break;
			}

			context.SetLineWidth((float)Thickness);
			var desiredTotalSpacing = SpacingAfter + SpacingBefore;

			float leftForSpacing = 0;
			float actualSpacingBefore = 0;
			float actualSpacingAfter = 0;

			if (Orientation == SeparatorOrientation.Horizontal)
			{
				leftForSpacing = (float)Bounds.Size.Height - (float)Thickness;
			}
			else
			{
				leftForSpacing = (float)Bounds.Size.Width - (float)Thickness;
			}
			if (desiredTotalSpacing > 0)
			{
				float spacingCompressionRatio = (float)(leftForSpacing / desiredTotalSpacing);
				actualSpacingBefore = (float)SpacingBefore * spacingCompressionRatio;
				actualSpacingAfter = (float)SpacingAfter * spacingCompressionRatio;
			}
			else
			{
				actualSpacingBefore = 0;
				actualSpacingAfter = 0;
			}
			float thicknessOffset = (float)Thickness / 2.0f;

			if (Orientation == SeparatorOrientation.Horizontal)
			{
				var half = Bounds.Size.Height / 2.0f;
				context.MoveTo(0, actualSpacingBefore + thicknessOffset);
				context.AddLineToPoint(rect.Width, actualSpacingBefore + thicknessOffset);
			}
			else
			{
				var half = Bounds.Size.Width / 2.0f;
				context.MoveTo(actualSpacingBefore + thicknessOffset, 0);
				context.AddLineToPoint(actualSpacingBefore + thicknessOffset, rect.Height);
			}
			context.StrokePath();
		}
Exemplo n.º 25
0
		/// <summary>
		/// Initializes a new instance of the <see cref="UISeparator"/> class.
		/// </summary>
		/// <param name="bounds">The bounds.</param>
		public UISeparator(CoreGraphics.CGRect bounds)
			: base(bounds)
		{
			Initialize();
		}
			public override void Draw (CoreGraphics.CGRect rect)
			{
				base.Draw (rect);

				var c = UIGraphics.GetCurrentContext ();

				var b = Bounds;

				//
				// Background
				//
				var theme = DocumentAppDelegate.Shared.Theme;
				var backColor =
					theme.IsDark ?
					(touching ?
						UIColor.Black :
						UIColor.FromWhiteAlpha (0.25f, 1.0f)) :
					(touching ?
						UIColor.FromRGB ((nfloat)229/2/255,(nfloat)229/2/255,(nfloat)238/2/255) :
						UIColor.FromRGB ((nfloat)229/255,(nfloat)229/255,(nfloat)238/255));

				backColor.SetFill ();
				var sw = (nfloat)10.0f;
				c.FillRect (new CGRect ((b.Width-sw)/2, 0, sw, b.Height));

				//
				// Draw the button
				//
				var buttonColor =
					theme.IsDark ?
					UIColor.FromWhiteAlpha (0.5f, 1) :
					UIColor.FromRGB ((nfloat)255/255,(nfloat)255/255,(nfloat)255/255);
				var bw = (nfloat)4.0f;
				var bh = (nfloat)44.0f;
				var l = (b.Width - bw) / 2;
				var t = (b.Height - bh) / 2;
				var bRect = new CGRect (l, t, bw, bh);
				var bp = UIBezierPath.FromRoundedRect (bRect, bw/2);
				buttonColor.SetFill ();
				bp.Fill ();
			}
Exemplo n.º 27
0
 public VlcVideoView(CoreGraphics.CGRect rect)
     : base(rect)
 {
     AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
 }
Exemplo n.º 28
0
 public override void ResizeSubviewsWithOldSize(CoreGraphics.CGSize oldSize)
 {
     base.ResizeSubviewsWithOldSize(oldSize);
     ResizeWithCorrectAspectRatio();
 }
Exemplo n.º 29
0
        // Draw the view
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            CGRect bounds = this.Bounds;

            // Using the system focus ring instead. Achieved by overriding DrawFocusRingMask and FocusRingMaskBounds
            //			// Am I the window's first responder?
            //			if (this.Window.FirstResponder == this) {
            //				NSColor.KeyboardFocusIndicator.Set();
            //				NSBezierPath.DefaultLineWidth = 4.0f;
            //				NSBezierPath.StrokeRect(bounds);
            //			}

            if (Highlighted) {
                NSGradient gr = new NSGradient(NSColor.White, mBgColor);
                gr.DrawInRect(bounds, new CGPoint(0.0f, 0.0f));
            } else {
                mBgColor.Set();
                NSBezierPath.FillRect(bounds);
            }

            DrawStringCenteredInRectangle(mLetter, bounds);
        }
Exemplo n.º 30
0
		public override void Draw (CoreGraphics.CGRect rect)
		{
			base.Draw (rect);
			Layer.CornerRadius = 8;
			ClipsToBounds = true;
		}