當前位置: 首頁>>代碼示例>>C#>>正文


C# ToolStripLabel.GetPreferredSize方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ToolStripLabel.GetPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:C# ToolStripLabel.GetPreferredSize方法的具體用法?C# ToolStripLabel.GetPreferredSize怎麽用?C# ToolStripLabel.GetPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ToolStripLabel的用法示例。


在下文中一共展示了ToolStripLabel.GetPreferredSize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: HeaderStrip

        public HeaderStrip()
        {
            this.Dock = DockStyle.Top;
            this.GripStyle = ToolStripGripStyle.Hidden;
            this.AutoSize = false;

            // Set renderer - override background painting
            SetRenderer();

            // Setup Headers
            Font font = SystemFonts.MenuFont;
            this.Font = new Font("Arial", font.SizeInPoints + 3.75F, FontStyle.Bold);
            this.ForeColor = System.Drawing.Color.Gray;

            ToolStripLabel tsl = new ToolStripLabel();
            tsl.Font = this.Font;
            tsl.Text = "I";

            this.Height = tsl.GetPreferredSize(Size.Empty).Height + 6;
        }
開發者ID:Dawn-of-Light,項目名稱:QuestDesigner,代碼行數:20,代碼來源:HeaderStrip.cs

示例2: SetHeaderStyle

		private void SetHeaderStyle()
		{
			// Get system font
			Font font = SystemFonts.MenuFont;

			if ( _headerStyle == AreaHeaderStyle.Large )
			{
				Font = new Font( @"Arial", font.SizeInPoints + 3.75F, FontStyle.Bold );
				ForeColor = Color.White;
			}
			else
			{
				Font = font;
				ForeColor = Color.White;
			}

			// Only way to calculate size
			var tsl = new ToolStripLabel {Font = Font, Text = @"I"};

			// Set Size
			Height = tsl.GetPreferredSize( Size.Empty ).Height + 6;
		}
開發者ID:iraychen,項目名稱:ZetaResourceEditor,代碼行數:22,代碼來源:HeaderStrip.cs

示例3: SetHeaderStyle

		private void SetHeaderStyle()
		{
			// Get system font
			Font	font = SystemFonts.MenuFont;

			if (_headerStyle == AreaHeaderStyle.Large)
			{
				this.Font = new Font("Arial", font.SizeInPoints + 3.75F, FontStyle.Bold);
				this.ForeColor = System.Drawing.Color.White;
			}
			else
			{
				this.Font = font;
				this.ForeColor = System.Drawing.Color.Black;
			}

			// Only way to calculate size
			ToolStripLabel	tsl = new ToolStripLabel();
			tsl.Font =		this.Font;
			tsl.Text =		"I";

			// Set Size
			this.Height = tsl.GetPreferredSize(Size.Empty).Height + 6;
		}
開發者ID:haoasqui,項目名稱:MailSystem.NET,代碼行數:24,代碼來源:HeaderStrip.cs

示例4: BehaviorAutoSize

		[NUnit.Framework.Category ("NotWorking")]	// Font dependent, values are for win32
		public void BehaviorAutoSize ()
		{
			// Lots of things depend on this, it needs to be 100% correct...
			ToolStripItem tsi = new ToolStripLabel ();

			string string1 = "ABCDEFG";
			string string2 = "qwertyuiop--123456";
			Font f1 = tsi.Font;
			Font f2 = new Font ("Arial", 14);
			Size string1size = TextRenderer.MeasureText (string1, f1);
			Size string2size = TextRenderer.MeasureText (string2, f1);
			Size string1size2 = TextRenderer.MeasureText (string1, f2);
			Size string2size2 = TextRenderer.MeasureText (string2, f2);
			Image i = new Bitmap (16, 16);
			Image i2 = new Bitmap (22, 22);

			Assert.AreEqual (new Size (0, 0), tsi.GetPreferredSize (Size.Empty), "K1");

			// Text only
			tsi.Text = string1;
			Assert.AreEqual (new Size (string1size.Width, string1size.Height), tsi.GetPreferredSize (Size.Empty), "K2");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size.Width, string1size.Height), tsi.GetPreferredSize (Size.Empty), "K3");

			tsi.Font = f2;
			tsi.Text = string1;
			Assert.AreEqual (new Size (string1size2.Width, string1size2.Height), tsi.GetPreferredSize (Size.Empty), "K4");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size2.Width, string1size2.Height), tsi.GetPreferredSize (Size.Empty), "K5");

			// Text and image
			tsi.Image = i;
			tsi.Font = f1;
			tsi.Text = string1;
			Assert.AreEqual (new Size (string1size.Width + 16, string1size.Height + 3), tsi.GetPreferredSize (Size.Empty), "K6");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size.Width + 16, string2size.Height + 3), tsi.GetPreferredSize (Size.Empty), "K7");

			tsi.Image = i2;
			tsi.Font = f2;
			tsi.Text = string1;
			Assert.AreEqual (new Size (string1size2.Width + 22, Math.Max (string1size2.Height, 22)), tsi.GetPreferredSize (Size.Empty), "K8");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size2.Width + 22, Math.Max (string1size2.Height, 22)), tsi.GetPreferredSize (Size.Empty), "K9");

			// Image only
			tsi.Image = i;
			tsi.Text = string.Empty;

			Assert.AreEqual (new Size (16, 16), tsi.GetPreferredSize (Size.Empty), "K10");

			tsi.Image = i2;
			Assert.AreEqual (new Size (22, 22), tsi.GetPreferredSize (Size.Empty), "K11");

			// DisplayStyle = text
			tsi.Image = null;
			tsi.Text = string1;
			tsi.Font = f1;
			tsi.DisplayStyle = ToolStripItemDisplayStyle.Text;

			Assert.AreEqual (new Size (string1size.Width, string1size.Height), tsi.GetPreferredSize (Size.Empty), "K12");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size.Width, string1size.Height), tsi.GetPreferredSize (Size.Empty), "K13");

			tsi.Font = f2;
			tsi.Text = string1;
			Assert.AreEqual (new Size (string1size2.Width, string1size2.Height), tsi.GetPreferredSize (Size.Empty), "K14");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size2.Width, string1size2.Height), tsi.GetPreferredSize (Size.Empty), "K15");

			// DisplayStyle = image
			tsi.Image = i;
			tsi.Text = string.Empty;
			tsi.DisplayStyle = ToolStripItemDisplayStyle.Image;

			Assert.AreEqual (new Size (16, 16), tsi.GetPreferredSize (Size.Empty), "K16");

			tsi.Image = i2;
			Assert.AreEqual (new Size (22, 22), tsi.GetPreferredSize (Size.Empty), "K17");

			// DisplayStyle = textandimage, imagebeforetext
			tsi.Image = i;
			tsi.Font = f1;
			tsi.Text = string1;
			tsi.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
			Assert.AreEqual (new Size (string1size.Width + 16, 16), tsi.GetPreferredSize (Size.Empty), "K18");

			tsi.Text = string2;
			Assert.AreEqual (new Size (string2size.Width + 16, 16), tsi.GetPreferredSize (Size.Empty), "K19");

			tsi.Image = i2;
			tsi.Font = f2;
			tsi.Text = string1;
//.........這裏部分代碼省略.........
開發者ID:Profit0004,項目名稱:mono,代碼行數:101,代碼來源:ToolStripLabelTest.cs


注:本文中的System.Windows.Forms.ToolStripLabel.GetPreferredSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。