static void inputBox_Closing(object sender, DialogCancelEventArgs e)
        {
            ImageBrowserWindow <BrowseType> inputBox = (ImageBrowserWindow <BrowseType>)sender;
            String errorPrompt = null;

            if (inputBox.Accepted && !inputBox.SendResult(inputBox.SelectedValue, ref errorPrompt))
            {
                MessageBox.show(errorPrompt, "Error", MessageBoxStyle.IconError | MessageBoxStyle.Ok);
                e.Cancel = true;
            }
        }
        public static void GetInput(Browser browser, bool modal, SendResult <BrowseType> sendResult, ResourceProvider resourceProvider, Action <String, Action <String> > importCallback = null)
        {
            ImageBrowserWindow <BrowseType> inputBox = new ImageBrowserWindow <BrowseType>(browser.Prompt, resourceProvider);

            inputBox.setBrowser(browser);
            if (importCallback != null)
            {
                inputBox.importButton.MouseButtonClick += (source, e) =>
                {
                    FileOpenDialog openDialog = new FileOpenDialog(MainWindow.Instance, "Choose Image", "Images|*.jpg;*.jpeg;*.png");
                    openDialog.showModal((result, paths) =>
                    {
                        if (result == NativeDialogResult.OK)
                        {
                            String path      = paths.First();
                            String extension = Path.GetExtension(path);
                            if (extension.Equals(".png", StringComparison.InvariantCultureIgnoreCase) || extension.Equals(".jpg", StringComparison.InvariantCultureIgnoreCase) || extension.Equals(".jpeg", StringComparison.InvariantCultureIgnoreCase))
                            {
                                importCallback(path, previewPath =>
                                {
                                    ThreadManager.invoke(new Action(() =>
                                    {
                                        BrowserNode node = new BrowserNode("", previewPath);
                                        inputBox.addNodes(node, node);
                                    }));
                                });
                            }
                            else
                            {
                                MessageBox.show(String.Format("Cannot open a file with extension '{0}'. Please choose a file that is a Png Image (.png) or a Jpeg (.jpg or .jpeg).", extension), "Can't Load Image", MessageBoxStyle.IconWarning | MessageBoxStyle.Ok);
                            }
                        }
                    });
                };
            }
            else
            {
                inputBox.importButton.Visible = false;
            }
            inputBox.SendResult = sendResult;
            inputBox.Closing   += new EventHandler <DialogCancelEventArgs>(inputBox_Closing);
            inputBox.Closed    += new EventHandler(inputBox_Closed);
            inputBox.center();
            inputBox.open(modal);
        }
        private static void inputBox_Closed(object sender, EventArgs e)
        {
            ImageBrowserWindow <BrowseType> inputBox = (ImageBrowserWindow <BrowseType>)sender;

            inputBox.Dispose();
        }