コード例 #1
0
        static unsafe UIImage DrawCells(int nfc, int cellSize, float[] data)
        {
            var width  = cellSize * nfc;
            var height = cellSize * nfc;

            UIGraphics.BeginImageContext(new CoreGraphics.CGSize(width, height));
            var maxi = Array.IndexOf(data, data.Max());

            for (var i = 0; i < nfc; i++)
            {
                var v = Math.Clamp(data[i], -1f, 1f);
                var r = v < 0 ? 255 : 0;
                var g = v >= 0 ? 255 : 0;
                UIColor.FromRGBA(r, g, 0, (byte)(255 * Math.Abs(v))).SetColor();
                UIGraphics.RectFill(new CoreGraphics.CGRect(i * cellSize, 0, cellSize, cellSize));
                if (i == maxi)
                {
                    i.ToString().DrawString(new CoreGraphics.CGPoint(i * cellSize, cellSize), UIFont.SystemFontOfSize(cellSize));
                }
                UIColor.FromWhiteAlpha(1.0f, 0.5f).SetColor();
                UIGraphics.RectFrame(new CoreGraphics.CGRect(i * cellSize, 0, cellSize, cellSize));
            }
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(image);
        }
コード例 #2
0
ファイル: TTTCountView.cs プロジェクト: zfs990/ios-samples
        public override void Draw(CGRect rect)
        {
            TintColor.SetColor();
            CGRect bounds = Bounds;
            float  x      = (float)bounds.Right - LineWidth;

            for (int n = 0; n < Count; n++)
            {
                x -= LineMargin;
                if ((n + 1) % LineGroupCount == 0)
                {
                    UIBezierPath path = new UIBezierPath();
                    path.MoveTo(
                        new CGPoint(x + 0.5f * LineWidth,
                                    bounds.Top + 0.5f * LineWidth));
                    path.AddLineTo(
                        new CGPoint(x + 0.5f * LineWidth + LineGroupCount * LineMargin,
                                    bounds.Bottom - 0.5f * LineWidth));
                    path.Stroke();
                }
                else
                {
                    CGRect lineRect = bounds;
                    lineRect.X     = x;
                    lineRect.Width = LineWidth;
                    UIGraphics.RectFill(lineRect);
                }
            }
        }
コード例 #3
0
        private void DrawBlankMiddleCircle()
        {
            var size = new SizeF(this.Bounds.Size.Width - 40f, this.Bounds.Size.Height - 40f);

            UIGraphics.BeginImageContextWithOptions(size, false, 0f);
            UIColor.Clear.SetFill();
            UIGraphics.RectFill(new RectangleF(0f, 0f, size.Width, size.Height));

            var radius = (nfloat)(Math.Min(size.Width, size.Height) / 2);
            var angle  = 2f * (float)Math.PI / 1;

            var center     = new PointF(size.Width / 2, size.Height / 2);
            var bezierPath = UIBezierPath.FromArc(center, radius, 0, 1 * angle, true);

            bezierPath.AddLineTo(center);
            bezierPath.ClosePath();

            var color = UIColor.FromRGB(83, 83, 83);

            color.SetFill();
            color.SetStroke();

            bezierPath.Fill();
            bezierPath.Stroke();

            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            img.Draw(new PointF(20f, 20f));
        }
コード例 #4
0
        private void DrawHueCircle()
        {
            var size = new SizeF(this.Bounds.Size.Width, this.Bounds.Size.Height);

            UIGraphics.BeginImageContextWithOptions(size, true, 0f);
            UIColor.FromRGB(83, 83, 83).SetFill();
            UIGraphics.RectFill(new RectangleF(0f, 0f, size.Width, size.Height));

            var          sectors = 180;
            var          radius  = (nfloat)(Math.Min(size.Width, size.Height) / 2);
            var          angle   = 2f * (float)Math.PI / sectors;
            UIBezierPath bezierPath;

            for (var i = 0; i < sectors; i++)
            {
                var center = new PointF(size.Width / 2, size.Height / 2);
                bezierPath = UIBezierPath.FromArc(center, radius, i * angle, (i + 1) * angle, true);
                bezierPath.AddLineTo(center);
                bezierPath.ClosePath();

                var color = UIColor.FromHSBA((float)i / sectors, 1f, 1f, 1f);
                color.SetFill();
                color.SetStroke();

                bezierPath.Fill();
                bezierPath.Stroke();
            }

            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            img.Draw(new PointF(0f, 0f));
        }
