public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { //IWindowsFormsEditorService iws = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); object returnvalue = value; if (!(context.Instance is IConstant)) { return(base.EditValue(context, provider, value)); } if (IsFile(context.Instance as IConstant)) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = (string)returnvalue; if (ofd.ShowDialog() == DialogResult.OK) { returnvalue = ofd.FileName; } ofd.Dispose(); return(returnvalue); } if (IsFileGroup(context.Instance as IConstant)) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; //if (value!=null) if ((string)value!=string.Empty) ofd.FileNames = STR.ToArray(value as string,","); if (ofd.ShowDialog() == DialogResult.OK) { returnvalue = StringUtil.FromStrArray("\"{0}\",", ofd.FileNames).TrimEnd(','); } ofd.Dispose(); return(returnvalue); } if (IsDir(context.Instance as IConstant)) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc == null) { return(value); } // Displays a drop-down control. Control inputControl = new PathEditorControl((string)value, edSvc); edSvc.DropDownControl(inputControl); return(((PathEditorControl)inputControl).inputTextBox.Text); // if (returnvalue==null) System.Windows.Forms.MessageBox.Show("shit","",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); // FolderBrowserDialog fbd = new FolderBrowserDialog(); // if (value!=null) if (value!=string.Empty) fbd.SelectedPath = value as string; // fbd.ShowDialog(); // returnvalue = fbd.SelectedPath; // fbd.Dispose(); // return returnvalue; } return(base.EditValue(context, provider, value)); // IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); // if( edSvc == null ) // { // Form f1 = new Form(); // f1.StartPosition = FormStartPosition.CenterParent; // edSvc.ShowDialog(f1); // } }
object DefaultValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { object returnvalue = value; if (context.Instance is IConstant) { if (IsFile(context.Instance as IConstant)) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = (string)returnvalue; if (ofd.ShowDialog() == DialogResult.OK) { returnvalue = ofd.FileName; } ofd.Dispose(); return(returnvalue); } if (IsFileGroup(context.Instance as IConstant)) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { returnvalue = StringUtil.FromStrArray("\"{0}\",", ofd.FileNames).TrimEnd(','); } ofd.Dispose(); return(returnvalue); } if (IsDir(context.Instance as IConstant)) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc == null) { return(value); } Control inputControl = new PathEditorControl((string)value, edSvc); edSvc.DropDownControl(inputControl); return(((PathEditorControl)inputControl).inputTextBox.Text); } } else { if (IsDirObj(context.Instance)) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc == null) { return(value); } Control inputControl = new PathEditorControl((string)value, edSvc); edSvc.DropDownControl(inputControl); return(((PathEditorControl)inputControl).inputTextBox.Text); } } return(DefaultValue(context, provider, value)); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc == null) { return(value); } // Displays a drop-down control. Control inputControl = new PathEditorControl((string)value, edSvc); edSvc.DropDownControl(inputControl); return(((PathEditorControl)inputControl).inputTextBox.Text); // return base.EditValue(context, provider, value); }