コード例 #1
0
        public CalloutAnnotation(int count, CGRect rect, nfloat lineWidth, UIColor color)
        {
            Path = UIBezierPath.FromOval(rect);
            Path.LineWidth = lineWidth;

            var center = new CGPoint (rect.GetMidX(), rect.GetMidY());

            Center = center;

            nfloat startAngle = (nfloat)(Math.PI * 0.75);
            nfloat endAngle = (nfloat)(Math.PI * 0.60);

            Clip = UIBezierPath.FromArc(center, center.X + lineWidth, startAngle, endAngle, true);
            Clip.AddLineTo(center);
            Clip.ClosePath();
            Clip.LineWidth = lineWidth;

            Tail = new UIBezierPath ();
            Tail.MoveTo(new CGPoint (center.X - 11, center.Y + 9));
            Tail.AddLineTo(new CGPoint (center.X - 11, center.Y + 18));
            Tail.AddLineTo(new CGPoint (center.X - 3, center.Y + 13));
            Tail.LineWidth = lineWidth;

            Rect = rect;
            Color = color;
            Count = count;
        }
コード例 #2
0
ファイル: TabControl.cs プロジェクト: Immons/XamarinHelper
 public TabControl(CGRect frame, UIColor selectedTabColor, UIColor unselectedTabColor)
 {
     this.unselectedTabColor = unselectedTabColor;
     this.selectedTabColor = selectedTabColor;
     this.items = new List<TabControlItem>();
     this.Frame = frame;
 }
コード例 #3
0
		public static UIColor ToUIColor(this Color color, UIColor defaultColor)
		{
			if (color.IsDefault)
				return defaultColor;

			return color.ToUIColor();
		}
コード例 #4
0
		public void Live(string timeRemaining, UIColor timeRemainingColor)
		{
			BackgroundColor = UIColor.Clear;

			SetTitle(timeRemaining);
			SetTitleColor(timeRemainingColor);
		}
コード例 #5
0
		void CreateRadialGauge()
		{
			this.radialGauge.Delegate = new GaugeDelegate ();
			this.View.AddSubview (this.radialGauge);

			TKGaugeRadialScale scale = new TKGaugeRadialScale (new NSNumber (0), new NSNumber (6));
			this.radialGauge.AddScale (scale);
			scale.AddIndicator(new TKGaugeNeedle(2.3f, 0.6f));

			UIColor[] colors = new UIColor[] { 
				new UIColor (0.871f, 0.871f, 0.871f, 1.00f),
				new UIColor (0.533f, 0.796f, 0.290f, 1.00f),
				new UIColor (1.000f, 0.773f, 0.247f, 1.00f),
				new UIColor (1.000f, 0.467f, 0.161f, 1.00f),
				new UIColor (0.769f, 0.000f, 0.043f, 1.00f)
			};
				
			nfloat max = ((NSNumber)scale.Range.Maximum).FloatValue;
			nfloat rangeWidth = max / colors.Length;
			nfloat start = 0;
			foreach (UIColor color in colors)
			{
				TKGaugeSegment segment = new TKGaugeSegment (new NSNumber(start), new NSNumber(start + rangeWidth));
				segment.Fill = new TKSolidFill (color);
				scale.AddSegment(segment);
				start += rangeWidth;
			}
		}
コード例 #6
0
        /// <summary>
        /// Converts the UIColor to a Xamarin Color object.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <param name="defaultColor">The default color.</param>
        /// <returns>UIColor.</returns>
        public static UIColor ToUIColorOrDefault(this Xamarin.Forms.Color color, UIColor defaultColor)
        {
            if (color == Xamarin.Forms.Color.Default)
                return defaultColor;

            return color.ToUIColor();
        }
