Ejemplo n.º 1
0
        /// <summary>
        /// Updates an existing abbreviation object.
        /// </summary>
        /// <param name="abbreviation">Abbreviation to update</param>
        /// <returns>true if updated successfully</returns>
        public bool Update(Abbreviation abbreviation)
        {
            if (Exists(abbreviation.Mnemonic))
            {
                Remove(abbreviation.Mnemonic);
                return(Add(abbreviation));
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the abbreviation object to the list.  If it already exists,
        /// it is replaced.
        /// </summary>
        /// <param name="abbreviation">Abbreviation to add</param>
        /// <returns>true on success</returns>
        public bool Add(Abbreviation abbreviation)
        {
            if (String.IsNullOrEmpty(abbreviation.Mnemonic) || String.IsNullOrWhiteSpace(abbreviation.Mnemonic) ||
                String.IsNullOrWhiteSpace(abbreviation.Expansion) || String.IsNullOrEmpty(abbreviation.Expansion))
            {
                return(false);
            }

            _abbreviationList[abbreviation.Mnemonic] = abbreviation;
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Matchs the abbr with the filter and tells
        /// whether there is a match or not. Checks only the
        /// mnemonic
        /// </summary>
        /// <param name="abbr">abbr</param>
        /// <param name="filter">search filter</param>
        /// <returns></returns>
        private bool includeAbbr(Abbreviation abbr, String filter)
        {
            bool add = true;

            if (!String.IsNullOrEmpty(filter) && !abbr.Mnemonic.StartsWith(filter, StringComparison.InvariantCultureIgnoreCase))
            {
                add = false;
            }

            return add;
        }
Ejemplo n.º 4
0
 public ItemTag(Abbreviation abbr)
 {
     DataType = ItemType.Abbreviation;
     Abbr = abbr;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates an existing abbreviation object.
        /// </summary>
        /// <param name="abbreviation">Abbreviation to update</param>
        /// <returns>true if updated successfully</returns>
        public bool Update(Abbreviation abbreviation)
        {
            if (Exists(abbreviation.Mnemonic))
            {
                Remove(abbreviation.Mnemonic);
                return Add(abbreviation);
            }

            return false;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds the abbreviation object to the list.  If it already exists,
        /// it is replaced.
        /// </summary>
        /// <param name="abbreviation">Abbreviation to add</param>
        /// <returns>true on success</returns>
        public bool Add(Abbreviation abbreviation)
        {
            if (String.IsNullOrEmpty(abbreviation.Mnemonic) ||
                String.IsNullOrWhiteSpace(abbreviation.Mnemonic) ||
                String.IsNullOrWhiteSpace(abbreviation.Expansion) ||
                String.IsNullOrEmpty(abbreviation.Expansion))
            {
                return false;
            }

            _abbreviationList[abbreviation.Mnemonic] = abbreviation;
            return true;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes the class
        /// </summary>
        private void init()
        {
            _dialogCommon = new DialogCommon(this);

            Add = false;
            Delete = false;
            OutputAbbreviation = new Abbreviation(String.Empty, String.Empty, Abbreviation.AbbreviationMode.Speak);
            Cancel = false;

            if (!_dialogCommon.Initialize())
            {
                Log.Debug("Initialization error");
            }

            Load += AbbreviationsEditorForm_Load;
            FormClosing += AbbreviationsEditorForm_FormClosing;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// User wants to edit an abbreviation. Get confirmation to see
 /// if the user want to edit or delete
 /// </summary>
 /// <param name="abbr">Abbreviation to be edited</param>
 private void _form_EvtEditAbbreviation(Abbreviation abbr)
 {
     if (!_editDeleteMenuShown)
     {
         _abbreviationSelected = abbr;
         _editDeleteConfirmScanner = Context.AppPanelManager.CreatePanel("AbbreviationEditDeleteConfirm", "Abbreviation");
         if (_editDeleteConfirmScanner != null)
         {
             _editDeleteMenuShown = true;
             IPanel panel = _editDeleteConfirmScanner as IPanel;
             Context.AppPanelManager.Show(Context.AppPanelManager.GetCurrentPanel(), panel);
         }
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// User is done. Confirm, perform validation and check
        /// that everything is OK and then quit.
        /// </summary>
        private void finish()
        {
            var abbr = tbAbbreviation.Text.Trim();
            if (String.IsNullOrEmpty(abbr))
            {
                DialogUtils.ShowTimedDialog(this, "Error", "Please enter an abbreviation!");
                return;
            }

            if (String.IsNullOrEmpty(tbExpansion.Text.Trim()))
            {
                DialogUtils.ShowTimedDialog(this, "Error", "Expansion is empty");
                return;
            }

            bool saveAndQuit = false;
            bool confirm = false;

            if (Add)
            {
                // a new abbreviation is beein added
                if (Context.AppAbbreviations.Exists(abbr))
                {
                    DialogUtils.ShowTimedDialog(
                                    Context.AppPanelManager.GetCurrentPanel() as Form,
                                    "Add",
                                    "Can't Save. Abbr for '" + abbr + "' already exists");
                }
                else
                {
                    saveAndQuit = true;
                    confirm = true;
                }
            }
            else if (Context.AppAbbreviations.Exists(abbr) &&
                    String.Compare(abbr, InputAbbreviation.Mnemonic.Trim(), true) != 0)
            {
                if (DialogUtils.Confirm("You are changing existing abbr " + tbAbbreviation.Text + " . Continue?"))
                {
                    saveAndQuit = true;
                }
            }
            else
            {
                saveAndQuit = true;
                confirm = true;
            }

            if (saveAndQuit)
            {
                bool quit = true;

                if (confirm)
                {
                    quit = DialogUtils.Confirm("Save Abbreviation and Quit?");
                }

                if (quit)
                {
                    OutputAbbreviation = new Abbreviation(tbAbbreviation.Text, tbExpansion.Text, _mode);
                    _dialogCommon.GetRootWidget();
                    Cancel = false;
                    Windows.CloseForm(this);
                }
            }
        }
Ejemplo n.º 10
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(_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);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Deletes an abbreviation from the list and reloads
 /// the list
 /// </summary>
 /// <param name="abbr">abbreviation to delete</param>
 private void deleteAbbreviation(Abbreviation abbr)
 {
     Context.AppAbbreviations.Remove(abbr.Mnemonic);
     Context.AppAbbreviations.Save();
     Context.AppAbbreviations.Load();
     _form.LoadAbbreviations();
 }
Ejemplo n.º 12
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(_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);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Invoked when there is a request to run a command. This
        /// could as a result of the user activating a button on the
        /// scanner and there is a command associated with the button
        /// </summary>
        /// <param name="command">command to run</param>
        /// <param name="commandArg">any optional arguments</param>
        /// <param name="handled">was this handled?</param>
        public override void OnRunCommand(String command, object commandArg, ref bool handled)
        {
            handled = true;

            switch (command)
            {
                case "clearText":
                    _form.ClearFilter();
                    break;

                case "CancelEditDelAbbreviation":
                    closeEditDeleteConfirmScanner();
                    break;

                case "EditAbbreviation":
                    closeEditDeleteConfirmScanner();
                    if (_abbreviationSelected != null)
                    {
                        editAbbreviation(_abbreviationSelected);
                    }

                    break;

                case "DeleteAbbreviation":
                    if (_abbreviationSelected != null)
                    {
                        if (DialogUtils.ConfirmScanner("Delete " + _abbreviationSelected.Mnemonic + "?"))
                        {
                            deleteAbbreviation(_abbreviationSelected);
                            _abbreviationSelected = null;
                            closeEditDeleteConfirmScanner();
                        }
                    }

                    break;

                default:
                    Log.Debug(command);
                    if (_form != null)
                    {
                        _form.OnRunCommand(command, ref handled);
                    }

                    break;
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// User wants to edit or delete an abbr
 /// </summary>
 /// <param name="itemTag">Tag associated with the list item selected</param>
 private void handleEditAbbreviation(Abbreviation abbr)
 {
     if (EvtEditAbbreviation != null)
     {
         Invoke(new MethodInvoker(() => EvtEditAbbreviation(abbr)));
     }
 }