public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw(rect);
            this.LayoutIfNeeded();

            var          control      = (RoundedCornerView)Element;
            UIRectCorner uIRectCorner = 0;

            if (control != null)
            {
                if (control.TopLeft)
                {
                    uIRectCorner |= UIRectCorner.TopLeft;
                }
                if (control.TopRight)
                {
                    uIRectCorner |= UIRectCorner.TopRight;
                }
                if (control.BottomLeft)
                {
                    uIRectCorner |= UIRectCorner.BottomRight;
                }
                if (control.BottomRight)
                {
                    uIRectCorner |= UIRectCorner.BottomLeft;
                }

                if (!control.BottomLeft && !control.BottomRight && !control.TopLeft && !control.TopRight)
                {
                    uIRectCorner = UIRectCorner.AllCorners;
                }

                nfloat radius            = control.CornerRadius;
                var    maskingShapeLayer = new CAShapeLayer
                {
                    Path = UIBezierPath.FromRoundedRect(Bounds, uIRectCorner, new CGSize(radius, radius)).CGPath
                };
                Layer.Mask = maskingShapeLayer;

                this.ClipsToBounds       = true;
                this.Layer.MasksToBounds = true;
                this.Layer.BorderWidth   = control.BorderWidth;

                if (control.BorderWidth > 0)
                {
                    control.Padding        = new Thickness(control.BorderWidth);
                    this.Layer.BorderColor = control.BorderColor.ToCGColor();
                }
            }
        }
Ejemplo n.º 2
0
        public void AddEllipseInRect()
        {
            var rect   = new RectangleF(0, 0, 15, 15);
            var matrix = CGAffineTransform.MakeIdentity();

            using (CGPath p1 = new CGPath())
                using (CGPath p2 = new CGPath()) {
                    Assert.IsTrue(p1.IsEmpty, "IsEmpty-1");
                    p1.AddEllipseInRect(rect);
                    p2.AddEllipseInRect(matrix, rect);
                    Assert.IsFalse(p1.IsEmpty, "IsEmpty-2");
                    Assert.That(p1, Is.EqualTo(p2), "CGPathEqualToPath");
                }
        }
        public void IF_ShowView(View view, Point point, Action completeAction)
        {
            var renderer = Platform.CreateRenderer(view);
            var size     = new CoreGraphics.CGRect(point.X, point.Y, 100, 50);

            renderer.NativeView.Frame            = size;
            renderer.NativeView.AutoresizingMask = UIViewAutoresizing.All;
            renderer.NativeView.ContentMode      = UIViewContentMode.ScaleToFill;
            renderer.Element.Layout(size.ToRectangle());
            var nativeView = renderer.NativeView;

            nativeView.SetNeedsLayout();
            nativeView.Layer.CornerRadius = 5;

            var window = GetCurrentWindow();

            var coverView = new UIView(new CGRect(0, 0, window.Bounds.Width, window.Bounds.Height));

            coverView.BackgroundColor = UIColor.Gray.ColorWithAlpha(0.5f);
            coverView.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                UIView.Animate(duration: 0.2, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut,
                               animation: () =>
                {
                    nativeView.Frame = new CGRect(size.X, size.Y, 0, 0);
                    coverView.AddSubview(nativeView);
                },
                               completion: () =>
                {
                    coverView.RemoveFromSuperview();
                    if (completeAction != null)
                    {
                        completeAction();
                    }
                });
            }));
            window.AddSubview(coverView);

            nativeView.Frame = new CGRect(size.X + 50, size.Y + 25, 0, 0);

            UIView.Animate(duration: 0.1, delay: 0, options: UIViewAnimationOptions.CurveEaseOut,
                           animation: () =>
            {
                nativeView.Frame = new CGRect(size.X, size.Y, size.Width, 50);
                coverView.AddSubview(nativeView);
            },
                           completion: () =>
            {
            });
        }
Ejemplo n.º 4
0
        public override void DrawText(CoreGraphics.CGRect rect)
        {
            // by default, the label renders its text in the center of the frame.
            // we want the text to render at the top of the frame, so we must shrink the text bounds to just encompass the text.
            if (VerticalAlignment == VerticalAlignment.Stretch && !string.IsNullOrEmpty(Text))
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    rect = MeasureString(Text, rect.Size);
                }
            }

            base.DrawText(rect);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draw the specified rect.
        /// </summary>
        /// <param name="rect">Rect.</param>
        public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw(rect);

            using (CGContext context = UIGraphics.GetCurrentContext())
            {
                context.SetAllowsAntialiasing(true);
                context.SetShouldAntialias(true);
                context.SetShouldSmoothFonts(true);

                var canvas = new CGContextCanvas(context);
                Element.Draw(canvas, new NGraphics.Rect(rect.Left, rect.Top, rect.Width, rect.Height));
            }
        }