コード例 #7
0
ファイル: TouchDrawView.cs プロジェクト: yingfangdu/BNR
        public TouchDrawView(CGRect rect)
            : base(rect)
        {
            linesInProcess = new Dictionary<string, Line>();
            this.BackgroundColor = UIColor.White;
            this.MultipleTouchEnabled = true;

            UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(tap);
            this.AddGestureRecognizer(tapRecognizer);

            UITapGestureRecognizer dbltapRecognizer = new UITapGestureRecognizer(dblTap);
            dbltapRecognizer.NumberOfTapsRequired = 2;
            this.AddGestureRecognizer(dbltapRecognizer);

            UILongPressGestureRecognizer pressRecognizer = new UILongPressGestureRecognizer(longPress);
            this.AddGestureRecognizer(pressRecognizer);

            moveRecognizer = new UIPanGestureRecognizer(moveLine);
            moveRecognizer.WeakDelegate = this;
            moveRecognizer.CancelsTouchesInView = false;
            this.AddGestureRecognizer(moveRecognizer);

            UISwipeGestureRecognizer swipeRecognizer = new UISwipeGestureRecognizer(swipe);
            swipeRecognizer.Direction = UISwipeGestureRecognizerDirection.Up;
            swipeRecognizer.NumberOfTouchesRequired = 3;
            this.AddGestureRecognizer(swipeRecognizer);

            selectedColor = UIColor.Red;
        }
コード例 #8
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            if (BorderWidthAll > 0)
            {
                BorderWidth = new UIEdgeInsets(BorderWidthAll, BorderWidthAll, BorderWidthAll, BorderWidthAll);
            }

            if (BorderColorAll != null)
            {
                BorderColorTop = BorderColorBottom = BorderColorLeft = BorderColorRight = BorderColorAll;
            }

            var xMin = rect.GetMinX();
            var xMax = rect.GetMaxX();

            var yMin = rect.GetMinY();
            var yMax = rect.GetMaxY();

            var fWidth = this.Frame.Size.Width;
            var fHeight = this.Frame.Size.Height;

            var context = UIGraphics.GetCurrentContext();

            if (context != null)
                DrawBorders(context, xMin, xMax, yMin, yMax, fWidth, fHeight);
        }
コード例 #9
0
        public FABarButtonItem(FA icon, string title, UIColor fontColor, EventHandler handler)
            : base()
        {
            UIView view = new UIView (new CGRect (0, 0, 32, 32));

            _iconButton = new UIButton (new CGRect (0, 0, 32, 21)) {
                Font = icon.Font (20),
            };
            _iconButton.SetTitleColor (fontColor, UIControlState.Normal);
            _iconButton.TouchUpInside += handler;

            _titleLabel = new UILabel (new CGRect (0, 18, 32, 10)) {
                TextColor = fontColor,
                Font = UIFont.SystemFontOfSize(10f),
                TextAlignment = UITextAlignment.Center
            };

            this.Title = title;
            this.Icon = icon.String();

            view.Add (_iconButton);
            view.Add (_titleLabel);

            CustomView = view;
        }
コード例 #10
0
 internal CropperResizerView(UIColor color = null, nfloat transparancy = default(nfloat), nfloat lineWidth = default(nfloat))
 {
     this.BackgroundColor = UIColor.Clear;
     _color = color ?? UIColor.Red;
     _transparancy = transparancy == 0 ? 0.8f : transparancy;
     _lineWidth = lineWidth == 0 ? 3f : lineWidth;
 }
コード例 #11
0
 static MessageView()
 {
     TitleFont = UIFont.BoldSystemFontOfSize(16.0f);
     DescriptionFont = UIFont.SystemFontOfSize(14.0f);
     TitleColor = UIColor.FromWhiteAlpha(1.0f, 1.0f);
     DescriptionColor = UIColor.FromWhiteAlpha(1.0f, 1.0f);
 }