コード例 #5
0
ファイル: AppDelegate.cs プロジェクト: zlkevinet/RepoStumble
        private static void SetupTheme()
        {
            var primaryColor = UIColor.FromRGB(0x4e, 0x4b, 0xbe);

            UIGraphics.BeginImageContext(new CoreGraphics.CGSize(1, 64f));
            primaryColor.SetFill();
            UIGraphics.RectFill(new CoreGraphics.CGRect(0, 0, 1, 64));
            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
            UINavigationBar.Appearance.TintColor           = UIColor.White;
            UINavigationBar.Appearance.BarTintColor        = primaryColor;
            UINavigationBar.Appearance.BackgroundColor     = primaryColor;
            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
                TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(18f)
            });
            UINavigationBar.Appearance.SetBackgroundImage(img, UIBarPosition.Any, UIBarMetrics.Default);

            UIToolbar.Appearance.BackgroundColor = UIColor.White;

            UITabBar.Appearance.TintColor = primaryColor;

            RepositoryStumble.ViewControllers.ViewModelPrettyDialogViewController.RefreshIndicatorColor = UIColor.White;

            UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade);
        }
コード例 #6
0
ファイル: Theme.cs プロジェクト: ronaldris21/TODOS
        private static UIImage CreateBackgroundImage(UIColor color)
        {
            UIGraphics.BeginImageContext(new CoreGraphics.CGSize(1, 1f));
            color.SetFill();
            UIGraphics.RectFill(new CoreGraphics.CGRect(0, 0, 1, 1));
            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(img);
        }
コード例 #7
0
        public static UIImage MakeImageWithColorAndSize(this UIImage image, UIColor color, CGSize size)
        {
            UIGraphics.BeginImageContextWithOptions(size, false, 0);
            color.SetFill();
            UIGraphics.RectFill(new CGRect(0, 0, size.Width, size.Height));
            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(img);
        }
コード例 #8
0
ファイル: MapRenderer.cs プロジェクト: smremde/Mapsui
        private static UIImage ToImage(UIView view, RectangleF frame)
        {
            UIGraphics.BeginImageContext(frame.Size);
            UIColor.Clear.SetColor();
            UIGraphics.RectFill(view.Frame);
            view.Layer.RenderInContext(UIGraphics.GetCurrentContext());
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(image);
        }
コード例 #9
0
ファイル: ObjectExtensions.cs プロジェクト: showmap/smartwalk
        public static UIImage ToImage(this UIColor color)
        {
            UIGraphics.BeginImageContextWithOptions(new CGSize(1, 1), false, 0);
            color.SetFill();
            UIGraphics.RectFill(new CGRect(0, 0, 1, 1));
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(image);
        }
コード例 #10
0
        public override void Draw(CoreGraphics.CGRect rect)
        {
            UIColor.FromHSB(80.0f / 360.0f, 0.1f, 0.9f).SetFill();
            UIGraphics.RectFill(rect);

            UIColor.Black.SetColor();
            var text = new NSString($"Drag {Name}");
            var b    = Bounds;

            b.Inflate(-22, -22);
            text.DrawString(b, UIFont.BoldSystemFontOfSize(24));
        }
コード例 #11
0
        /// <summary>
        /// Generates an image of a solid color with the supplied dimenations.
        /// </summary>
        /// <param name="color">The color of the image.</param>
        /// <param name="size">The dimensions of the image.</param>
        /// <returns>A rectangular image of a solid color.</returns>
        public static UIImage CreateImageFromColor(UIColor color, CGSize size)
        {
            var rect = new CGRect(new CGPoint(0, 0), size);

            UIGraphics.BeginImageContextWithOptions(size, false, 0);
            color.SetFill();
            UIGraphics.RectFill(rect);
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(image);
        }
コード例 #12
0
        public static UIImage imageFromColor(UIColor color)
        {
            var rect = new CGRect(x: 0, y: 0, width: 1, height: 1);

            UIGraphics.BeginImageContextWithOptions(rect.Size, false, 0.0f);
            color.SetFill();
            UIGraphics.RectFill(rect);
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(image);
        }
