예제 #1
0
		/// <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;
		}
예제 #2
0
        /// <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;
        }