コード例 #12
0
        public static UIImage ImageFromFont(string text, UIColor iconColor, CGSize iconSize, string fontName)
        {
            UIGraphics.BeginImageContextWithOptions(iconSize, false, 0);

              var textRect = new CGRect(CGPoint.Empty, iconSize);
              var path = UIBezierPath.FromRect(textRect);
              UIColor.Clear.SetFill();
              path.Fill();

              var font = UIFont.FromName(fontName, iconSize.Width);
              using (var label = new UILabel() { Text = text, Font = font })
              {
            GetFontSize(label, iconSize, 500, 5);
            font = label.Font;
              }
              iconColor.SetFill();
              using (var nativeString = new NSString(text))
              {
            nativeString.DrawString(textRect, new UIStringAttributes
              {
            Font = font,
            ForegroundColor = iconColor,
            BackgroundColor = UIColor.Clear,
            ParagraphStyle = new NSMutableParagraphStyle
            {
              Alignment = UITextAlignment.Center
            }
              });
              }
              var image = UIGraphics.GetImageFromCurrentImageContext();
              UIGraphics.EndImageContext();
              image = image.ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal);
              return image;
        }
コード例 #13
0
 public CellDisclosureAccessory(CGRect frame)
     : base(frame)
 {
     this.BackgroundColor = UIColor.Clear;
     this.color = App.ForegroundColor.ToUIColor();
     this.highlightedColor = App.NavigationColor.ToUIColor();
 }
コード例 #14
0
		/// <summary>
		/// Initializes a new instance of the <see cref="FontAwesomeXamarin.FAButton"/> class.
		/// This class extends UIButton. It does set set a default Frame. You must do this yourself
		/// </summary>
		/// <param name="icon">Icon.</param>
		/// <param name="fontColor">Font color.</param>
		/// <param name="iconSize">Icon size.</param>
		public FAButton (string icon, UIColor fontColor, float iconSize = 20) : base(UIButtonType.System)
		{
			Icon = icon;
			IconSize = iconSize;
			this.SetTitleColor (fontColor, UIControlState.Normal);
			this.SetTitleColor (fontColor.ColorWithAlpha(100), UIControlState.Highlighted);
		}
コード例 #15
0
ファイル: NewsFeedElement.cs プロジェクト: xNUTs/CodeBucket
        private static Tuple<NSMutableAttributedString,List<NewsCellView.Link>> CreateAttributedStringFromBlocks(UIFont font, UIColor primaryColor, IEnumerable<TextBlock> blocks)
        {
            var attributedString = new NSMutableAttributedString();
            var links = new List<NewsCellView.Link>();

            nint lengthCounter = 0;
            int i = 0;

            foreach (var b in blocks)
            {
                UIColor color = null;
                if (b.Tapped != null)
                    color = LinkColor;

                color = color ?? primaryColor; 

                var ctFont = new CoreText.CTFont(font.Name, font.PointSize);
                var str = new NSAttributedString(b.Value, new CoreText.CTStringAttributes() { ForegroundColor = color.CGColor, Font = ctFont });
                attributedString.Append(str);
                var strLength = str.Length;

                if (b.Tapped != null)
                {
                    var weakTapped = new WeakReference<Action>(b.Tapped);
                    links.Add(new NewsCellView.Link { Range = new NSRange(lengthCounter, strLength), Callback = () => weakTapped.Get()?.Invoke(), Id = i++ });
                }

                lengthCounter += strLength;
            }

            return new Tuple<NSMutableAttributedString, List<NewsCellView.Link>>(attributedString, links);
        }
コード例 #16
0
        public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, string filePath, UIColor kleur)
        {
            var view = BaseItemView.Create(frame, nodeViewController, node, kleur);
            UIWebView webView = new UIWebView();

			string extension = Path.GetExtension (filePath);
			if (extension == ".odt") {
				string viewerPath = NSBundle.MainBundle.PathForResource ("over/viewer/index", "html");

				Uri fromUri = new Uri(viewerPath);
				Uri toUri = new Uri(filePath);
				Uri relativeUri = fromUri.MakeRelativeUri(toUri);
				String relativePath = Uri.UnescapeDataString(relativeUri.ToString());

				NSUrl finalUrl = new NSUrl ("#" + relativePath.Replace(" ", "%20"), new NSUrl(viewerPath, false));
				webView.LoadRequest(new NSUrlRequest(finalUrl));
				webView.ScalesPageToFit = true;
				view.ContentView = webView;

				return view;
			} else {
				NSUrl finalUrl = new NSUrl (filePath, false);
				webView.LoadRequest(new NSUrlRequest(finalUrl));
				webView.ScalesPageToFit = true;
				view.ContentView = webView;

				return view;
			}
		
        }
