コード例 #1
0
        private async void _stripReadConfig_Click(Object sender, EventArgs e)
        {
            this._dialogOpenFile.Title = Resources.SchemaExportForm_ReadConfig;
            if (this._dialogOpenFile.ShowDialog() == DialogResult.OK)
            {
                String fileName = this._dialogOpenFile.FileName;
                try
                {
                    var config = ConfigManager.LoadConfig <GlobalConfig>(fileName);

                    this._ctlExcelExportConfig.ImportConfigInfo(config.ExcelExportConfigString);
                    await this.RenderingGlobalConfig(config);

                    //都完成后保存存储信息
                    this.CurrentGlobalPath = fileName;
                    fileName = Path.GetFileName(this.CurrentGlobalPath);

                    this._stripItemSaveCurrentConfig.Text = $"保存配置 {fileName} (&S)";
                    this._stripItemAsConfig.Text          = $"配置 {fileName} 另存为(&A)";

                    this.CurrentGlobalConfig = config;
                }
                catch (Exception exc)
                {
                    MessageBox.Show("无效的配置文件!" + exc.Message);
                }
            }
        }
コード例 #2
0
 private async Task LoadConnectionHistoryAsync()
 {
     if (!File.Exists(ConnectionHistoryConfig.FilePath))
     {
         this.ConnectionHistoryConfig = new ConnectionHistoryConfig();
         return;
     }
     this.ConnectionHistoryConfig = await Task.FromResult(
         ConfigManager.LoadConfig <ConnectionHistoryConfig>(
             ConnectionHistoryConfig.FilePath));
 }