View plaincopy to clipboardprint?
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using System. IO;
Using System. Windows. Forms. Design;
Using System. Drawing. Design;
Namespace Quick. Dialog
{
Public partial class OptionsDlg: Form
{
OptionsInfo m_optInfo = new OptionsInfo ();
Public OptionsDlg ()
{
InitializeComponent ();
InitOptInfo ();
}
Private void InitOptInfo ()
{
LogicCommon comon = new LogicCommon ();
M_optInfo.ReportPath = comon. GetQualityKeys ("ReportPath ");
M_optInfo.ClientLocat = comon. GetQualityKeys ("ClientLocat ");
M_optInfo.InitDataList ();
}
Private void OptionsDlg_Load (object sender, EventArgs e)
{
PropertyGrid_optProp.SelectedObject = m_optInfo;
}
Private void propertyGrid_optProp_PropertyValueChanged (object s, PropertyValueChangedEventArgs e)
{
String strKey = e. ChangedItem. Label;
Object objValue = e. ChangedItem. Value;
M_optInfo.m_optDataList [strKey] = objValue. ToString ();
}
Private void button_ OK _Click (object sender, EventArgs e)
{
String strReportPath = m_optInfo.m_optDataList ["ReportPath"];
LogicCommon common = new LogicCommon ();
If (strReportPath = "")
{
MessageBox. Show ("the report file path cannot be blank! "," Error ", MessageBoxButtons. OK, MessageBoxIcon. Exclamation );
Return;
}
Try
{
Directory. CreateDirectory (strReportPath );
Common. SetQualityKeys ("ReportPath", strReportPath );
}
Catch (System. Exception err)
{
MessageBox. Show (err. Message, "invalid path ");
Return;
}
String strClientLocat = m_optInfo.m_optDataList ["ClientLocat"];
If (strClientLocat = "")
{
MessageBox. Show ("the client path cannot be blank! "," Error ", MessageBoxButtons. OK, MessageBoxIcon. Exclamation );
Return;
}
Common. SetQualityKeys ("ClientLocat", strClientLocat );
This. DialogResult = DialogResult. OK;
}
Private void button_cancel_Click (object sender, EventArgs e)
{
}
}
Public class PathEditor: UITypeEditor
{
Public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
{
If (context! = Null & context. Instance! = Null)
{
Return UITypeEditorEditStyle. Modal;
}
Return base. GetEditStyle (context );
}
Public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorService = null;
If (context! = Null & context. Instance! = Null & provider! = Null)
{
EditorService = (IWindowsFormsEditorService) provider. GetService (typeof (IWindowsFormsEditorService ));
If (editorService! = Null)
{
FolderBrowserDialog dirDlg = new FolderBrowserDialog ();