5 changed files with 0 additions and 395 deletions
@ -1,53 +0,0 @@ |
|||||||
<Components version="1.0"> |
|
||||||
<System.Windows.Forms.UserControl> |
|
||||||
<Name value="XmlUserControl1" /> |
|
||||||
<DockPadding value="" /> |
|
||||||
<ClientSize value="{Width=352, Height=112}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="fontPreviewLabel" /> |
|
||||||
<Text value="AaBbCcXxYyZz" /> |
|
||||||
<TextAlign value="MiddleCenter" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="19" /> |
|
||||||
<Size value="{Width=336, Height=40}" /> |
|
||||||
<Location value="{X=8,Y=64}" /> |
|
||||||
<BackColor value="Color [ControlLightLight]" /> |
|
||||||
<BorderStyle value="FixedSingle" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="fontSizeLabel" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.TextEditor.General.FontSizeLabel}" /> |
|
||||||
<TextAlign value="BottomLeft" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="17" /> |
|
||||||
<Size value="{Width=112, Height=20}" /> |
|
||||||
<Location value="{X=232,Y=8}" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
<System.Windows.Forms.ComboBox> |
|
||||||
<Name value="fontSizeComboBox" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="18" /> |
|
||||||
<Location value="{X=232,Y=32}" /> |
|
||||||
<Size value="{Width=112, Height=21}" /> |
|
||||||
</System.Windows.Forms.ComboBox> |
|
||||||
<System.Windows.Forms.ComboBox> |
|
||||||
<Name value="fontListComboBox" /> |
|
||||||
<DrawMode value="OwnerDrawFixed" /> |
|
||||||
<TabIndex value="16" /> |
|
||||||
<Location value="{X=8,Y=32}" /> |
|
||||||
<Size value="{Width=216, Height=22}" /> |
|
||||||
<DropDownStyle value="DropDownList" /> |
|
||||||
<RightToLeft value="No" /> |
|
||||||
</System.Windows.Forms.ComboBox> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="CreatedObject9" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.TextEditor.General.TextfontLabel}" /> |
|
||||||
<TextAlign value="BottomLeft" /> |
|
||||||
<TabIndex value="15" /> |
|
||||||
<Size value="{Width=208, Height=20}" /> |
|
||||||
<Location value="{X=8,Y=8}" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.UserControl> |
|
||||||
</Components> |
|
@ -1,37 +0,0 @@ |
|||||||
<Components version="1.0"> |
|
||||||
<System.Windows.Forms.UserControl> |
|
||||||
<Name value="OutputWindowOptionsPanel" /> |
|
||||||
<DockPadding value="" /> |
|
||||||
<ClientSize value="{Width=400, Height=248}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.GroupBox> |
|
||||||
<Name value="FontGroupBox" /> |
|
||||||
<TabIndex value="2" /> |
|
||||||
<Location value="{X=8,Y=72}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<Size value="{Width=384, Height=144}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox}" /> |
|
||||||
</System.Windows.Forms.GroupBox> |
|
||||||
<System.Windows.Forms.GroupBox> |
|
||||||
<Name value="formatGroupBox" /> |
|
||||||
<TabIndex value="1" /> |
|
||||||
<Location value="{X=8,Y=8}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<Size value="{Width=384, Height=56}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.OutputPanel.Format}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.CheckBox> |
|
||||||
<Name value="wordWrapCheckBox" /> |
|
||||||
<Location value="{X=8,Y=34}" /> |
|
||||||
<Checked value="True" /> |
|
||||||
<Size value="{Width=368, Height=16}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.OutputPanel.WordWrap}" /> |
|
||||||
<CheckState value="Checked" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
</System.Windows.Forms.CheckBox> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.GroupBox> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.UserControl> |
|
||||||
</Components> |
|
@ -1,251 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Drawing; |
|
||||||
using System.Drawing.Text; |
|
||||||
using System.Threading; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Gui.XmlForms; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Gui |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of FontSelectionPanel.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("XMLForms-based FontSelectionPanel is obsolete, use FontSelector instead!")] |
|
||||||
public class old_FontSelectionPanel : BaseSharpDevelopUserControl |
|
||||||
{ |
|
||||||
public string CurrentFontString { |
|
||||||
get { |
|
||||||
Font font = CurrentFont; |
|
||||||
if (font != null) |
|
||||||
return font.ToString(); |
|
||||||
else |
|
||||||
return null; |
|
||||||
} |
|
||||||
set { |
|
||||||
CurrentFont = old_FontSelectionPanel.ParseFont(value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Font CurrentFont { |
|
||||||
get { |
|
||||||
if (helper == null) |
|
||||||
return null; |
|
||||||
return helper.GetSelectedFont(); |
|
||||||
} |
|
||||||
set { |
|
||||||
if (helper == null) { |
|
||||||
helper = new FontSelectionPanelHelper((ComboBox)ControlDictionary["fontSizeComboBox"], (ComboBox)ControlDictionary["fontListComboBox"], value); |
|
||||||
helper.StartThread(); |
|
||||||
((ComboBox)ControlDictionary["fontListComboBox"]).MeasureItem += helper.MeasureComboBoxItem; |
|
||||||
((ComboBox)ControlDictionary["fontListComboBox"]).DrawItem += helper.ComboBoxDrawItem; |
|
||||||
} else { |
|
||||||
int index = 0; |
|
||||||
for (int i = 0; i < ((ComboBox)ControlDictionary["fontListComboBox"]).Items.Count; ++i) { |
|
||||||
FontSelectionPanelHelper.FontDescriptor descriptor = (FontSelectionPanelHelper.FontDescriptor)((ComboBox)ControlDictionary["fontListComboBox"]).Items[i]; |
|
||||||
if (descriptor.Name == value.Name) { |
|
||||||
index = i; |
|
||||||
} |
|
||||||
} |
|
||||||
((ComboBox)ControlDictionary["fontListComboBox"]).SelectedIndex = index; |
|
||||||
} |
|
||||||
((ComboBox)ControlDictionary["fontSizeComboBox"]).Text = value.Size.ToString(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public old_FontSelectionPanel() |
|
||||||
{ |
|
||||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.SharpDevelop.Resources.old_FontSelectionPanel.xfrm")); |
|
||||||
|
|
||||||
for (int i = 6; i <= 24; ++i) { |
|
||||||
((ComboBox)ControlDictionary["fontSizeComboBox"]).Items.Add(i); |
|
||||||
} |
|
||||||
((ComboBox)ControlDictionary["fontSizeComboBox"]).TextChanged += new EventHandler(UpdateFontPreviewLabel); |
|
||||||
((ComboBox)ControlDictionary["fontSizeComboBox"]).Enabled = false; |
|
||||||
((ComboBox)ControlDictionary["fontListComboBox"]).Enabled = false; |
|
||||||
|
|
||||||
((ComboBox)ControlDictionary["fontListComboBox"]).TextChanged += new EventHandler(UpdateFontPreviewLabel); |
|
||||||
((ComboBox)ControlDictionary["fontListComboBox"]).SelectedIndexChanged += new EventHandler(UpdateFontPreviewLabel); |
|
||||||
} |
|
||||||
|
|
||||||
FontSelectionPanelHelper helper; |
|
||||||
|
|
||||||
public static Font ParseFont(string font) |
|
||||||
{ |
|
||||||
try { |
|
||||||
string[] descr = font.Split(new char[]{',', '='}); |
|
||||||
return new Font(descr[1], Single.Parse(descr[3])); |
|
||||||
} catch (Exception ex) { |
|
||||||
LoggingService.Warn(ex); |
|
||||||
return SD.WinForms.DefaultMonospacedFont; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UpdateFontPreviewLabel(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
helper.UpdateFontPreviewLabel(ControlDictionary["fontPreviewLabel"]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class FontSelectionPanelHelper |
|
||||||
{ |
|
||||||
ComboBox fontSizeComboBox, fontListComboBox; |
|
||||||
Font defaultFont; |
|
||||||
|
|
||||||
public FontSelectionPanelHelper(ComboBox fontSizeComboBox, ComboBox fontListComboBox, Font defaultFont) |
|
||||||
{ |
|
||||||
this.fontSizeComboBox = fontSizeComboBox; |
|
||||||
this.fontListComboBox = fontListComboBox; |
|
||||||
this.defaultFont = defaultFont; |
|
||||||
boldComboBoxFont = new Font(fontListComboBox.Font, FontStyle.Bold); |
|
||||||
} |
|
||||||
|
|
||||||
public void StartThread() |
|
||||||
{ |
|
||||||
Thread thread = new Thread(DetectMonospacedThread); |
|
||||||
thread.IsBackground = true; |
|
||||||
thread.Start(); |
|
||||||
} |
|
||||||
|
|
||||||
void DetectMonospacedThread() |
|
||||||
{ |
|
||||||
Thread.Sleep(0); // first allow UI thread to do some work
|
|
||||||
DebugTimer.Start(); |
|
||||||
InstalledFontCollection installedFontCollection = new InstalledFontCollection(); |
|
||||||
Font currentFont = defaultFont; |
|
||||||
List<FontDescriptor> fonts = new List<FontDescriptor>(); |
|
||||||
|
|
||||||
int index = 0; |
|
||||||
foreach (FontFamily fontFamily in installedFontCollection.Families) { |
|
||||||
if (fontFamily.IsStyleAvailable(FontStyle.Regular) && fontFamily.IsStyleAvailable(FontStyle.Bold) && fontFamily.IsStyleAvailable(FontStyle.Italic)) { |
|
||||||
if (fontFamily.Name == currentFont.Name) { |
|
||||||
index = fonts.Count; |
|
||||||
} |
|
||||||
fonts.Add(new FontDescriptor(fontFamily)); |
|
||||||
} |
|
||||||
} |
|
||||||
DebugTimer.Stop("Getting installed fonts"); |
|
||||||
SD.MainThread.InvokeAsync(delegate { |
|
||||||
fontListComboBox.Items.AddRange(fonts.ToArray()); |
|
||||||
fontSizeComboBox.Enabled = true; |
|
||||||
fontListComboBox.Enabled = true; |
|
||||||
fontListComboBox.SelectedIndex = index; |
|
||||||
fontSizeComboBox.Text = currentFont.Size.ToString(); |
|
||||||
}).FireAndForget(); |
|
||||||
DebugTimer.Start(); |
|
||||||
using (Bitmap newBitmap = new Bitmap(1, 1)) { |
|
||||||
using (Graphics g = Graphics.FromImage(newBitmap)) { |
|
||||||
foreach (FontDescriptor fd in fonts) { |
|
||||||
fd.DetectMonospaced(g); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
DebugTimer.Stop("Detect Monospaced"); |
|
||||||
fontListComboBox.Invalidate(); |
|
||||||
} |
|
||||||
|
|
||||||
internal void MeasureComboBoxItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) |
|
||||||
{ |
|
||||||
ComboBox comboBox = (ComboBox)sender; |
|
||||||
if (e.Index >= 0) { |
|
||||||
FontDescriptor fontDescriptor = (FontDescriptor)comboBox.Items[e.Index]; |
|
||||||
SizeF size = e.Graphics.MeasureString(fontDescriptor.Name, comboBox.Font); |
|
||||||
e.ItemWidth = (int)size.Width; |
|
||||||
e.ItemHeight = (int)comboBox.Font.Height; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static StringFormat drawStringFormat = new StringFormat(StringFormatFlags.NoWrap); |
|
||||||
Font boldComboBoxFont; |
|
||||||
|
|
||||||
internal void ComboBoxDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) |
|
||||||
{ |
|
||||||
ComboBox comboBox = (ComboBox)sender; |
|
||||||
e.DrawBackground(); |
|
||||||
|
|
||||||
Rectangle drawingRect = new Rectangle(e.Bounds.X, |
|
||||||
e.Bounds.Y, |
|
||||||
e.Bounds.Width, |
|
||||||
e.Bounds.Height); |
|
||||||
|
|
||||||
Brush drawItemBrush = SystemBrushes.WindowText; |
|
||||||
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { |
|
||||||
drawItemBrush = SystemBrushes.HighlightText; |
|
||||||
} |
|
||||||
|
|
||||||
if (comboBox.Enabled == false) { |
|
||||||
e.Graphics.DrawString(ResourceService.GetString("ICSharpCode.SharpDevelop.Gui.Pads.ClassScout.LoadingNode"), |
|
||||||
comboBox.Font, |
|
||||||
drawItemBrush, |
|
||||||
drawingRect, |
|
||||||
drawStringFormat); |
|
||||||
} else if (e.Index >= 0) { |
|
||||||
FontDescriptor fontDescriptor = (FontDescriptor)comboBox.Items[e.Index]; |
|
||||||
e.Graphics.DrawString(fontDescriptor.Name, |
|
||||||
fontDescriptor.IsMonospaced ? boldComboBoxFont : comboBox.Font, |
|
||||||
drawItemBrush, |
|
||||||
drawingRect, |
|
||||||
drawStringFormat); |
|
||||||
} |
|
||||||
e.DrawFocusRectangle(); |
|
||||||
} |
|
||||||
|
|
||||||
public Font GetSelectedFont() |
|
||||||
{ |
|
||||||
if (!fontListComboBox.Enabled) |
|
||||||
return null; |
|
||||||
float fontSize = 10f; |
|
||||||
try { |
|
||||||
fontSize = Math.Max(6, Single.Parse(fontSizeComboBox.Text)); |
|
||||||
} catch (Exception) {} |
|
||||||
|
|
||||||
FontDescriptor fontDescriptor = (FontDescriptor)fontListComboBox.Items[fontListComboBox.SelectedIndex]; |
|
||||||
|
|
||||||
return new Font(fontDescriptor.Name, |
|
||||||
fontSize); |
|
||||||
} |
|
||||||
|
|
||||||
public void UpdateFontPreviewLabel(Control fontPreviewLabel) |
|
||||||
{ |
|
||||||
Font currentFont = GetSelectedFont(); |
|
||||||
fontPreviewLabel.Visible = currentFont != null; |
|
||||||
if (currentFont != null) { |
|
||||||
fontPreviewLabel.Font = currentFont; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class FontDescriptor |
|
||||||
{ |
|
||||||
FontFamily fontFamily; |
|
||||||
internal string Name; |
|
||||||
internal bool IsMonospaced; |
|
||||||
|
|
||||||
public FontDescriptor(FontFamily fontFamily) |
|
||||||
{ |
|
||||||
this.fontFamily = fontFamily; |
|
||||||
this.Name = fontFamily.Name; |
|
||||||
} |
|
||||||
|
|
||||||
internal void DetectMonospaced(Graphics g) |
|
||||||
{ |
|
||||||
this.IsMonospaced = DetectMonospaced(g, fontFamily); |
|
||||||
} |
|
||||||
|
|
||||||
static bool DetectMonospaced(Graphics g, FontFamily fontFamily) |
|
||||||
{ |
|
||||||
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 = TextRenderer.MeasureText("i.", f).Width; |
|
||||||
int w2 = TextRenderer.MeasureText("mw", f).Width; |
|
||||||
return w1 == w2; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,46 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System.Windows.Forms; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// The Output Window options panel.
|
|
||||||
/// </summary>
|
|
||||||
public class old_OutputWindowOptionsPanel : XmlFormsOptionPanel |
|
||||||
{ |
|
||||||
public static readonly string OutputWindowsProperty = "SharpDevelop.UI.OutputWindowOptions"; |
|
||||||
old_FontSelectionPanel fontSelectionPanel; |
|
||||||
|
|
||||||
public old_OutputWindowOptionsPanel() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public override void LoadPanelContents() |
|
||||||
{ |
|
||||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.SharpDevelop.Resources.old_OutputWindowOptionsPanel.xfrm")); |
|
||||||
|
|
||||||
Properties properties = PropertyService.NestedProperties(OutputWindowsProperty); |
|
||||||
fontSelectionPanel = new old_FontSelectionPanel(); |
|
||||||
fontSelectionPanel.Dock = DockStyle.Fill; |
|
||||||
ControlDictionary["FontGroupBox"].Controls.Add(fontSelectionPanel); |
|
||||||
((CheckBox)ControlDictionary["wordWrapCheckBox"]).Checked = properties.Get("WordWrap", true); |
|
||||||
|
|
||||||
fontSelectionPanel.CurrentFontString = properties.Get("DefaultFont", SD.WinForms.DefaultMonospacedFont.ToString()).ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool StorePanelContents() |
|
||||||
{ |
|
||||||
Properties properties = PropertyService.NestedProperties(OutputWindowsProperty); |
|
||||||
properties.Set("WordWrap", ((CheckBox)ControlDictionary["wordWrapCheckBox"]).Checked); |
|
||||||
string currentFontString = fontSelectionPanel.CurrentFontString; |
|
||||||
if (currentFontString != null) |
|
||||||
properties.Set("DefaultFont", currentFontString); |
|
||||||
|
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue