Browse Source

Some changes to resources / font loading.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@645 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
9d3e4e8eab
  1. 2
      src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/DigitsNode.cs
  2. 2
      src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/EnvironmentNode.cs
  3. 2
      src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/KeywordListNode.cs
  4. 2
      src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/MarkerNode.cs
  5. 3
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs
  6. 2
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs
  7. 12
      src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs
  8. 5
      src/Main/Base/Project/Src/Gui/Components/FontSelectionPanel.cs
  9. 2
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.cs
  10. 2
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs
  11. 4
      src/Main/Base/Project/Src/Gui/Dialogs/TreeViewOptions.cs
  12. 4
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs
  13. 12
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  14. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs
  15. 2
      src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/CodeTemplatePanel.cs
  16. 7
      src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/GeneralTextEditorPanel.cs
  17. 36
      src/Main/Core/Project/Src/Services/ResourceService/ResourceService.cs
  18. 4
      src/Main/StartUp/Project/SharpDevelopMain.cs

2
src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/DigitsNode.cs

@ -79,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes @@ -79,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes
DigitsNode node = (DigitsNode)parent;
Properties properties = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()));
sampleLabel.Font = ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()));
sampleLabel.Font = ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()));
color = node.Color;
PreviewUpdate(sampleLabel, color);
}

2
src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/EnvironmentNode.cs

@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes @@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes
this.UseItemStyleForSubItems = false;
Properties properties = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()));
basefont = ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()));
basefont = ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()));
listfont = listFont;
ColorUpdate();

2
src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/KeywordListNode.cs

@ -158,7 +158,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes @@ -158,7 +158,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes
}
Properties properties = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()));
sampleLabel.Font = ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()));
sampleLabel.Font = ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()));
color = node.Color;
nameBox.Text = node.Name;

2
src/AddIns/Misc/HighlightingEditor/Project/Src/Nodes/MarkerNode.cs

@ -133,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes @@ -133,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.HighlightingEditor.Nodes
Properties properties = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()));
sampleLabel.Font = ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()));
sampleLabel.Font = ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()));
color = node.Color;
nameBox.Text = node.What;

3
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs

@ -15,6 +15,7 @@ using System.Windows.Forms; @@ -15,6 +15,7 @@ using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui;
using NSvn.Common;
using NSvn.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
namespace ICSharpCode.Svn
@ -34,7 +35,7 @@ namespace ICSharpCode.Svn @@ -34,7 +35,7 @@ namespace ICSharpCode.Svn
Get<ListView>("toRevision").SelectedIndexChanged += new EventHandler(ShowDiff);
ControlDictionary["diffRichTextBox"].Enabled = false;
ControlDictionary["diffRichTextBox"].Font = new Font("Courier New", 10);
ControlDictionary["diffRichTextBox"].Font = ResourceService.CourierNew10;
ControlDictionary["splitter1"].Height = 3;
ListViewItem newItem;

2
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.Svn @@ -37,7 +37,7 @@ namespace ICSharpCode.Svn
changesList = Get<ListView>("changes");
revisionList.SelectedIndexChanged += RevisionListViewSelectionChanged;
ControlDictionary["commentRichTextBox"].Enabled = false;
ControlDictionary["commentRichTextBox"].Font = new Font("Courier New", 10);
ControlDictionary["commentRichTextBox"].Font = ResourceService.CourierNew10;
// Work around WinForms/XmlForms bug:
ControlDictionary["splitter1"].Height = 3;

12
src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs

@ -310,13 +310,13 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -310,13 +310,13 @@ namespace ICSharpCode.SharpDevelop.Gui
static ExtTreeNode()
{
font = new Font("Tahoma", 9);
boldFont = new Font("Tahoma", 9, FontStyle.Bold);
italicFont = new Font("Tahoma", 9, FontStyle.Italic);
font = ResourceService.LoadFont("Tahoma", 9);
boldFont = ResourceService.LoadFont("Tahoma", 9, FontStyle.Bold);
italicFont = ResourceService.LoadFont("Tahoma", 9, FontStyle.Italic);
monospacedFont = new Font("Courier New", 10);
boldMonospacedFont = new Font("Courier New", 10, FontStyle.Bold);
italicMonospacedFont = new Font("Courier New", 10, FontStyle.Italic);
monospacedFont = ResourceService.LoadFont("Courier New", 10);
boldMonospacedFont = ResourceService.LoadFont("Courier New", 10, FontStyle.Bold);
italicMonospacedFont = ResourceService.LoadFont("Courier New", 10, FontStyle.Italic);
}
#endregion

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

@ -104,8 +104,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -104,8 +104,9 @@ namespace ICSharpCode.SharpDevelop.Gui
try {
string[] descr = font.Split(new char[]{',', '='});
return new Font(descr[1], Single.Parse(descr[3]));
} catch (Exception) {
return new Font("Courier New", 10);
} catch (Exception ex) {
LoggingService.Warn(ex);
return ResourceService.CourierNew10;
}
}