コード例 #13
0
        private static UIImage ToImage(UIView view, CGRect frame)
        {
            UIGraphics.BeginImageContext((CGSize)frame.Size);
            view.Layer.BackgroundColor = TransparentColor;
            var context = UIGraphics.GetCurrentContext();

            UIGraphics.RectFill((CGRect)view.Frame);
            view.Layer.RenderInContext(UIGraphics.GetCurrentContext());
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(image);
        }
コード例 #14
0
        public static void Setup()
        {
            UIGraphics.BeginImageContext(new CoreGraphics.CGSize(1, 64f));
            Theme.PrimaryNavigationBarColor.SetFill();
            UIGraphics.RectFill(new CoreGraphics.CGRect(0, 0, 1, 64));
            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

            var navBarContainers = new [] { typeof(MenuNavigationController), typeof(ThemedNavigationController), typeof(MainNavigationController) };

            foreach (var navbarAppearance in navBarContainers.Select(x => UINavigationBar.AppearanceWhenContainedIn(x)))
            {
                navbarAppearance.TintColor       = Theme.PrimaryNavigationBarTextColor;
                navbarAppearance.BarTintColor    = Theme.PrimaryNavigationBarColor;
                navbarAppearance.BackgroundColor = Theme.PrimaryNavigationBarColor;
                navbarAppearance.SetTitleTextAttributes(new UITextAttributes {
                    TextColor = Theme.PrimaryNavigationBarTextColor, Font = UIFont.SystemFontOfSize(18f)
                });
                navbarAppearance.SetBackgroundImage(img, UIBarPosition.Any, UIBarMetrics.Default);
                navbarAppearance.BackIndicatorImage = Images.BackButton;
                navbarAppearance.BackIndicatorTransitionMaskImage = Images.BackButton;
            }

            UISegmentedControl.Appearance.TintColor = UIColor.FromRGB(110, 110, 117);
            UISegmentedControl.AppearanceWhenContainedIn(typeof(UINavigationBar)).TintColor = UIColor.White;

            UISwitch.Appearance.OnTintColor = UIColor.FromRGB(0x41, 0x83, 0xc4);

            // Composer Input Accessory Buttons
            UIButton.AppearanceWhenContainedIn(typeof(UIScrollView)).TintColor = Theme.PrimaryNavigationBarColor;

            //UITableViewHeaderFooterView.Appearance.TintColor = UIColor.FromRGB(228, 228, 228);
            var headerFooterContainers = new [] { typeof(UITableViewHeaderFooterView) };

            foreach (var navbarAppearance in headerFooterContainers)
            {
                UILabel.AppearanceWhenContainedIn(navbarAppearance).TextColor = UIColor.FromRGB(110, 110, 117);
                UILabel.AppearanceWhenContainedIn(navbarAppearance).Font      = UIFont.SystemFontOfSize(14f);
            }

            StringElement.DefaultTintColor = Theme.PrimaryNavigationBarColor;

            UIToolbar.Appearance.BarTintColor = UIColor.FromRGB(245, 245, 245);

            UIBarButtonItem.AppearanceWhenContainedIn(typeof(UISearchBar)).SetTitleTextAttributes(new UITextAttributes {
                TextColor = UIColor.White
            }, UIControlState.Normal);
        }
コード例 #15
0
        UIImage UndeLineColorPosition(UIColor color, CGSize size, CGSize lineSize)
        {
            var rect     = new CGRect(0, 0, size.Width, size.Height);
            var rectLine = new CGRect(0, size.Height - lineSize.Height, lineSize.Width, lineSize.Height);

            UIGraphics.BeginImageContextWithOptions(size, false, 0);
            UIColor.Clear.SetFill();
            UIGraphics.RectFill(rect); color.SetFill();
            UIGraphics.RectFill(rectLine);
            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(img);
        }