コード例 #17
0
		public RefreshTableHeaderView (CGRect rect) : base (rect)
		{
			this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			
			BackgroundColor = new UIColor (0.88f, 0.9f, 0.92f, 1);
			CreateViews ();
		}
コード例 #18
0
        public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, UIColor kleur)
        {
            var view = (BaseItemView)Nib.Instantiate (null, null) [0];
            view.Frame = frame;
            view.Node = node;
            view.NodePath = node.Path;
            view.SetShadow();

            view.TerugButton.TouchUpInside += delegate
            {
                nodeViewController.PopView();
            };

            view.TitelLabel.Text = node.Name;
            view.TitelLabel.SetFont();
            view.FullScreenButton.TouchUpInside += delegate {
                nodeViewController.ToggleFullScreen();
            };

            if (kleur != null)
            {
                view.kleurenBalk.BackgroundColor = kleur;
            }
            view.HideBackButton();
            return view;
        }
コード例 #19
0
		/// <summary>
		/// Adds the text.
		/// </summary>
		/// <param name="image">The image.</param>
		/// <param name="text">The text.</param>
		/// <param name="point">The point.</param>
		/// <param name="font">The font.</param>
		/// <param name="color">The color.</param>
		/// <param name="alignment">The alignment.</param>
		/// <returns>UIImage.</returns>
		public static UIImage AddText(
			this UIImage image,
			string text,
			CGPoint point,
			UIFont font,
			UIColor color,
			UITextAlignment alignment = UITextAlignment.Left)
		{
			//var labelRect = new RectangleF(point, new SizeF(image.Size.Width - point.X, image.Size.Height - point.Y));
			var h = text.StringHeight(font, image.Size.Width);
			var labelRect = new CGRect(point, new CGSize(image.Size.Width - point.X, h));

			var label = new UILabel(labelRect)
				            {
					            Font = font,
					            Text = text,
					            TextColor = color,
					            TextAlignment = alignment,
					            BackgroundColor = UIColor.Clear
				            };

			var labelImage = label.ToNativeImage();

			using (var context = image.Size.ToBitmapContext())
			{
				var rect = new CGRect(new CGPoint(0, 0), image.Size);
				context.DrawImage(rect, image.CGImage);
				context.DrawImage(labelRect, labelImage.CGImage);
				context.StrokePath();
				return UIImage.FromImage(context.ToImage());
			}
		}
コード例 #20
0
		/// <summary>
		/// Initializes a new instance of UITableView.
		/// </summary>
		/// <param name="data">Source Data.</param>
		/// <param name="cellHeight">cellHeight, use 0 for default.</param>
		/// <param name="fSize">Cell Font size.</param>
		/// <param name="cellSelectedBackgroundColor">Cell selected background color, Use Clear for default</param>
		/// <param name="cellSelectedTextColor">Cell selected text color, Use Clear for default</param>
		public DropDownTable(IList<string> data, nfloat cellHeight,
			nfloat fSize, UIColor cellSelectedBackgroundColor, UIColor cellSelectedTextColor,
			string selectedText = "") : base()
		{
			CellLayoutMarginsFollowReadableWidth = false;
			this.MultipleTouchEnabled = true;
			this._FontSize = fSize;
			this._CellHeight = cellHeight;
			this._CellSBackgroundColor = cellSelectedBackgroundColor;
			this._CellSTextColor = cellSelectedTextColor;

			Source = new DropDownSource (data, this._FontSize, this._CellHeight, this._CellSBackgroundColor, 
				this._CellSTextColor, selectedText);

			//ContentInset =  new UIEdgeInsets(0, -10, 0, 0);
			LayoutMargins = UIEdgeInsets.Zero;
			SeparatorInset = UIEdgeInsets.Zero;

			// select default row
			var idx = data.ToList().FindIndex(x => x == selectedText);
			System.Diagnostics.Debug.WriteLine (idx);
			if (idx >= 0) {
				this.SelectRow (Foundation.NSIndexPath.FromItemSection (idx, 0), false, UITableViewScrollPosition.Top);
			}

			(Source as DropDownSource).OnSelected += RowSelected;
		}
