private void HelpMessage_Click(object sender, EventArgs e) {//Show the form help message if (helpMessage == "" || helpMessage == null) { RJMessageBox.Show("No help message has been added for this form", "Message"); } else { RJMessageBox.Show(helpMessage, "Quick Help"); } }
private void ShowDropdownMenu() { try //Show drop down menu { dropdownMenu.Show(this, DropdownMenuPosition.BottomRight); } catch (Exception ex) { RJMessageBox.Show("An error has occurred\n" + ex.ToString()); } }
private void ChilFormHelp_Click(object sender, EventArgs e) { //Show child form help message if (activeChildForm.HelpMessage == "" || activeChildForm.HelpMessage == null) //No message { RJMessageBox.Show("No help message has been added for this form", "Message"); } else//Show help message { RJMessageBox.Show(activeChildForm.HelpMessage, "Help"); } }
private void PrintDocument() { var bmpScreenshot = new Bitmap(pnlDocument.Width, pnlDocument.Height); //Set the bitmap object to the size of the desktop panel pnlDocument.DrawToBitmap(bmpScreenshot, new Rectangle(0, 0, bmpScreenshot.Width, bmpScreenshot.Height)); //Draw the document panel on the bitmap imgDocument = (Image)bmpScreenshot; //Set the screenshot to the document to print try { printDoc.Print();//Start document printing //This method calls the PrintPage event ( private void printDoc_PrintPage(object sender, PrintPageEventArgs e)) } catch (Exception ex) { RJMessageBox.Show("There was a problem trying to print, please try again.\nDetails\n" + ex); } }
protected virtual void CloseWindow() { if (isPrimaryForm) { var result = RJMessageBox.Show("Seguro quieres cerrar la applicacion?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == System.Windows.Forms.DialogResult.Yes) { Application.Exit(); } } else//If it is a child form { this.Close();//Close current form } }
private void CloseAllChildForm() { //Close all secondary forms var childForms = Application.OpenForms.OfType <ChildForm>().FirstOrDefault(); // Check if there is a secondary form open if (childForms != null) //If there is any form open, close all forms except this form and the main form of the application(e.g. Login form) { Application.OpenForms.Cast <Form>().Except(new Form[] { this, Program.MainForm }).ToList().ForEach(x => x.Close()); listChildForms.Clear();//Clear List forms pnlMarker.Visible = false; ResetToDefaults(); } else //if there are no open forms show message { RJMessageBox.Show("No child form is open", "Message"); } }
private void ShowDropdownMenu() { try //Show the button drop down menu { dropdownMenu.OwnerIsMenuButton = true; //Indicate to the drop-down menu that its owner is a menu button if (this.Width > 100) //If the side menu is expanded, show the dropdown menu at the bottom right of the menu button { dropdownMenu.Show(this, DropdownMenuPosition.BottomRight); } else //If the side menu is collapsed, show the dropdown menu at the top right of the menu button { dropdownMenu.Show(this, DropdownMenuPosition.TopRight); } } catch (Exception ex) { RJMessageBox.Show("An error has occurred\n" + ex.ToString()); } }
private void SaveAppearanceSettings() { //Save appearance settings Settings.SettingsManager.SaveAppearanceSettings(rbDarkTheme.Checked ? (int)UITheme.Dark : (int)UITheme.Light, /*Theme*/ (int)cbStyles.SelectedValue, /*Style*/ tbmFormBorderSize.Value, /*Form border size*/ tbColorFormBorder.Checked, /*Color form border*/ tbChildFormMarker.Checked, /*Child form marker*/ tbIconMenuItem.Checked, /*Form icon in activated menu item*/ tbMultiChildForms.Checked); /*Multiple child forms*/ //Show restart message var result = RJMessageBox.Show("Please Restart the application to view changes\nRestart now?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes)//Restart application { Application.Restart(); Environment.Exit(0); /* Note: When executing the application from visual studio, the configuration file is saved * in the folder RJCodeUI_M1.vshost.exe. And when restarting the application the configuration * file is obtained from the C:\Users\YourUsername\AppData\Local\RJCodeUI_M1\RJCodeUI_M1.exe folder, * since after restarting the application it * runs independently of visual studio, so it will not load the settings you established on the * first restart since it will take the file of * C:\Users\YourUsername\AppData\Local\RJCodeUI_M1\RJCodeUI_M1.exe configuration. If you want to * test and apply the settings established when you are developing the application, I recommend * you close the application (or stop debugging) and rerun from visual studio or compile the project * and run the application directly from the project's bin folder.*/ } else //Show restart message label in case you did not reboot from the message box. { lblRestartApp.Visible = true; } }
protected void OpenChildForm <childForm>(Func <childForm> _delegate, object senderMenuItem, CTMenuButton ownerMenuButton) where childForm : ChildForm { ///Generic method with a Generic Delegate (Func <TResult>), Menu Button and Menu Item Parameters where the data type is RJChildForm. if (ownerMenuButton == null || senderMenuItem == null || senderMenuItem.GetType() != typeof(ToolStripMenuItem)) //validate parameters { RJMessageBox.Show("Please send valid object, null values are not allowed"); return; } ChildForm form = Application.OpenForms.OfType <childForm>().FirstOrDefault();//Checks if the child form is already open #region - Show Child Form as a New Instance if (form == null) //If there is no result, the form is not open, create the instance and display it on the desktop panel { deactivateFormEvent = false; //Don't deactivate form when child form opens form = _delegate(); // Execute the delegate form.IsChildForm = true; form.TopLevel = false; //Indicates that the form is not TopLevel form.Dock = DockStyle.Fill; form.MarkerPosition = ownerMenuButton.Location.Y; //Set marker position CleanDesktop(); //Remove current child form from desktop panel if (UIAppearance.MultiChildForms == false) { CloseActiveChildForm(); // Close current child form if multiple child forms option is disabled- This does not affect if the secondary form is open in a new window. } listChildForms.Add(form); //add FORM to form list pnlDesktop.Controls.Add(form); //add FORM to desktop panel pnlDesktop.Tag = form; form.Show(); //show on desktop panel form.BringToFront(); form.Focus(); activeChildForm = form; //set FORM as active child form SetChildFormItems(); //-> Set the Caption, Icon and Options of the child form in the layout of the main form ownerMenuButton.Activate(form, (ToolStripMenuItem)senderMenuItem); //-> Activate the menu button and associate // a form for the button to remain highlighted until all forms are closed. // You can have many associated forms since the menu button shows a drop-down menu. // Also activate the menu item and associate it to the form so that the menu item remains // highlighted when the form is instantiated. deactivateFormEvent = true;//Reset value } #endregion #region - Redisplay Existing Form or Child Form else //If the form is already open, just show the form again { if (form.IsChildForm && form != activeChildForm) { //if the form is a child form and the form is different from the active child form add back to the panel and set as active child form CleanDesktop(); //Remove current child form from desktop panel pnlDesktop.Controls.Add(form); //add FORM to desktop panel pnlDesktop.Tag = form; activeChildForm = form; //set FORM as active child form SetChildFormItems(); //-> Set the Caption, Icon and Options of the child form in the layout of the main form } if (form.WindowState == FormWindowState.Minimized) { form.WindowState = FormWindowState.Normal; } form.Show();//show the form on the desktop panel or outside in a new window if the form IS NOT A CHILD FORM form.BringToFront(); form.Focus(); } #endregion }