コード例 #16
0
ファイル: TriangleView.cs プロジェクト: littlefeihu/checktask
        /// <summary>
        /// Draw the triangle
        /// </summary>
        /// <param name="rect">Rect.</param>
        public override void Draw(CGRect rect)
        {
            UIColor.Clear.SetColor();
            UIGraphics.RectFill(rect);
            CGContext context = UIGraphics.GetCurrentContext();

            context.BeginPath();
            context.MoveTo(0.0f, 0.0f);
            context.AddLineToPoint(ENDGE_LENGTH, ENDGE_LENGTH);
            context.AddLineToPoint(ENDGE_LENGTH, 0.0f);
            context.ClosePath();
            TriangleBackgroundColor.SetFill();
            context.DrawPath(CGPathDrawingMode.Fill);
            AddSubview(ActionView);
        }
コード例 #17
0
        public static UIImage GetImageFromColor(UIColor color)
        {
            var rect = new CGRect(0, 0, 1, 1);

            UIGraphics.BeginImageContext(rect.Size);
            var context = UIGraphics.GetCurrentContext();

            context.SetFillColor(color.CGColor);
            UIGraphics.RectFill(rect);
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(image);
        }
コード例 #18
0
        public static UIImage ToImage(this UIColor color, CGRect rect)
        {
            UIGraphics.BeginImageContext(rect.Size);
            var context = UIGraphics.GetCurrentContext();

            context.SetFillColor(color.CGColor);
            UIGraphics.RectFill(rect);

            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();


            return(image);
        }
コード例 #19
0
        public byte[] GenerateSolidColor(float size, Color color, string cacheName)
        {
            var existing = GetExisting(cacheName);

            if (existing != null)
            {
                return(existing);
            }

            UIGraphics.BeginImageContextWithOptions(new CGSize(size, size), true, 1);
            UIGraphics.GetCurrentContext().SetFillColor(new CGColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f));
            UIGraphics.RectFill(new CGRect(0, 0, size, size));
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(Put(cacheName, image));
        }
コード例 #20
0
        // Helper method for drawing the current selection range (as a simple filled rect)
        void DrawRangeAsSelection(NSRange selectionRange)
        {
            // If not in editing mode, we do not draw selection rects
            if (!IsEditing)
            {
                return;
            }

            // If selection range empty, do not draw
            if (selectionRange.Length == 0 || selectionRange.Location == NSRange.NotFound)
            {
                return;
            }

            // set the fill color to the selection color
            SelectionColor.SetFill();

            // Iterate over the lines in our CTFrame, looking for lines that intersect
            // with the given selection range, and draw a selection rect for each intersection
            var lines = frame.GetLines();

            for (int i = 0; i < lines.Length; i++)
            {
                CTLine  line         = lines [i];
                NSRange lineRange    = line.StringRange;
                NSRange range        = new NSRange(lineRange.Location, lineRange.Length);
                NSRange intersection = RangeIntersection(range, selectionRange);
                if (intersection.Location != NSRange.NotFound && intersection.Length > 0)
                {
                    // The text range for this line intersects our selection range
                    nfloat xStart = line.GetOffsetForStringIndex(intersection.Location);
                    nfloat xEnd   = line.GetOffsetForStringIndex(intersection.Location + intersection.Length);
                    var    origin = new CGPoint [lines.Length];
                    // Get coordinate and bounds information for the intersection text range
                    frame.GetLineOrigins(new NSRange(i, 0), origin);
                    nfloat ascent, descent, leading;
                    line.GetTypographicBounds(out ascent, out descent, out leading);
                    // Create a rect for the intersection and draw it with selection color
                    CGRect selectionRect = new CGRect(xStart, origin [0].Y - descent, xEnd - xStart, ascent + descent);
                    UIGraphics.RectFill(selectionRect);
                }
            }
        }
コード例 #21
0
        public static UIImage Tint(this UIImage img, UIColor tint, CGBlendMode blendMode)
        {
            UIGraphics.BeginImageContextWithOptions(img.Size, false, 0f);
            tint.SetFill();
            var bounds = new RectangleF(0, 0, img.Size.Width, img.Size.Height);

            UIGraphics.RectFill(bounds);

            img.Draw(bounds, blendMode, 1f);

            if (blendMode != CGBlendMode.DestinationIn)
            {
                img.Draw(bounds, CGBlendMode.DestinationIn, 1f);
            }

            var tintedImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(tintedImage);
        }