コード例 #21
0
 public int Add(string title, UIColor color, Action action)
 {
     var index = (int)AddButton (title);
     dict.Add (index, action);
     colors.Add(index,color);
     return index;
 }
コード例 #22
0
        public static FavoriteNodeView Create (CGRect frame, NodeViewController nodeViewController, UIColor kleur)
        {
            var view = (FavoriteNodeView)Nib.Instantiate (null, null) [0];
            view.Frame = frame;
            view.SetShadow();
            view._nodeViewController = nodeViewController;
            view.NodeItemTableController.RefreshControl = new UIRefreshControl()
            {
                TintColor = UIColor.FromRGB(143, 202, 232),
                AttributedTitle = new NSAttributedString("Map aan het verversen")
            };

            view.NodeItemTableController.RefreshControl.ValueChanged += delegate
            {
                view.Refresh();
            };

            view.SyncButton.TouchUpInside += delegate
            {;
                view.Refresh(scrollToTop: true);
            };

            if (kleur != null)
            {
                view.KleurenBalk.BackgroundColor = kleur;
            }
                
            view.Refresh(scrollToTop: true);
            return view;
        }
コード例 #23
0
 private AutoLayoutContentView(string name, UIColor color, string font)
 {
     OurConstraints = new AutoLayoutConstraints ();
     base.BackgroundColor = color;
     Font = font;
     Name = name;
 }
コード例 #24
0
		public static void AddBorder(this UIView view, UIRectEdge edge, UIColor color, nfloat thickness) {

			var border = new CALayer ();
			var f = view.Frame;
			switch(edge)
			{
			case UIRectEdge.Top:
				border.Frame = new CGRect(0, 0, f.Width, thickness);
				break;
			case UIRectEdge.Bottom:
				border.Frame = new CGRect (0, f.Height - thickness, f.Width, thickness);
				break;
			case UIRectEdge.Left:
				border.Frame = new CGRect(0, 0, thickness, f.Height);
				break;
			case UIRectEdge.Right:
				border.Frame = new CGRect(f.Width - thickness, 0, thickness, f.Height);
				break;
			default:
				break;
			}

			border.BackgroundColor = color.CGColor;
			view.Layer.AddSublayer (border);
		}
コード例 #25
0
 private void SetBackgroundColor(SKColor color)
 {
     if (this.background != null)
     {
         background.Color = color;
     }
 }
コード例 #26
0
 /// <summary>
 /// Creates a new instance of the GlassButton using the specified dimensions
 /// </summary>
 public GlassButton(CGRect frame)
     : base(frame)
 {
     NormalColor = new UIColor(0.55f, 0.04f, 0.02f, 1);
     HighlightedColor = UIColor.Black;
     DisabledColor = UIColor.Gray;
 }
