Browse Source

Font selection panel is now much faster in initalization.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@48 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 21 years ago
parent
commit
aebdd74371
  1. 17
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  2. 55
      src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs
  3. 1
      src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs

17
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs

@ -24,15 +24,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -24,15 +24,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
ICSharpCode.NRefactory.Parser.LookupTableVisitor lookupTableVisitor;
IProjectContent projectContent = null;
public IProjectContent ProjectContent {
get {
return projectContent;
}
set {
projectContent = value;
}
}
bool showStatic = false;
bool inNew = false;
@ -42,6 +33,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -42,6 +33,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
int caretLine;
int caretColumn;
public IProjectContent ProjectContent {
get {
return projectContent;
}
set {
projectContent = value;
}
}
public ICompilationUnit CompilationUnit {
get {

55
src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs

@ -65,12 +65,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -65,12 +65,12 @@ namespace ICSharpCode.SharpDevelop.Gui
((ComboBox)ControlDictionary["fontSizeComboBox"]).Items.Add(i);
}
((ComboBox)ControlDictionary["fontSizeComboBox"]).TextChanged += new EventHandler(UpdateFontPreviewLabel);
foreach (FontFamily fontFamily in installedFontCollection.Families) {
if (fontFamily.IsStyleAvailable(FontStyle.Regular) && fontFamily.IsStyleAvailable(FontStyle.Bold) && fontFamily.IsStyleAvailable(FontStyle.Italic)) {
((ComboBox)ControlDictionary["fontListComboBox"]).Items.Add(new FontDescriptor(fontFamily.Name, IsMonospaced(fontFamily)));
if (fontFamily.IsStyleAvailable(FontStyle.Regular) && fontFamily.IsStyleAvailable(FontStyle.Bold) && fontFamily.IsStyleAvailable(FontStyle.Italic)) {
((ComboBox)ControlDictionary["fontListComboBox"]).Items.Add(new FontDescriptor(fontFamily));
}
}
Console.WriteLine("GET FONTS DONE!!!");
((ComboBox)ControlDictionary["fontListComboBox"]).TextChanged += new EventHandler(UpdateFontPreviewLabel);
((ComboBox)ControlDictionary["fontListComboBox"]).SelectedIndexChanged += new EventHandler(UpdateFontPreviewLabel);
((ComboBox)ControlDictionary["fontListComboBox"]).MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.MeasureComboBoxItem);
@ -91,20 +91,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -91,20 +91,6 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
bool IsMonospaced(FontFamily fontFamily)
{
using (Bitmap newBitmap = new Bitmap(1, 1)) {
using (Graphics g = Graphics.FromImage(newBitmap)) {
using (Font f = new Font(fontFamily, 10)) {
// determine if the length of i == m because I see no other way of
// getting if a font is monospaced or not.
int w1 = (int)g.MeasureString("i.", f).Width;
int w2 = (int)g.MeasureString("mw", f).Width;
return w1 == w2;
}
}
}
}
public static Font ParseFont(string font)
{
@ -146,31 +132,42 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -146,31 +132,42 @@ namespace ICSharpCode.SharpDevelop.Gui
class FontDescriptor
{
string name;
bool isMonospaced;
FontFamily fontFamily;
bool isMonospaced = false;
bool initializedMonospace = false;
public string Name {
get {
return name;
}
set {
name = value;
return fontFamily.Name;
}
}
public bool IsMonospaced {
get {
if (!initializedMonospace) {
isMonospaced = GetIsMonospaced(fontFamily);
}
return isMonospaced;
}
set {
isMonospaced = value;
}
bool GetIsMonospaced(FontFamily fontFamily)
{
using (Bitmap newBitmap = new Bitmap(1, 1)) {
using (Graphics g = Graphics.FromImage(newBitmap)) {
using (Font f = new Font(fontFamily, 10)) {
// determine if the length of i == m because I see no other way of
// getting if a font is monospaced or not.
int w1 = (int)g.MeasureString("i.", f).Width;
int w2 = (int)g.MeasureString("mw", f).Width;
return w1 == w2;
}
}
}
}
public FontDescriptor(string name, bool isMonospaced)
public FontDescriptor(FontFamily fontFamily)
{
this.name = name;
this.isMonospaced = isMonospaced;
this.fontFamily = fontFamily;
}
}

1
src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs

@ -27,6 +27,7 @@ namespace ICSharpCode.Core @@ -27,6 +27,7 @@ namespace ICSharpCode.Core
XmlDoc XmlDoc {
get;
}
ICollection<IClass> Classes {
get;
}

Loading…
Cancel
Save