コード例 #22
0
        public override void Draw(CGRect rect)
        {
            UIColor.White.SetFill();
            UIGraphics.RectFill(rect);

            // Optimization opportunity: Draw the existing collection in a different view,
            // and only draw each time we add a stroke.
            var collection = StrokeCollection;

            if (collection != null)
            {
                foreach (var stroke in strokeCollection.Strokes)
                {
                    Draw(stroke);
                }
            }

            var toDraw = StrokeToDraw;

            if (toDraw != null)
            {
                Draw(toDraw);
            }
        }
コード例 #23
0
        /// <summary>
        /// Configures the navigation bar to use a transparent background (see-through but without any blur).
        /// </summary>
        private void ApplyTransparentBackgroundToTheNavigationBar(float opacity)
        {
            UIImage transparentBackground = null;

            // The background of a navigation bar switches from being translucent
            // to transparent when a background image is applied.  The intensity of
            // the background image's alpha channel is inversely related to the
            // transparency of the bar.  That is, a smaller alpha channel intensity
            // results in a more transparent bar and vis-versa.
            //
            // Below, a background image is dynamically generated with the desired
            // opacity.
            UIGraphics.BeginImageContextWithOptions(new CGSize(1f, 1f),
                                                    false,
                                                    base.NavigationController.NavigationBar.Layer.ContentsScale);

            var context = UIGraphics.GetCurrentContext();

            context.SetFillColor(1f, 1f, 1f, opacity);
            UIGraphics.RectFill(new CGRect(0f, 0f, 1f, 1f));
            transparentBackground = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            // You should use the appearance proxy to customize the appearance of
            // UIKit elements.  However changes made to an element's appearance
            // proxy do not effect any existing instances of that element currently
            // in the view hierarchy.  Normally this is not an issue because you
            // will likely be performing your appearance customizations in
            // -application:didFinishLaunchingWithOptions:.  However, this example
            // allows you to toggle between appearances at runtime which necessitates
            // applying appearance customizations directly to the navigation bar.
            /* let navigationBarAppearance = UINavigationBar.appearance(whenContainedInInstancesOf: [UINavigationController.self]) */
            var navigationBarAppearance = base.NavigationController.NavigationBar;

            navigationBarAppearance.SetBackgroundImage(transparentBackground, UIBarMetrics.Default);
        }
コード例 #24
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            // 半透明区域
            UIColor.FromWhiteAlpha(0, 0.7f).SetFill();
            UIGraphics.RectFill(rect);

            //// 透明区域
            CGRect scanner_rect = new CGRect(Scanner_X, Scanner_Y, Scanner_Width, Scanner_Width);

            UIColor.Clear.SetFill();
            UIGraphics.RectFill(scanner_rect);

            // 边框
            UIBezierPath borderPath = UIBezierPath.FromRect(new CGRect(Scanner_X, Scanner_Y, Scanner_Width, Scanner_Width));

            borderPath.LineCapStyle = CGLineCap.Round;
            borderPath.LineWidth    = Scanner_BorderWidth;
            UIColor.White.SetColor();
            borderPath.Stroke();

            for (int index = 0; index < 4; ++index)
            {
                UIBezierPath tempPath = UIBezierPath.Create();
                tempPath.LineWidth = Scanner_CornerWidth;
                _lineColor.SetColor();

                switch (index)
                {
                // 左上角棱角
                case 0:
                {
                    tempPath.MoveTo(new CGPoint(Scanner_X + Scanner_CornerLength, Scanner_Y));
                    tempPath.AddLineTo(new CGPoint(Scanner_X, Scanner_Y));
                    tempPath.AddLineTo(new CGPoint(Scanner_X, Scanner_Y + Scanner_CornerLength));
                }
                break;

                // 右上角
                case 1:
                {
                    tempPath.MoveTo(new CGPoint(Scanner_X + Scanner_Width - Scanner_CornerLength, Scanner_Y));
                    tempPath.AddLineTo(new CGPoint(Scanner_X + Scanner_Width, Scanner_Y));
                    tempPath.AddLineTo(new CGPoint(Scanner_X + Scanner_Width, Scanner_Y + Scanner_CornerLength));
                }
                break;

                // 左下角
                case 2:
                {
                    tempPath.MoveTo(new CGPoint(Scanner_X, Scanner_Y + Scanner_Width - Scanner_CornerLength));
                    tempPath.AddLineTo(new CGPoint(Scanner_X, Scanner_Y + Scanner_Width));
                    tempPath.AddLineTo(new CGPoint(Scanner_X + Scanner_CornerLength, Scanner_Y + Scanner_Width));
                }
                break;

                // 右下角
                case 3:
                {
                    tempPath.MoveTo(new CGPoint(Scanner_X + Scanner_Width - Scanner_CornerLength, Scanner_Y + Scanner_Width));
                    tempPath.AddLineTo(new CGPoint(Scanner_X + Scanner_Width, Scanner_Y + Scanner_Width));
                    tempPath.AddLineTo(new CGPoint(Scanner_X + Scanner_Width, Scanner_Y + Scanner_Width - Scanner_CornerLength));
                }
                break;

                default:
                    break;
                }
                tempPath.Stroke();
            }
        }