コード例 #27
0
ファイル: GaugeCustomization.cs プロジェクト: tremors/ios-sdk
		void CreateRadialGauge()
		{
			this.radialGauge = new TKRadialGauge ();
			this.View.AddSubview (this.radialGauge);

			TKGaugeRadialScale scale = new TKGaugeRadialScale ();
			this.radialGauge.AddScale (scale);
			scale.StartAngle = 0;
			scale.EndAngle = (nfloat)Math.PI*2.0f;
			scale.Stroke = new TKStroke (UIColor.Clear);
			scale.Ticks.Hidden = true;
			scale.Labels.Hidden = true;

			for (int i=0; i < 3; i++) {
				TKGaugeSegment segment = new TKGaugeSegment (new NSNumber (0), new NSNumber (100));
				segment.Fill = new TKSolidFill(this.colors[i].ColorWithAlpha(0.4f));
				segment.Width = 0.2f;
				segment.Location = 0.5f + i * 0.25f;
				segment.Cap = TKGaugeSegmentCap.Round;
				scale.AddSegment(segment);

				TKGaugeSegment gradientSegment = new TKGaugeSegment ();
				UIColor[] colors = new UIColor[] { this.colors[i], this.colors [i + 3] };
				gradientSegment.Fill = new TKLinearGradientFill (colors, new CGPoint(0.0f, 0.0f), new CGPoint(1.0f, 1.0f));
				gradientSegment.Width = 0.2f;
				gradientSegment.Location = 0.5f + i * 0.25f;
				gradientSegment.Cap = TKGaugeSegmentCap.Round;
				scale.AddSegment (gradientSegment);
				gradientSegment.SetRange(new TKRange(new NSNumber(0), new NSNumber(20+ this.r.Next(50)) ), 0.5f, CAMediaTimingFunction.EaseInEaseOut);
			}
		}
コード例 #28
0
		void CreateLinearGauge()
		{
			this.linearGauge = new TKLinearGauge();
			this.linearGauge.WeakDelegate = this.gaugeDelegate;
			this.linearGauge.Orientation = TKLinearGaugeOrientation.Vertical;
			this.View.AddSubview(this.linearGauge);

			TKGaugeLinearScale scale = new TKGaugeLinearScale (new NSNumber(-10), new NSNumber(40));	
			this.linearGauge.AddScale (scale);

			TKGaugeSegment segment = new TKGaugeSegment (new NSNumber(-10), new NSNumber(18));
			segment.Location = 0.56f;
			segment.Width = 0.05f;
			segment.Width2 = 0.05f;
			segment.Cap = TKGaugeSegmentCap.Round;

			scale.AddSegment (segment);

			UIColor[] colors = new UIColor[] { 
				new UIColor (0.149f, 0.580f, 0.776f, 1.00f),
				new UIColor (0.537f, 0.796f, 0.290f, 1.00f),
				new UIColor (1.000f, 0.773f, 0.247f, 1.00f),
				new UIColor (1.000f, 0.463f, 0.157f, 1.00f),
				new UIColor (0.769f, 0.000f, 0.047f, 1.00f)
			};
			this.AddSegments(scale, colors, 0.5f, 0.05f);
		}
コード例 #29
0
ファイル: MGCornersView.cs プロジェクト: pazof/MonoCross
 public void SetCornerBackgroundColor(UIColor color)
 {
     if (color != CornerBackgroundColor) {
         CornerBackgroundColor = color;
         SetNeedsDisplay();
     }
 }
コード例 #30
0
        public static Color ToColor(this UIColor color)
        {
            nfloat red;
            nfloat green;
            nfloat blue;
            nfloat alpha;

            if (color == null)
            {
                return(Color.Default);
            }
#if __IOS__
            color.GetRGBA(out red, out green, out blue, out alpha);
#else
            if (color.Type == NSColorType.Catalog)
            {
                color = UIColor.Black.UsingColorSpace(NSColorSpace.DeviceRGB);
            }
            // TODO:
            //throw new InvalidOperationException("Cannot convert a NSColorType.Catalog color without specifying the color space, use the overload to specify an NSColorSpace");

            color.GetRgba(out red, out green, out blue, out alpha);
#endif
            return(new Color(red, green, blue, alpha));
        }
コード例 #31
0
        NSDictionary MakeAttrs(NativeColor color, NativeColor darkColor) => new NativeStringAttributes
        {
            Font            = codeFont,
            ForegroundColor = IsDark ? darkColor : color,
            ParagraphStyle  = defaultParagraph,
        }

        .Dictionary;
