/// <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)) { showTimedDialog(R.GetString("Error"), R.GetString("PleaseEnterAnAbbreviation")); return; } if (String.IsNullOrEmpty(tbExpansion.Text.Trim())) { showTimedDialog(R.GetString("Error"), R.GetString("ExpansionIsEmpty")); return; } bool saveAndQuit = false; bool confirm = false; if (Add) { // a new abbreviation is being added if (Context.AppAbbreviationsManager.Abbreviations.Exists(abbr)) { showTimedDialog(R.GetString("Add"), String.Format(R.GetString("CantSaveAbbreviation"), abbr)); } else { saveAndQuit = true; confirm = true; } } else if (Context.AppAbbreviationsManager.Abbreviations.Exists(abbr) && String.Compare(abbr, InputAbbreviation.Mnemonic.Trim(), true) != 0) { if (DialogUtils.Confirm(String.Format(R.GetString("YouAreChangingExistingAbbr"), tbAbbreviation.Text))) { saveAndQuit = true; } } else { saveAndQuit = true; confirm = true; } if (saveAndQuit) { bool quit = true; if (confirm) { quit = DialogUtils.Confirm(R.GetString("SaveAndQuit")); } if (quit) { OutputAbbreviation = new Abbreviation(tbAbbreviation.Text, tbExpansion.Text, _mode); Cancel = false; Windows.CloseForm(this); } } }
/// <summary> /// Triggered when a widget is actuated. /// </summary> /// <param name="widget">Which one triggered?</param> public void OnButtonActuated(Widget widget) { bool quit = false; Log.Debug(); Invoke(new MethodInvoker(delegate { switch (widget.Name) { case "B1": setText(textBoxEntry.Text + widget.Value); break; case "B2": setText(textBoxEntry.Text + widget.Value); break; case "B3": setText(textBoxEntry.Text + widget.Value); break; case "B4": setText(textBoxEntry.Text + widget.Value); break; case "buttonBackspace": // delete last letter if (textBoxEntry.Text.Length == 1) { setText(String.Empty); } else if (textBoxEntry.Text.Length > 1) { setText(textBoxEntry.Text.Substring(0, textBoxEntry.Text.Length - 1)); } break; case "buttonReset": setText(String.Empty); break; case "buttonExit": quit = true; break; } if (quit) { if (DialogUtils.Confirm(R.GetString("ExitQuestion"))) { Context.AppQuit = true; Windows.CloseForm(this); } else { textBoxEntry.Focus(); } } })); }