private static void RenderSolutionNameIcon(string name)
 {
     if (!string.IsNullOrWhiteSpace(name))
     {
         const float margin         = 4;
         NSString    text           = (NSString)name;
         var         paragraphStyle = (NSParagraphStyle)NSParagraphStyle.DefaultParagraphStyle.MutableCopy();
         paragraphStyle.Alignment = NSTextAlignment.Center;
         var attributes = new NSStringAttributes()
         {
             Font            = NSFont.SystemFontOfSize(19, NSFontWeight.Regular),
             ForegroundColor = NSColor.White,
             ParagraphStyle  = paragraphStyle
         };
         var textRect         = new CGSize(_defaultImage.Size.Width - margin * 2, _defaultImage.Size.Height - 2 * margin);
         var rect             = text.BoundingRectWithSize(textRect, NSStringDrawingOptions.UsesLineFragmentOrigin, attributes.Dictionary);
         var centerAdjustment = _defaultImage.Size.Width - rect.Width - 2 * margin;
         rect.Offset(margin + centerAdjustment / 2, margin);
         var brandedImage = NSImage.ImageWithSize(_defaultImage.Size, false, (dstRect) =>
         {
             _defaultImage.Draw(dstRect);
             DrawBackgroundInRect(rect);
             text.DrawInRect(rect, attributes);
             return(true);
         });
         NSApplication.SharedApplication.ApplicationIconImage = brandedImage;
     }
     else
     {
         NSApplication.SharedApplication.ApplicationIconImage = _defaultImage;
     }
 }
Exemplo n.º 2
0
		public override void DrawRect(CGRect dirtyRect)
		{
			CGRect nameRect = CGRect.Empty;
			CGRect raiseRect = CGRect.Empty;
			raiseRect.Size = nameRect.Size = new CGSize(0.0f, lineHeight);

			nameRect.Location = new CGPoint(pageRect.Location.X, nameRect.Location.X);
			nameRect.Size = new CGSize(200.0f, nameRect.Size.Height);
			raiseRect.Location = new CGPoint(nameRect.GetMaxX(), raiseRect.Location.Y);
			raiseRect.Size = new CGSize(100.0f, raiseRect.Size.Height);

			nuint emptyRows = 2;
			for (nuint i = 0; i < employeeLinesPerPage; i++) {
				nuint index = (currentPage * employeeLinesPerPage) + i;
				if (index >= people.Count) {
					emptyRows = totalLinesPerPage - i;
					break;
				}
				Person p = people.GetItem<Person>(index);

				// Draw index and name
				nameRect.Location = new CGPoint(nameRect.Location.X, pageRect.Location.Y + (i * lineHeight));
				NSString nameString = new NSString(String.Format("{0:D2}: {1}", index+1, p.Name));
				nameString.DrawInRect(nameRect, attributes);

				raiseRect.Location = new CGPoint(raiseRect.Location.X, nameRect.Location.Y);
				NSString raiseString = new NSString(String.Format("{0:P1}", p.ExpectedRaise));
				raiseString.DrawInRect(raiseRect, attributes);
			}
			NSString printPageNumber = new NSString(String.Format("Page {0}", currentPage + 1));
			printPageNumber.DrawInRect(new CGRect(nameRect.Location.X, nameRect.Location.Y + nameRect.Size.Height * emptyRows, 200.0f, nameRect.Size.Height), attributes);

		}
Exemplo n.º 3
0
        internal void Draw(CGContext context, float x, float y, UGColor color)
        {
#if __MACOS__
            NSStringAttributes attributes = null;
            using (var nsColor = color.ToNSColor())
            {
                attributes = new NSStringAttributes()
                {
                    Font            = _textFormat.Native,
                    ForegroundColor = nsColor,
                };
            }
#else
            UIStringAttributes attributes = null;
            using (var uiColor = color.ToUIColor())
            {
                attributes = new UIStringAttributes()
                {
                    Font            = _textFormat.Native,
                    ForegroundColor = uiColor,
                };
            }
#endif

            var bounds = LayoutBounds;
            var rect   = new CGRect(
                x + bounds.X,
                y + bounds.Y,
                bounds.Width,
                bounds.Height);
            var scaleMatrix = CGAffineTransformHelper.CreateScale(
                1F,
                -1F,
                (float)rect.X,
                (float)rect.Y);
            try
            {
                context.SaveState();
                context.ConcatCTM(scaleMatrix);
                context.TranslateCTM(0, -bounds.Height);
#if __MACOS__
                _native.DrawInRect(rect, attributes);
#else
                _native.DrawString(rect, attributes);
#endif
            }
            finally { context.RestoreState(); }
        }