コード例 #1
0
        public static string SelectModuleExport(IEnumerable <Type> modelTypes, string title = "Select a file to export to.", string filePath = null)
        {
            using (var dialog = new SaveFileDialog())
            {
                dialog.AutoUpgradeEnabled = true;
                dialog.CheckPathExists    = true;
                dialog.CheckPathExists    = true;
                dialog.Filter             = ModuleFilterGenerator.GenerateFilter(modelTypes, FormatModuleFlags.Export);
                dialog.Title         = title;
                dialog.FileName      = filePath;
                dialog.ValidateNames = true;
                dialog.AddExtension  = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    return(dialog.FileName);
                }
            }

            return(null);
        }
コード例 #2
0
        public static string SelectModuleImport <T>(string title = "Select a file to import.", string filePath = null)
        {
            using (var dialog = new OpenFileDialog())
            {
                dialog.AutoUpgradeEnabled = true;
                dialog.CheckPathExists    = true;
                dialog.CheckPathExists    = true;
                dialog.Filter             = ModuleFilterGenerator.GenerateFilter(typeof(T));
                dialog.Title         = title;
                dialog.FileName      = filePath;
                dialog.ValidateNames = true;
                dialog.AddExtension  = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    return(dialog.FileName);
                }
            }

            return(null);
        }