Author: cwittich Date: Wed Aug 20 08:45:59 2008 New Revision: 35475
URL: http://svn.reactos.org/svn/reactos?rev=35475&view=rev Log: add some more settings to the options dialog
Modified: trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.Designer.cs trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.cs trunk/tools/reactosdbg/RosDBG/Settings.cs
Modified: trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.Designer.cs URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/SerialTarge... ============================================================================== --- trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.Designer.cs [iso-8859-1] (original) +++ trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.Designer.cs [iso-8859-1] Wed Aug 20 08:45:59 2008 @@ -38,6 +38,7 @@ // // cPort // + this.cPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cPort.FormattingEnabled = true; this.cPort.Location = new System.Drawing.Point(77, 9); this.cPort.Name = "cPort"; @@ -46,6 +47,7 @@ // // cBaud // + this.cBaud.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cBaud.FormattingEnabled = true; this.cBaud.Items.AddRange(new object[] { "9600",
Modified: trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.cs URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/SerialTarge... ============================================================================== --- trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.cs [iso-8859-1] (original) +++ trunk/tools/reactosdbg/RosDBG/SerialTargetSelect.cs [iso-8859-1] Wed Aug 20 08:45:59 2008 @@ -31,8 +31,21 @@ { cPort.Items.Add(s); } - cPort.SelectedIndex = 0; - cBaud.SelectedIndex = 0; + SelectComboItem(cPort, Settings.ComPort); + SelectComboItem(cBaud, Settings.Baudrate); + } + + private void SelectComboItem(ComboBox obj, string text) + { + obj.SelectedIndex = 0; + foreach (object item in obj.Items) + { + if (item.ToString() == text) + { + obj.SelectedItem = item; + break; + } + } }
private void bOK_Click(object sender, EventArgs e)
Modified: trunk/tools/reactosdbg/RosDBG/Settings.cs URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/Settings.cs... ============================================================================== --- trunk/tools/reactosdbg/RosDBG/Settings.cs [iso-8859-1] (original) +++ trunk/tools/reactosdbg/RosDBG/Settings.cs [iso-8859-1] Wed Aug 20 08:45:59 2008 @@ -8,6 +8,7 @@ using System.Configuration; using System.Windows.Forms; using System.Drawing.Design; +using System.IO.Ports;
namespace RosDBG { @@ -15,6 +16,29 @@ { public class SettingsPropertyValues : ApplicationSettingsBase { + private SerialConnSettings _serialconnsettings; + + /* Hack to work around a crash (bug in .net?) + * using a TypeConverter in a class which is derived from + * ApplicationSettingsBase results in a crash + */ + [UserScopedSetting, DefaultSettingValue("COM1")] + [Browsable(false)] + public string Port + { + get { return this["Port"].ToString(); } + set { this["Port"] = value; } + } + + [UserScopedSetting, DefaultSettingValue("115200")] + [Browsable(false)] + public string Baudrate + { + get { return this["Baudrate"].ToString(); } + set { this["Baudrate"] = value; } + } + /* end of hack */ + [CategoryAttribute("Directories"), DescriptionAttribute("Directory settings")] [UserScopedSetting, DefaultSettingValue("."), Editor(typeof(DirectoryEditor), typeof(UITypeEditor))] public string SourceDirectory @@ -38,6 +62,13 @@ get { return this["Pipe"].ToString(); } set { this["Pipe"] = value; } } + + [CategoryAttribute("Connection"), DescriptionAttribute("Connection settings")] + public SerialConnSettings Serial + { + get { return new SerialConnSettings(Port, Baudrate, this); } + set { _serialconnsettings = value; } + }
public SettingsPropertyValues() { @@ -45,11 +76,66 @@ } }
+ #region TypeConverter + public class ComPortConverter : StringConverter + { + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + + public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) + { + return true; + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + { + return new StandardValuesCollection((string[]) SerialPort.GetPortNames()); + } + } + #endregion + + [TypeConverterAttribute(typeof(ExpandableObjectConverter))] + public class SerialConnSettings + { + private string _Port; + private string _Baudrate; + private SettingsPropertyValues _Parent; + + public SerialConnSettings(string Port, string Baud, SettingsPropertyValues parent) + { + _Port = Port; + _Baudrate = Baud; + _Parent = parent; + } + + public override string ToString() + { + return this.Port + ";" + this.Baudrate; + } + + [TypeConverter(typeof(ComPortConverter))] + public string Port + { + get { return _Port; } + set { _Port = value; _Parent.Port = _Port; } + } + + public string Baudrate + { + get { return _Baudrate; } + set { _Baudrate = value; _Parent.Baudrate = _Baudrate; } + } + } + static SettingsPropertyValues mProperties = new SettingsPropertyValues();
public static string SourceDirectory { get { return mProperties.SourceDirectory; } } public static string OutputDirectory { get { return mProperties.OutputDirectory; } } - public static string Pipe { get { return mProperties.Pipe; } } + public static string Pipe { get { return mProperties.Pipe; } } + public static string ComPort { get { return mProperties.Port; } } + public static string Baudrate { get { return mProperties.Baudrate; } }
Settings() {