/// <summary> /// Displays the abbreviation dialog box that allows /// the user to either edit or delete an abbreviation /// </summary> /// <param name="operation">type of operation - edit/add/delete</param> private void editOrAddAbbreviation(AbbrOperation operation) { var dlg = Context.AppPanelManager.CreatePanel("AbbreviationEditorForm"); if (dlg == null) { return; } var invoker = (dlg as IExtension).GetInvoker(); invoker.SetValue("InputAbbreviation", operation.InputAbbreviation); invoker.SetValue("Add", operation.Add); _form.Pause(); Context.AppPanelManager.ShowDialog(Context.AppPanelManager.GetCurrentPanel(), dlg as IPanel); _form.Resume(); bool?canceled = invoker.GetBoolValue("Cancel"); var outputAbbreviation = invoker.GetValue("OutputAbbreviation") as Abbreviation; if (outputAbbreviation != null) { bool?deleted = invoker.GetBoolValue("Delete"); if (deleted != null) { operation.Cancel = canceled.Value; operation.Delete = deleted.Value; } operation.OutputAbbreviation = outputAbbreviation; } }
/// <summary> /// Edits an existing abbreviation in the list of /// abbreviations and then saves and reloads the list /// </summary> /// <param name="abbr">abbreviation to be edited</param> private void editAbbreviation(Abbreviation abbr) { Windows.SetVisible(_form, false); var operation = new AbbrOperation { InputAbbreviation = abbr, Add = false }; editOrAddAbbreviation(operation); if (!operation.Cancel) { if (operation.Delete) { Context.AppAbbreviations.Remove(abbr.Mnemonic); } else { if (!Context.AppAbbreviations.Exists(operation.OutputAbbreviation.Mnemonic)) { Context.AppAbbreviations.Add(operation.OutputAbbreviation); } else { Context.AppAbbreviations.Update(operation.OutputAbbreviation); } } Context.AppAbbreviations.Save(); Context.AppAbbreviations.Load(); } _form.LoadAbbreviations(); Windows.SetVisible(_form, true); }
/// <summary> /// Adds a new abbreviation to the list, saves /// and reloads the abbreviation list /// </summary> /// <param name="abbr">abbreviation to add</param> private void addAbbreviation(Abbreviation abbr) { Windows.SetVisible(_form, false); var operation = new AbbrOperation { InputAbbreviation = abbr, Add = true }; editOrAddAbbreviation(operation); if (!operation.Cancel) { Context.AppAbbreviations.Add(operation.OutputAbbreviation); Context.AppAbbreviations.Save(); Context.AppAbbreviations.Load(); } _form.LoadAbbreviations(); Windows.SetVisible(_form, true); }
/// <summary> /// Displays the abbreviation dialog box that allows /// the user to either edit or delete an abbreviation /// </summary> /// <param name="operation">type of operation - edit/add/delete</param> private void editOrAddAbbreviation(AbbrOperation operation) { var dlg = Context.AppPanelManager.CreatePanel("AbbreviationEditorForm"); if (dlg == null) { return; } var invoker = (dlg as IExtension).GetInvoker(); invoker.SetValue("InputAbbreviation", operation.InputAbbreviation); invoker.SetValue("Add", operation.Add); _form.Pause(); Context.AppPanelManager.ShowDialog(Context.AppPanelManager.GetCurrentPanel(), dlg as IPanel); _form.Resume(); bool? canceled = invoker.GetBoolValue("Cancel"); var outputAbbreviation = invoker.GetValue("OutputAbbreviation") as Abbreviation; if (outputAbbreviation != null) { bool? deleted = invoker.GetBoolValue("Delete"); if (deleted != null) { operation.Cancel = canceled.Value; operation.Delete = deleted.Value; } operation.OutputAbbreviation = outputAbbreviation; } }
/// <summary> /// Edits an existing abbreviation in the list of /// abbreviations and then saves and reloads the list /// </summary> /// <param name="abbr">abbreviation to be edited</param> private void editAbbreviation(Abbreviation abbr) { Windows.SetVisible(_form, false); var operation = new AbbrOperation { InputAbbreviation = abbr, Add = false }; editOrAddAbbreviation(operation); if (!operation.Cancel) { if (operation.Delete) { Context.AppAbbreviations.Remove(abbr.Mnemonic); } else { if (!Context.AppAbbreviations.Exists(operation.OutputAbbreviation.Mnemonic)) { Context.AppAbbreviations.Add(operation.OutputAbbreviation); } else { Context.AppAbbreviations.Update(operation.OutputAbbreviation); } } Context.AppAbbreviations.Save(); Context.AppAbbreviations.Load(); } _form.LoadAbbreviations(); Windows.SetVisible(_form, true); }
/// <summary> /// Adds a new abbreviation to the list, saves /// and reloads the abbreviation list /// </summary> /// <param name="abbr">abbreviation to add</param> private void addAbbreviation(Abbreviation abbr) { Windows.SetVisible(_form, false); var operation = new AbbrOperation { InputAbbreviation = abbr, Add = true }; editOrAddAbbreviation(operation); if (!operation.Cancel) { Context.AppAbbreviations.Add(operation.OutputAbbreviation); Context.AppAbbreviations.Save(); Context.AppAbbreviations.Load(); } _form.LoadAbbreviations(); Windows.SetVisible(_form, true); }