ArcGISCompare.MiscProcs.TrimText C# (CSharp) Method

TrimText() static private method

static private TrimText ( string OrigText, Font f, Size ProposedSize ) : String
OrigText string
f System.Drawing.Font
ProposedSize System.Drawing.Size
return String
        internal static String TrimText(string OrigText, Font f, Size ProposedSize)
        {
            Size TheSize = TextRenderer.MeasureText(OrigText, f);

              String TheShortString = OrigText;
              String DerivedString = OrigText.Substring(0, 3);
              String PathString = TheShortString.Substring(2);
              try
              {
              while (TheSize.Width >= ProposedSize.Width)
              {
              PathString = PathString.Substring(1);
              if (PathString.Contains("\\"))
              {
                  PathString = PathString.Substring(PathString.IndexOf("\\") + 1);
                  TheShortString = DerivedString + "..." + PathString;
              }
              TheSize = TextRenderer.MeasureText(TheShortString, f);
              }
              }
              catch { }
              return TheShortString;
        }