2
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.EditStandardHeaderPanel.xfrm"));
ControlDictionary["headerTextBox"].Font = new Font("Courier New", 10);
ControlDictionary["headerTextBox"].Font = ResourceService.CourierNew10;
foreach (StandardHeader header in StandardHeader.StandardHeaders) {
((ComboBox)ControlDictionary["headerChooser"]).Items.Add(header);
}

2
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -39,7 +39,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
ControlDictionary["FontGroupBox"].Controls.Add(fontSelectionPanel);
((CheckBox)ControlDictionary["wordWrapCheckBox"]).Checked = properties.Get("WordWrap", true);
fontSelectionPanel.CurrentFontString = properties.Get("DefaultFont", new Font("Courier New", 10).ToString()).ToString();
fontSelectionPanel.CurrentFontString = properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString();
}
public override bool StorePanelContents()

4
src/Main/Base/Project/Src/Gui/Dialogs/TreeViewOptions.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{
public GradientHeaderPanel(int fontSize) : this()
{
Font = new Font("Tahoma", fontSize);
Font = ResourceService.LoadFont("Tahoma", fontSize);
}
public GradientHeaderPanel() : base()
@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Gui
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.TreeViewOptionsDialog.xfrm"));
this.optionsPanelLabel = new GradientHeaderPanel();
this.optionsPanelLabel.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.optionsPanelLabel.Font = new Font("Tahoma", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.optionsPanelLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.optionsPanelLabel.BorderStyle = BorderStyle.Fixed3D;
this.optionsPanelLabel.Dock = DockStyle.Fill;

4
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs

@ -113,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -113,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Gui
properties = (Properties)PropertyService.Get(OutputWindowOptionsPanel.OutputWindowsProperty, new Properties());
textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()).ToString());
textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString());
properties.PropertyChanged += new PropertyChangedEventHandler(PropertyChanged);
textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick;
@ -275,7 +275,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -275,7 +275,7 @@ namespace ICSharpCode.SharpDevelop.Gui
SetWordWrap();
}
if (e.Key == "DefaultFont") {
textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()).ToString());
textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString());
}
}

12
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -163,8 +163,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -163,8 +163,9 @@ namespace ICSharpCode.SharpDevelop.Gui
ISite site = ((IComponent)item).Site;
if (site != null) {
string name = site.Name;
Font f = new Font(comboBox.Font, FontStyle.Bold);
mea.ItemWidth += (int)mea.Graphics.MeasureString(name + "-", f).Width;
using (Font f = new Font(comboBox.Font, FontStyle.Bold)) {
mea.ItemWidth += (int)mea.Graphics.MeasureString(name + "-", f).Width;
}
}
}
}
@ -195,9 +196,10 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -195,9 +196,10 @@ namespace ICSharpCode.SharpDevelop.Gui
ISite site = ((IComponent)item).Site;
if (site != null) {
string name = site.Name;
Font f = new Font(comboBox.Font, FontStyle.Bold);
g.DrawString(name, f, stringColor, xPos, dea.Bounds.Y);
xPos += (int)g.MeasureString(name + "-", f).Width;
using (Font f = new Font(comboBox.Font, FontStyle.Bold)) {
g.DrawString(name, f, stringColor, xPos, dea.Bounds.Y);
xPos += (int)g.MeasureString(name + "-", f).Width;
}
}
}

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
static SharpDevelopTextEditorProperties()
{
Properties properties2 = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()));
FontContainer.DefaultFont = FontContainer.ParseFont(properties2.Get("DefaultFont", new Font("Courier New", 10).ToString()));
FontContainer.DefaultFont = FontContainer.ParseFont(properties2.Get("DefaultFont", ResourceService.CourierNew10.ToString()));
properties2.PropertyChanged += new PropertyChangedEventHandler(CheckFontChange);
}

2
src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/CodeTemplatePanel.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -48,7 +48,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
ControlDictionary["removeGroupButton"].Click += new System.EventHandler(RemoveGroupEvent);
((TextBox)ControlDictionary["templateTextBox"]).Font = new System.Drawing.Font("Courier New", 10f);
((TextBox)ControlDictionary["templateTextBox"]).Font = ResourceService.CourierNew10;
((TextBox)ControlDictionary["templateTextBox"]).TextChanged += new EventHandler(TextChange);
((ListView)ControlDictionary["templateListView"]).Activation = ItemActivation.Standard;

7
src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/GeneralTextEditorPanel.cs