コード例 #25
0
        private void DrawGripThumbInRect(CGRect rect)
        {
            nfloat width = 9.0f;
            nfloat height;

            if (SplitViewController.IsVertical)
            {
                height = 30.0f;
            }
            else
            {
                height = width;
                width  = 30.0f;
            }

            // Draw grip in centred in rect.
            var gripRect = new CGRect(0, 0, width, height);

            gripRect.X = (rect.Width - gripRect.Width) / 2.0f;
            gripRect.Y = (rect.Height - gripRect.Height) / 2.0f;

            nfloat stripThickness = 1.0f;
            var    stripColor     = UIColor.FromWhiteAlpha(0.35f, 1.0f);
            var    lightColor     = UIColor.FromWhiteAlpha(1.0f, 1.0f);
            nfloat space          = 3.0f;

            if (SplitViewController.IsVertical)
            {
                gripRect.Width = stripThickness;
                stripColor.SetFill();
                stripColor.SetStroke();
                UIGraphics.RectFill(gripRect);

                gripRect.X += stripThickness;
                gripRect.Y += 1f;
                lightColor.SetFill();
                lightColor.SetStroke();
                UIGraphics.RectFill(gripRect);
                gripRect.X -= stripThickness;
                gripRect.Y -= 1f;

                gripRect.X += space + stripThickness;
                stripColor.SetFill();
                stripColor.SetStroke();
                UIGraphics.RectFill(gripRect);

                gripRect.X += stripThickness;
                gripRect.Y += 1f;
                lightColor.SetFill();
                lightColor.SetStroke();
                UIGraphics.RectFill(gripRect);
                gripRect.X -= stripThickness;
                gripRect.Y -= 1f;

                gripRect.X += space + stripThickness;
                stripColor.SetFill();
                stripColor.SetStroke();
                UIGraphics.RectFill(gripRect);

                gripRect.X += stripThickness;
                gripRect.Y += 1f;
                lightColor.SetFill();
                lightColor.SetStroke();
                UIGraphics.RectFill(gripRect);
            }
            else
            {
                gripRect.Height = stripThickness;
                stripColor.SetFill();
                stripColor.SetStroke();
                UIGraphics.RectFill(gripRect);

                gripRect.Y += stripThickness;
                gripRect.X -= 1f;
                lightColor.SetFill();
                lightColor.SetStroke();
                UIGraphics.RectFill(gripRect);
                gripRect.Y -= stripThickness;
                gripRect.X += 1f;

                gripRect.Y += space + stripThickness;
                stripColor.SetFill();
                stripColor.SetStroke();
                UIGraphics.RectFill(gripRect);

                gripRect.Y += stripThickness;
                gripRect.X -= 1f;
                lightColor.SetFill();
                lightColor.SetStroke();
                UIGraphics.RectFill(gripRect);
                gripRect.Y -= stripThickness;
                gripRect.X += 1f;

                gripRect.Y += space + stripThickness;
                stripColor.SetFill();
                stripColor.SetStroke();
                UIGraphics.RectFill(gripRect);

                gripRect.Y += stripThickness;
                gripRect.X -= 1f;
                lightColor.SetFill();
                lightColor.SetStroke();
                UIGraphics.RectFill(gripRect);
            }
        }
