diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 52fd591e9b..467d66f1f5 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -643,14 +643,8 @@ - - UserControl - - - UserControl - @@ -733,10 +727,8 @@ - - diff --git a/src/Main/Base/Project/Resources/old_FontSelectionPanel.xfrm b/src/Main/Base/Project/Resources/old_FontSelectionPanel.xfrm deleted file mode 100644 index d31418b44d..0000000000 --- a/src/Main/Base/Project/Resources/old_FontSelectionPanel.xfrm +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Main/Base/Project/Resources/old_OutputWindowOptionsPanel.xfrm b/src/Main/Base/Project/Resources/old_OutputWindowOptionsPanel.xfrm deleted file mode 100644 index 0f70c2a92e..0000000000 --- a/src/Main/Base/Project/Resources/old_OutputWindowOptionsPanel.xfrm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Main/Base/Project/Src/Gui/Components/old_FontSelectionPanel.cs b/src/Main/Base/Project/Src/Gui/Components/old_FontSelectionPanel.cs deleted file mode 100644 index b48934598a..0000000000 --- a/src/Main/Base/Project/Src/Gui/Components/old_FontSelectionPanel.cs +++ /dev/null @@ -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 -{ - /// - /// Description of FontSelectionPanel. - /// - [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 fonts = new List(); - - 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; - } - } - } - } -} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/old_OutputWindowOptionsPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/old_OutputWindowOptionsPanel.cs deleted file mode 100644 index 047f4898e8..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/old_OutputWindowOptionsPanel.cs +++ /dev/null @@ -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 -{ - /// - /// The Output Window options panel. - /// - 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; - } - } -}