Ejemplo n.º 6
0
        public static NSMutableData CreatePdfFile(this WebKit.WKWebView webView, UIViewPrintFormatter printFormatter)
        {
            var bounds = webView.Bounds;

            webView.Bounds = new CoreGraphics.CGRect(bounds.X, bounds.Y, bounds.Width, webView.ScrollView.ContentSize.Height);
            var pdfPageFrame = new CoreGraphics.CGRect(0, 0, webView.Bounds.Width, webView.Bounds.Height);
            var renderer     = new PdfRenderer();

            renderer.AddPrintFormatter(printFormatter, 0);
            renderer.SetValueForKey(NSValue.FromCGRect(UIScreen.MainScreen.Bounds), new NSString("paperRect"));
            renderer.SetValueForKey(NSValue.FromCGRect(pdfPageFrame), new NSString("printableRect"));
            webView.Bounds = bounds;
            return(renderer.PrintToPdf());
        }
Ejemplo n.º 7
0
            public LoadingView()
            {
                Frame=new CoreGraphics.CGRect(new CoreGraphics.CGPoint(0,0),UIScreen.MainScreen.Bounds.Size);
                BackgroundColor=UIColor.FromRGBA(0,0,0,50);
                AutoresizingMask=UIViewAutoresizing.All;
                UIImage img=UIImage.FromBundle("1143454.gif");
                UIImageView imgView=new UIImageView(img);
                UIView.BeginAnimations(null);
                UIView.SetAnimationDuration(10);
                UIView.SetAnimationRepeatCount(10000000);

                imgView.Transform=CGAffineTransform.MakeRotation(360);
                UIView.CommitAnimations();
                AddSubview(imgView);
            }
Ejemplo n.º 8
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();
        }
        public AppDelegate()
        {
            ObjCRuntime.Runtime.MarshalManagedException += (sender, args) =>
            {
                Console.WriteLine(args.Exception);
            };

            var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;

            var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);

            //var rect = NSWindow.FrameRectFor(NSScreen.MainScreen.Frame, style);
            _window                 = new NSWindow(rect, style, NSBackingStore.Buffered, false);
            _window.Title           = "Twitter XF Mac";
            _window.TitleVisibility = NSWindowTitleVisibility.Hidden;
        }
Ejemplo n.º 10
0
        public CollectionViewCell(RectangleF frame) : base(frame)
        {
            var rand = new Random();

            BackgroundView = new UIView {
                BackgroundColor = UIColor.FromRGB(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256))
            };
            SelectedBackgroundView = new UIView {
                BackgroundColor = UIColor.Green
            };
            ContentView.Layer.BorderColor = UIColor.LightGray.CGColor;
            ContentView.Layer.BorderWidth = 2.0f;
            Label        = new UILabel(frame);
            Label.Center = ContentView.Center;
            ContentView.AddSubview(Label);
        }
Ejemplo n.º 11
0
        public Window()
        {
            var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
            var rect  = new CoreGraphics.CGRect(100, 100, 1024, 768);

            _window = new Uno.UI.Controls.Window(rect, style, NSBackingStore.Buffered, false);

            _mainController = ViewControllerGenerator?.Invoke() ?? new RootViewController();

            ObserveOrientationAndSize();

            Dispatcher = CoreDispatcher.Main;
            CoreWindow = new CoreWindow(_window);

            InitializeCommon();
        }
        private NSData CreatePdfFile(UIViewPrintFormatter printFormatter)
        {
            var renderer = new UIPrintPageRenderer();

            renderer.AddPrintFormatter(printFormatter, 0);
            var point = new CoreGraphics.CGPoint(0, 0);

            var paperSize     = new CoreGraphics.CGSize(this.Frame.Size.Width, this.Frame.Size.Height);
            var printableRect = new CoreGraphics.CGRect(point, new CoreGraphics.CGSize(paperSize.Width, paperSize.Height));
            var paperRect     = new CoreGraphics.CGRect(point, new CoreGraphics.CGSize(paperSize.Width, paperSize.Height));

            renderer.SetValueForKey(NSValue.FromCGRect(paperRect), new NSString("paperRect"));
            renderer.SetValueForKey(NSValue.FromCGRect(printableRect), new NSString("printableRect"));

            return(renderer.PrintToPDF(paperRect));
        }
Ejemplo n.º 13
0
        public override void DrawRect(CoreGraphics.CGRect area, UIViewPrintFormatter formatter)
        {
            //var width = area.Width - (margin * 2);
            //var height = area.Height - (margin * 2);

            //var path = new CGPath();

            //path.MoveToPoint(margin + radius, margin);


            //path.

            //draw rectangle

            base.DrawRect(area, formatter);
        }
Ejemplo n.º 14
0
			public unsafe override void Draw (RectangleF rect)
			{
				var start = new PointF (rect.Left, rect.Bottom);
				var end = new PointF (rect.Left, rect.Top);

				var domain = new nfloat[] {0f, 1f};
				var range = new nfloat[] {0f, 1f, 0f, 1f};
				using (var context = UIGraphics.GetCurrentContext ())
				using (var rgb = CGColorSpace.CreateDeviceGray())
				using (var shadingFunction = new CGFunction(domain, range, Shading))
				using (var shading = CGShading.CreateAxial (rgb, start, end, shadingFunction, true, false))
				{
					context.DrawShading (shading);
				}

				base.Draw (rect);
			}
