/// <summary> /// Displays a message box containing information about an exception, for the currently executing application, plus optional additional information. /// </summary> /// <param name="owner">The window owning the dialog</param> /// <param name="caption">The caption to display on the dialog</param> /// <param name="icon">The icon to display on the dialog</param> /// <param name="buttons">The buttons to display on the dialog</param> /// <param name="ex">The exception to display on the dialog</param> /// <param name="infoLines">Optional additional information to display on the dialog</param> /// <returns>The result of the dialog</returns> public static DialogResult DisplayException(IWin32Window owner, string caption, MessageBoxIcon icon, MessageBoxButtons buttons, Exception ex, params string[] infoLines) { bool hasAdditionalInfo = false; System.Text.StringBuilder sb = new System.Text.StringBuilder(); /// begin with the application information that generated the exception sb.Append(string.Format("The application '{0}' has encountered the following exception or condition.\n\n", Path.GetFileName(System.Windows.Forms.Application.ExecutablePath))); /// append the additional information if any was supplied if (infoLines != null) { hasAdditionalInfo = true; sb.Append("Additional Information:\n\n"); foreach(string line in infoLines) sb.Append(string.Format("{0}\n", line)); } if (ex != null) { /// append the information contained in the exception sb.Append(string.Format("{0}Exception Information:\n\n", (hasAdditionalInfo ? "\n" : null))); sb.Append(ex.ToString()); } /// display a message and return the result return MessageBox.Show(owner, sb.ToString(), caption, buttons, icon); }
public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons) { MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons, MessageBoxIcon.None); return form.RunDialog (); }
public static DialogResult Show(string msg, string title, MessageBoxButtons btns, MessageBoxIcon icon) { // Create a callback delegate _hookProcDelegate = new Win32.WindowsHookProc(HookCallback); // Remember the title & message that we'll look for. // The hook sees *all* windows, so we need to make sure we operate on the right one. _msg = msg; _title = title; // Set the hook. // Suppress "GetCurrentThreadId() is deprecated" warning. // It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx() #pragma warning disable 0618 _hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId()); #pragma warning restore 0618 // Pop a standard MessageBox. The hook will center it. DialogResult rslt = MessageBox.Show(msg, title, btns, icon); // Release hook, clean up (may have already occurred) Unhook(); return rslt; }
void ApplyButtons(MessageBoxButtons buttons) { HideAllButtons(); if (buttons == MessageBoxButtons.OK) { PositiveButton.Visibility = System.Windows.Visibility.Visible; PositiveButton.Content = AppStrings.OKButtonText; } else if (buttons == MessageBoxButtons.OKCancel) { PositiveButton.Visibility = System.Windows.Visibility.Visible; NegativeButton.Visibility = System.Windows.Visibility.Visible; PositiveButton.Content = AppStrings.OKButtonText; NegativeButton.Content = AppStrings.CancelButtonText; } else if (buttons == MessageBoxButtons.YesNo) { PositiveButton.Visibility = System.Windows.Visibility.Visible; NegativeButton.Visibility = System.Windows.Visibility.Visible; PositiveButton.Content = AppStrings.YesButtonText; NegativeButton.Content = AppStrings.NoButtonText; } else if (buttons == MessageBoxButtons.Custom) { PositiveButton.Visibility = string.IsNullOrEmpty(_model.PositiveButtonText) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible; NegativeButton.Visibility = string.IsNullOrEmpty(_model.NegativeButtonText) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible; CancelButton.Visibility = string.IsNullOrEmpty(_model.CancelButtonText) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible; PositiveButton.Content = _model.PositiveButtonText; NegativeButton.Content = _model.NegativeButtonText; CancelButton.Content = _model.CancelButtonText; } }
public MiserugeErrorException(string message, string dialogTitle, MessageBoxIcon icon, MessageBoxButtons buttons) : base(message) { this.DialogTitle = dialogTitle; this.Icon = icon; this.Buttons = buttons; }
public DialogResult ShowDialog(Control parent, MessageBoxButtons buttons) { var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null); SWF.Control c = (parent == null) ? null : (SWF.Control)parent.ControlObject; SWF.DialogResult result = SWF.MessageBox.Show(c, Text, caption, Convert(buttons), Convert(Type)); return Generator.Convert(result); }
/// <include file='doc\MessageBox.uex' path='docs/doc[@for="MessageBox.Show6"]/*' /> /// <devdoc> /// <para> /// Displays a message box with specified text, caption, and style. /// Makes the dialog RTL if the resources for this dll have been localized to a RTL language. /// </para> /// </devdoc> public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options) { if (RTLAwareMessageBox.IsRTLResources) { options |= (MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading); } return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options); }
public DialogResult showMessage(IWin32Window owner, string message, string title, MessageBoxIcon icon, MessageBoxButtons buttons) { //Wenn kein Owner mitgegeben wurde, dann Versuchen das Hauptfenster anzuzeigen if (owner == null || owner.Handle == IntPtr.Zero) owner = new dummyWindow(Process.GetCurrentProcess().MainWindowHandle); const string appTitle = "updateSystem.NET Administration"; //Nachricht loggen logLevel lLevel; switch (icon) { case MessageBoxIcon.Error: lLevel = logLevel.Error; break; case MessageBoxIcon.Exclamation: lLevel = logLevel.Warning; break; default: lLevel = logLevel.Info; break; } Log.writeState(lLevel, string.Format("{0}{1}", string.IsNullOrEmpty(title) ? "" : string.Format("{0} -> ", title), message)); var dlgResponse = Environment.OSVersion.Version.Major >= 6 ? showTaskDialog(owner, appTitle, title, message, buttons, icon) : showMessageBox(owner, appTitle, title, message, icon, buttons); Log.writeKeyValue(lLevel, "Messagedialogresult", dlgResponse.ToString()); return dlgResponse; }
/// <summary> /// Draws a MessageBox that always stays on top with a title, selectable buttons and an icon /// </summary> static public DialogResult Show(string message, string title, MessageBoxButtons buttons,MessageBoxIcon icon) { // Create a host form that is a TopMost window which will be the // parent of the MessageBox. Form topmostForm = new Form(); // We do not want anyone to see this window so position it off the // visible screen and make it as small as possible topmostForm.Size = new System.Drawing.Size(1, 1); topmostForm.StartPosition = FormStartPosition.Manual; System.Drawing.Rectangle rect = SystemInformation.VirtualScreen; topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10, rect.Right + 10); topmostForm.Show(); // Make this form the active form and make it TopMost topmostForm.Focus(); topmostForm.BringToFront(); topmostForm.TopMost = true; // Finally show the MessageBox with the form just created as its owner DialogResult result = MessageBox.Show(topmostForm, message, title, buttons,icon); topmostForm.Dispose(); // clean it up all the way return result; }
public static DialogResult Warning(String message, MessageBoxButtons buttons) { Logger.Warning(message); return MessageBox.Show(message , Session.GetResStr("warning") , buttons, MessageBoxIcon.Warning); }
public CustomMessageBox(string Title, string Msg, MessageBoxButtons Buttons) { InitializeComponent(); MsgButtons = Buttons; Message = Msg; TitleText = Title; }
public UserDialog (IWin32Window owner, Control content, MessageBoxButtons buttons) { InitializeComponent(); ClientSize = new System.Drawing.Size(content.Width, content.Height + buttonPanel.Height); contentPanel.Controls.Add(content); content.Dock = DockStyle.Fill; StartPosition = owner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent; if (buttons == MessageBoxButtons.OK) { okButton.Visible = true; cancelButton.Visible = false; } else if (buttons == MessageBoxButtons.OKCancel) { okButton.Visible = true; cancelButton.Visible = true; } else { throw new NotImplementedException("UserDialog currently only supports OK and OKCancel values for MessageBoxButtons"); } }
public static DialogResult Info(String message, MessageBoxButtons buttons) { Logger.Info(message); return MessageBox.Show(message , Session.GetResStr("information") , buttons, MessageBoxIcon.Information); }
public DialogResult ShowDialog(string message, string title, MessageBoxButtons buttons) { DialogResult result = MessageBox.Show( message, title, buttons); loggingService.Value.Info(message + "; result = " + result.ToString()); return result; }
/// <summary> /// Shows the alert dialog. /// </summary> /// <param name="core"> /// The StyleCop core instance. /// </param> /// <param name="parent"> /// The parent control. /// </param> /// <param name="message"> /// The message to display on the dialog. /// </param> /// <param name="title"> /// The title of the dialog. /// </param> /// <param name="buttons"> /// The dialog buttons. /// </param> /// <param name="icon"> /// The dialog icon. /// </param> /// <returns> /// Returns the dialog result. /// </returns> public static DialogResult Show(StyleCopCore core, Control parent, string message, string title, MessageBoxButtons buttons, MessageBoxIcon icon) { Param.RequireNotNull(core, "core"); Param.Ignore(parent); Param.RequireValidString(message, "message"); Param.RequireValidString(title, "title"); Param.Ignore(buttons); Param.Ignore(icon); if (core.DisplayUI) { return DisplayMessageBox(parent, message, title, buttons, icon); } else { // Alert Dialogs which provide options other than OK cannot be handled when the // program is running in a non-UI mode. if (buttons != MessageBoxButtons.OK) { throw new InvalidOperationException(Strings.AlertDialogWithOptionsInNonUIState); } SendToOutput(core, message, icon); return DialogResult.OK; } }
// Token: 0x06002C9D RID: 11421 // RVA: 0x0012157C File Offset: 0x0011F77C public static DialogResult smethod_8(string string_0, MessageBoxButtons messageBoxButtons_0, MessageBoxIcon messageBoxIcon_0) { Class115.smethod_6(true); DialogResult result = MessageBox.Show(string_0, "osu!", messageBoxButtons_0, messageBoxIcon_0); Class115.smethod_6(false); return result; }
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options) { _owner = owner; Initialize(); return MessageBox.Show(owner, text, caption, buttons, icon, defButton, options); }
/// <summary> /// 异常日志信息 /// </summary> /// <param name="text"></param> /// <param name="caption"></param> /// <param name="buttons"></param> /// <param name="icon"></param> /// <param name="ex"></param> /// <param name="FormType"></param> /// <returns></returns> public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, Exception ex,Type FormType) { log = LogManager.GetLogger(FormType); log.Error(ex); return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, icon); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Displays a customized message box in front of the specified window. /// </summary> /// <param name="owner">Owner window of the message box.</param> /// <param name="messageBoxText">Text to display.</param> /// <param name="caption">Title bar caption to display.</param> /// <param name="button">A value that specifies which button or buttons to display.</param> /// <param name="icon">Icon to display.</param> /// <returns>Button value which message box is clicked by the user.</returns> public static MessageBoxExButtonType Show(Window owner, string messageBoxText, string caption, MessageBoxButtons button, MessageBoxImage icon) { bool checkBoxState = false; // NOTE: ignored MessageBoxEx msbBox = new MessageBoxEx(); return msbBox._Show(owner, messageBoxText, caption, button, icon, null, ref checkBoxState); }
public static DialogResult Show(string text, string head, MessageBoxButtons buttons) { form1.Dispose(); form1 = new Form(); InitializeComponent(); if (form1.ParentForm == null) form1.StartPosition = FormStartPosition.CenterScreen; label1.Location = new Point(12, label1.Location.Y); btnNames = AsignButtons(buttons); form1.Text = head; label1.Text = text; FormAutoHeigh(); CenterButtons(btnNames.Length); MakeButtons(btnNames, selNoBtn); AddSound(icon); DialogResult rez = form1.ShowDialog(); form1.Dispose(); return rez; }
public static void ShowMessage(string msgHeader, string msgContext, Public_MessageBox msgBox, MessageBoxButtons msgButtons) { frmMessage f = new frmMessage(); f.ShowMessage(msgHeader, msgContext, msgBox, msgButtons); f.ShowDialog(); }
public static DialogResult Show(IWin32Window owner, string caption, string title, MessageBoxButtons buttons, MessageBoxIcon icon) { using (RepositionableMessageBox rmb = new RepositionableMessageBox(caption, title, buttons, icon)) { return rmb.ShowDialog(owner); } }
public static void ShowMessage(string message, string title = "HLSL Tools", MessageBoxButtons messageBoxButtons = MessageBoxButtons.OK, MessageBoxIcon messageBoxIcon = MessageBoxIcon.Warning, MessageBoxDefaultButton messageBoxDefaultButton = MessageBoxDefaultButton.Button1) { MessageBox.Show(message, title, messageBoxButtons, messageBoxIcon, messageBoxDefaultButton); }
public static DialogResult Show(string RichTextMessage, string StaticMessage, string WindowTitle, MessageBoxButtons Buttons) { RichTextMessageBox messageBox = new RichTextMessageBox(); messageBox.rtbMessage.Text = RichTextMessage; messageBox.lblStaticMessage.Text = StaticMessage; messageBox.Text = WindowTitle; messageBox.buttons = Buttons; switch (Buttons) { case MessageBoxButtons.OK: messageBox.button1.Visible = false; messageBox.button2.Visible = false; messageBox.button3.Text = "OK"; messageBox.button3.Tag = DialogResult.OK; break; case MessageBoxButtons.OKCancel: messageBox.button1.Visible = false; messageBox.button2.Text = "OK"; messageBox.button2.Tag = DialogResult.OK; messageBox.button3.Text = "Cancel"; messageBox.button3.Tag = DialogResult.Cancel; break; default: throw new NotImplementedException("Buttons option '" + Convert.ToString(Buttons) + "' is not supported."); } return messageBox.ShowDialog(); }
public QuickBooksException(string displayMessage, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) { _displayMessage = displayMessage; _caption = caption; _buttons = buttons; _icon = icon; }
/// <summary> /// 一般的なダイアログ表示用メソッドです。 /// </summary> public static DialogResult Show(IWin32Window owner, string message, string title, MessageBoxButtons buttons) { return WinForms.MessageBox.Show( owner, message, title, buttons); }
public MessageForm(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageBoxButtons buttons, string[] attachedFilePathes, MessageFormSettings settingsOverrides) { var defaultSettings = DefaultMessageFormSettingsProvider.GetDefaultMessageFormSettings(); _settings = MessageFormSettings.Merge(settingsOverrides, defaultSettings); _messageData = CreateMessageFormData(type, message, caption, exceptionInfo, _settings); _buttons = buttons; _attachedFilePathes = attachedFilePathes; InitializeComponent(); this.Text = _messageData.Title; this.SetMessage(_messageData.DisplayText); this.SetIcon(type); switch (_messageData.MessageType) { case MessageFormType.Error: case MessageFormType.Warning: this.ShowErrorDetails(); break; } this.InitializeButtons(type, buttons); this.ResizeView(_messageData.DisplayText); }
public static DialogResult Show(string Caption,MessageBoxButtons buttons, MessageBoxIcon icon) { Msgbox = new extramessage_frm(); Msgbox.txt.Text = Caption; if (icon == MessageBoxIcon.Information) { Msgbox.pictureBox1.BackgroundImage = Almas.Properties.Resources.info; Msgbox.Text = "پیام"; } else if (icon == MessageBoxIcon.Error) { Msgbox.pictureBox1.BackgroundImage = Almas.Properties.Resources.error; Msgbox.Text = "اخطار"; } else if (icon == MessageBoxIcon.Warning) { Msgbox.pictureBox1.BackgroundImage = Almas.Properties.Resources.warning; Msgbox.Text = "هشدار"; } if (buttons == MessageBoxButtons.OK) { Msgbox.panel1.Visible = true; Msgbox.panel2.Visible = false; } else if (buttons == MessageBoxButtons.YesNo) { Msgbox.panel2.Visible = true; Msgbox.panel1.Visible = false; } Msgbox.ShowDialog(); return result; }
/// <summary> /// Create a messagebox with the specific buttons. This is a temporary addition until this can be rewritten. /// </summary> /// <param name="messageBoxData"></param> /// <param name="messageBoxTitle"></param> /// <param name="buttons"></param> /// <param name="icon"></param> public MessageBoxForm(string messageBoxData, string messageBoxTitle, MessageBoxButtons buttons, Icon icon) { if (icon != null) { msgIcon = icon; } InitializeComponent(); InitMessageBox(messageBoxData, messageBoxTitle); if (buttons == MessageBoxButtons.OKCancel) { buttonOk.Location = buttonNo.Location; buttonCancel.Visible = true; } else if(buttons == MessageBoxButtons.YesNo) { buttonCancel.Visible = false; buttonOk.Text = @"YES"; buttonNo.Visible = true; } else if (buttons == MessageBoxButtons.YesNoCancel) { buttonCancel.Visible = true; buttonOk.Visible = true; buttonNo.Visible = true; buttonOk.Text = @"YES"; } }
public static DialogResult showMessageBox(this O2AppDomainFactory o2AppDomainFactory, string message, string messageBoxTitle, MessageBoxButtons messageBoxButtons) { return (DialogResult) o2AppDomainFactory.proxyInvokeStatic("O2_Kernel", "O2Proxy", "showMessageBox", new object[] {message, messageBoxTitle, messageBoxButtons}); }
private void cmbWOModel_SelectedIndexChanged(object sender, EventArgs e) { cmbLL.ResetText(); cmbLL.Enabled = true; label16.Visible = false; label3.Visible = false; tbCustomer.Text = ""; tbModel.Text = ""; tbPWBType.Text = ""; tbStencil.Text = ""; tbPCB.Text = ""; woQty.Text = ""; llQty.Text = ""; lbSummaryLLWO.Text = ""; lbSummaryWOLL.Text = ""; compareQty.Text = ""; comparePartcode.Text = ""; gbSummary.Visible = false; compareQty.BackColor = SystemColors.Control; comparePartcode.BackColor = SystemColors.Control; partCodeUsedNotMatchLLWO = 0; partCodeUsedNotMatchWOLL = 0; partCodeNotMatchLLWO = 0; partCodeNotMatchWOLL = 0; LLWONMPartCodes = ""; WOLLNMPartCodes = ""; dataGridViewCompareLLWO.DataSource = null; dataGridViewCompareLLWO.Refresh(); dataGridViewCompareWOLL.DataSource = null; dataGridViewCompareWOLL.Refresh(); while (dataGridViewCompareLLWO.Columns.Count > 0) { dataGridViewCompareLLWO.Columns.RemoveAt(0); } while (dataGridViewCompareWOLL.Columns.Count > 0) { dataGridViewCompareWOLL.Columns.RemoveAt(0); } cmbLL.Items.Clear(); string woPTSN = cmbWOPtsn.Text; string queryLLDropDown = "SELECT wo_PTSN FROM tbl_ll WHERE wo_PTSN = '" + woPTSN + "'GROUP BY wo_PTSN"; try { connection.Open(); using (MySqlDataAdapter adpt = new MySqlDataAdapter(queryLLDropDown, connection)) { DataTable dset = new DataTable(); adpt.Fill(dset); if (dset.Rows.Count > 0) { for (int i = 0; i < dset.Rows.Count; i++) { cmbLL.Items.Add(dset.Rows[i][0]); cmbLL.ValueMember = dset.Rows[i][0].ToString(); } } else { string message = "No any Loading List for selected Work Order, Do you want to upload Loading List File?"; string title = "Confirmation Upload Loading List "; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { ImportLL ill = new ImportLL(); ill.tbWoPTSN.Text = woPTSN; try { string queryCustName = "SELECT customer FROM tbl_wo WHERE wo_PTSN = '" + woPTSN + "'"; using (MySqlDataAdapter adt = new MySqlDataAdapter(queryCustName, connection)) { DataTable dst = new DataTable(); adt.Fill(dst); if (dst.Rows.Count > 0) { ill.tbCust.Text = dst.Rows[0]["customer"].ToString(); } } string queryProcessDropDown = "SELECT tbl_customer.process_Name FROM tbl_wo, tbl_customer WHERE tbl_wo.customer = tbl_customer.custname AND tbl_wo.wo_PTSN = '" + woPTSN + "'"; using (MySqlDataAdapter adpts = new MySqlDataAdapter(queryProcessDropDown, connection)) { DataTable dsets = new DataTable(); adpts.Fill(dsets); if (dsets.Rows.Count > 0) { string process = dsets.Rows[0][0].ToString().Replace(" ", String.Empty);; int totalProcess = process.Split(',').Length; var processName = process.Split(','); for (int j = 0; j < totalProcess; j++) { ill.cmbProcess.Items.Add(processName[j]); ill.cmbProcess.ValueMember = processName[j].ToString(); } } else { } } } catch (Exception ex) { // tampilkan pesan error MessageBox.Show(ex.Message); } ill.Show(); this.Hide(); } } } connection.Close(); } catch (Exception ex) { connection.Close(); // tampilkan pesan error MessageBox.Show(ex.Message); } }
public void Notificar(string titulo, string mensaje, MessageBoxButtons botones, MessageBoxIcon icono) { MessageBox.Show(mensaje, titulo, botones, icono); }
public DialogForm(string message, MessageBoxButtons messageBoxButtons) { InitializeComponent(); _Message = message; _MessageBoxButtons = messageBoxButtons; }
public static DialogResult MessageBox(string text, string title, MessageBoxButtons buttons, MessageBoxIcon icons = MessageBoxIcon.None) { return(System.Windows.Forms.MessageBox.Show(text, title, buttons, icons)); }
private void SaveDRT() { // MessageBox.Show("Test"); MySqlConnection con = new MySqlConnection(MyConnectionString); //con.Open(); if (Txt_IDMesinDRT.Text == "" || Txt_MaxSpeedDRT.Text == "" || Txt_MinSpeedDRT.Text == "" || Txt_SpindleDRT.Text == "") { string Pesan = "Input data must be complete. Invalid input data !"; string judul = "Developer System WijayaSoft"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(Pesan, judul, buttons, MessageBoxIcon.Warning); } else { try { //string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); MySqlCommand cmd = con.CreateCommand(); cmd.CommandText = "select ID_MESIN from MASTER_MESIN_DRT where ID_MESIN='" + Txt_IDMesinDRT.Text + "'"; con.Open(); MySqlDataReader Reader = cmd.ExecuteReader(); while (Reader.Read()) { CECKID = Reader.GetValue(0).ToString(); } Reader.Close(); con.Close(); if (CECKID == "" || CECKID == null) { con.Open(); cmd.CommandText = "insert into MASTER_MESIN_DRT (ID_MESIN,JUMLAH_SPINDLE,MAX_SPEED,MIN_SPEED,LAMA_PENGERJAAN) VALUES (@ID_MESIN,@JUMLAH_SPINDLE,@MAX_SPEED,@MIN_SPEED,@LAMA_PENGERJAAN)"; cmd.Parameters.AddWithValue("@ID_MESIN", Txt_IDMesinDRT.Text); cmd.Parameters.AddWithValue("@JUMLAH_SPINDLE", Txt_SpindleDRT.Text); cmd.Parameters.AddWithValue("@MAX_SPEED", Txt_MaxSpeedDRT.Text); cmd.Parameters.AddWithValue("@MIN_SPEED", Txt_MinSpeedDRT.Text); cmd.Parameters.AddWithValue("@LAMA_PENGERJAAN", TxtDurationDRT.Text); cmd.ExecuteNonQuery(); string pesan = "Data have been saved"; string judul = "WijayaSoft"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(pesan, judul, buttons, MessageBoxIcon.Information); ClearDRT(); con.Close(); Mesin_DRT(); AutoIDMesinDRT(); } else { con.Open(); cmd.CommandText = "update MASTER_MESIN_DRT set JUMLAH_SPINDLE='" + Txt_SpindleDRT.Text + "',MAX_SPEED='" + Txt_MaxSpeedDRT.Text + "',MIN_SPEED='" + Txt_MinSpeedDRT.Text + "',LAMA_PENGERJAAN='" + TxtDurationDRT.Text + "' where ID_MESIN='" + Txt_IDMesinDRT.Text + "'"; cmd.ExecuteNonQuery(); string pesan = "Data have been Update"; string judul = "WijayaSoft"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(pesan, judul, buttons, MessageBoxIcon.Information); ClearDRT(); con.Close(); Mesin_DRT(); AutoIDMesinDRT(); } } catch (Exception err) { string pesan = "Error when try to Insert data to Database. Please contact Developer" + err.ToString(); string judul = "Developer System WijayaSoft"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(pesan, judul, buttons, MessageBoxIcon.Error); } } }
public static void Upload(string directory, string bucket, string prefix) { if (s3Client != null) { string[] filePaths = Directory.GetFiles(directory); string amazonPath = bucket + "/" + prefix; try { var listResponse = s3Client.ListObjectsV2(new ListObjectsV2Request { BucketName = bucket, Prefix = prefix }); if (listResponse.S3Objects.Count > 0) //test if folder exists => move { List <Task> taskList = new List <Task>(); foreach (string filePath in filePaths) { Interlocked.Exchange(ref _progressMessage, "Building queue"); fileQueue.Enqueue(filePath); } for (int i = 0; i < semaphoreCount + 1; i++) //+ 1 thread that blocks t until all workers finish { taskList.Add(new Task(() => UploadFiles(amazonPath))); } Task[] tasks = taskList.ToArray(); Console.WriteLine("Files: " + fileQueue.Count); files = fileQueue.Count; var watch = Stopwatch.StartNew(); _pool.Release(semaphoreCount); Interlocked.Exchange(ref _progressMessage, "Uploading..... "); try { foreach (Task task in tasks) { task.Start(); } } catch (AggregateException ex) { Console.WriteLine("An action has thrown an exception. THIS WAS UNEXPECTED.\n{0}", ex.InnerException.ToString()); } Task t = Task.WhenAll(tasks); try { t.Wait(); Interlocked.Exchange(ref _progressMessage, "Uploaded..... "); watch.Stop(); Thread.Sleep(1000); Console.WriteLine($"Time Taken: { watch.ElapsedMilliseconds} ms."); Console.WriteLine($"Files uploaded: {uploadSum}"); Console.WriteLine($"Errors: {errorQueue.Count}"); } catch { } } else { string message = $"Bucket does not exist - contact administrator"; string caption = $"Bucket error"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } } catch (AmazonS3Exception amazonS3Exception) { string message = $"Could not connect to bucket - contact administrator {amazonS3Exception.Message}"; string caption = $"{amazonS3Exception.ErrorCode}"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } catch (Exception ex) { string message = $"An unknow error occured - contact administrator {ex.Message}"; string caption = $"{ex.Message}"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } } else { string message = "Could not connect to amazon - check login credentials"; string caption = "Amazon connection error"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } }
private static async void UploadFiles(string bucketName) { _pool.WaitOne(); string path; while (fileQueue.TryDequeue(out path)) { string fileName = Path.GetFileName(path); try { PutObjectRequest putRequest = new PutObjectRequest { BucketName = bucketName, Key = fileName, CannedACL = S3CannedACL.PublicRead, }; string base64 = checkMD5(path); using (FileStream stream = new FileStream(path, FileMode.Open)) { putRequest.MD5Digest = base64; putRequest.InputStream = stream; putRequest.ContentType = "image/jpg"; PutObjectResponse response = await s3Client.PutObjectAsync(putRequest); } Interlocked.Add(ref uploadSum, 1); double newValue = ((double)uploadSum / (double)files) * 100; Interlocked.Exchange(ref _progressValue, newValue); } catch (AmazonS3Exception amazonS3Exception) { if (amazonS3Exception.ErrorCode != null) { if (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity")) { string message = $"Invalid login credentials {amazonS3Exception.Message}"; string caption = $"{amazonS3Exception.ErrorCode}"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } else if (amazonS3Exception.ErrorCode.Equals("AccessDenied")) { string message = $"Bucket permission Error {amazonS3Exception.Message}"; string caption = $"{amazonS3Exception.ErrorCode}"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } else { string message = $"Unknown Amazon error {amazonS3Exception.Message}"; string caption = $"{amazonS3Exception.ErrorCode}"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } } else { string message = $"An unknown error occured {amazonS3Exception.Message}"; string caption = $"{amazonS3Exception.ErrorCode}"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult cancel; cancel = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error); } break; } catch (Exception e) { errorQueue.Add(path); fileQueue.Enqueue(path); //retry file upload Console.WriteLine( "Unknown encountered on server. Message:'{0}' when writing an object" , e.Message); } } _pool.Release(); Console.WriteLine("exiting thread"); }
public static DialogResult ShowMessage(string message, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information) => MessageBox.Show(message, "W3b L1nk", buttons, icon);
/// <summary> /// Captures the exception. /// </summary> /// <param name="exception">The exception.</param> /// <param name="currentWindow">The current window.</param> /// <param name="title">The title.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="className">Name of the class.</param> /// <param name="methodSignature">The method signature.</param> /// <param name="defaultTypeface">The default typeface.</param> public static void CaptureException(Exception exception, KryptonForm currentWindow, Control control = null, string title = @"Exception Caught", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Error, string className = "", string methodSignature = "", Font defaultTypeface = null) { defaultTypeface = new Font(currentWindow.Font.FontFamily, currentWindow.Font.Size, currentWindow.Font.Style, currentWindow.Font.Unit); if (className != "") { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in class: '{ className }.cs'.", title, buttons, icon, messageboxTypeface: defaultTypeface); } else if (methodSignature != "") { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in method: '{ methodSignature }'.", title, buttons, icon, messageboxTypeface: defaultTypeface); } else if (className != "" && methodSignature != "") { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in class: '{ className }.cs'.\n\nError in method: '{ methodSignature }'.", title, buttons, icon, messageboxTypeface: defaultTypeface); } else { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.", title, buttons, icon, messageboxTypeface: defaultTypeface); } }
public static async Task <DialogResult> ShowAsync(string Title, string Message, MessageBoxButtons DisplayButtons = MessageBoxButtons.OK, MessageBoxIcon DisplayIcon = MessageBoxIcon.Info) { var MessageView = new PopupMessageView(Title, Message, DisplayButtons, DisplayIcon); var popup = new PopupDialogBase <DialogResult>(MessageView); MessageView.ButtonEventHandler += (s, e) => { popup.PageClosedTaskCompletionSource.SetResult(((PopupMessageView)s).Result); }; await PopupNavigation.Instance.PushAsync(popup); //await PopupNavigation.PushAsync(popup); var result = await popup.PageClosedTask; await PopupNavigation.Instance.PopAsync(); return(result); }
public static DialogResult MsgBox(string text, MessageBoxButtons buttons, MessageBoxIcon icon) { return(MsgBox(text, buttons, icon, MessageBoxDefaultButton.Button1)); }
public void RestoreDatabase(string[] selectedFiles, string filePath, string backupName) { _form1.DisableDBControls(false); _form1.DisableSQLControls(false); List <string> runningSQLServer = SQLManagement.GetRunningSQLServers(); if (runningSQLServer.Count > 1) { MessageBox.Show("There are multiple sql servers running. Please stop any sql servers not being used. Environment Manager will target the remaining running sql server."); _form1.DisableDBControls(true); _form1.DisableSQLControls(true); return; } if (runningSQLServer.Count == 0) { MessageBox.Show("There are no sql servers running. Please start a sql server and try again."); _form1.DisableDBControls(true); _form1.DisableSQLControls(true); return; } //Unzip database ZipFile.ExtractToDirectory(filePath + ".zip", filePath); foreach (string server in runningSQLServer) { try { SqlConnection sqlCon = new SqlConnection(@"Data Source=" + Environment.MachineName + "\\" + server + @";Initial Catalog=MASTER;User ID=sa;Password=sa;"); foreach (string file in selectedFiles) { string restoreScript = @"ALTER DATABASE " + file + " SET SINGLE_USER WITH ROLLBACK IMMEDIATE; RESTORE DATABASE " + file + " FROM DISK='" + filePath + "\\" + file + ".bak' WITH FILE = 1, NOUNLOAD, REPLACE; ALTER DATABASE " + file + " SET MULTI_USER;"; try { SqlDataAdapter restoreDynScript = new SqlDataAdapter(restoreScript, sqlCon); DataTable restoreDynTable = new DataTable(); restoreDynScript.Fill(restoreDynTable); } catch (Exception restoreError) { string errorMessage = "There was an error restoring \"" + file + "\"."; try { ExceptionHandling.LogException2("Restore Database", "System.Data.SqlClient.SqlException", restoreError.Message, restoreError.Source, restoreError.StackTrace); } catch (Exception e1) { MessageBox.Show(e1.ToString()); } MessageBox.Show(errorMessage); _form1.DisableDBControls(true); _form1.DisableSQLControls(true); return; } } } catch (Exception sqlConnectionError) { string errorMessage = "Could not connect to the SQL Server. Please verify your SQL Server is running and try again."; try { ExceptionHandling.LogException2("Restore Database", "System.Data.SqlClient.SqlException", sqlConnectionError.Message, sqlConnectionError.Source, sqlConnectionError.StackTrace); } catch (Exception e2) { MessageBox.Show(e2.ToString()); } MessageBox.Show(errorMessage); _form1.DisableDBControls(true); _form1.DisableSQLControls(true); return; } } //Delete the backup folder. Directory.Delete(filePath); using (StreamWriter sw = File.AppendText(Environment.CurrentDirectory + @"\Files\Database Log.txt")) { sw.WriteLine("{" + DateTime.Now + "} - RESTORED: " + backupName); } string message = "Backup \"" + backupName + "\" was successfully restored."; string caption = "COMPLETE"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBoxIcon icon = MessageBoxIcon.Exclamation; DialogResult result; result = MessageBox.Show(message, caption, buttons, icon); _form1.DisableDBControls(true); _form1.DisableSQLControls(true); }
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons) { return(Show(text, caption, buttons, MessageBoxIcon.None)); }
/// <summary> /// Shows the exception. /// </summary> /// <param name="exceptionMessage">The exception message.</param> /// <param name="useKryptonMessageBox">if set to <c>true</c> [use krypton message box].</param> /// <param name="useExtendedKryptonMessageBox">if set to <c>true</c> [use extended krypton message box].</param> /// <param name="useWin32MessageBox">if set to <c>true</c> [use win32 message box].</param> /// <param name="useConsole">if set to <c>true</c> [use console].</param> /// <param name="useToolStripLabel">if set to <c>true</c> [use tool strip label].</param> /// <param name="toolStripLabel">The tool strip label.</param> /// <param name="args">The arguments.</param> /// <param name="caption">The caption.</param> /// <param name="buttons">The buttons.</param> /// <param name="defaultButton">The default button.</param> /// <param name="icon">The icon.</param> /// <param name="options">The options.</param> public void ShowException(string exceptionMessage, bool useKryptonMessageBox = false, bool useExtendedKryptonMessageBox = false, bool useWin32MessageBox = false, bool useConsole = false, bool useToolStripLabel = false, ToolStripLabel toolStripLabel = null, object args = null, string caption = "Exception Caught", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button3, MessageBoxIcon icon = MessageBoxIcon.Exclamation, MessageBoxOptions options = MessageBoxOptions.DefaultDesktopOnly) { if (useKryptonMessageBox) { KryptonMessageBox.Show(exceptionMessage, caption, buttons, icon, defaultButton, options); } else if (useExtendedKryptonMessageBox) { } else if (useWin32MessageBox) { MessageBox.Show(exceptionMessage, caption, buttons, icon, defaultButton, options); } else if (useConsole) { Console.WriteLine($"[ { DateTime.Now.ToString() } ]: { exceptionMessage }"); } }
//处理命令 private void DoCommand(ref string command, ref string parameter) { if (command == "Connected") { //WriteToClient(ref socket, "true"); } else if (command == "PcInfo") { SystemInfo systemInfo = new SystemInfo(); WriteToClient(ref socket, systemInfo.GetMyComputerName() + "\n" + systemInfo.GetMyScreens() + "\n" + systemInfo.GetMyCpuInfo() + "\n" + systemInfo.GetMyMemoryInfo() + "\n" + systemInfo.GetMyDriveInfo() + "\n" + systemInfo.GetMyOSName() + "\n" + systemInfo.GetMyUserName() + "\n" + systemInfo.GetMyPaths()); } //*************************************************************************************** //文件管理 else if (command == "Filelist")//文件列表 { try { string dir = ""; DirectoryInfo curDir = new DirectoryInfo(parameter); if (!curDir.Exists) { dir = ""; WriteToClient(ref socket, "<OK>Dir Send\r\n" + dir); return; } DirectoryInfo[] dirdir = curDir.GetDirectories(); FileInfo[] dirFiles = curDir.GetFiles(); foreach (FileInfo f in dirFiles) { dir = dir + "F:" + f.Name + "\t" + f.Length + "\t" + f.CreationTime.ToString() + "\t" + f.LastWriteTime.ToString() + "\r\n"; } foreach (DirectoryInfo d in dirdir) { dir = dir + "D:" + d.Name + "\r\n"; } WriteToClient(ref socket, "<OK>Dir Send\r\n" + dir); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Driverlist")//磁盘列表 { string[] drives = Environment.GetLogicalDrives(); string str = "<OK>Dir Send\r\n"; foreach (string s in drives) { str += s + "\r\n"; } WriteToClient(ref socket, str); } else if (command == "DeleteFile")//删除文件 { try { File.Delete(parameter); } catch { } string str = "<OK>File Deleted\r\n"; WriteToClient(ref socket, str); } else if (command == "DeleteDirectory")//删除文件夹 { try { DeleteDir(parameter); } catch { } string str = "<OK>Directory Deleted\r\n"; WriteToClient(ref socket, str); } else if (command == "Upload")//客户端上传文件 { thread = new Thread(new ThreadStart(Upload)); thread.Start(); } else if (command == "Download")//客户端下载文件 { thread = new Thread(new ThreadStart(Download)); thread.Start(); } else if (command == "Updir")//客户端上传文件夹 { thread = new Thread(new ThreadStart(Updir)); thread.Start(); } else if (command == "Downdir")//客户端下载文件夹 { thread = new Thread(new ThreadStart(Downdir)); thread.Start(); } else if (command == "Rename")//重命名文件 { try { char[] a = new char[] { '\r' }; string[] spl = parameter.Split(a); string para1 = spl[0]; string para2 = spl[1]; File.Copy(para1, para2, true); File.Delete(para1); WriteToClient(ref socket, "<OK>File Renamed!\r\n"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "move")//移动文件 { try { char[] a = new char[] { '\r' }; string[] spl = parameter.Split(a); string para1 = spl[0]; string para2 = spl[1]; File.Move(para1, para2); WriteToClient(ref socket, "<OK>File moved!\r\n"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Mkdir")//新建文件夹 { try { Directory.CreateDirectory(parameter); WriteToClient(ref socket, "<OK>Mkdir finished!\r\n"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Mkfile")//新建文件 { try { File.Create(parameter); WriteToClient(ref socket, "<OK>Mkfile finished!\r\n"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Run")//运行文件 { try { string[] str = parameter.Split('\r'); Process Proc = new Process(); if (str.Length >= 2) { switch (str[1]) { case "min": Proc.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; break; case "max": Proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; break; case "hidden": Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; break; case "canshu": Proc.StartInfo.Arguments = str[2]; break; default: Proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal; break; } } if (Directory.Exists(str[0]))//打开文件夹 { Proc.StartInfo.FileName = "explorer.exe"; Proc.StartInfo.Arguments = str[0]; } else//打开文件 { Proc.StartInfo.FileName = str[0]; } Proc.Start(); WriteToClient(ref socket, "<OK>Run finished!\r\n"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } //************************************************************************************************* //屏幕监控 else if (command == "ViewScreen")//屏幕监控 { thread = new Thread(new ThreadStart(ViewScreen)); thread.Start(); } else if (command == "EventLog")//事件日志 { try { string[] str = parameter.Split(' '); switch (str[0]) { case "list": GetEventlogList(parameter.Substring(parameter.IndexOf(' ') + 1)); break; case "del": DelEventlog(parameter.Substring(parameter.IndexOf(' ') + 1)); break; } WriteToClient(ref socket, "<OK>Send EventLog finished!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Service")//系统服务列表 { try { string[] str = parameter.Split(' '); switch (str[0]) { case "list": GetServiceList(); break; case "start": StartService(parameter.Substring(parameter.IndexOf(' ') + 1)); break; case "stop": StopService(parameter.Substring(parameter.IndexOf(' ') + 1)); break; case "autostart": AutoStartService(parameter.Substring(parameter.IndexOf(' ') + 1)); break; } WriteToClient(ref socket, "<OK>Send Service finished!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Process")//进程列表 { try { string[] str = parameter.Split(' '); switch (str[0]) { case "list": GetProcessList(); break; case "kill": KillProcess(str[1]); break; } WriteToClient(ref socket, "<OK>Send Process finished!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "StartUp")//开机启动 { try { string[] str = parameter.Split(' '); switch (str[0]) { case "list": GetStartUpList(); break; case "kill": KillStartUp(parameter.Substring(parameter.IndexOf(' ') + 1)); break; } WriteToClient(ref socket, "<OK>Send StartUp finished!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "NetWork")//网络连接 { try { ArrayList arr = GetNetstart(); foreach (string a in arr) { string[] str = a.Split('\n'); ArrayList arr1 = GetProcess(int.Parse(str[4])); Write(ref socket, str[0] + "\t" + arr1[0].ToString() + "\t" + str[1] + "\t" + str[2] + "\t" + str[3] + "\t" + str[4] + "\t" + arr1[1].ToString() + "\n"); } WriteToClient(ref socket, "<OK>Send NetWork finished!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "Regedit")//注册表 { try { string[] str = parameter.Split(' '); str[1] = parameter.Substring(parameter.IndexOf(' ') + 1); string r = ""; switch (str[0]) { case "getsubkey": GetSubKey(str[1]); break; case "getkeyvalue": GetKeyValue(str[1]); break; case "new": r = NewReg(str[1], false); break; case "rename": r = RenameReg(str[1], false); break; case "del": r = DelReg(str[1], false); break; case "new1": r = NewReg(str[1], true); break; case "rename1": r = RenameReg(str[1], true); break; case "del1": r = DelReg(str[1], true); break; } WriteToClient(ref socket, r); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } //************************************************************************************************* //远程控制 else if (command == "shutdown") { } else if (command == "restart") { } else if (command == "waring") { WriteToClient(ref socket, "<OK>waring sended!"); ++c; MessageBox.Show(parameter + c.ToString(), "Waring"); } else if (command == "message") { try { string[] str = parameter.Split('\n'); MessageBoxButtons m = MessageBoxButtons.OK; MessageBoxIcon ico = MessageBoxIcon.Information; switch (str[2]) { case "确定": m = MessageBoxButtons.OK; break; case "确定、取消": m = MessageBoxButtons.OKCancel; break; case "是、否": m = MessageBoxButtons.YesNo; break; case "是、否、取消": m = MessageBoxButtons.YesNoCancel; break; case "重试、取消": m = MessageBoxButtons.RetryCancel; break; case "终止、重试、忽略": m = MessageBoxButtons.AbortRetryIgnore; break; } switch (str[3]) { case "普通": ico = MessageBoxIcon.Information; break; case "询问": ico = MessageBoxIcon.Question; break; case "错误": ico = MessageBoxIcon.Error; break; case "警告": ico = MessageBoxIcon.Warning; break; } MessageBox.Show(str[0], str[1], m, ico); WriteToClient(ref socket, "<OK>message sended!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "textmsg") { try { string[] str = parameter.Split('\n'); System.Drawing.Text.InstalledFontCollection MyFamilies = new System.Drawing.Text.InstalledFontCollection(); FontForm ff = new FontForm(); ff.label1.Text = str[0]; ff.label1.Location = new Point(int.Parse(str[1]), int.Parse(str[2])); ff.label1.Font = new Font(new FontFamily(str[3]), int.Parse(str[4])); ff.label1.ForeColor = Color.FromName(str[5]); ff.Show(); WriteToClient(ref socket, "<OK>textmsg sended!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "openie") { try { string[] str = parameter.Split('\n'); str[0] = str[0].Trim(); str[1] = str[1].Trim(); if (str[0] != "") { Cmd.RunIE(str[0]); } if (str[1] != "") { Uri url = new Uri(str[1]); HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse hwrsp = (HttpWebResponse)hwr.GetResponse(); WebHeaderCollection whc = hwrsp.Headers; string fileName = whc["filename"];//.Get(7); MessageBox.Show(fileName); Stream strm = hwrsp.GetResponseStream(); StreamReader sr = new StreamReader(strm); FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); while (sr.Peek() > -1) { sw.WriteLine(sr.ReadLine()); } sw.Close(); fs.Close(); sr.Close(); strm.Close(); if (str[2] == "true") { Cmd.RunFile(fileName); } } WriteToClient(ref socket, "<OK>openie sended!"); } catch (Exception e) { WriteToClient(ref socket, e.Message); } } else if (command == "显示桌面") { try { System.Diagnostics.Process MyProcess; MyProcess = new System.Diagnostics.Process(); MyProcess.StartInfo.FileName = "MyDesktop.scf"; MyProcess.StartInfo.Verb = "Open"; MyProcess.Start(); } catch (Exception e) { WriteToClient(ref socket, e.Message); MessageBox.Show(e.Message); } WriteToClient(ref socket, "<OK>显示桌面 sended!"); } ///////////断开连接 else if (command == "quit") { WriteToClient(ref socket, "<OK>connected closed!"); socket.Close(); } else { WriteToClient(ref socket, "<ERROR>unrecognized command!"); MessageBox.Show("test"); } }
static DialogResult ShowUI(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) { if (text == null) { text = ""; } if (caption == null) { caption = ""; } string link = ""; string linktext = ""; Regex linkregex = new Regex(@"(\[link;([^\]]+);([^\]]+)\])", RegexOptions.IgnoreCase); Match match = linkregex.Match(text); if (match.Success) { link = match.Groups[2].Value; linktext = match.Groups[3].Value; text = text.Replace(match.Groups[1].Value, ""); } // ensure we are always in a known state _state = DialogResult.None; // convert to nice wrapped lines. text = AddNewLinesToText(text); // get pixel width and height Size textSize = TextRenderer.MeasureText(text, SystemFonts.DefaultFont); // allow for icon if (icon != MessageBoxIcon.None) { textSize.Width += SystemIcons.Question.Width; } var msgBoxFrm = new Form { FormBorderStyle = FormBorderStyle.Fixed3D, ShowInTaskbar = true, StartPosition = FormStartPosition.CenterParent, Text = caption, MaximizeBox = false, MinimizeBox = false, Width = textSize.Width + 50, Height = textSize.Height + 120, TopMost = true, AutoScaleMode = AutoScaleMode.None, }; Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle); int titleHeight = screenRectangle.Top - msgBoxFrm.Top; var lblMessage = new Label { Left = 58, Top = 15, Width = textSize.Width + 10, Height = textSize.Height + 10, Text = text }; msgBoxFrm.Controls.Add(lblMessage); msgBoxFrm.Width = lblMessage.Right + 50; if (link != "" && linktext != "") { var linklbl = new LinkLabel { Left = lblMessage.Left, Top = lblMessage.Bottom, Width = lblMessage.Width, Height = 15, Text = linktext, Tag = link }; linklbl.Click += linklbl_Click; msgBoxFrm.Controls.Add(linklbl); } var actualIcon = getMessageBoxIcon(icon); if (actualIcon == null) { lblMessage.Location = new Point(FORM_X_MARGIN, FORM_Y_MARGIN); } else { var iconPbox = new PictureBox { Image = actualIcon.ToBitmap(), Location = new Point(FORM_X_MARGIN, FORM_Y_MARGIN) }; msgBoxFrm.Controls.Add(iconPbox); } AddButtonsToForm(msgBoxFrm, buttons); // display even if theme fails try { if (ApplyTheme != null) { ApplyTheme(msgBoxFrm); } //ThemeManager.ApplyThemeTo(msgBoxFrm); } catch { } DialogResult test; test = msgBoxFrm.ShowDialog(); DialogResult answer = _state; return(answer); }
protected void MessageBox(string msg, MessageBoxButtons btn = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Error) { //MessageBox.Show(this, msg, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); Logging.Logg().Error(msg, Logging.INDEX_MESSAGE.NOT_SET); }
private static void AddButtonsToForm(Form msgBoxFrm, MessageBoxButtons buttons) { Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle); int titleHeight = screenRectangle.Top - msgBoxFrm.Top; var t = Type.GetType("Mono.Runtime"); if ((t != null)) { titleHeight = 25; } switch (buttons) { case MessageBoxButtons.OK: var but = new MyButton { Size = new Size(75, 23), Text = "OK", Left = msgBoxFrm.Width - 100 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 40 - FORM_Y_MARGIN - titleHeight }; but.Click += delegate { _state = DialogResult.OK; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(but); msgBoxFrm.AcceptButton = but; break; case MessageBoxButtons.YesNo: if (msgBoxFrm.Width < (75 * 2 + FORM_X_MARGIN * 3)) { msgBoxFrm.Width = (75 * 2 + FORM_X_MARGIN * 3); } var butyes = new MyButton { Size = new Size(75, 23), Text = "Yes", Left = msgBoxFrm.Width - 75 * 2 - FORM_X_MARGIN * 2, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butyes.Click += delegate { _state = DialogResult.Yes; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butyes); msgBoxFrm.AcceptButton = butyes; var butno = new MyButton { Size = new Size(75, 23), Text = "No", Left = msgBoxFrm.Width - 75 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butno.Click += delegate { _state = DialogResult.No; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butno); msgBoxFrm.CancelButton = butno; break; case MessageBoxButtons.OKCancel: if (msgBoxFrm.Width < (75 * 2 + FORM_X_MARGIN * 3)) { msgBoxFrm.Width = (75 * 2 + FORM_X_MARGIN * 3); } var butok = new MyButton { Size = new Size(75, 23), Text = "OK", Left = msgBoxFrm.Width - 75 * 2 - FORM_X_MARGIN * 2, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butok.Click += delegate { _state = DialogResult.OK; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butok); msgBoxFrm.AcceptButton = butok; var butcancel = new MyButton { Size = new Size(75, 23), Text = "Cancel", Left = msgBoxFrm.Width - 75 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butcancel.Click += delegate { _state = DialogResult.Cancel; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butcancel); msgBoxFrm.CancelButton = butcancel; break; default: throw new NotImplementedException("Only MessageBoxButtons.OK and YesNo supported at this time"); } }
public static void Mensaje(string mensaje, MessageBoxButtons boton = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information) { MessageBox.Show(mensaje, "Sistema de Estudiantil Universitario", boton, icon); }
public static DialogResult Mes(string descr, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxButtons butt = MessageBoxButtons.OK) { if (descr.Length > 0) { return(MessageBox.Show(descr, Application.ProductName, butt, icon)); } else { return(DialogResult.OK); } }
/// <summary> /// Displays a message box. /// </summary> /// <param name="owner">Owner window.</param> /// <param name="text">Text to display.</param> /// <param name="caption">Text to display in the title bar.</param> /// <param name="cdText">Text to display near check box.</param> /// <param name="buttons">Buttons to display in the message box.</param> /// <returns>One of the <see cref="DialogResult"/> values.</returns> public DialogResult Show(IWin32Window owner, string text, string caption, string cbText, MessageBoxButtons buttons) { return(Show(owner, text, caption, cbText, buttons, MessageBoxIcon.None)); }
/// <summary> /// Captures the exception. /// </summary> /// <param name="exception">The exception.</param> /// <param name="title">The title.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="className">Name of the class.</param> /// <param name="methodSignature">The method signature.</param> public static void CaptureException(Exception exception, string title = @"Exception Caught", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Error, string className = "", string methodSignature = "") { if (className != "") { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in class: '{ className }.cs'.", title, buttons, icon); } else if (methodSignature != "") { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in method: '{ methodSignature }'.", title, buttons, icon); } else if (className != "" && methodSignature != "") { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in class: '{ className }.cs'.\n\nError in method: '{ methodSignature }'.", title, buttons, icon); } else { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.", title, buttons, icon); } }
public static DialogResult Box(this string message, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information) { return(MessageBox.Show(message, Program.AppName, buttons, icon)); }
internal static DialogResult Pregunta(string mensaje, MessageBoxButtons boton, MessageBoxIcon icon) { DialogResult respuesta = MessageBox.Show(mensaje, "Sistema de Estudiantil Universitario", boton, icon); return(respuesta); }
public DialogResult ShowMessage(string message, string caption, MessageBoxButtons buttons) { return(MessageBox.Show(GetDialogOwnerWindow(), message, caption, buttons)); }
/// <summary> /// Displays a message box. /// </summary> /// <param name="owner">Owner window.</param> /// <param name="text">Text to display.</param> /// <param name="caption">Text to display in the title bar.</param> /// <param name="cdText">Text to display near check box.</param> /// <param name="buttons">Buttons to display in the message box.</param> /// <param name="icon">Icon to display in the mesage box.</param> /// <returns>One of the <see cref="DialogResult"/> values.</returns> public DialogResult Show(IWin32Window owner, string text, string caption, string cdText, MessageBoxButtons buttons, MessageBoxIcon icon) { button1.Click += new EventHandler(OnButtonClick); button2.Click += new EventHandler(OnButtonClick); button3.Click += new EventHandler(OnButtonClick); this.Text = caption; msgText.Text = text; cbOption.Text = cdText; if (Environment.OSVersion.Platform == PlatformID.Win32NT) { NativeMethods.EnableMenuItem(NativeMethods.GetSystemMenu(this.Handle, false), NativeMethods.SC_CLOSE, NativeMethods.MF_BYCOMMAND | NativeMethods.MF_GRAYED); } else { this.ControlBox = false; } SetButtonsToDisplay(buttons); SetIconToDisplay(icon); MessageBeep(icon); ShowDialog(owner); return(m_dialogResult); }
public FormMessageData(string Msg, string Caption, MessageBoxButtons btns, MessageBoxIcon icon, List <MessageEntity> Lst) { InitializeComponent(); txtMSG.Text = Msg; this.Text = Caption; btnYes.Visible = false; btnOK.Visible = false; btnCancel.Visible = false; switch (btns) { case MessageBoxButtons.AbortRetryIgnore: break; case MessageBoxButtons.OK: btnOK.Visible = true; btnOK.Text = "تائید"; btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; break; case MessageBoxButtons.OKCancel: btnYes.Visible = true; btnCancel.Visible = true; btnYes.Text = "تائید"; btnCancel.Text = "انصراف"; btnYes.DialogResult = System.Windows.Forms.DialogResult.OK; btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; break; case MessageBoxButtons.RetryCancel: break; case MessageBoxButtons.YesNo: btnYes.Visible = true; btnCancel.Visible = true; btnYes.Text = "بلی"; btnCancel.Text = "خیر"; btnYes.DialogResult = System.Windows.Forms.DialogResult.Yes; btnCancel.DialogResult = System.Windows.Forms.DialogResult.No; break; case MessageBoxButtons.YesNoCancel: break; default: break; } switch (icon) { case MessageBoxIcon.Error: Img.Image = Eris.Helper.Properties.Resources.Error; break; case MessageBoxIcon.Information: Img.Image = Eris.Helper.Properties.Resources.Information; break; case MessageBoxIcon.None: break; case MessageBoxIcon.Question: Img.Image = Eris.Helper.Properties.Resources.Question; break; case MessageBoxIcon.Warning: Img.Image = Eris.Helper.Properties.Resources.Warning; break; default: Img.Image = Eris.Helper.Properties.Resources.Error; break; } JanusSetting.GridFormatConditionSetting(GrdListData, GrdListData.RootTable.Columns[0], 2, Janus.Windows.GridEX.ConditionOperator.Equal, Color.Red); JanusSetting.GridFormatConditionSetting(GrdListData, GrdListData.RootTable.Columns[0], 3, Janus.Windows.GridEX.ConditionOperator.Equal, Color.DarkGreen); JanusSetting.GridFormatConditionSetting(GrdListData, GrdListData.RootTable.Columns[0], 4, Janus.Windows.GridEX.ConditionOperator.Equal, Color.DarkOrange); JanusSetting.GridFormatConditionSetting(GrdListData, GrdListData.RootTable.Columns[0], 5, Janus.Windows.GridEX.ConditionOperator.Equal, Color.Aqua); MessageBS.DataSource = Lst; GrdListData.Refetch(); }
public DialogResult ShowInfo(string info, string caption = "KaNote", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Asterisk) { return(MessageBox.Show(info, caption, buttons, icon)); }
private void btnDelEventModel_Click(object sender, EventArgs e) { Int32 iModelID; Int32 iRow; if (dgvModels.SelectedRows == null || dgvModels.SelectedRows.Count == 0) { DevComponents.DotNetBar.MessageBoxEx.Show(LocalizationRecourceManager.GetString(m_strSectionName, "MsgDelEventModel1")); return; } else { string message = LocalizationRecourceManager.GetString(m_strSectionName, "MsgDelEventModel2"); string caption = "Draw Arrange"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; if (DevComponents.DotNetBar.MessageBoxEx.Show(message, caption, buttons) == DialogResult.Yes) { iRow = dgvModels.SelectedRows[0].Index; iModelID = GetFieldValue(dgvModels, iRow, "F_ModelID"); } else { return; } } try { Int32 iResult; SqlCommand oneSqlCommand = new SqlCommand(); oneSqlCommand.Connection = m_DatabaseConnection; oneSqlCommand.CommandText = "proc_DelModelByID"; oneSqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter cmdParameter1 = new SqlParameter( "@ModelID", SqlDbType.Int, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Current, iModelID); oneSqlCommand.Parameters.Add(cmdParameter1); SqlParameter cmdParameterResult = new SqlParameter( "@Result", SqlDbType.Int, 4, ParameterDirection.Output, true, 0, 0, "", DataRowVersion.Current, 0); oneSqlCommand.Parameters.Add(cmdParameterResult); if (m_DatabaseConnection.State == System.Data.ConnectionState.Closed) { m_DatabaseConnection.Open(); } if (oneSqlCommand.ExecuteNonQuery() != 0) { iResult = (Int32)cmdParameterResult.Value; switch (iResult) { case 0: DevComponents.DotNetBar.MessageBoxEx.Show(LocalizationRecourceManager.GetString(m_strSectionName, "MsgDelEventModel3")); break; default: //其余的需要为删除成功! FillModels(); Int32 iSelRow = iRow - 1; if ((iSelRow >= 0) && (iSelRow < dgvModels.RowCount)) { dgvModels.FirstDisplayedScrollingRowIndex = iSelRow; dgvModels.Rows[iSelRow].Selected = true; } break; } } } catch (Exception ex) { DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message); } }
public static void Show(string text, string caption, MessageBoxButtons button, MessageBoxIcon icon) { MessageBox.Show(text, caption, button, icon, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); }