コード例 #26
0
        public override void Draw(CGRect rect)
        {
            if (SplitViewController.DividerStyle == DividerStyle.Thin)
            {
                base.Draw(rect);
            }
            else if (SplitViewController.DividerStyle == DividerStyle.PaneSplitter)
            {
                // Draw gradient background.
                var bounds     = Bounds;
                var rgb        = CGColorSpace.CreateDeviceRGB();
                var locations  = new nfloat[] { 0, 1 };
                var components = new nfloat[]
                {
                    // light
                    0.988f, 0.988f, 0.988f, 1.0f,
                    // dark
                    0.875f, 0.875f, 0.875f, 1.0f
                };
                var     gradient = new CGGradient(rgb, components, locations);
                var     context  = UIGraphics.GetCurrentContext();
                CGPoint start;
                CGPoint end;
                if (SplitViewController.IsVertical)
                {
                    // Light left to dark right.
                    start = new CGPoint(bounds.GetMinX(), bounds.GetMidY());
                    end   = new CGPoint(bounds.GetMaxX(), bounds.GetMidY());
                }
                else
                {
                    // Light top to dark bottom.
                    start = new CGPoint(bounds.GetMidX(), bounds.GetMinY());
                    end   = new CGPoint(bounds.GetMidX(), bounds.GetMaxY());
                }
                context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsAfterEndLocation);
                rgb.Dispose();
                gradient.Dispose();

                // Draw borders.
                var borderThickness = 1.0f;
                UIColor.FromWhiteAlpha(0.7f, 1.0f).SetFill();
                UIColor.FromWhiteAlpha(0.7f, 1.0f).SetStroke();
                var borderRect = bounds;
                if (SplitViewController.IsVertical)
                {
                    borderRect.Width = borderThickness;
                    UIGraphics.RectFill(borderRect);
                    borderRect.X = bounds.GetMaxX() - borderThickness;
                    UIGraphics.RectFill(borderRect);
                }
                else
                {
                    borderRect.Height = borderThickness;
                    UIGraphics.RectFill(borderRect);
                    borderRect.Y = bounds.GetMaxY() - borderThickness;
                    UIGraphics.RectFill(borderRect);
                }

                // Draw grip.
                DrawGripThumbInRect(bounds);
            }
        }
コード例 #27
0
        public override void Draw(CGRect rect)
        {
            //UIColor.White.SetFill ();

            //Opaque = false;
            //UIColor.Clear.SetFill();

            if (editing)
            {
                Opaque = false;
                UIColor.Clear.SetFill();
                //BackgroundColor = UIColor.Green;
                //BackgroundColor = UIColor.FromWhiteAlpha(1.0f, 0.4f);
                //Alpha = 1.0f;
                //SetNeedsDisplay();
                //var context = UIGraphics.GetCurrentContext();
                //context.SetBlendMode(CGBlendMode.Clear);
                //context.ClearRect(rect);
                //foreach (UIView ass in Subviews)
                //{
                //	ass.Opaque = false;
                //	ass.BackgroundColor = UIColor.Clear;
                //}
                //if (context == null)
                //return;
                //context.SetFillColor(UIColor.Clear.CGColor);
            }
            else
            {
                UIColor.White.SetFill();
            }



            //UIColor.FromRGBA(0, 0, 0, 0).SetFill();
            //Alpha = 0.5f;
            //UIColor.FromWhiteAlpha(1.0f, 0.5f).SetFill();
            //BackgroundColor = UIColor.Clear;
            //this.Alpha = 0.5f;
            //UIColor.Red.SetFill();

            //var img = UIImage.FromFile("dynapadscreenshot.png");
            //UIImageView imgView = new UIImageView(rect);
            //imgView.Image = img;
            //imgView.ContentMode = UIViewContentMode.ScaleAspectFit; // or ScaleAspectFill
            //														//imgView.Alpha = 0.5f;
            //														//scrollView.AddSubview(imgView);
            //														//scrollView.SendSubviewToBack(imgView);
            //UIGraphics.BeginImageContext(rect.Size);
            //img.Draw(rect);
            //img = UIGraphics.GetImageFromCurrentImageContext();
            //UIGraphics.EndImageContext();

            //AddSubview(imgView);
            //SendSubviewToBack(imgView);

            //UIColor.Black.SetStroke();
            //UIColor.Clear.SetColor();
            //UIColor.FromPatternImage(img).SetFill();

            UIGraphics.RectFill(rect);

            // Optimization opportunity: Draw the existing collection in a different view,
            // and only draw each time we add a stroke.
            var collection = StrokeCollection;

            if (collection != null)
            {
                foreach (var stroke in strokeCollection.Strokes)
                {
                    Draw(stroke);
                }
            }

            //Draw(new Stroke());

            var toDraw = StrokeToDraw;

            if (toDraw != null)
            {
                Draw(toDraw);
            }
        }