@ -99,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels @@ -99,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels
((ComboBox)ControlDictionary["textEncodingComboBox"]).SelectedIndex = encodingIndex;
encoding = CharacterEncodings.GetEncodingByIndex(encodingIndex).CodePage;
Font currentFont = ParseFont(((Properties)CustomizationObject).Get("DefaultFont", new Font("Courier New", 10).ToString()).ToString());
Font currentFont = ParseFont(((Properties)CustomizationObject).Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString());
for (int i = 6; i <= 24; ++i) {
((ComboBox)ControlDictionary["fontSizeComboBox"]).Items.Add(i);
@ -217,8 +217,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels @@ -217,8 +217,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels
try {
string[] descr = font.Split(new char[]{',', '='});
return new Font(descr[1], Single.Parse(descr[3]));
} catch (Exception) {
return new Font("Courier New", 10);
} catch (Exception ex) {
LoggingService.Warn(ex);
return ResourceService.CourierNew10;
}
}
}

36
src/Main/Core/Project/Src/Services/ResourceService/ResourceService.cs

@ -39,12 +39,6 @@ namespace ICSharpCode.Core @@ -39,12 +39,6 @@ namespace ICSharpCode.Core
PropertyService.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChange);
LoadLanguageResources(PropertyService.Get(uiLanguageProperty, Thread.CurrentThread.CurrentUICulture.Name));
Assembly exe = Assembly.GetEntryAssembly();
if (exe != null) {
strings.Add(new ResourceManager("Resources.StringResources", exe));
icons.Add(new ResourceManager("Resources.BitmapResources", exe));
}
}
/// <summary>English strings (list of resource managers)</summary>
@ -129,12 +123,17 @@ namespace ICSharpCode.Core @@ -129,12 +123,17 @@ namespace ICSharpCode.Core
/// <example><c>ResourceService.RegisterStrings("TestAddin.Resources.StringResources", GetType().Assembly);</c></example>
public static void RegisterStrings(string baseResourceName, Assembly assembly)
{
strings.Add(new ResourceManager(baseResourceName, assembly));
RegisterNeutralStrings(new ResourceManager(baseResourceName, assembly));
ResourceAssembly ra = new ResourceAssembly(assembly, baseResourceName, false);
resourceAssemblies.Add(ra);
ra.Load();
}
public static void RegisterNeutralStrings(ResourceManager stringManager)
{
strings.Add(stringManager);
}
/// <summary>
/// Registers image resources in the resource service.
/// </summary>
@ -143,12 +142,17 @@ namespace ICSharpCode.Core @@ -143,12 +142,17 @@ namespace ICSharpCode.Core
/// <example><c>ResourceService.RegisterImages("TestAddin.Resources.BitmapResources", GetType().Assembly);</c></example>
public static void RegisterImages(string baseResourceName, Assembly assembly)
{
icons.Add(new ResourceManager(baseResourceName, assembly));
RegisterNeutralImages(new ResourceManager(baseResourceName, assembly));
ResourceAssembly ra = new ResourceAssembly(assembly, baseResourceName, true);
resourceAssemblies.Add(ra);
ra.Load();
}
public static void RegisterNeutralImages(ResourceManager imageManager)
{
icons.Add(imageManager);
}
/// <summary>
/// Take string/bitmap resources from an assembly and merge them in the resource service
/// </summary>
@ -205,6 +209,16 @@ namespace ICSharpCode.Core @@ -205,6 +209,16 @@ namespace ICSharpCode.Core
}
#region Font loading
static Font courierNew10;
public static Font CourierNew10 {
get {
if (courierNew10 == null)
courierNew10 = LoadFont("Courier New", 10);
return courierNew10;
}
}
/// <summary>
/// The LoadFont routines provide a safe way to load fonts.
/// </summary>
@ -231,7 +245,8 @@ namespace ICSharpCode.Core @@ -231,7 +245,8 @@ namespace ICSharpCode.Core
{
try {
return new Font(fontName, size, style);
} catch (Exception) {
} catch (Exception ex) {
LoggingService.Warn(ex);
return SystemInformation.MenuFont;
}
}
@ -264,7 +279,8 @@ namespace ICSharpCode.Core @@ -264,7 +279,8 @@ namespace ICSharpCode.Core
{
try {
return new Font(fontName, size, style, unit);
} catch (Exception) {
} catch (Exception ex) {
LoggingService.Warn(ex);
return SystemInformation.MenuFont;
}
}

4
src/Main/StartUp/Project/SharpDevelopMain.cs

@ -162,6 +162,10 @@ namespace ICSharpCode.SharpDevelop @@ -162,6 +162,10 @@ namespace ICSharpCode.SharpDevelop
MessageService.CustomErrorReporter = ShowErrorBox;
#endif
Assembly exe = typeof(SharpDevelopMain).Assembly;
ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe));
ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe));
RegisterDoozers();
InitializeCore();

Loading…
Cancel
Save