/// <summary> /// Handles the Click event of the pbRenameSelectedSession control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void pbRenameSelectedSession_Click(object sender, EventArgs e) { if (cmbSessions.SelectedItem != null) { var session = (FileSession)cmbSessions.SelectedItem; if (ValidateSessionName(tbRenameSession, false, session.Id)) { // set the session name to the instance.. session.SessionName = tbRenameSession.Text.Trim(' '); ScriptNotepadDbContext.DbContext.SaveChanges(); // set the session to the settings as it's saved as string using the session name.. FormSettings.Settings.CurrentSessionEntity = session; // set the instance back to the combo box.. cmbSessions.SelectedItem = session; MessageBoxExtended.Show( DBLangEngine.GetMessage("msgSessionRenameSuccess", "The session was successfully renamed.|A message indicating a successful session rename."), DBLangEngine.GetMessage("msgSuccess", "Success|A message indicating a successful operation."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Information, ExtendedDefaultButtons.Button1); } else { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgWarningInvalidSessionName", "The session name '{0}' is either invalid or already exists in the database|The given session name is invalid (white space or null) or the given session name already exists in the database", tbRenameSession.Text), DBLangEngine.GetMessage("msgWarning", "Warning|A message warning of some kind problem."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Warning, ExtendedDefaultButtons.Button1); } } }
/// <summary> /// Handles the Click event of the pbAddNewSessionWithName control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void pbAddNewSessionWithName_Click(object sender, EventArgs e) { // a user wishes to add a new session with a name.. if (ValidateSessionName(tbAddNewSessionWithName, true)) { ScriptNotepadDbContext.DbContext.FileSessions.Add(new FileSession { SessionName = tbAddNewSessionWithName.Text.Trim(' ') }); ScriptNotepadDbContext.DbContext.SaveChanges(); // list the sessions to the combo box.. ListSessions(); MessageBoxExtended.Show( DBLangEngine.GetMessage("msgSessionCreateSuccess", "The session was successfully created.|A message indicating a successful session creation."), DBLangEngine.GetMessage("msgSuccess", "Success|A message indicating a successful operation."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Information, ExtendedDefaultButtons.Button1); } else { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgWarningInvalidSessionName", "The session name '{0}' is either invalid or already exists in the database|The given session name is invalid (white space or null) or the given session name already exists in the database", tbAddNewSessionWithName.Text), DBLangEngine.GetMessage("msgWarning", "Warning|A message warning of some kind problem."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Warning, ExtendedDefaultButtons.Button1); } }
private void button8_Click(object sender, EventArgs e) { MessageBoxExtended.Localize("fi"); MessageBox.Show( MessageBoxExtended.Show(this, "Helevetin helevetin helevetti!", "Testing..", //MessageBoxButtonsExtended.YesNo, MessageBoxButtonsExtended.YesNoYesToAllRememberNoToAllRemember, MessageBoxIcon.Hand).ToString()); }
// a user wishes to delete scripts from the database.. private void btDeleteScript_Click(object sender, EventArgs e) { // display a confirmation dialog.. if (MessageBoxExtended.Show( DBLangEngine.GetMessage("msgDeleteScriptConfirm", "Delete selected script snippet(s)?|A confirmation question whether to delete selected script snippets from the database"), DBLangEngine.GetMessage("msgConfirm", "Confirm|A caption text for a confirm dialog"), MessageBoxButtonsExtended.YesNo, MessageBoxIcon.Question) == DialogResultExtended.Yes) { bool deleted = false; // a flag indicating if any scripts were actually deleted.. // loop though the selected items in the list box.. foreach (var item in lbScriptList.SelectedItems) { // assume that an item in the list box is a CODE_SNIPPETS class instance.. var snippet = (CodeSnippet)item; // check if the script's name is valid for deletion.. if (IsScriptPossibleToDelete(snippet.ScriptName)) { // some boolean algebra to determine if anything was actually delete from the database.. try { ScriptNotepadDbContext.DbContext.CodeSnippets.Remove(snippet); deleted = true; } catch (Exception ex) { ExceptionLogger.LogError(ex); } } } if (deleted) // only refresh the list if some deletions were made.. { ScriptNotepadDbContext.DbContext.SaveChanges(); // get the remaining code snippets in the database.. codeSnippets = ScriptNotepadDbContext.DbContext.CodeSnippets.ToArray(); // filter the list box contents based on the given filters.. FilterSnippets((ScriptSnippetType)cmbScriptType.SelectedIndex, tbFilter.Text); } } }
private void btInstallPlugin_Click(object sender, EventArgs e) { odDLL.Title = DBLangEngine.GetMessage("msgDialogSelectPlugin", "Select a plugin to install|A title for an open file dialog to indicate user that the user is selecting a plugin dll to be installed"); odDLL.InitialDirectory = FormSettings.Settings.FileLocationOpenPlugin; if (odDLL.ShowDialog() == DialogResult.OK) { FormSettings.Settings.FileLocationOpenPlugin = Path.GetDirectoryName(odDLL.FileName); if (TestFileIsAssembly.IsAssembly(odDLL.FileName)) { try { // try to copy the file to the plug-in folder.. File.Copy(odDLL.FileName, // ReSharper disable once AssignNullToNotNullAttribute Path.Combine(FormSettings.Settings.PluginFolder, Path.GetFileName(odDLL.FileName)), true); } catch (Exception ex) { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgErrorPluginInstall", "The plug-in instillation failed with the following error: '{0}'.|Something failed during copying a plug-in to the plug-ins folder", ex.Message), DBLangEngine.GetMessage("msgError", "Error|A message describing that some kind of error occurred."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Error, ExtendedDefaultButtons.Button1); // log the exception.. ExceptionLogger.LogError(ex); } } else { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgWarningPluginNotAssembly", "The plug-in initialization failed because it is not a valid .NET Framework assembly.|The given assembly isn't a .NET Framework assembly"), DBLangEngine.GetMessage("msgWarning", "Warning|A message warning of some kind problem."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Warning, ExtendedDefaultButtons.Button1); } } }
private void pbDeleteSelectedSession_Click(object sender, EventArgs e) { if (cmbSessions.SelectedItem != null) { FileSession session = (FileSession)cmbSessions.SelectedItem; if (session.Id == 1) // Id == 1 is the default.. { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgDefaultSessionCanNotDelete", "The default session can not be deleted.|A message informing that the default session can not be deleted."), DBLangEngine.GetMessage("msgInformation", "Information|A message title describing of some kind information."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Information, ExtendedDefaultButtons.Button1); } else if (session.SessionName == FormSettings.Settings.CurrentSessionEntity.SessionName) { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgCurrentSessionCanNotDelete", "The currently active session can not be deleted.|A message informing that the currently active session can not be deleted."), DBLangEngine.GetMessage("msgInformation", "Information|A message title describing of some kind information."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Information, ExtendedDefaultButtons.Button1); } else { if (MessageBoxExtended.Show( DBLangEngine.GetMessage("msgConfirmDeleteEntireSession", "Please confirm you want to delete an entire session '{0}' from the database. This operation can not be undone. Continue?|A confirmation dialog if the user wishes to delete an entire session from the database. (NO POSSIBILITY TO UNDO!).", session.SessionName), DBLangEngine.GetMessage("msgConfirm", "Confirm|A caption text for a confirm dialog."), MessageBoxButtonsExtended.YesNo, MessageBoxIcon.Question, ExtendedDefaultButtons.Button2) == DialogResultExtended.Yes) { if (FileSessionHelper.DeleteEntireSession(session)) { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgSessionDeleteSuccess", "The session was successfully deleted.|A message indicating a successful session delete."), DBLangEngine.GetMessage("msgSuccess", "Success|A message indicating a successful operation."), MessageBoxButtonsExtended.OK, MessageBoxIcon.Information, ExtendedDefaultButtons.Button1); } } } } }
// an event which occurs when the save or a save as button is clicked.. private void tsbSaveButtons_Click(object sender, EventArgs e) { // if the script's name is invalid.. if (!ValidateScriptName(tstScriptName.Text)) { ErrorBlink(); // ..indicate an error.. return; // ..and return.. } // if the currentCodeSnippet is null then create a new one.. if (currentCodeSnippet == null) { currentCodeSnippet = CreateNewCodeSnippet(scintillaScript.Text, tstScriptName.Text, SelectedScriptType); } // display an error if the script's name is any of the reserved script names.. if (ScriptNotepadDbContext.DbContext.CodeSnippets.Any(f => f.ScriptName.In( defaultNameScriptTemplateText, defaultNameScriptTemplateLines, "Simple line ending change script", "Simple replace script", "Simple XML manipulation script"))) { MessageBoxExtended.Show( DBLangEngine.GetMessage("msgReservedScriptName", "The given script name is reserved for the script samples. The script wasn't saved.|A message informing that the given script name is reserved for static sample scripts."), DBLangEngine.GetMessage("msgWarning", "Warning|A message warning of some kind problem"), MessageBoxButtonsExtended.OK, MessageBoxIcon.Warning, ExtendedDefaultButtons.Button1); EnableDisableControlsOnChange(true); return; } ScriptNotepadDbContext.DbContext.CodeSnippets.Add(currentCodeSnippet); ScriptNotepadDbContext.DbContext.SaveChanges(); // enable the controls as the user chose to save the changes of the script.. EnableDisableControlsOnChange(true); }