From aebdd743710c9039c73dc59056a076fd1bd3e5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Thu, 20 Jan 2005 09:25:57 +0000 Subject: [PATCH] Font selection panel is now much faster in initalization. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@48 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../NRefactoryResolver/NRefactoryResolver.cs | 17 +++--- .../Src/Gui/Components/FontSelectionPanel.cs | 57 +++++++++---------- .../Services/ParserService/IProjectContent.cs | 1 + 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs index 7d3c95f8ab..f0a4569b97 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs @@ -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 int caretLine; int caretColumn; + public IProjectContent ProjectContent { + get { + return projectContent; + } + set { + projectContent = value; + } + } public ICompilationUnit CompilationUnit { get { diff --git a/src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs b/src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs index f54f098ae1..ed294a33de 100644 --- a/src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs +++ b/src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs @@ -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,21 +91,7 @@ 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) { try { @@ -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; } } diff --git a/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs index ed545c61ac..b86890f570 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs @@ -27,6 +27,7 @@ namespace ICSharpCode.Core XmlDoc XmlDoc { get; } + ICollection Classes { get; }