当前位置: 首页>>代码示例>>C#>>正文


C# NSString.StringSize方法代码示例

本文整理汇总了C#中MonoMac.Foundation.NSString.StringSize方法的典型用法代码示例。如果您正苦于以下问题:C# NSString.StringSize方法的具体用法?C# NSString.StringSize怎么用?C# NSString.StringSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MonoMac.Foundation.NSString的用法示例。


在下文中一共展示了NSString.StringSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateSize

		void CalculateSize ()
		{
			NSString str = new NSString (badgeNumber.ToString());
			NSDictionary attibutedStringAttributed = NSDictionary.FromObjectAndKey(Font, NSAttributedString.FontAttributeName);

			numberSize = str.StringSize (attibutedStringAttributed);
			Frame = new RectangleF (Frame.Location, new SizeF (Math.Max (numberSize.Width, height), height));
		}
开发者ID:robertmiles3,项目名称:xamarin-store-app,代码行数:8,代码来源:BadgeView.cs

示例2: MeasureText

 public static SizeF MeasureText(CGContext context, string text, string fontName, float fontSize)
 {
     NSString str = new NSString(text);
     var dict = new NSMutableDictionary();
     dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
     var size = str.StringSize(dict);
     return size;
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:8,代码来源:CoreGraphicsHelper.cs

示例3: MakeGLDisplayListFirst

		// Create the set of display lists for the bitmaps
		bool MakeGLDisplayListFirst (char first, int count, int baseDL)
		{

			int curListIndex;
			NSColor blackColor;
			NSMutableDictionary attribDict;
			int dListNum;
			NSString currentChar;
			char currentUnichar;
			SizeF charSize;
			RectangleF charRect;
			NSImage theImage;
			bool retval;

			// Make sure the list isn't already under construction
			GL.GetInteger (GetPName.ListIndex, out curListIndex);
			if (curListIndex != 0) {
				Console.WriteLine ("Display list already under construction");
				return false;
			}

			// Save pixel unpacking state
			GL.PushClientAttrib (ClientAttribMask.ClientPixelStoreBit);

			GL.PixelStore (PixelStoreParameter.UnpackSwapBytes, 0);
			GL.PixelStore (PixelStoreParameter.UnpackLsbFirst, 0);
			GL.PixelStore (PixelStoreParameter.UnpackSkipPixels, 0);
			GL.PixelStore (PixelStoreParameter.UnpackSkipRows, 0);
			GL.PixelStore (PixelStoreParameter.UnpackRowLength, 0);
			GL.PixelStore (PixelStoreParameter.UnpackAlignment, 0);

			blackColor = NSColor.Black;

			attribDict = new NSMutableDictionary ();
			attribDict.SetValueForKey (font, NSAttributedString.FontAttributeName);
			attribDict.SetValueForKey (NSColor.White, NSAttributedString.ForegroundColorAttributeName);
			attribDict.SetValueForKey (blackColor, NSAttributedString.BackgroundColorAttributeName);

			charRect.Location.X = charRect.Location.Y = 0;

			theImage = new NSImage (new SizeF (0,0));
			retval = true;

			for (dListNum = baseDL, currentUnichar = first; currentUnichar < first + count; 
				dListNum++, currentUnichar++) {

				currentChar = new NSString (Char.ToString (currentUnichar));
				charSize = currentChar.StringSize (attribDict);
				charRect.Size = charSize;
				charRect = charRect.Integral ();
				if (charRect.Size.Width > 0 && charRect.Size.Height > 0) {

					theImage.Size = charRect.Size;
					theImage.LockFocus ();
					NSGraphicsContext.CurrentContext.ShouldAntialias = false;
					blackColor.Set ();
					NSBezierPath.FillRect (charRect);
					currentChar.DrawString (charRect, attribDict);
					theImage.UnlockFocus ();

					if (!MakeDisplayList(dListNum, theImage)) {
						retval = false;
						break;
					}
				}
			}
			return retval;
		}
开发者ID:Anomalous-Software,项目名称:monomac,代码行数:69,代码来源:BitmapFont.cs

示例4: DrawStringOutline

		private void DrawStringOutline(string text, NSColor color, RectangleF rect, int align)
		{
			NSString nsString = new NSString (text);

			int halign = align % 3;
			int valign = align / 3;


			var objectsText = new object[] { m_font, color };
			var keysText = new object[] { NSAttributedString.FontAttributeName, NSAttributedString.ForegroundColorAttributeName };
			var attributesText = NSDictionary.FromObjectsAndKeys(objectsText, keysText);

			var objectsOutline = new object[] { m_font, NSColor.White };
			var keysOutline = new object[] { NSAttributedString.FontAttributeName, NSAttributedString.ForegroundColorAttributeName };
			var attributesOutline = NSDictionary.FromObjectsAndKeys(objectsOutline, keysOutline);


			SizeF size = nsString.StringSize (attributesText);

			if (halign == 0) {
			} else if (halign == 1) {
				rect.X = (rect.Left + rect.Right) / 2 - size.Width / 2;
			} else if (halign == 2) {
				rect.X = rect.Right - size.Width;
			}
			rect.Width = size.Width;

			if (valign == 0) {
			} else if (valign == 1) {
				rect.Y = (rect.Top + rect.Bottom) / 2 - size.Height / 2;
			} else if (valign == 2) {
				rect.Y = rect.Bottom - size.Height;
			}
			rect.Height = size.Height;

			NSColor.Black.Set ();
			for (int ox = -1; ox <= 1; ox++) {
				for (int oy = -1; oy <= 1; oy++) {
					RectangleF rectString = rect;
					rectString.Offset (new PointF (ox, oy));
					nsString.DrawString (Invert (rectString), attributesOutline);
				}
			}
			nsString.DrawString(Invert(rect), attributesText);
		}
开发者ID:liftir,项目名称:airvpn-client,代码行数:45,代码来源:ChartView.cs


注:本文中的MonoMac.Foundation.NSString.StringSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。