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("報告文件路徑不能為空!", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
try
{
Directory.CreateDirectory(strReportPath);
common.SetQualityKeys("ReportPath", strReportPath);
}
catch (System.Exception err)
{
MessageBox.Show(err.Message, "無效路徑");
return;
}
string strClientLocat = m_optInfo.m_optDataList["ClientLocat"];
if (strClientLocat == "")
{
MessageBox.Show("客戶端路徑不能為空!", "錯誤", 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();