コード例 #28
0
        public static void Setup()
        {
            var theme = new Theme();

            CurrentTheme = theme;

            var defaultValues = IoC.Resolve <IDefaultValueService>();

            bool largeFonts;

            if (!defaultValues.TryGet("large_fonts", out largeFonts))
            {
                largeFonts = false;
            }
            Theme.CurrentTheme.FontSizeRatio = largeFonts ? 1.3f : 1.0f;

            UIGraphics.BeginImageContext(new System.Drawing.SizeF(1, 64f));
            UIColor.FromRGB(50, 50, 50).SetFill();
            UIGraphics.RectFill(new System.Drawing.RectangleF(0, 0, 1, 64));
            var img = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            NameTimeStringElement.NameColor = Theme.CurrentTheme.MainTitleColor;
            //Element.FontSizeRatio = Theme.CurrentTheme.FontSizeRatio;

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
            UINavigationBar.Appearance.TintColor           = UIColor.White;
            UINavigationBar.Appearance.BarTintColor        = UIColor.FromRGB(50, 50, 50);
            UINavigationBar.Appearance.BackgroundColor     = UIColor.FromRGB(50, 50, 50);
            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
                TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(18f)
            });
            UINavigationBar.Appearance.SetBackgroundImage(img, UIBarPosition.Any, UIBarMetrics.Default);
            //CodeFramework.iOS.Utils.Hud.BackgroundTint = UIColor.FromRGBA(228, 228, 228, 128);
            UINavigationBar.Appearance.BackIndicatorImage = Images.BackButton;
            UINavigationBar.Appearance.BackIndicatorTransitionMaskImage = Images.BackButton;

            UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(0, -64), UIBarMetrics.LandscapePhone);
            UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(0, -64), UIBarMetrics.Default);
//
//            UserVoice.UVStyleSheet.Instance.NavigationBarTintColor = UIColor.White;
//            UserVoice.UVStyleSheet.Instance.NavigationBarTextColor = UIColor.White;

            UISegmentedControl.Appearance.TintColor = UIColor.FromRGB(110, 110, 117);
            UISegmentedControl.AppearanceWhenContainedIn(typeof(UINavigationBar)).TintColor = UIColor.White;

            // Composer Input Accessory Buttons
            UIButton.AppearanceWhenContainedIn(typeof(UIScrollView)).TintColor = UIColor.FromRGB(50, 50, 50);

            UITableViewHeaderFooterView.Appearance.TintColor = UIColor.FromRGB(228, 228, 228);
            UILabel.AppearanceWhenContainedIn(typeof(UITableViewHeaderFooterView)).TextColor = UIColor.FromRGB(136, 136, 136);
            UILabel.AppearanceWhenContainedIn(typeof(UITableViewHeaderFooterView)).Font      = UIFont.SystemFontOfSize(13f * Theme.CurrentTheme.FontSizeRatio);

            UIToolbar.Appearance.BarTintColor = UIColor.FromRGB(245, 245, 245);

            UIBarButtonItem.AppearanceWhenContainedIn(typeof(UISearchBar)).SetTitleTextAttributes(new UITextAttributes {
                TextColor = UIColor.White
            }, UIControlState.Normal);

//            CodeFramework.Elements.NewsFeedElement.LinkColor = theme.MainTitleColor;
//            CodeFramework.Elements.NewsFeedElement.TextColor = theme.MainTextColor;
//            CodeFramework.Elements.NewsFeedElement.NameColor = theme.MainTitleColor;
        }