コード例 #32
0
 public AppleMathView(TypesettingContext <TFont, TGlyph> typesettingContext, float fontSize)
 {
     Layer.GeometryFlipped = true;
     BackgroundColor       = NColor.FromRGB(0.9f, 0.9f, 0.9f);
     TextColor             = NColor.Black;
     FontSize            = fontSize;
     _typesettingContext = typesettingContext;
 }
コード例 #33
0
ファイル: StringElement.cs プロジェクト: jianwoo/CodeHub
 public StringElement()
 {
     Font = DefaultTitleFont.WithSize(DefaultTitleFont.PointSize);
     SubtitleFont = DefaultDetailFont.WithSize(DefaultDetailFont.PointSize);
     BackgroundColor = BgColor;
     TextColor = DefaultTitleColor;
     DetailColor = DefaultDetailColor;
 }
コード例 #34
0
ファイル: Ring.cs プロジェクト: pavlob0910/my-start-stable
		public void ResetStyle(bool isiOS7, UIColor colorToUse)
		{
			Color = colorToUse;
			BackgroundColor = isiOS7 ? UIColor.White : UIColor.DarkGray;
			ProgressUpdateInterval = 300;


		}
コード例 #35
0
        public static UIColor ToNative(this Color color, UIColor defaultColor)
        {
            if (color.IsDefault)
            {
                return(defaultColor);
            }

            return(color.ToNative());
        }
コード例 #36
0
        public static UIColor FromXamarinColor(Color xfColor)
        {
            UIKit.UIColor uiColor = UIColor.FromRGBA(
                (byte)(xfColor.R * 255),
                (byte)(xfColor.G * 255),
                (byte)(xfColor.B * 255),
                (byte)(xfColor.A * 255));

            return(uiColor);
        }
コード例 #37
0
        public static UIColor FromPatternImageFromBundle(string bgImage)
        {
            var image = UIImage.FromBundle(bgImage);

            if (image == null)
            {
                return(UIColor.White);
            }

            return(UIColor.FromPatternImage(image));
        }
コード例 #38
0
        public static Color?ToColor(this UIColor color)
        {
            if (color == null)
            {
                return(null);
            }

            color.GetRGBA(out nfloat red, out nfloat green, out nfloat blue, out nfloat alpha);

            return(new Color((float)red, (float)green, (float)blue, (float)alpha));
        }
コード例 #39
0
ファイル: MyScene.cs プロジェクト: zfs990/ios-samples
        public MyScene(CGSize size) : base(size)
        {
            BackgroundColor = new UIKit.UIColor(.15f, .15f, .3f, 1);

            AddChild(new SKLabelNode("Chalkduster")
            {
                Text     = "Hello World",
                FontSize = 30,
                Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY()),
            });
        }
コード例 #40
0
ファイル: GameScene.cs プロジェクト: zain-tariq/ios-samples
        public override void DidMoveToView(SKView view)
        {
            // Setup your scene here
            BackgroundColor = new UIKit.UIColor(.15f, .15f, .3f, 1);
            var myLabel = new SKLabelNode("Chalkduster")
            {
                FontSize = 30,
                Text     = "Hello, World!",
                Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY())
            };

            AddChild(myLabel);
        }
コード例 #41
0
        public Button(string text) : base()
        {
            // create a label
            var fontName = "Optima-ExtraBlack";

            this.label           = SKLabelNode.FromFont(fontName);
            this.label.Text      = text;
            this.label.FontSize  = 18;
            this.label.FontColor = SKColor.White;
            this.label.Position  = new CGPoint(0f, -8f);

            // create the background
            this.size       = new CGSize(this.label.Frame.Size.Width + 10f, 30f);
            this.background = new SKSpriteNode(SKColor.FromCIColor(new CoreImage.CIColor(0f, 0f, 0f, 0.75f)), size);

            // add to the root node
            this.AddChild(this.background);
            this.AddChild(this.label);

            // Track mouse event
            base.UserInteractionEnabled = true;
        }
