private void chkRunDefault_CheckedChanged(object sender, EventArgs e) { if (m_Filling) { return; } if (m_TextChanged) // finalise the text first, otherwise editing will make a mess { string error = StoreTextChanges(); if (error != null) // block the change until the text is fixed: { MessageBox.Show(error); m_Filling = true; chkRunDefault.Checked = !chkRunDefault.Checked; m_Filling = false; return; } } m_Script.RunDefault = chkRunDefault.Checked; // then do some checks to help user if (m_DefaultScript != null) { if (!chkRunDefault.Checked && m_DefaultScript.CommandList.Any()) // && !m_Script.CommandList.Any()) - better to always ask, not just if list empty. If user added one custom command and unticks, they still very much want the defaults { // only exception is if the default is empty if (GUIUtilities.QuestionBox("[SAW_Edit_CopyDefaults]", MessageBoxButtons.YesNo) == DialogResult.Yes) { // only copies any commands that are not already present. Inserts at start of list m_Script.CommandList.InsertRange(0, from c in m_DefaultScript.CommandList where !m_Script.CommandList.Any(user => user.IdenticalTo(c)) select c.Clone()); if (m_Script.Visit.VisitType == Script.VisitTarget.VisitTypes.None) { m_Script.Visit = m_DefaultScript.Visit; } FillUI(); } } else if (chkRunDefault.Checked && m_Script.CommandList.Any(user => m_DefaultScript.CommandList.Any(def => def.IdenticalTo(user)))) { // second condition checks if any user command matches any default command if (GUIUtilities.QuestionBox("[SAW_Edit_RemoveDefaults]", MessageBoxButtons.YesNo) == DialogResult.Yes) { m_Script.CommandList.RemoveAll(user => m_DefaultScript.CommandList.Any(def => def.IdenticalTo(user))); if (m_Script.Visit.Equals(m_DefaultScript.Visit)) { m_Script.Visit.VisitType = Script.VisitTarget.VisitTypes.None; } FillUI(); } } } Edited(); }
private void btnReset_Click(object sender, EventArgs e) { if (GUIUtilities.QuestionBox("[SAW_Edit_ResetConfirm]", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } m_Filling = true; m_Script.CommandList.Clear(); lstCommands.Items.Clear(); txtScript.Clear(); chkRunDefault.Checked = true; m_Script.RunDefault = true; m_Filling = false; }
private void CheckKeyNotAssigned() { if (m_KeyActionChanged && m_KeyIsChanged && m_DisplayedKey != Keys.None && !tvActions.SelectedAction.IsEmpty && btnSetKey.Enabled && !tvActions.SelectedAction.Equals(m_Applied.KeyAction(m_DisplayedKey))) // second-line prevents a spurious warning if the user has selected a matching key and action (in which case clicking the button is ignored) { // the user has made a selection from key assignment but not actually pressed the assign button if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyNotAssigned").Replace("%0", txtKey.Text).Replace("%1", tvActions.SelectedAction.DescriptionWithoutAccelerator()), MessageBoxButtons.YesNo) == DialogResult.Yes) { btnSetKey_Click(this, EventArgs.Empty); } else { m_KeyIsChanged = false; m_KeyActionChanged = false; } } }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { Document document = new Document(false); // must be before IF below for first branch document.Page(0).SetSize(Globals.Root.CurrentConfig.ReadSize(Config.Page_Size, Config.Page_Size_Default)); if (CurrentDocument != null) { document.ActivityID = CurrentDocument.ActivityID; document.Page(0).SetSize(CurrentDocument.Page(0).PhysicalSize, CurrentDocument.Page(0).Margin); } document.SetDefaultGridAndSnapFromActivity(); if (CurrentDocument.UserSettings != null && (CurrentDocument.UserSettings.Values.Count > 0) || CurrentDocument.BothSettings != null && (CurrentDocument.BothSettings.Values.Count > 0)) { if (GUIUtilities.QuestionBox(Strings.Item("NewDocument_CopySettings"), MessageBoxButtons.YesNo) == DialogResult.Yes) { Transaction objTransaction = new Transaction(); // settings methods below require a transaction, but we won't store this for undo if (CurrentDocument.UserSettings != null) { document.GetCreateUserSettings(objTransaction).CopyFrom(CurrentDocument.UserSettings, Datum.CopyDepth.Duplicate, Mapping.Ignore); } if (CurrentDocument.BothSettings != null) { document.GetCreateBothSettings(objTransaction).CopyFrom(CurrentDocument.BothSettings, Datum.CopyDepth.Duplicate, Mapping.Ignore); } } } if (Globals.Root.CurrentConfig.ReadBoolean(Config.Multiple_Documents) && !CurrentDocument.IsEmpty) { // create new index - current doc kept even if saved, as long as not totally empty Globals.Root.AddNewDocument(document); } else { if (!Globals.Root.Editor.CheckDiscardCurrent(false)) { return; } Globals.Root.CurrentDocument = document; } Document.NextUntitledIndex += 1; }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { if (CurrentPage.SelectedCount != 1) { return; } var selected = CurrentPage.SelectedShapes.FirstOrDefault(); if (!(selected is Scriptable)) { return; } int helpID = (selected as Scriptable).SAWID; if (GUIUtilities.QuestionBox(Strings.Item("SAW_Edit_SetHelpConfirm", helpID.ToString()), MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } transaction.Edit(CurrentDocument); CurrentPage.HelpSAWID = helpID; }
private void frmRun_FormClosing(object sender, FormClosingEventArgs e) { // not called when reverting to user mode as the form is just hidden // rather only called if the user explicitly closes it - which must quit (the editor form will still exist hidden) //Debug.WriteLine(Switches.Switching.PhysicalSwitch.Switch(0).Type); if (e.CloseReason == CloseReason.UserClosing && (PhysicalSwitch.Switch(0)?.Type ?? PhysicalSwitch.Types.Null) == PhysicalSwitch.Types.Pointer) { this.TopMost = false; // if true the question won't be visible! var response = GUIUtilities.QuestionBox("[SAW_Run_CloseConfirm]", MessageBoxButtons.YesNo); this.TopMost = true; if (response != DialogResult.Yes) { e.Cancel = true; return; } } MainView.StopScan(); if (!Globals.Root.Closing) { Globals.Root.CloseApplication(); } }
public void lnkBackgroundImage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { // Alternate filter used; non-bitmaps may not work (especially if tiling) string filename = FileDialog.ShowOpen(FileDialog.Context.Image, "[Filter_Image1]"); if (string.IsNullOrEmpty(filename)) { return; } m_Page.BackgroundImage = (SharedImage)Globals.Root.CurrentDocument.AddSharedResourceFromFile(filename, m_Transaction); if (m_Page.BackgroundImage != null) // just in case { SizeF imageSize = m_Page.BackgroundImage.GetSize(64); // small size provided here means a resource (!?!) doesn't trigger if (imageSize.Width > 100 && imageSize.Height > 100 && Globals.Root.CurrentDocument.Count == 1) { // This is only done if the document has a single page. if (GUIUtilities.QuestionBox(Strings.Item("Paper_MatchImageSize"), MessageBoxButtons.YesNo) == DialogResult.Yes) { SetSizeToMatchImage(); } } } ReflectPaper(); }
public void btnKeysReset_Click(object sender, EventArgs e) { if (GUIUtilities.QuestionBox(Strings.Item("Config_Keys_ResetConfirm"), MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } List <string> remove = new List <string>(); // the configuration keys to be removed foreach (string key in m_Config.Values.Keys) { if (key.StartsWith("Key_")) { remove.Add(key); } } foreach (string key in remove) { m_Config.Values.Remove(key); } DisplayKey(m_DisplayedKey); tvActions_AfterSelect(this, null); WrittenToCurrent(); m_KeyIsChanged = false; }
public void btnSetKey_Click(object sender, EventArgs e) { if (tvActions.SelectedAction.IsEmpty || m_DisplayedKey == Keys.None) { return; } Functions.Action action = tvActions.SelectedAction; Functions.Action existing = m_Applied.KeyAction(m_DisplayedKey); if (action.Equals(existing)) { return; } if (!existing.IsEmpty) { if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyReplaceWarning").Replace("%0", lblKeyCurrent.Text), MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } List <Keys> keys = m_Applied.GetKeysForAction(action); if (keys != null && keys.Count == 1 && keys[0] != m_DisplayedKey) { if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyRemoveExisting").Replace("%0", GUIUtilities.KeyDescription(keys[0])), MessageBoxButtons.YesNo) == DialogResult.Yes) { m_Config.Write(Config.KeyKey(keys[0]), ""); } } m_Config.Write(Config.KeyKey(m_DisplayedKey), action.ToString()); WrittenToCurrent(); m_Applied.DiscardKeyLookup(); DisplayKey(m_DisplayedKey); tvActions_AfterSelect(this, null); m_KeyActionChanged = false; m_KeyIsChanged = false; }