Ejemplo n.º 15
0
        //This method allows us to update the insets if the Frame changes
        internal void UpdateInsets()
        {
            //being called from LayoutSubviews but keyboard wasn't shown yet
            if (_lastKeyboardRect.IsEmpty)
            {
                return;
            }

            UIWindow window = _fetchWindow();

            // Code left verbose to make its operation more obvious
            if (window == null)
            {
                // we are not currently displayed and can safely ignore this
                // most likely this renderer is on a page which is currently not displayed (e.g. in NavController)
                return;
            }

            UIView field = FindFirstResponder(_targetView);

            //the view that is triggering the keyboard is not inside our UITableView?
            //if (field == null)
            //  return;

            CGSize boundsSize = _targetView.Frame.Size;

            //since our keyboard frame is RVC CoordinateSpace, lets convert it to our targetView CoordinateSpace
            CGRect rect = _targetView.Superview.ConvertRectFromView(_lastKeyboardRect, null);
            //let's see how much does it cover our target view
            CGRect overlay = RectangleF.Intersect(rect, _targetView.Frame);

            _setInsetAction(new UIEdgeInsets(0, 0, overlay.Height, 0));

            if (field is UITextView &&
                _setContentOffset != null)
            {
                nfloat  keyboardTop   = boundsSize.Height - overlay.Height;
                CGPoint fieldPosition = field.ConvertPointToView(field.Frame.Location, _targetView.Superview);
                nfloat  fieldBottom   = fieldPosition.Y + field.Frame.Height;
                nfloat  offset        = fieldBottom - keyboardTop;
                if (offset > 0)
                {
                    _setContentOffset(new PointF(0, offset));
                }
            }
        }
        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);
                }
            }
        }
Ejemplo n.º 17
0
        public override void DrawInRect(GLKView view, CoreGraphics.CGRect rect)
        {
            if (!isActive())
            {
                return;
            }

            UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;
            CGSize size;

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            if (firstGLUpdate == false)
            {
                ApplyCameraGlOrientation(orientation);
                firstGLUpdate = true;
            }
            if (orientation == UIInterfaceOrientation.Portrait ||
                orientation == UIInterfaceOrientation.PortraitUpsideDown)
            {
                size = new CGSize(ViewportHeight, ViewportWidth);
            }
            else
            {
                size = new CGSize(ViewportWidth, ViewportHeight);
            }

            RenderCamera(size, Angle);

            if (isTracking())
            {
                if (CurrentMarker != null)
                {
                    if (CurrentMarker.Id == "3_543")
                    {
                        float[] mvpMatrix = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                        if (computeModelViewProjectionMatrix(ref mvpMatrix))
                        {
                            mMonkeyMesh.DrawMesh(ref mvpMatrix);
                            RenderUtils.CheckGLError();
                        }
                    }
                }
            }
            GL.Finish();
        }
