예제 #1
0
        /// <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);

            _abbrForm.Pause();
            Context.AppPanelManager.ShowDialog(Context.AppPanelManager.GetCurrentPanel(), dlg as IPanel);
            _abbrForm.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;
            }
        }
예제 #2
0
        /// <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(_abbrForm, 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();
            }

            _abbrForm.LoadAbbreviations();
            Windows.SetVisible(_abbrForm, true);
        }
예제 #3
0
        /// <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(_abbrForm, 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();
            }

            _abbrForm.LoadAbbreviations();

            Windows.SetVisible(_abbrForm, true);
        }
예제 #4
0
        /// <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);

            _abbrForm.Pause();
            Context.AppPanelManager.ShowDialog(Context.AppPanelManager.GetCurrentPanel(), dlg as IPanel);
            _abbrForm.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;
            }
        }
예제 #5
0
        /// <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(_abbrForm, 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();
            }

            _abbrForm.LoadAbbreviations();
            Windows.SetVisible(_abbrForm, true);
        }
예제 #6
0
        /// <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(_abbrForm, 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();
            }

            _abbrForm.LoadAbbreviations();

            Windows.SetVisible(_abbrForm, true);
        }