/// <summary>
 /// Show a File dialog when button is clicked.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <param name="filterType">Type of the filter.</param>
 /// <param name="dialogType">Type of the dialog.</param>
 /// <returns></returns>
 public void File_Dialog_Button(Button button, enDialog_FileIOType filterType = enDialog_FileIOType.All,
                                enDialog_FileIO dialogType = enDialog_FileIO.FileOpen)
 {
     button.Click -= File_Dialog_ButtonClick;
     button.Click += File_Dialog_ButtonClick;
     button.Tag    = new stateDialog(dialogType, filterType);
 }
        public bool File_Dialog(string path, out string selectedFile, enDialog_FileIO dialogType = enDialog_FileIO.FileOpen,
                                enDialog_FileIOType filterType = enDialog_FileIOType.All, string title = "", string filter = "")
        {
            selectedFile = path;
            FileDialog dialog = null;

            if (dialogType == enDialog_FileIO.FileOpen)
            {
                dialog = new OpenFileDialog();
                if (title == "")
                {
                    title = "Open File";
                }
            }
            else
            {
                dialog = new SaveFileDialog();
                if (title == "")
                {
                    title = "Save File";
                }
            }

            File_Dialog_Setup(dialog, title, path, filterType, filter);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                selectedFile = dialog.FileName;
                return(true);
            }
            return(false);
        }
 /// <summary>
 /// Show a File dialog when button is clicked.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <param name="selectedFile">The selected file.</param>
 /// <param name="filterType">Type of the filter.</param>
 /// <param name="dialogType">Type of the dialog.</param>
 /// <param name="updateButton">if set to <c>true</c> [update button].</param>
 /// <returns></returns>
 public bool File_Dialog_Button_Click(Button button, out string selectedFile, enDialog_FileIOType filterType = enDialog_FileIOType.All,
                                      enDialog_FileIO dialogType = enDialog_FileIO.FileOpen, bool updateButton = true)
 {
     if (File_Dialog(button.Text, out selectedFile, dialogType, filterType))
     {
         if (updateButton)
         {
             button.Text = selectedFile;
         }
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="stateDialog"/> class.
 /// </summary>
 /// <param name="dialogType">Type of the dialog.</param>
 /// <param name="filterType">Type of the filter.</param>
 public stateDialog(enDialog_FileIO dialogType = enDialog_FileIO.FileOpen, enDialog_FileIOType filterType = enDialog_FileIOType.All)
 {
     DialogType = dialogType;
     FilterType = filterType;
 }
 /// <summary>
 /// Show a File dialog when button is clicked.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <param name="selectedFile">The selected file.</param>
 /// <param name="filterType">Type of the filter.</param>
 /// <param name="dialogType">Type of the dialog.</param>
 /// <param name="updateButton">if set to <c>true</c> [update button].</param>
 /// <returns></returns>
 public static bool zFile_Dialog_Button_Click(this Button button, out string selectedFile,
                                              enDialog_FileIOType filterType = enDialog_FileIOType.All,
                                              enDialog_FileIO dialogType     = enDialog_FileIO.FileOpen, bool updateButton = true)
 {
     return(Lamedal_WinForms.Instance.libUI.WinForms.Dialog_Simple.File_Dialog_Button_Click(button, out selectedFile, filterType, dialogType, updateButton));
 }
 /// <summary>
 /// Show a File dialog when button is clicked.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <param name="filterType">Type of the filter.</param>
 /// <param name="dialogType">Type of the dialog.</param>
 /// <returns></returns>
 public static void zFile_Dialog_Button(this Button button, enDialog_FileIOType filterType = enDialog_FileIOType.All,
                                        enDialog_FileIO dialogType = enDialog_FileIO.FileOpen)
 {
     Lamedal_WinForms.Instance.libUI.WinForms.Dialog_Simple.File_Dialog_Button(button, filterType, dialogType);
 }
 /// <summary>
 /// Show File dialog.
 /// </summary>
 /// <param name="selectedFile">The selected file.</param>
 /// <param name="dialogType">Type of the dialog.</param>
 /// <param name="filterType">Type of the filter.</param>
 /// <param name="title">The title.</param>
 /// <param name="filter">The filter.</param>
 /// <returns></returns>
 public bool File_Dialog(out string selectedFile,
                         enDialog_FileIO dialogType     = enDialog_FileIO.FileOpen,
                         enDialog_FileIOType filterType = enDialog_FileIOType.All, string title = "", string filter = "")
 {
     return(Lamedal_WinForms.Instance.libUI.WinForms.Dialog_Simple.File_Dialog(_path, out selectedFile, dialogType, filterType, title, filter));
 }