void ShowErrorLoadDictionary(KryptonTaskDialog dialog, string dir) { if (!dialog.CheckboxState) { dialog.Content = string.Format(Strings.DictNotFound, dir); dialog.ShowDialog(); } }
public static DialogResult ShowKryptonMessageBox(string title, string mainIntrustion, string content, TaskDialogButtons commonButton, MessageBoxIcon icon, IWin32Window owner = null) { KryptonTaskDialog kUserDialog = new KryptonTaskDialog(); kUserDialog.WindowTitle = title; kUserDialog.MainInstruction = mainIntrustion; kUserDialog.Content = content; kUserDialog.CommonButtons = commonButton; kUserDialog.Icon = icon; return(kUserDialog.ShowDialog(owner)); }
public Dictionaries(IEnumerable <string> dictionaryFolders) { dictFolders = dictionaryFolders; dicts = new List <SpellDictionary>(); engine = new SpellEngine(); KryptonTaskDialog dialog = new KryptonTaskDialog(); dialog.WindowTitle = Strings.ErrorLoadDict; dialog.CheckboxText = Strings.IgnoreError; dialog.CheckboxState = false; dialog.Icon = MessageBoxIcon.Error; foreach (string folder in dictFolders) { if (!Directory.Exists(folder)) { continue; } string[] dictSubFolders = Directory.GetDirectories(folder); if (dictSubFolders.Length == 0) { ShowErrorLoadDictionary(dialog, folder); } else { foreach (string subFolder in dictSubFolders) { try { LoadDictionary(subFolder); CultureInfo[] cultureinfo = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures); foreach (CultureInfo info in cultureinfo) { foreach (SpellDictionary dict in dicts) { if (dict.Locale.ToUpperInvariant() == info.Name.ToUpperInvariant()) { dict.UpdateLocaleName(info.DisplayName); break; } } } } catch (FileNotFoundException) { ShowErrorLoadDictionary(dialog, subFolder); } } } } }
private void MenuItemRestoreClick(object sender, EventArgs e) { if (!this.database.IsEmpty) { KryptonTaskDialog dlg = new KryptonTaskDialog(); dlg.WindowTitle = Strings.Import; dlg.MainInstruction = Strings.ImportData; dlg.Content = Strings.DataClear; dlg.Icon = MessageBoxIcon.Question; dlg.CommonButtons = TaskDialogButtons.OK | TaskDialogButtons.Cancel; dlg.RadioButtons.AddRange(new KryptonTaskDialogCommand[] { this.commandClearData, this.commandCreateNew }); if (dlg.ShowDialog() == DialogResult.Cancel) { return; } if (dlg.DefaultRadioButton == this.commandClearData) { this.database.Recreate(); } else { if (!this.CreateDatabase()) { return; } } } if (this.restoreBackupDialog.ShowDialog() == DialogResult.OK) { XmlDocument doc = new XmlDocument(); doc.Load(this.restoreBackupDialog.FileName); ImportExecutorClass ic = new ImportExecutorClass(this.database, doc, "/database/configuration"); ic.ExecuteImport(); this.ImportFolders(doc); this.ImportFilters(doc); ImportExecutorData ide = new ImportExecutorData(this.database, doc, "/database/records/record"); ide.ExecuteImport(); this.formGroupList.UpdateCategories(); //this.Folders.UpdateCategories(); this.formConfig.CreateCategoriesList(); //this.Configuration.CreateCategoriesList(); } }
private string CheckFileExists(string filename) { if (File.Exists(filename)) { return(filename); } if (_textData.IsOpened && Path.GetFileName(_textData.Filename) == Path.GetFileName(filename)) { return(filename); } string baseDir = Utilities.GetAbsolutePath(Properties.Settings.Default.ScriptPath); var files = Directory.GetFiles(baseDir, Path.GetFileName(filename), SearchOption.AllDirectories); if (files.Length == 0) { return(null); } var ktd = new KryptonTaskDialog { Icon = MessageBoxIcon.Information, CommonButtons = TaskDialogButtons.Cancel, WindowTitle = "看上去这个存档中记录的路径信息不太正确", MainInstruction = "不过,下面这个文件可能是正确的 :", Content = Utilities.GetRelativePath(files[0], Utilities.GetAbsolutePath("")), }; var ktdcOk = new KryptonTaskDialogCommand { DialogResult = DialogResult.OK, Image = Properties.Resources.arrow_right_green, Text = "好,就用这个", }; var ktdcNo = new KryptonTaskDialogCommand { DialogResult = DialogResult.Cancel, Image = Properties.Resources.arrow_right_red, Text = "不,这个是错误的", }; ktd.CommandButtons.AddRange(new[] { ktdcOk, ktdcNo }); if (ktd.ShowDialog() == DialogResult.OK) { return(files[0]); } return(null); }
bool Confirm(string pKey, string pMsg) { if (((ToolStripMenuItem)this.ToolStripMenuItemOption.DropDownItems[pKey]).Checked) { KryptonTaskDialog dialog = new KryptonTaskDialog { CheckboxText = @"以后不再确认", CheckboxState = false, WindowTitle = @"确认", MainInstruction = string.Format("{0}\t", pMsg), //不加\t中文显示缺最后一个字 Icon = MessageBoxIcon.Question, CommonButtons = TaskDialogButtons.OK | TaskDialogButtons.Cancel }; if (dialog.ShowDialog() == DialogResult.OK) { ((ToolStripMenuItem)this.ToolStripMenuItemOption.DropDownItems[pKey]).Checked = dialog.CheckboxState == false; return(true); } return(false); } return(true); }
public bool ShowConfigure() { this.LoadParameters(); lang = MainForm.Config.App.View.LocalName; if (ShowDialog() == DialogResult.OK) { this.SaveParameters(); if ((lang != MainForm.Config.App.View.LocalName) && MainForm.Config.App.View.WarningChangeLanguage) { KryptonTaskDialog d = new KryptonTaskDialog(); d.WindowTitle = Strings.LangChangedTitle; d.Content = Strings.LangChangedContent; d.CheckboxText = Strings.LangChangedCheck; d.CheckboxState = false; d.ShowDialog(); MainForm.Config.App.View.WarningChangeLanguage = !d.CheckboxState; } return(true); } return(false); }
private void btnStackTrace_Click(object sender, EventArgs e) { try { void InfiniteLoopIt(int howDeep) { if (howDeep > 50) { throw new InsufficientExecutionStackException(); } InfiniteLoopIt(++howDeep); } InfiniteLoopIt(1); } catch (Exception ex) { MessageBox.Show(this, ex.StackTrace, ex.Message); KryptonMessageBox.Show(this, ex.StackTrace, ex.Message); KryptonTaskDialog.Show(ex.Message, "MinInstruction", ex.StackTrace, MessageBoxIcon.Stop, TaskDialogButtons.Close); } }