add some more settings to the options dialog

svn path=/trunk/tools/reactosdbg/; revision=793
This commit is contained in:
Christoph von Wittich 2008-08-20 13:45:59 +00:00
parent d3c610fc17
commit 21d81c6691
3 changed files with 104 additions and 3 deletions

View File

@ -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",

View File

@ -31,8 +31,21 @@ namespace RosDBG
{
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)

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Configuration;
using System.Windows.Forms;
using System.Drawing.Design;
using System.IO.Ports;
namespace RosDBG
{
@ -15,6 +16,29 @@ namespace RosDBG
{
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 @@ namespace RosDBG
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 @@ namespace RosDBG
}
}
#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()
{