Ejemplo n.º 18
0
        public override void Draw(CoreGraphics.CGRect rect)
        {
            RoundedBoxView rbv = (RoundedBoxView)this.Element;

            using (var context = UIGraphics.GetCurrentContext()) {
                context.SetFillColor(rbv.Color.ToCGColor());
                context.SetStrokeColor(rbv.OutlineColor.ToCGColor());
                context.SetLineWidth((float)rbv.OutlineWidth);

                var rc = this.Bounds.Inset(5, 5);

                float radius = (float)rbv.CornerRadius;
                radius = (float)Math.Max(0, Math.Min(radius, Math.Max(rc.Height / 2, rc.Width / 2)));
                var path = CGPath.FromRoundedRect(rc, radius, radius);
                context.AddPath(path);
                context.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
Ejemplo n.º 19
0
        public static NSMutableData CreatePdfFile(this WKWebView webView, UIViewPrintFormatter printFormatter, PageSize pageSize, PageMargin margin)
        {
            var bounds = webView.Bounds;

            //webView.Bounds = new CoreGraphics.CGRect(bounds.X, bounds.Y, bounds.Width, webView.ScrollView.ContentSize.Height);
            webView.Bounds = new CoreGraphics.CGRect(0, 0, (nfloat)pageSize.Width, (nfloat)pageSize.Height);
            margin         = margin ?? new PageMargin();
            var pdfPageFrame = new CoreGraphics.CGRect((nfloat)margin.Left, (nfloat)margin.Top, webView.Bounds.Width - margin.HorizontalThickness, webView.Bounds.Height - margin.VerticalThickness);
            //var pdfPageFrame = new CoreGraphics.CGRect(0, 0, 72 * 8, 72 * 10.5);
            var renderer = new PdfRenderer();

            renderer.AddPrintFormatter(printFormatter, 0);
            //renderer.SetValueForKey(NSValue.FromCGRect(UIScreen.MainScreen.Bounds), new NSString("paperRect"));
            renderer.SetValueForKey(NSValue.FromCGRect(webView.Bounds), new NSString("paperRect"));
            renderer.SetValueForKey(NSValue.FromCGRect(pdfPageFrame), new NSString("printableRect"));
            webView.Bounds = bounds;
            return(renderer.PrintToPdf());
        }
Ejemplo n.º 20
0
        public override void ViewWillAppear(bool animated)
        {
            RectangleF navigationFrame = MenuAreaController.View.Frame;

            if (MenuLocation == MenuLocations.Right)
            {
                navigationFrame.X = navigationFrame.Width - MenuWidth;
            }
            else if (MenuLocation == MenuLocations.Left)
            {
                navigationFrame.X = 0;
            }
            navigationFrame.Width         = MenuWidth;
            navigationFrame.Location      = PointF.Empty;
            MenuAreaController.View.Frame = navigationFrame;
            View.SetNeedsLayout();
            base.ViewWillAppear(animated);
        }
        public override void Draw(CoreGraphics.CGRect rect)
        {
            CustomBoxView boxView = (CustomBoxView)Element;

            using (var context = UIGraphics.GetCurrentContext())
            {
                context.SetFillColor(boxView.Color.ToCGColor());
                context.SetStrokeColor(boxView.BorderColor.ToCGColor());
                context.SetLineWidth((float)boxView.BorderThickness);


                var rectangle = Bounds.Inset((int)boxView.BorderThickness,
                                             (int)boxView.BorderThickness);

                var path = CGPath.FromRect(rectangle);
                context.AddPath(path);
                context.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
Ejemplo n.º 22
0
        public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw(rect);

            var exBoxView = (ExBoxView)Element;

            using (var context = UIGraphics.GetCurrentContext())
            {
                var shadowSize = exBoxView.ShadowSize;
                var blur       = shadowSize;
                var radius     = exBoxView.Radius;

                context.SetFillColor(exBoxView.Color.ToCGColor());
                var bounds = Bounds.Inset(shadowSize * 2, shadowSize * 2);
                context.AddPath(CGPath.FromRoundedRect(bounds, radius, radius));
                context.SetShadow(new SizeF(shadowSize, shadowSize), blur);
                context.DrawPath(CGPathDrawingMode.Fill);
            }
        }
Ejemplo n.º 23
0
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            RectangleF navigationFrame = View.Bounds;

            if (MenuLocation == MenuLocations.Right)
            {
                navigationFrame.X = navigationFrame.Width - MenuWidth;
            }
            else if (MenuLocation == MenuLocations.Left)
            {
                navigationFrame.X = 0;
            }
            navigationFrame.Width = MenuWidth;
            if (MenuAreaController.View.Frame != navigationFrame)
            {
                MenuAreaController.View.Frame = navigationFrame;
            }
        }
Ejemplo n.º 24
0
        public static async void ShowWebivew(WebAuthenticatorWebView webview)
        {
            var app  = NSApplication.SharedApplication;
            var rect = new CoreGraphics.CGRect(0, 0, 400, 600);

            window = new ModalWindow(webview, rect);
            while (shownInWindow == null)
            {
                shownInWindow = app.MainWindow;
                if (shownInWindow == null)
                {
                    await Task.Delay(1000);
                }
            }

            webview.BeginLoadingInitialUrl();
            app.RunModalForWindow(window);
            //app.BeginSheet (window, shownInWindow);
        }
        public UIImage ImageFromGradient(string color)
        {
            var gradientArray = color.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);

            nfloat[]  locations = new nfloat[gradientArray.Length];
            CGColor[] colorList = new CGColor[gradientArray.Length];
            for (int i = 0; i < gradientArray.Length; i++)
            {
                var gradientColorOffset = gradientArray[i].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                colorList[i] = Xamarin.Forms.Color.FromHex(gradientColorOffset[0]).ToCGColor();
                int   offsetInt   = Int32.Parse(gradientColorOffset[1].Replace("%", ""));
                float offsetFloat = offsetInt / 100f;
                locations[i] = offsetFloat;
            }

            var rect = new CoreGraphics.CGRect(0, 0, Control.Frame.Width, Control.Frame.Height);

            var colorSpace = CGColorSpace.CreateDeviceRGB();

            UIGraphics.BeginImageContext(rect.Size);
            CoreGraphics.CGGradient gradient = new CGGradient(colorSpace, colorList, locations);

            colorSpace.Dispose();

            var context = UIGraphics.GetCurrentContext();

            context.DrawLinearGradient(gradient, new CGPoint(0, 0), new CGPoint(0, Control.Frame.Height), CGGradientDrawingOptions.None);

            gradient.Dispose();

            try
            {
                var img = UIGraphics.GetImageFromCurrentImageContext();

                UIGraphics.EndImageContext();

                return(img);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 26
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            if (mImage == null)
            {
                base.DrawRect(dirtyRect);
                return;
            }

            using (CGContext gc = NSGraphicsContext.CurrentContext.GraphicsPort)
            {
                if (mDrawBackground)
                {
                    DrawBackground(gc);
                }

                gc.DrawImage(Frame, mImage.CGImage);
                DrawImageBorder(gc, Frame, ImageDiffColors.ImageBorderColor);
            }
        }
Ejemplo n.º 27
0
            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();
            }
        public override void Draw(CoreGraphics.CGRect rect)
        {
            base.Draw(rect);

            this.LayoutIfNeeded();

            RoundedContentView rcv = (RoundedContentView)Element;

            if (rcv == null)
            {
                return;
            }
            this.ClipsToBounds         = true;
            this.Layer.BackgroundColor = rcv.FillColor.ToCGColor();
            this.Layer.MasksToBounds   = true;
            this.Layer.CornerRadius    = (nfloat)rcv.CornerRadius;
            if (rcv.HasShadow)
            {
                this.Layer.ShadowRadius  = 3.0f;
                this.Layer.ShadowColor   = UIColor.Gray.CGColor;
                this.Layer.ShadowOffset  = new CGSize(1, 1);
                this.Layer.ShadowOpacity = 0.60f;
                //this.Layer.ShadowPath = UIBezierPath.FromRect(Layer.ContentsRect).CGPath;
                this.Layer.MasksToBounds = false;
            }
            if (rcv.Circle)
            {
                this.Layer.CornerRadius = (int)(Math.Min(Element.Width, Element.Height) / 2);
            }
            this.Layer.BorderWidth = 0;

            if (rcv.BorderWidth > 0 && rcv.BorderColor.A > 0.0)
            {
                this.Layer.BorderWidth = rcv.BorderWidth;
                this.Layer.BorderColor =
                    new UIKit.UIColor(
                        (nfloat)rcv.BorderColor.R,
                        (nfloat)rcv.BorderColor.G,
                        (nfloat)rcv.BorderColor.B,
                        (nfloat)rcv.BorderColor.A).CGColor;
            }
        }
        private void ShowLoginUI()
        {
            // Get the URL for the service being requested.
            var info       = _loginTaskCompletionSource.Task.AsyncState as CredentialRequestInfo;
            var serviceUrl = info.ServiceUri.GetLeftPart(UriPartial.Path);

            // Create a view to show login controls over the map view.
            var ovBounds = new CoreGraphics.CGRect(0, 80, _myMapView.Bounds.Width, _myMapView.Bounds.Height - 80);

            _loginUI = new LoginOverlay(ovBounds, 0.85f, UIColor.DarkGray, serviceUrl);

            // Handle the login event to get the login entered by the user.
            _loginUI.OnLoginInfoEntered += LoginEntered;

            // Handle the cancel event when the user closes the dialog without entering a login.
            _loginUI.OnCanceled += LoginCanceled;

            // Add the login UI view (will display semi-transparent over the map view)
            View.Add(_loginUI);
        }
Ejemplo n.º 30
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            if (DarkTheme)
            {
                NSColor.Clear.Set();
                NSGraphics.RectFill(dirtyRect, NSCompositingOperation.SourceOver);
                return;
            }
            else
            {
                NSColor.FromRgb(245, 245, 245).Set();
                NSBezierPath.FillRect(dirtyRect);
            }

            if (dirtyRect.Y == 0 && !DarkTheme)
            {
                NSColor.FromRgb(233, 233, 233).Set();
                NSBezierPath.FillRect(new CGRect(dirtyRect.X, 0, dirtyRect.Width, 1));
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Places the root view on top of the navigation view.
        /// </summary>
        private void SetVisibleView()
        {
            if (!StatusBarMoves)
            {
                UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade);
            }

            RectangleF frame = View.Bounds;

            if (IsOpen)
            {
                frame.X = MenuWidth;
            }

            SetViewSize();
            SetLocation(frame);

            View.AddSubview(_contentAreaView);
            AddChildViewController(ContentAreaController);
        }
		public override nfloat Height (RectangleF bounds)
		{
			var height = 40.0f + TextHeight (bounds);
			return height;
		}
Ejemplo n.º 33
0
		public void AddProcedure(string code,string description)
		{
			
			UITextView txtdesc;
			UIView view = procedureScrollView.ViewWithTag(procedurewithTag);
			if (view != null) {
				txtdesc = view as UITextView;
				if (string.IsNullOrEmpty (txtdesc.Text)) {
					return;
				}
			}

			CoreGraphics.CGRect descriptionFrame = new CoreGraphics.CGRect(14,baseYProcDescriptionValue,377,30);
			CoreGraphics.CGRect codeFrame = new CoreGraphics.CGRect(405,baseYProcCodeValue,70,30);

			UITextField codeText = new UITextField(codeFrame);
			MultilineTextView descriptionText = new MultilineTextView(descriptionFrame);
			codeText.Text=code;
			codeText.BorderStyle = UITextBorderStyle.RoundedRect;

			procedurecodewithTag = procedurecodewithTag + 1;
			codeText.Tag = procedurecodewithTag;
			codeText.ShouldBeginEditing += delegate {
				if(this.procedureDetails == null){
					showKeyBoard = false;
					return false;
				}else{
					showKeyBoard = true;
					return true;
				}
			};

			codeText.EditingDidEnd += (object sender, EventArgs e) => {
				showKeyBoard = false;
			};

			descriptionText.ShouldBeginEditing += delegate {
				if(this.procedureDetails == null){
					return false;
				}else{
					showKeyBoard = true;
					return true;
				}
			};

			descriptionText.ShouldEndEditing += delegate {
				showKeyBoard = false;
				return true;
			};


			procedurewithTag = procedurewithTag+1 ;
			descriptionText.Tag =procedurewithTag;

			int mh=MeasureTextLine(description);
			nfloat fh=30;
			if (mh == 280) {

				baseYProcDescriptionValue += 10;
				baseYProcCodeValue += 10;	
				mh=30;
			}
			else if(mh>600 && mh < 899){								
				baseYProcDescriptionValue += 20;
				baseYProcCodeValue += 20;	
				fh=50;
			}
			else if (mh > 900) {
				baseYProcDescriptionValue += 30;
				baseYProcCodeValue += 30;	
				fh = 60;
			} else if (mh > 1200) {
				baseYProcDescriptionValue += 40;
				baseYProcCodeValue += 40;	
				fh = 77;
			}
			descriptionText.Layer.Frame=new CoreGraphics.CGRect(descriptionText.Frame.X,descriptionText.Frame.Y,descriptionText.Frame.Width,fh);	
			descriptionText.Text=description;

			//descriptionText.Changed += (senderDesc, e) => {
			descriptionText.Changed += (senderDesc, e) => {

				txtpmrn.ResignFirstResponder();
				txtpFirstName.ResignFirstResponder();
				txtpLastName.ResignFirstResponder();

				if(descriptionText.Text.Length > 1)
				{	
//					bool itemPreviouslySearched = false;
//					string lastSelectedProcedures = ReadFile("lastSelectedProcedures.txt");
//					if(lastSelectedProcedures != string.Empty){
//						lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastSelectedProcedures,typeof(ProcedureDiagnosticMaster));
//						foreach (DataResults item in lastSelectedProceduresObj.results) {
//							if(item.Name != null){
//								if(item.Name.ToLower().Contains(descriptionText.Text.Trim().ToLower())){
//									itemPreviouslySearched = true;
//									break;
//								}
//							}
//						}
//					}

//					if(itemPreviouslySearched){
//						int uvWidth=280;
//						List<CodePickerModel> list=SetDataSource(out uvWidth,lastSelectedProceduresObj);
//						float x = (float)descriptionText.Frame.X;
//						float y = (float)descriptionText.Frame.Y;
//
//						cp	=new CodePicker(this,uvWidth,descriptionText.Text,"CPT");
//						cp.PresentFromPopover(descriptionText,x,y,uvWidth);
//						cp.DataSource=list;
//						cp._ValueChanged +=  async delegate {		
//							int ProcCodeID = cp.SelectedValue;
//							codeText.Text = cp.SelectedCodeValue;
//							int nl=MeasureTextLine(cp.SelectedText);
//							nfloat th=30;
//							if (nl == 280) {
//
//								baseYProcDescriptionValue += 0;
//								baseYProcCodeValue += 0;	
//								mh=30;
//							}
//							else if(nl>600 && nl < 899){								
//								baseYProcDescriptionValue += 10;
//								baseYProcCodeValue += 10;	
//								th=50;
//							}
//							else if(nl>900){
//
//								baseYProcDescriptionValue += 20;
//								baseYProcCodeValue += 20;	
//								th=60;
//							}
//							else if(nl>1200){
//								baseYProcDescriptionValue += 30;
//								baseYProcCodeValue += 30;	
//								th=77;
//							}
//							descriptionText.Layer.Frame=new CoreGraphics.CGRect(descriptionText.Frame.X,descriptionText.Frame.Y,descriptionText.Frame.Width,th);	
//							descriptionText.Text = cp.SelectedText;
//
//							UpdateProcedureDiagnostic(ProcCodeID,cp.SelectedCodeValue,cp.SelectedText,1);
//							selectedprocedureCodeid.Add(ProcCodeID);
//						}; 
//					}else{
//						if(descriptionText.Text.Trim().Length > 0)
//						{
							DownloadData("CPT",descriptionText.Text,codeText,descriptionText);

//						}
//					}
				}

			};


			procedureScrollView.AddSubview(codeText);
			baseYProcCodeValue += 54;

			procedureScrollView.AddSubview(descriptionText);
			baseYProcDescriptionValue += 54;

			procedureScrollView.SizeToFit ();

			procedureScrollView.ContentSize = new SizeF (float.Parse (procedureScrollView.Frame.Width.ToString ()), float.Parse (procedureScrollView.Frame.Height.ToString ())+55
			);
		}
		private nfloat TextHeight (RectangleF bounds)
		{
			using (NSString str = new NSString (this.Subject))
			{
				return str.GetBoundingRect (new SizeF (bounds.Width - 20, 1000), NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
				{
					Font = subjectFont,
					ParagraphStyle = new NSMutableParagraphStyle ()
					{
						LineBreakMode = UILineBreakMode.WordWrap,	
					},
				}, null).Height;
			}
		}
Ejemplo n.º 35
0
			public override void LayoutSubviews()
			{
				base.LayoutSubviews();
				if (Items == null || Items.Length == 0)
					return;
				nfloat padding = 11f;
				var itemWidth = (Bounds.Width - padding) / Items.Length - padding;
				var x = padding;
				var itemH = Bounds.Height - 10;
				foreach (var item in Items)
				{
					var frame = new RectangleF(x, 5, itemWidth, itemH);
					item.CustomView.Frame = frame;
					x += itemWidth + padding;
				}
				x = itemWidth + padding * 1.5f;
				var y = Bounds.GetMidY();
				foreach (var l in _lines)
				{
					l.Center = new PointF(x, y);
					x += itemWidth + padding;
				}
			}
Ejemplo n.º 36
0
		public IImage ImageFromFile (string filename)
		{
#if MONOMAC
			var img = new NSImage ("Images/" + filename);
			var rect = new NativeRect (NativePoint.Empty, img.Size);
			return new UIKitImage (img.AsCGImage (ref rect, NSGraphicsContext.CurrentContext, new Foundation.NSDictionary ()));
#else
			return new UIKitImage (UIImage.FromFile ("Images/" + filename).CGImage);
#endif
		}
		/// <summary>
		/// Sets the location of the root view.
		/// </summary>
		/// <param name="frame">Frame.</param>
		private void SetLocation(RectangleF frame)
		{
			frame.Y = 0;
			_contentAreaView.Layer.AnchorPoint = new PointF (.5f, .5f);

			// exit if we're already at the desired location
			if (_contentAreaView.Frame.Location == frame.Location)
				return;

			frame.Size = _contentAreaView.Frame.Size;

			// set the root views cetner
			var center = new PointF(frame.Left + frame.Width / 2,
				frame.Top + frame.Height / 2);
			_contentAreaView.Center = center;

			// if x is greater than 0 then position the status view
			if (Math.Abs(frame.X - 0) > float.Epsilon)
			{
				GetStatusImage();
				var statusFrame = _statusImage.Frame;
				statusFrame.X = _contentAreaView.Frame.X;
				_statusImage.Frame = statusFrame;
			}
		}
Ejemplo n.º 38
0
				public override void LayoutSubviews()
				{
					base.LayoutSubviews();

					const float padding = 5f;
					var imageSize = _imageView.SizeThatFits(Bounds.Size);
					var fullStringSize = _label.SizeThatFits(Bounds.Size);

					if (imageSize.Width > 0 && (string.IsNullOrEmpty(Text) || fullStringSize.Width > Bounds.Width / 3))
					{
						_imageView.Frame = new RectangleF(PointF.Empty, imageSize);
						_imageView.Center = new PointF(Bounds.GetMidX(), Bounds.GetMidY());
						_label.Hidden = true;
						return;
					}

					_label.Hidden = false;
					var availableWidth = Bounds.Width - padding * 3 - imageSize.Width;
					var stringSize = _label.SizeThatFits(new SizeF(availableWidth, Bounds.Height - padding * 2));

					availableWidth = Bounds.Width;
					availableWidth -= stringSize.Width;
					availableWidth -= imageSize.Width;

					var x = availableWidth / 2;

					var frame = new RectangleF(new PointF(x, Bounds.GetMidY() - imageSize.Height / 2), imageSize);
					_imageView.Frame = frame;

					frame.X = frame.Right + (imageSize.Width > 0 ? padding : 0);
					frame.Size = stringSize;
					frame.Height = Bounds.Height;
					frame.Y = 0;
					_label.Frame = frame;
				}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.Title = "More";
            var navBar = NavigationController.NavigationBar;
            navBar.BarTintColor = UIColor.White;

            nfloat ScreenWidth = UIScreen.MainScreen.Bounds.Width;
            nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
            navBar.ShadowImage = new UIImage();

            var ContactView = new UIView(new CGRect(0, 0, ScreenWidth, 300))
                {
                    BackgroundColor = UIColor.White
                };

            var ContactUsView = new UIViewWithBorders(new CGRect(0, 0, ScreenWidth, 55))
                {
                    BackgroundColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_4)
                };

            ContactUsView.BorderWidth = new UIEdgeInsets(1, 1, 1, 1);
            ContactUsView.BorderColorBottom = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_5);

            var ContactUsLabel = new UILabel(new CGRect(16, 15, ScreenWidth - 32, 39))
                {
                    Font = UIFont.FromName("HelveticaNeue", 12f),
                    TextAlignment = UITextAlignment.Left,
                    Text = "CONTACT US",
                    TextColor =  UIColor.Clear.FromHexString (RSColors.RS_DARK_GRAY),
                    BackgroundColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_4)
                };

            ContactUsView.Add(ContactUsLabel);
            ContactView.AddSubview(ContactUsView);

            //WebView
            var settingWebView = new UIWebView(new CGRect(0, ContactUsView.Frame.Height + ContactUsView.Frame.Y + 10, ContactUsView.Frame.Width, ContactView.Frame.Height - 120));
            loadingOverlay = new LoadingOverlay(settingWebView.Bounds);
            settingWebView.ScrollView.ScrollEnabled = false;
            settingWebView.AddSubview(loadingOverlay);
            ContactView.AddSubview(settingWebView);
            settingWebView.LoadRequest(new NSUrlRequest(new NSUrl(UrlConsts.URL_MORE_CONTACT_INFO)));
            settingWebView.LoadFinished += (sender, e) =>
                {
                    if (loadingOverlay != null)
                    {
                        loadingOverlay.Hide();
                        loadingOverlay = null;
                    }
                };
            settingWebView.BackgroundColor = UIColor.White;

            var MoreView = new UIView(new CGRect(-1, settingWebView.Frame.Height + settingWebView.Frame.Y + 1, ScreenWidth + 2, 55))
                {
                    BackgroundColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_4),
                };
            var MoreLabel = new UILabel(new CGRect(8, 15, 60, 39))
                {
                    Font = UIFont.FromName("HelveticaNeue", 12f),
                    TextAlignment = UITextAlignment.Left,
                    Text = "   MORE",
                    TextColor =  UIColor.Clear.FromHexString (RSColors.RS_DARK_GRAY)
                };
            MoreView.Layer.BorderWidth = 1;
            MoreView.Layer.BorderColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_5).CGColor;

            MoreView.AddSubview(MoreLabel);
            ContactView.AddSubview(MoreView);

            var SettingsTableData = new List<SettingsItem>();

            var profileItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "Personal Information"
                        },
                    OnClickAction = "PushProfile"
                };
            SettingsTableData.Add(profileItem);

            var changeLogInItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "Change Log In"
                        },
                    OnClickAction = "PushChangeLogIn"
                };
            SettingsTableData.Add(changeLogInItem);

            var retireLinkItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "Go to www.TextShield.com"
                        },
                    OnClickAction = "LaunchTextShieldWeb"
                };
            SettingsTableData.Add(retireLinkItem);

            var policyItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "Privacy Policy"
                        },
                    OnClickAction = "PushPrivatePolicy"
                };
            SettingsTableData.Add(policyItem);

            var legalItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "Legal"
                        },
                    OnClickAction = "PushLegal"
                };
            SettingsTableData.Add(legalItem);

            var termsItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "Terms of Use"
                        },
                    OnClickAction = "PushTermsConditions"
                };
            SettingsTableData.Add(termsItem);


            var versionItem = new SettingsItem
                {
                    EntryData = new TableData
                        {
                            Title = "About"
                        },
                    OnClickAction = "About"
                };
            SettingsTableData.Add(versionItem);

            var TableViewSource = new SettingsTableViewSource(this, SettingsTableData);

            CGRect SettingsTableViewFrame;
            CGRect LogoutButtonFrame;

            var statusNavHeight = NavigationController.NavigationBar.Frame.Height + UIApplication.SharedApplication.StatusBarFrame.Height;

            SettingsTableViewFrame = new CGRect(0, statusNavHeight, View.Frame.Width, View.Frame.Height - TabBarController.TabBar.Frame.Height - statusNavHeight);
            LogoutButtonFrame = new CoreGraphics.CGRect(-10, 15f, View.Frame.Width + 10, 55f);

            UITableView SettingsTableView = new UITableView(SettingsTableViewFrame);

            var LogoutButton = new UIButton(LogoutButtonFrame);

            var LogoutView = new UIViewWithBorders(new CGRect(0, 0, View.Frame.Width, 90f));
            LogoutView.BackgroundColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_4);
            LogoutButton.SetTitle("LOG OUT", UIControlState.Normal);
            LogoutButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            LogoutButton.Font = UIFont.FromName("HelveticaNeue-Medium", 14f);
            LogoutButton.SetTitleColor(UIColor.FromRGB(255, 54, 54), UIControlState.Normal);
            LogoutButton.BackgroundColor = UIColor.White;
            LogoutButton.Layer.BorderWidth = 1;
            LogoutButton.Layer.BorderColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_5).CGColor;
            SettingsTableView.SeparatorInset = new UIEdgeInsets(0, 16, 0, 0);

            if (!UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
            {
                SettingsTableView.ContentInset = new UIEdgeInsets(statusNavHeight * -1, 0, 0, 0);
            }
            LogoutView.Add(LogoutButton);
            SettingsTableView.BackgroundColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_4);
            SettingsTableView.TableHeaderView = ContactView;
            SettingsTableView.TableFooterView = LogoutView;
            LogoutView.BorderWidth = new UIEdgeInsets(1, 1, 1, 1);
            LogoutView.BorderColorTop = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_5);
            SettingsTableView.Source = TableViewSource;
            SettingsTableView.ReloadData();
            SettingsTableView.ScrollIndicatorInsets = new UIEdgeInsets(0, 0, 0, 0);
            View.AddSubview(SettingsTableView);
            View.BackgroundColor = UIColor.Clear.FromHexString(RSColors.RS_LIGHT_GRAY_4);

            LogoutButton.TouchUpInside += (object sender, EventArgs e) =>
                {
                    NSUserDefaults.StandardUserDefaults.SetBool(true, TouchIDUtil.TouchIDSettings.UserLogout.ToString());
                    base.InvalidateSession();
                };

        }
		public override void Draw (RectangleF bounds, CGContext context, UIView view)
		{
			UIColor.White.SetFill ();
			context.FillRect (bounds);
			
			context.DrawLinearGradient (gradient, new PointF (bounds.Left, bounds.Top), new PointF (bounds.Left, bounds.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);
			
			UIColor.Black.SetColor ();
			((NSString) From).DrawString (new RectangleF (10, 5, bounds.Width / 2, 10 ), NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
			{
				Font = fromFont,
			}, null);
			
			UIColor.Brown.SetColor ();
			((NSString) Sent).DrawString (new RectangleF (bounds.Width / 2, 5, (bounds.Width / 2) - 10, 10), NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
			{
				Font = dateFont,
				ParagraphStyle = new NSMutableParagraphStyle ()
				{
					Alignment = UITextAlignment.Right,
				},
			}, null);
			
			UIColor.DarkGray.SetColor();
			((NSString) Subject).DrawString (new RectangleF (10, 30, bounds.Width - 20, TextHeight (bounds)), NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
			{
				Font = subjectFont,
				ParagraphStyle = new NSMutableParagraphStyle ()
				{
					LineBreakMode = UILineBreakMode.WordWrap,
				},
			}, null);
		}
Ejemplo n.º 41
0
 public iPhoneOSGameView(RectangleF frame)
     : base(frame)
 {
     stopwatch = new System.Diagnostics.Stopwatch ();
 }