コード例 #42
0
 public static void AddBorder(this _View thisButton, float borderThickness = 1, _Color borderColor = null)
 {
     if (borderColor != null)
     {
         thisButton.Layer.BorderColor = borderColor.CGColor;
     }
     if (borderThickness > 0)
     {
         if (Math.Abs(borderThickness - 1f) < float.Epsilon && ViewHelper.IsRetinaDisplay)
         {
             borderThickness = (float)ViewHelper.OnePixel;
         }
         thisButton.Layer.BorderWidth = borderThickness;
     }
 }
コード例 #43
0
 public static void RoundCorners(this _View thisButton, float radius = 2, float borderThickness = 0, _Color borderColor = null)
 {
     thisButton.AddBorder(borderThickness, borderColor);
     thisButton.Layer.CornerRadius = radius;
 }
コード例 #44
0
 /// <remarks>
 /// This method is required for performance. Creating a native Color
 /// requires a round-trip with Objective-C, so updating this value only when opacity
 /// and color changes is more efficient.
 /// </remarks>
 private void UpdateColorWithOpacity(Color newColor)
 {
     ColorWithOpacity = GetColorWithOpacity(newColor);
 }
コード例 #45
0
 public SolidColorBrush(Color color) : this()
 {
     Color = color;
     UpdateColorWithOpacity(color);
 }
コード例 #46
0
ファイル: SolidColorBrush.cs プロジェクト: zzyzy/uno
 public SolidColorBrush(Color color) : this()
 {
     Color = color;
 }
コード例 #47
0
ファイル: SolidColorBrush.cs プロジェクト: zzyzy/uno
 partial void UpdateColorWithOpacity(Color newColor, double opacity);
コード例 #48
0
ファイル: SolidColorBrush.cs プロジェクト: zzyzy/uno
 partial void OnColorChanged(Color oldValue, Color newValue);
コード例 #49
0
 public static UIColor ToNative(this Color?color, UIColor defaultColor)
 => color?.ToNative() ?? defaultColor;
コード例 #50
0
        public static Color ToColor(this UIColor color, NSColorSpace colorSpace)
        {
            var convertedColor = color.UsingColorSpace(colorSpace);

            return(convertedColor.ToColor());
        }
コード例 #51
0
        /// <remarks>
        /// This method is required for performance. Creating a native Color
        /// requires a round-trip with Objective-C, so updating this value only when opacity
        /// and color changes is more efficient.
        /// </remarks>
        partial void UpdateColorWithOpacity(Color newColor, double opacity)
        {
            newColor.A = (byte)(newColor.A * opacity);

            ColorWithOpacity = newColor;
        }
コード例 #52
0
 public static NativeColor ColorWithAlphaComponent(this NativeColor color, nfloat alpha) => color.ColorWithAlpha(alpha);
コード例 #53
0
 public static void Set(this NativeColor color) => color.SetColor();
コード例 #54
0
 public static NativeColor Gray(int g) => NativeColor.FromWhite(g / ((nfloat)255), 1);
コード例 #55
0
ファイル: SolidColorBrush.wasm.cs プロジェクト: zzyzy/uno
 /// <remarks>
 /// This method is required for performance. Creating a native Color
 /// requires a round-trip with Objective-C, so updating this value only when opacity
 /// and color changes is more efficient.
 /// </remarks>
 partial void UpdateColorWithOpacity(Color newColor, double opacity)
 {
     ColorWithOpacity = GetColorWithOpacity(newColor);
 }
コード例 #56
0
ファイル: SolidColorBrush.cs プロジェクト: zzyzy/uno
 partial void OnColorChanged(Color oldValue, Color newValue)
 {
     UpdateColorWithOpacity(newValue, Opacity);
 }
コード例 #57
0
 public static NativeColor Rgb(int r, int g, int b) => NativeColor.FromRgb(r, g, b);
コード例 #58
0
 public static UIColor ToPlatform(this Color?color, UIColor defaultColor)
 => color?.ToPlatform() ?? defaultColor;