Hi,
Is there any example to do the following without getting into creating custom windows forms:
I need to double click on the component,
Then similarly to Rhino Windows File Open command a window is opened to select directory.
Once the Open button is selected the directory is copied as a string inside component.
nathanletwory
(Nathan 'jesterKing' Letwory)
April 8, 2018, 2:22pm
2
Here us how I do it through a component menu item. You probably can figure out from there how to do that from a double-click:
menu,
Utils.ColorSpaceToStringR(it),
((_, __) =>
{
u.ColorSpace = it; u.ExpireSolution(true);
}),
true, u.ColorSpace == it);
}
protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
{
Menu_AppendItem(menu, "Select Image File...", (_, __) =>
{
var fdi = new OpenFileDialog
{
Filter = "Image Files(*.bmp;*.jpg;*.png)|*.bmp;*.jpg;*.png|All files (*.*)|*.*"
};
var res = fdi.ShowDialog();
if (res == DialogResult.OK)
{
ImageFile = fdi.FileName;
ExpireSolution(true);
Thanks it works perfectly. Just one question incase of selecting not a file but folder.
Should I use something else instead of OpenFileDialog?
protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) {
Menu_AppendItem(menu, "Select Directory...", (_, __) => {
var fdi = new OpenFileDialog { };
var res = fdi.ShowDialog();
if (res == DialogResult.OK) {
directory = fdi.InitialDirectory;
Rhino.RhinoApp.WriteLine(fdi.FileName);
ExpireSolution(true);
}
});
}
Found This seems to work, thank you:)
protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) {
Menu_AppendItem(menu, "Select Directory...", (_, __) => {
var folderDialog = new FolderBrowserDialog();
var run = folderDialog.ShowDialog();
if (run == DialogResult.OK) {
directory = folderDialog.SelectedPath;
Rhino.RhinoApp.WriteLine(directory);
ExpireSolution(true);
}
});
}