Various UI elements especially those Ribbon ones have already been demonstrated and discussed in many early posts. There are many miscellaneous UI elements too such as Context Menu and Browser (BrowserPane) we also talked about before. They do not really belong to the Ribbon system.
In this post, let’s have a look at the Inventor Open FileDialog. Inventor API provides the single FileDialog to address both Open and Save situations. Here is the C# code to create an Inventor FileDialog for Open along with some testing code.
public static string[] TestCreateInventorFileDialogOpen(Inventor.Application app)
{
Inventor.FileDialog fileDia;
app.CreateFileDialog(out fileDia);
fileDia.DialogTitle = "Inventor Open File Dialog";
fileDia.InitialDirectory = @"C:\Temp\Inventor Files";
fileDia.CancelError = false;
fileDia.InsertMode = true;
fileDia.MultiSelectEnabled = true;
fileDia.OptionsEnabled = true;
fileDia.SuppressResolutionWarnings = false;
fileDia.SetHelpContext("HelpFileName.chm", 101);
fileDia.SetHelpTopic("HelpFileName.chm", "HelpTopic");
fileDia.Filter = "Inventor Drawing Files (*.idw)|*.idw|Inventor Presentation Files (*.ipn)|*.ipn";
fileDia.FilterIndex = 1;
fileDia.ShowOpen();
return new string[] { fileDia.FileName };
}
...
string[] files1 = UIMiscs.TestCreateInventorFileDialogOpen(AddinGlobal.InventorApp);
string filenames1 = string.Empty;
foreach (string file in files1)
{
filenames1 += file + System.Environment.NewLine;
}
MessageBox.Show(filenames1, "Files selected by Inventor Open FileDialog");
...
Here is how it looks like in Inventor if a single IDW file is selected.
As can be seen, the Inventor FileDialog has a control at the left side showing the thumbnail image for the selected file if single and good. We can also select multiple Inventor Drawings (.IDW files) as specified by the MultiSelectEnabled as true in the code.
The image preview is not available anymore this time and it looks natural. Here is the result we got in this test case.
As can be seen, the | character serves as the delimiter for the selected multiple file paths. It sounds not so bad as the | is not supposed to be used in file names or directories. We need to take a bit effort though to parse each path out ourselves.
The leading edge Inventor .NET Addin Wizard (InventorNetAddinWizard) can be found and downloaded from the A Wizard for Inventor .NET Addin page.
Recent Comments