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


C# StatusBar.CreateGraphics方法代码示例

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


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

示例1: StatusBarSizeGrip

		/// <summary>
		/// Initializes a new instance of the <see cref="StatusBarSizeGrip"/> class.
		/// </summary>
		/// <param name="bar">The status bar.</param>
		public StatusBarSizeGrip(StatusBar bar)
		{
			BorderStyle = StatusBarPanelBorderStyle.None;
			Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw;
			bar.DrawItem += new StatusBarDrawItemEventHandler(bar_DrawItem);
			int width = 16;
			if (Application.RenderWithVisualStyles)
			{
				using (Graphics g = bar.CreateGraphics())
				{
					VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal);
					Size sz = renderer.GetPartSize(g, ThemeSizeType.True);
					width = sz.Width;
				}
			}
			int widthT = width + SystemInformation.Border3DSize.Width * 2;
			// Can get widthT = 7 (< MinWidth = 10) on Mac Parallels, so we don't want to crash.
			Width = widthT >= MinWidth ? widthT : MinWidth;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:23,代码来源:xWindow.cs

示例2: TruncateFileName

        /// <summary>
        /// Truncate the given file's name if it is to long to fit in the given status bar
        /// </summary>
        /// <param name="file">FileInfo object to measure</param>
        /// <param name="status">StatusBar to measure against</param>
        /// <returns>file name or truncated file name if to long</returns>
        /// <history>
        /// [Curtis_Beard]	   04/21/2006	Created, fixes bug 1367852
        /// </history>
        private string TruncateFileName(System.IO.FileInfo file, StatusBar status)
        {
            const int EXTRA = 20;     //used for spacing of the sizer
             Graphics g = status.CreateGraphics();
             int _strLen = 0;
             string _name = file.FullName;

             _strLen = Convert.ToInt32(g.MeasureString(_name, status.Font).Width);
             if (_strLen >= (status.Width - EXTRA))
             {
            // truncate to just the root name and the file name (for now)
            _name = file.Directory.Root.Name + @"...\" + file.Name;
             }

             g.Dispose();

             return _name;
        }
开发者ID:joshball,项目名称:astrogrep,代码行数:27,代码来源:frmMain.cs


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