public Task<PhotoSelectionModeEnum> SelectMode() { var taskSource = new TaskCompletionSource<PhotoSelectionModeEnum>(); var messageBox = new CustomMessageBox { Caption = "Photo selection", Message = "Specify the source of the photos please.", LeftButtonContent = "My photos", RightButtonContent = "Astral photos" }; messageBox.Dismissed += (s, e) => { switch (e.Result) { case CustomMessageBoxResult.LeftButton: taskSource.TrySetResult(PhotoSelectionModeEnum.MyPhotos); break; case CustomMessageBoxResult.RightButton: taskSource.TrySetResult(PhotoSelectionModeEnum.BuiltinPhotos); break; default: taskSource.TrySetResult(PhotoSelectionModeEnum.None); break; } }; messageBox.Show(); return taskSource.Task; }
private void BasicMessageBox_Click(object sender, RoutedEventArgs e) { CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Pregunta?", Message = "Mensaje del CustomMessageBox.", LeftButtonContent = "Si", RightButtonContent = "No", IsFullScreen = (bool)FullScreenCheckBox.IsChecked }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: // Acción. break; case CustomMessageBoxResult.RightButton: // Acción. break; case CustomMessageBoxResult.None: // Acción. break; default: break; } }; messageBox.Show(); }
private void lstAdapters_SelectionChanged(object sender, SelectionChangedEventArgs e) { lstAdapterItem selItem = ((lstAdapterItem)lstAdapters.SelectedItem); TextBox dnsBox = new TextBox() { Text = selItem.PrimaryDNS }; TiltEffect.SetIsTiltEnabled(dnsBox, true); CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Edit DNS for " + selItem.Name, Message = "Primary DNS Server:", Content = dnsBox, LeftButtonContent = "save", RightButtonContent = "cancel", IsFullScreen = false }; messageBox.Dismissed += (s1, e1) => { if (e1.Result == CustomMessageBoxResult.LeftButton) { Registry.SetMultiStringValue(selItem.KeyRoot, selItem.KeyPath, "DNS", new string[] { dnsBox.Text }); //TODO: Clear the list first refreshAdapters(); } //TODO: Fix this //lstAdapters.SelectedIndex = -1; }; messageBox.Show(); }
public void Prompt(string message, string title, Action<string> onPrompt, Action onCancel = null) { var textBox = new TextBox(); var messageBox = new CustomMessageBox() { Caption = title, LeftButtonContent = "Подтвердить", RightButtonContent = "Отмена", Message = message, Content = textBox }; messageBox.Dismissed += (sender, args) => { switch (args.Result) { case CustomMessageBoxResult.LeftButton: onPrompt(textBox.Text); // Do something. break; case CustomMessageBoxResult.RightButton: // Do something. if (onCancel != null) onCancel(); break; case CustomMessageBoxResult.None: // Do something. if (onCancel != null) onCancel(); break; default: if (onCancel != null) onCancel(); break; } }; messageBox.Show(); }
public Task<bool> ShowDialogBox(string caption, string message, string leftbuttonContent, string rightButtonContent, Func<Task> leftButtonAction, Func<Task> rightButtonAction) { var messagebox = new CustomMessageBox() { Caption = caption, Message = message, LeftButtonContent = leftbuttonContent, RightButtonContent = rightButtonContent }; var tcs = new TaskCompletionSource<bool>(); messagebox.Dismissed += async (s, e) => { switch (e.Result) { case CustomMessageBoxResult.LeftButton: await leftButtonAction(); tcs.SetResult(true); break; case CustomMessageBoxResult.RightButton: await rightButtonAction(); tcs.SetResult(true); break; case CustomMessageBoxResult.None: tcs.SetResult(false); break; }; }; messagebox.Show(); return tcs.Task; }
private void Use_Zip_Code(object sender, System.Windows.RoutedEventArgs e) { TextBox textBox = new TextBox(); // restrict input to digits: InputScope inputScope = new InputScope(); InputScopeName inputScopeName = new InputScopeName(); inputScopeName.NameValue = InputScopeNameValue.Digits; inputScope.Names.Add(inputScopeName); textBox.InputScope = inputScope; CustomMessageBox messageBox = new CustomMessageBox() { Message = "Enter your US zip code:", LeftButtonContent = "okay", RightButtonContent = "cancel", Content = textBox }; messageBox.Loaded += (a, b) => { textBox.Focus(); }; messageBox.Show(); messageBox.Dismissed += (s, args) => { if (args.Result == CustomMessageBoxResult.LeftButton) { if (textBox.Text.Length >= 5) { geocodeUsingString(textBox.Text); } } }; }
public static void msgBuy() { CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Хотите приобрести расширенную версию?", Message = "Функции: словарь, озвучка слов и аудиролвание предоставляются только в расширенной версии приложения. Хотите приобрести (цена: 34 руб.)? Покупая расширенную версию, Вы поддерживаете дальнейшее создание уроков.", LeftButtonContent = "нет", RightButtonContent = "да", IsFullScreen = false }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: // Do something. break; case CustomMessageBoxResult.RightButton: BuyPro(); break; case CustomMessageBoxResult.None: // Do something. break; default: break; } }; messageBox.Show(); }
//添加分类 private void appbar_buttonAdd_Click(object sender, EventArgs e) { string kind = pivot.SelectedIndex > 0 ? "收入" : "支出"; TextBox txtBox = new TextBox(); CustomMessageBox msgBox = new CustomMessageBox() { Caption = "添加" + kind + "分类", LeftButtonContent = "保存", RightButtonContent = "取消", Content = txtBox }; msgBox.Dismissing += (s1, e1) => { switch(e1.Result) { case CustomMessageBoxResult.LeftButton: SaveCategory(txtBox.Text.Trim()); FreshList(); break; case CustomMessageBoxResult.RightButton: break; case CustomMessageBoxResult.None: break; default: break; } }; msgBox.Show(); }
internal static void CheckForPreviousException(bool isFirstRun) { try { string contents = null; using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { if (store.FileExists(filename)) { using (TextReader reader = new StreamReader(store.OpenFile(filename, FileMode.Open, FileAccess.Read, FileShare.None))) { contents = reader.ReadToEnd(); } SafeDeleteFile(store); } } if (contents != null) { string messageBoxText = null; if (isFirstRun) messageBoxText = "An unhandled error occurred the last time you ran this application. Would you like to send an email to report it?"; else messageBoxText = "An unhandled error has just occurred. Would you like to send an email to report it?"; CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Error Report", Message = messageBoxText, LeftButtonContent = "yes", RightButtonContent = "no", IsFullScreen = false }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: FeedbackHelper.Default.Feedback(contents, true); SafeDeleteFile(IsolatedStorageFile.GetUserStoreForApplication()); break; default: break; } }; messageBox.Show(); } } catch (Exception) { } finally { SafeDeleteFile(IsolatedStorageFile.GetUserStoreForApplication()); } }
//添加商家 private void appbar_buttonAdd_Click(object sender, EventArgs e) { TextBox txtBox = new TextBox(); CustomMessageBox msgBox = new CustomMessageBox() { Caption = "添加商家", LeftButtonContent = "保存", RightButtonContent = "取消", Content = txtBox }; msgBox.Dismissing += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: SaveStore(txtBox.Text.Trim()); StoreListBox.ItemsSource = Common.GetAllStore(); break; case CustomMessageBoxResult.RightButton: break; case CustomMessageBoxResult.None: break; default: break; } }; msgBox.Show(); }
public void Show(string text, string firstOption, string secondOption, Action firstAction, Action secondAction) { Mvx.Resolve<IMvxMainThreadDispatcher>().RequestMainThreadAction(() => { _messageBox = new CustomMessageBox { AllowDrop = false, Message = text, IsLeftButtonEnabled = true, IsRightButtonEnabled = true, LeftButtonContent = firstOption, RightButtonContent = secondOption }; _messageBox.Dismissed += (s, e) => { if (e.Result == CustomMessageBoxResult.LeftButton && firstAction != null) { firstAction(); } else if (e.Result == CustomMessageBoxResult.RightButton && secondAction != null) { secondAction(); } }; _messageBox.Show(); }); }
void CreateTaskList_Click(object sender, EventArgs e) { CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Create tasklist?", Message = "Give a name of a new list.", LeftButtonContent = "OK", RightButtonContent = "Cancel", ContentTemplate = (DataTemplate)Resources["CreateTaskListContentTemplate"] }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: { if (_vm.CreateTaskListCommand.CanExecute(null)) { _vm.CreateTaskListCommand.Execute(null); } break; } } }; messageBox.Show(); }
/// <summary> /// Displays a CustomMessageBox with no content. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event information.</param> private void BasicMessageBox_Click(object sender, RoutedEventArgs e) { CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Do you like this sample?", Message = "There are tons of things you can do using custom message boxes. To learn more, be sure to check out the source code at Codeplex.", LeftButtonContent = "yes", RightButtonContent = "no", IsFullScreen = (bool)FullScreenCheckBox.IsChecked }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: // Do something. break; case CustomMessageBoxResult.RightButton: // Do something. break; case CustomMessageBoxResult.None: // Do something. break; default: break; } }; messageBox.Show(); }
public void ShowDialogBox(string caption, string message, string leftbuttonContent, string rightButtonContent, Action leftButtonAction, Action rightButtonAction) { var messagebox = new CustomMessageBox() { Caption = caption, Message = message, LeftButtonContent = leftbuttonContent, RightButtonContent = rightButtonContent }; messagebox.Dismissed += (s,e) => { switch (e.Result) { case CustomMessageBoxResult.LeftButton: leftButtonAction(); break; case CustomMessageBoxResult.RightButton: rightButtonAction(); break; case CustomMessageBoxResult.None: break; }; }; messagebox.Show(); }
public MainPage() { InitializeComponent(); messageBox = new CustomMessageBox() { Message = "Приложение может использовать данные о вашем местоположении для отображения их на карте (эти данные никуда не передаются и не хранятся). Вы можете отключить это в настройках программы.", Caption = "Разрешить использовать сведения о местоположении?", LeftButtonContent = "Разрешить", RightButtonContent = "Запретить", }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: Settings.IsNavigationEnabled = true; break; case CustomMessageBoxResult.RightButton: case CustomMessageBoxResult.None: Settings.IsNavigationEnabled = false; break; default: break; } }; this.Loaded += (s, e) => { if(!IsolatedStorageSettings.ApplicationSettings.Contains("IsNavigationEnabled")) messageBox.Show(); }; }
public override void Alert(AlertConfig config) { this.Dispatch(() => { var alert = new CustomMessageBox { Caption = config.Title, Message = config.Message, LeftButtonContent = config.OkText, IsRightButtonEnabled = false }; alert.Dismissed += (sender, args) => config.OnOk?.Invoke(); alert.Show(); }); }
public IsoStorageHelper() { settings = IsolatedStorageSettings.ApplicationSettings; //check if an unhandled exception occured last time if (getUnhandledException())//if yes { //show custom message box asking if user wants to submit feedback on it //TODO - ask user if they want to submit feedback on the issue //if yes, compose email with exception details //if no, close the app Deployment.Current.Dispatcher.BeginInvoke(() => { CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Uh-oh! There was an error!", Message = "Would you like to submit the error information to the developer? \n It would help speed up the process of fixing the issue!", LeftButtonContent = "Yes", RightButtonContent = "Nope", }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: { //compose email new Feedback.FeedbackEmail(savedExceptionData); break; } case CustomMessageBoxResult.RightButton: { break; } case CustomMessageBoxResult.None: { break; } default: { break; } } }; messageBox.Show(); }); settings.Remove(Constants.IsolatedStorage.ISO_EXCEPTION);//clear the exception } }
private void CortanaOverlay(string message) { CortanaOverlayData data = new CortanaOverlayData("I heard you say:", message); CustomMessageBox CortanaOverlay = new CustomMessageBox() { ContentTemplate = (DataTemplate)this.Resources["CortanaOverlay"], LeftButtonContent = "Ok", RightButtonContent = "Cancel", IsFullScreen = false, Content = data }; speech(message); CortanaOverlay.Show(); }
public void ShowConfirmMessageBox(string caption, Func<Task> okClickedAsync) { CustomMessageBox messageBox = new CustomMessageBox() { Caption = caption, LeftButtonContent = AppResources.Ok, RightButtonContent = AppResources.Cancel }; messageBox.Dismissed += async (s1, e1) => { if (e1.Result == CustomMessageBoxResult.LeftButton) { await okClickedAsync(); } }; messageBox.Show(); }
// Button event to add default period data into table void btnAddDefault_Click(object sender, RoutedEventArgs e) { bool result = false; AutoResetEvent m = new AutoResetEvent(true); CustomMessageBox auto = new CustomMessageBox(m, "asdasdasd"); auto.Owner = this; auto.Show("asdasdasd"); result = dbManager.RestoreTable(DataBaseName.Period_Type); if (result) { m.Set(); Reload(); } }
public void ShowTrialMessage(string message) { var messageBox = new CustomMessageBox { Title = "Trial", Message = message, LeftButtonContent = "purchase", RightButtonContent = "ok" }; messageBox.Dismissed += (sender, e) => { if (e.Result == CustomMessageBoxResult.LeftButton) { Buy(); } }; messageBox.Show(); }
private void DeleteClicked(object sender, EventArgs e) { if (!GetViewModel().SelectedTags.Any()) { MessageBox.Show("You need to select the tags you want to delete", "Delete tags", MessageBoxButton.OK); return; } var messageBox = new CustomMessageBox { Caption = "Delete tags", Message = "Are you sure you want to delete the selected tags?", LeftButtonContent = "yes", RightButtonContent = "no", IsFullScreen = false }; messageBox.Dismissed += DeleteDismissed; messageBox.Show(); }
void soundButton_Click(object sender, RoutedEventArgs e) { try { string path = HomebrewHelperWP.Registry.ReadString(RegistryHive.HKLM, @"SOFTWARE\Microsoft\EventSounds\Sounds\" + ((Button)sender).Tag, "Sound"); CustomMessageBox custMsgBox = new CustomMessageBox(); custMsgBox.Title = "Change notification sound"; custMsgBox.Tag = ((Button)sender).Tag; custMsgBox.Caption = "Editing sound " + ((Button)sender).Tag; custMsgBox.Message = "Please select a new sound from the list below"; custMsgBox.Content = new RingtoneChooser() { SelectedRingtone = path }; custMsgBox.LeftButtonContent = "cancel"; custMsgBox.RightButtonContent = "save"; custMsgBox.IsFullScreen = true; custMsgBox.Dismissed += custMsgBox_Dismissed; custMsgBox.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btNova_Click(object sender, RoutedEventArgs e) { UCTexto uct = new UCTexto(); CustomMessageBox cmb = new CustomMessageBox() { Content = uct, LeftButtonContent = "Gravar", RightButtonContent = "Cancelar" }; cmb.Dismissing += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: try { if (!string.IsNullOrWhiteSpace(uct.tbTexto.Text)) { Anotacao anotacao = new Anotacao(); anotacao.IdPedido = idPedido; anotacao.Data = anotacao.DataUltimaAlteracao = DateTime.Now; anotacao.Texto = uct.tbTexto.Text; ControleAnotacao ca = new ControleAnotacao(); ca.gravar(anotacao); listAnotacoes.ItemsSource = null; listAnotacoes.ItemsSource = ca.buscar(idPedido); } } catch(Exception ex) { e1.Cancel = true; MessageBox.Show(ex.Message); } break; } }; cmb.Show(); }
private void ApplicationBarIconButton_Click(object sender, EventArgs e) { //Creating a new Page //Adding category to viewmodel box = new CustomMessageBox(); StackPanel sp = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical }; TextBlock txtDescription = new TextBlock(); txtDescription.Text = "Geef de naam van de nieuwe categorie:"; sp.Children.Add(txtDescription); txtNewCategory = new TextBox(); sp.Children.Add(txtNewCategory); box.LeftButtonContent = "Voeg toe"; box.RightButtonContent = "Cancel"; box.Content = sp; box.Dismissing += Box_Dismissing; box.Show(); }
public static void ShowAboutAppMessageBox(string createdByLine, string additionalContentLine) { var firstLineInMessageBox = new TextBlock() { Margin = new Thickness(10, 0, 0, 0), Text = createdByLine }; var secondLineInMessageBox = new TextBlock() { TextWrapping = System.Windows.TextWrapping.Wrap, Margin = new Thickness(10, 10, 20, 0), Text = additionalContentLine }; var hyperlinkButton = new HyperlinkButton() { Content = AppResources.CreatorEmail, Margin = new Thickness(0, 28, 0, 8), HorizontalAlignment = HorizontalAlignment.Left, NavigateUri = new Uri("mailto://" + AppResources.CreatorEmail, UriKind.Absolute) }; var contentStackPanel = new StackPanel(); contentStackPanel.Children.Add(firstLineInMessageBox); contentStackPanel.Children.Add(hyperlinkButton); contentStackPanel.Children.Add(secondLineInMessageBox); Version version = Assembly.GetExecutingAssembly().GetName().Version; CustomMessageBox messageBox = new CustomMessageBox() { Caption = String.Format("{0} {1} v{2}.{3}\nbuild {4}", AppResources.AboutSentence, AppResources.ApplicationTitle, version.Major, version.Minor, version.Build), Content = contentStackPanel, LeftButtonContent = "OK" }; messageBox.Show(); }
/// <summary> /// Handles the Click event of the BUT_rerequestparams control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void BUT_rerequestparams_Click(object sender, EventArgs e) { if (!MainV2.comPort.BaseStream.IsOpen) { return; } ((Control)sender).Enabled = false; try { MainV2.comPort.getParamList(); } catch (Exception ex) { CustomMessageBox.Show("Error: getting param list " + ex, Strings.ERROR); } ((Control)sender).Enabled = true; Activate(); }
bool getFirmwareLocal(uploader.Uploader.Board device) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Firmware|*.hex;*.ihx"; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = false; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { File.Copy(openFileDialog1.FileName, firmwarefile, true); } catch (Exception ex) { CustomMessageBox.Show("Error copying file\n" + ex.ToString(), "ERROR"); return(false); } return(true); } return(false); }
public override async Task ShowNotification(string notification, NotificationType notificationType) { var messageBox = new CustomMessageBox { Caption = Service.Current.Messages[notificationType.ToString()], Message = notification, LeftButtonContent = Service.Current.Messages["OK"], RightButtonContent = Service.Current.Messages["Copy"] }; var waiter = new AutoResetEvent(false); messageBox.Dismissed += (s1, e1) => { if (e1.Result == CustomMessageBoxResult.RightButton) Clipboard.SetText(notification); waiter.Set(); }; messageBox.Show(); await Task.Factory.StartNew(() => waiter.WaitOne()); }
private void BUT_rerequestparams_Click(object sender, EventArgs e) { if (!MainV2.comPort.BaseStream.IsOpen) { return; } ((MyButton)sender).Enabled = false; try { MainV2.comPort.getParamList(); } catch { CustomMessageBox.Show("Error: getting param list"); } ((MyButton)sender).Enabled = true; startup = true; startup = false; }
private void BUT_start_Click(object sender, EventArgs e) { ((MyButton)sender).Enabled = false; BUT_continue.Enabled = true; busy = true; try { // start the process off MainV2.comPort.doCommand(MAVLink.MAV_CMD.PREFLIGHT_CALIBRATION, 0, 0, 0, 0, 1, 0, 0); MainV2.comPort.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.STATUSTEXT, receivedPacket); } catch { busy = false; CustomMessageBox.Show(Strings.ErrorNoResponce, Strings.ERROR); return; } BUT_continue.Focus(); }
public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { CustomMessageBox.Show("You are no longer connected to the board\n the wizard will now exit", "Error"); Wizard.instance.Close(); return; } if (MainV2.comPort.MAV.param.ContainsKey("FRAME")) { ConfigFrameType.Frame frame = (ConfigFrameType.Frame)(int)(float) MainV2.comPort.MAV.param["FRAME"]; switch (frame) { case ConfigFrameType.Frame.X: pictureBox_Click(pictureBoxMouseOverX, new EventArgs()); break; case ConfigFrameType.Frame.Plus: pictureBox_Click(pictureBoxMouseOverplus, new EventArgs()); break; case ConfigFrameType.Frame.V: pictureBox_Click(pictureBoxMouseOvertrap, new EventArgs()); break; case ConfigFrameType.Frame.H: pictureBox_Click(pictureBoxMouseOverH, new EventArgs()); break; case ConfigFrameType.Frame.Y: pictureBox_Click(pictureBoxMouseOverY, new EventArgs()); break; } } }
private void downloadsinglethread() { try { for (int i = 0; i < CHK_logs.CheckedItems.Count; ++i) { int a = (int)CHK_logs.CheckedItems[i]; currentlog = a; var logname = GetLog((ushort)a); CreateLog(logname); if (chk_droneshare.Checked) { try { Utilities.DroneApi.droneshare.doUpload(logname); } catch (Exception ex) { CustomMessageBox.Show("Droneshare upload failed " + ex.ToString()); } } } status = serialstatus.Done; updateDisplay(); Console.Beep(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error in log " + currentlog); } }
private void BUT_Accept_Click(object sender, EventArgs e) { if (grid != null && grid.Count > 0) { if (rad_trigdist.Checked) { plugin.Host.comPort.setParam("CAM_TRIGG_DIST", (float)NUM_spacing.Value); } grid.ForEach(plla => { if (plla.Tag == "M") { if (rad_repeatservo.Checked) { plugin.Host.AddWPtoList(ArdupilotMega.MAVLink.MAV_CMD.WAYPOINT, 0, 0, 0, 0, plla.Lng, plla.Lat, plla.Alt); plugin.Host.AddWPtoList(ArdupilotMega.MAVLink.MAV_CMD.DO_REPEAT_SERVO, (float)num_reptservo.Value, (float)num_reptpwm.Value, 999, (float)num_repttime.Value, 0, 0, 0); } if (rad_digicam.Checked) { plugin.Host.AddWPtoList(ArdupilotMega.MAVLink.MAV_CMD.WAYPOINT, 0, 0, 0, 0, plla.Lng, plla.Lat, plla.Alt); plugin.Host.AddWPtoList(ArdupilotMega.MAVLink.MAV_CMD.DO_DIGICAM_CONTROL, 0, 0, 0, 0, 0, 0, 0); } } else { plugin.Host.AddWPtoList(ArdupilotMega.MAVLink.MAV_CMD.WAYPOINT, 0, 0, 0, 0, plla.Lng, plla.Lat, plla.Alt); } }); this.Close(); } else { CustomMessageBox.Show("Bad Grid", "Error"); } }
private void btnOK_Click(object sender, RoutedEventArgs e) { try { DetailModel = new FixtureFurnaceDetailEntity(); ObjectReflection.AutoMapping(Model, DetailModel); //明细表 DetailModel.FFDState = (int)Enum.Parse(typeof(FFDState), cmbFFDState.SelectedValue.ToString()); DetailModel.FFDIsAccomplish = (int)Enum.Parse(typeof(YesOrNoType), Accomplish.SelectedValue.ToString()); DetailModel.CAId = cmbCAI.SelectedValue == null ? 0 : (int)cmbCAI.SelectedValue; if (operateType == 1) { if ((new FixtureFurnaceDetailDB().Insert(DetailModel) < 1)) { CustomMessageBox.Show("添加数据过程出现错误!", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question); return; } } else { if (!(new FixtureFurnaceDetailDB()).Update(DetailModel)) { CustomMessageBox.Show("修改数据过程出现错误!", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question); return; } } this.DialogResult = new bool?(true); this.Close(); } catch (Exception ex) { MessageBoxX.Error(ex.Message); } }
public bool UpdateUserInfo(Employee employee) { try { OpenConnection(); string query = "update Employee set name=@name,gender=@gender,phonenumber=@phonenumber,address=@address," + "dateofBirth=@dateofBirth, imageFile=@imageFile where idEmployee=" + employee.IdEmployee; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@name", employee.Name); cmd.Parameters.AddWithValue("@gender", employee.Gender); cmd.Parameters.AddWithValue("@phoneNumber", employee.PhoneNumber); cmd.Parameters.AddWithValue("@address", employee.Address); cmd.Parameters.AddWithValue("@dateofBirth", employee.DateOfBirth); cmd.Parameters.AddWithValue("@imageFile", Convert.ToBase64String(employee.ImageFile)); int row = cmd.ExecuteNonQuery(); if (row != 1) { throw new Exception(); } else { return(true); } } catch (Exception e) { CustomMessageBox.Show(e.Message.ToString(), "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } finally { CloseConnection(); } }
public static void doUpload(string file) { doUserAndPassword(); string droneshareusername = MainV2.getConfig("droneshareusername"); string dronesharepassword = MainV2.getConfig("dronesharepassword"); if (dronesharepassword != "") { try { // fail on bad entry var crypto = new Crypto(); dronesharepassword = crypto.DecryptString(dronesharepassword); } catch { } } MAVLinkInterface mav = new MAVLinkInterface(); mav.BaseStream = new Comms.CommsFile(); mav.BaseStream.PortName = file; mav.getHeartBeat(); mav.Close(); string viewurl = Utilities.DroneApi.droneshare.doUpload(file, droneshareusername, dronesharepassword, mav.MAV.Guid, Utilities.DroneApi.APIConstants.apiKey); if (viewurl != "") { try { System.Diagnostics.Process.Start(viewurl); } catch (Exception ex) { log.Error(ex); CustomMessageBox.Show("Failed to open url " + viewurl); } } }
private void SendPassWithMail(User user) { try { var from = new MailAddress("*****@*****.**"); // make custom mail adress var to = new MailAddress(user.Email); var newPas = AESEncryptor.encryptPassword(RandomNumberGenerator.RandomPassword()); user.Password = newPas; UserServiceClient.AddOrUpdateUser(user); var message = new MailMessage(from, to); message.Subject = "Password restore"; message.Body = "Your pass - " + AESEncryptor.decryptPassword(newPas); var smtp = new SmtpClient("smtp.gmail.com", 587); smtp.Credentials = new NetworkCredential("*****@*****.**", "messageApp1"); smtp.EnableSsl = true; smtp.SendMailAsync(message); Application.Current.Dispatcher.Invoke(new Action((() => { try { CustomMessageBox.Show(Translations.GetTranslation()["RestorePass"].ToString(), Application.Current.Resources.MergedDictionaries[4]["EmailSend"].ToString()); IsSending = false; } finally { } }))); } finally { } }
private void BUT_writePIDS_Click(object sender, EventArgs e) { var temp = (Hashtable)changes.Clone(); foreach (string value in temp.Keys) { try { if ((float)changes[value] > (float)MainV2.comPort.MAV.param[value] * 2.0f) { if (CustomMessageBox.Show(value + " has more than doubled the last input. Are you sure?", "Large Value", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } MainV2.comPort.setParam(value, (float)changes[value]); try { // set control as well var textControls = this.Controls.Find(value, true); if (textControls.Length > 0) { textControls[0].BackColor = Color.FromArgb(0x43, 0x44, 0x45); } } catch { } } catch { CustomMessageBox.Show("Set " + value + " Failed", "Error"); } } }
public void Activate() { if (!MainV2.comPort.BaseStream.IsOpen) { CustomMessageBox.Show(Strings.ErrorNotConnected, Strings.ERROR); Wizard.instance.Close(); return; } if (MainV2.comPort.MAV.param.ContainsKey("FRAME")) { ConfigFrameType.Frame frame = (ConfigFrameType.Frame)(int) (float) MainV2.comPort.MAV.param["FRAME"]; switch (frame) { case ConfigFrameType.Frame.X: pictureBox_Click(pictureBoxMouseOverX, new EventArgs()); break; case ConfigFrameType.Frame.Plus: pictureBox_Click(pictureBoxMouseOverplus, new EventArgs()); break; case ConfigFrameType.Frame.V: pictureBox_Click(pictureBoxMouseOvertrap, new EventArgs()); break; case ConfigFrameType.Frame.H: pictureBox_Click(pictureBoxMouseOverH, new EventArgs()); break; case ConfigFrameType.Frame.Y: pictureBox_Click(pictureBoxMouseOverY, new EventArgs()); break; } } }
private void btnOpen_Click(object sender, EventArgs e) { var openDialog = new OpenFileDialog(); if (openDialog.ShowDialog() == DialogResult.OK) { try { var points = Newtonsoft.Json.JsonConvert.DeserializeObject <List <RoiPoint> >( File.ReadAllText(openDialog.FileName)); this.roiPoints.Clear(); this.roiPoints.AddRange(points); CustomMessageBox.Show("Points loaded: " + this.roiPoints.Count, Strings.OK); this.Close(); } catch (Exception ex) { CustomMessageBox.Show("Open failed. " + ex.Message, Strings.ERROR); } } }
void findfirmware(Utilities.Firmware.software fwtoupload) { DialogResult dr = CustomMessageBox.Show(Strings.AreYouSureYouWantToUpload + fwtoupload.name + Strings.QuestionMark, Strings.Continue, MessageBoxButtons.YesNo); if (dr == System.Windows.Forms.DialogResult.Yes) { try { MainV2.comPort.BaseStream.Close(); } catch { } fw.Progress -= fw_Progress; fw.Progress += fw_Progress1; string history = (CMB_history.SelectedValue == null) ? "" : CMB_history.SelectedValue.ToString(); bool updated = fw.update(MainV2.comPortName, fwtoupload, history); if (updated) { if (fwtoupload.url2560_2 != null && fwtoupload.url2560_2.ToLower().Contains("copter") && fwtoupload.name.ToLower().Contains("3.1")) { CustomMessageBox.Show(Strings.WarningAC31, Strings.Warning); } if (fwtoupload.url2560_2 != null && fwtoupload.url2560_2.ToLower().Contains("copter") && fwtoupload.name.ToLower().Contains("3.2")) { CustomMessageBox.Show(Strings.WarningAC32, Strings.Warning); } } else { CustomMessageBox.Show(Strings.ErrorUploadingFirmware, Strings.ERROR); } } }
private void txtItemType_KeyDown(object pObjSender, KeyEventArgs pObjArgs) { try { if (pObjArgs.Key == Key.Enter & ((pObjSender as TextBox).AcceptsReturn == false) && (pObjSender as TextBox).Focus()) { string lStrText = (pObjSender as TextBox).Text; //mObjInventoryFactory.GetItemDefinitionService().GetHeadTypeRelation(x.ItemId,lObjGoodsIssue.Batch.ItemTypeId) List <ItemType> lLstObjItemTypes = mObjInventoryFactory.GetItemTypeService() .SearchItemTypeByAuctionType(lStrText, AuctionType, FilterEnum.AUCTION) .Where(x => !x.Removed && (mObjInventoryFactory.GetItemDefinitionService().GetDefinitions(x.Id))).Select(y => y).ToList(); if (lLstObjItemTypes.Count == 1) { SetItemTypeObject(lLstObjItemTypes[0]); } else { (pObjSender as TextBox).Focusable = false; UserControl lUCItemType = new UCSearchItemType(lStrText, AuctionType, lLstObjItemTypes, FilterEnum.AUCTION); SetItemTypeObject(FunctionsUI.ShowWindowDialog(lUCItemType, this.GetParent()) as ItemType); (pObjSender as TextBox).Focusable = true; } } } catch (Exception lObjException) { CustomMessageBox.Show("Error", lObjException.Message, this.GetParent()); } }
private void GetCRC32ToolStripMenuItem_Click(object sender, EventArgs e) { ProgressReporterDialogue prd = new ProgressReporterDialogue(); CancellationTokenSource cancel = new CancellationTokenSource(); prd.doWorkArgs.CancelRequestChanged += (o, args) => { prd.doWorkArgs.ErrorMessage = "User Cancel"; cancel.Cancel(); _mavftp.kCmdResetSessions(); }; prd.doWorkArgs.ForceExit = false; var crc = 0u; prd.DoWork += (iprd) => { _mavftp.kCmdCalcFileCRC32(treeView1.SelectedNode.FullPath + "/" + listView1.SelectedItems[0].Text, ref crc, cancel); }; prd.RunBackgroundOperationAsync(); CustomMessageBox.Show(listView1.SelectedItems[0].Text + ": 0x" + crc.ToString("X")); }
private async Task GetRuc() { bool canConvert = long.TryParse(txtRUC.Text, out long Ruc); if (canConvert && txtRUC.Text.Length == 11) { try { RUC ruc = await ConsultaRuc.GetRuc(txtRUC.Text); if (ruc != null) { txtRazonSocial.Text = ruc.datos.result.razon_social; txtDireccion.Text = ruc.datos.result.direccion; } await Dispatcher.BeginInvoke(new System.Action(() => { Keyboard.Focus(txtRepresentanteLegal); }), System.Windows.Threading.DispatcherPriority.Loaded); } catch (Exception ex) { DialogResult result = CustomMessageBox.Show($"{ex.Message}", CustomMessageBox.CMessageBoxTitle.Información, CustomMessageBox.CMessageBoxButton.Aceptar, CustomMessageBox.CMessageBoxButton.No); } } }
private void txtAuctions_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { try { Auction lObjAuction = null; if ((e.Key == Key.Enter & ((sender as TextBox).AcceptsReturn == false) && (sender as TextBox).Focus()) || e.Key == Key.Tab) { IList <Auction> lLstAuction = SearchAuctions((sender as TextBox).Text); if (lLstAuction.Count == 1) { lObjAuction = lLstAuction[0]; } else { (sender as TextBox).Focusable = false; UserControl lUCAuction = new UCSearchAuction(txtSearchAuction.Text, lLstAuction.ToList(), FilterEnum.ACTIVE, AuctionSearchModeEnum.AUCTION); // new UCAuction(true, lLstAuction.ToList(), (sender as TextBox).Text); lObjAuction = FunctionsUI.ShowWindowDialog(lUCAuction, Window.GetWindow(this)) as Auction; (sender as TextBox).Focusable = true; } (sender as TextBox).Focus(); if (lObjAuction != null) { SetControls(lObjAuction); LoadDatagrid(); } else { (sender as TextBox).Focus(); } } } catch (Exception lObjException) { CustomMessageBox.Show("Subasta", lObjException.Message, Window.GetWindow(this)); } }
private void but_start_Click(object sender, EventArgs e) { if (threadrun == true) { threadrun = false; but_start.Text = Strings.Start; return; } foreach (var port in MainV2.Comports) { foreach (var MAV in port.MAVlist) { if (MAV.cs.armed && MAV.cs.alt > 1) { var result = CustomMessageBox.Show("There appears to be a drone in the air at the moment. Are you sure you want to continue?", "continue", MessageBoxButtons.YesNo); if (result == (int)DialogResult.Yes) { break; } return; } } } zedGraphControl1.AxisChange(); //if (SwarmInterface != null) { new System.Threading.Thread(mainloop) { IsBackground = true }.Start(); but_start.Text = Strings.Stop; } }
private void BUT_test_pitch_Click(object sender, EventArgs e) { double output = 1500; if (mavlinkCheckBox2.Checked) { output = map(myTrackBar2.Value, myTrackBar2.Maximum, myTrackBar2.Minimum, (double)mavlinkNumericUpDown6.Value, (double)mavlinkNumericUpDown5.Value); } else { output = map(myTrackBar2.Value, myTrackBar2.Minimum, myTrackBar2.Maximum, (double)mavlinkNumericUpDown6.Value, (double)mavlinkNumericUpDown5.Value); } try { MainV2.comPort.doCommand(MAVLink.MAV_CMD.DO_SET_SERVO, 2, (float)output, 0, 0, 0, 0, 0); } catch { CustomMessageBox.Show(Strings.ErrorNoResponce, Strings.ERROR); } }
private void Control_OnPolygonClick(GMapPolygon item, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { return; } if (item.Overlay.Control.IsDragging) { return; } if (_mapControl.Overlays.First(x => x.Polygons.Any(i => i.Name == item.Name)) != null) { if (item.Tag is Feature) { var prop = ((Feature)item.Tag).Properties; var st = String.Format("{0} is categorised as {1}", prop["name"], prop["detailedCategory"]); CustomMessageBox.Show(st, "Info", MessageBoxButtons.OK); } } }
private void BUT_Accept_Click(object sender, EventArgs e) { if (grid != null && grid.Count > 0) { grid.ForEach(plla => { if (plla.Tag == "M") { } else { plugin.Host.AddWPtoList(MAVLink.MAV_CMD.WAYPOINT, 0, 0, 0, 0, plla.Lng, plla.Lat, plla.Alt); } }); savesettings(); this.Close(); } else { CustomMessageBox.Show("Bad Grid", "Error"); } }
private void openMessage(object sender, RoutedEventArgs e) { List<string> list = new List<string>(); for (int i = 0; i < 16; i++) { list.Add("Teste " + i); } LongListSelector longList = new LongListSelector(); longList.ItemTemplate = (DataTemplate)Application.Current.Resources["listContent"]; longList.ItemsSource = list; CustomMessageBox customMessageBox = new CustomMessageBox() { Title = "Hotel Urbano", Background = new SolidColorBrush(Colors.White), Foreground = new SolidColorBrush(Colors.Black), Content = longList, LeftButtonContent = "Fechar" }; customMessageBox.Show(); }
public static void DoUpdate() { if (Program.WindowsStoreApp) { CustomMessageBox.Show(Strings.Not_available_when_used_as_a_windows_store_app); return; } IProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue() { Text = "Check for Updates", StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen }; ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.DoWork += new DoWorkEventHandler(DoUpdateWorker_DoWork); frmProgressReporter.UpdateProgressAndStatus(-1, "Checking for Updates"); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var zoomPanel = new ZoomPanel { Image = new Image() { Source = Image.Source }, Height = Application.Current.RootVisual.RenderSize.Height, Width = Application.Current.RootVisual.RenderSize.Width, }; var customMessageBox = new CustomMessageBox { Title = Title, Message = Message, Content = zoomPanel, IsLeftButtonEnabled = false, IsRightButtonEnabled = false, IsFullScreen = true }; customMessageBox.Show(); }
private void downloadthread(int startlognum, int endlognum) { try { for (int a = startlognum; a <= endlognum; a++) { currentlog = a; System.Threading.Thread.Sleep(1100); comPort.Write("dump "); System.Threading.Thread.Sleep(100); comPort.Write(a.ToString() + "\r"); comPort.DiscardInBuffer(); status = serialstatus.Createfile; while (status != serialstatus.Done) { System.Threading.Thread.Sleep(100); } } Console.Beep(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } }
private void BUT_reset_params_Click(object sender, EventArgs e) { if ( CustomMessageBox.Show("Reset all parameters to default\nAre you sure!!", "Reset", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { MainV2.comPort.setParam(new[] { "FORMAT_VERSION", "SYSID_SW_MREV" }, 0); Thread.Sleep(1000); MainV2.comPort.doReboot(false); MainV2.comPort.BaseStream.Close(); CustomMessageBox.Show( "Your board is now rebooting, You will be required to reconnect to the autopilot."); } catch (Exception ex) { log.Error(ex); CustomMessageBox.Show(Strings.ErrorCommunicating + "\n" + ex, Strings.ERROR); } } }
void loadBasePosList() { if (File.Exists(basepostlistfile)) { //load config System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(List <PointLatLngAlt>), new Type[] { typeof(Color) }); using (StreamReader sr = new StreamReader(basepostlistfile)) { try { baseposList = (List <PointLatLngAlt>)reader.Deserialize(sr); } catch (Exception ex) { log.Error(ex); CustomMessageBox.Show("Failed to load Base Position List\n" + ex.ToString(), Strings.ERROR); } } } updateBasePosDG(); }
/// <summary> /// Excel 내보내기 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnExport_Click(object sender, EventArgs e) { using (SaveFileDialog sfd = new SaveFileDialog()) { if (grdFrameInfo.Rows.Count == 0) { DialogResult result = CustomMessageBox.Show(MessageBoxButtons.OK, "확인", "엑셀 데이터가 없습니다."); } else { sfd.Filter = "csv(*.csv) | *.csv"; DialogResult result = CustomMessageBox.Show(MessageBoxButtons.OKCancel, "확인", "엑셀 저장 하시겠습니까?"); if (result == DialogResult.OK) { if (sfd.ShowDialog() == DialogResult.OK) { this.SaveCsv(sfd.FileName, grdFrameInfo, true); } } } } }
private void BUT_SaveModes_Click(object sender, EventArgs e) { try { if (MainV2.comPort.param.ContainsKey("FLTMODE1")) { MainV2.comPort.setParam("FLTMODE1", (float)Int32.Parse(CMB_fmode1.SelectedValue.ToString())); MainV2.comPort.setParam("FLTMODE2", (float)Int32.Parse(CMB_fmode2.SelectedValue.ToString())); MainV2.comPort.setParam("FLTMODE3", (float)Int32.Parse(CMB_fmode3.SelectedValue.ToString())); MainV2.comPort.setParam("FLTMODE4", (float)Int32.Parse(CMB_fmode4.SelectedValue.ToString())); MainV2.comPort.setParam("FLTMODE5", (float)Int32.Parse(CMB_fmode5.SelectedValue.ToString())); MainV2.comPort.setParam("FLTMODE6", (float)Int32.Parse(CMB_fmode6.SelectedValue.ToString())); } else if (MainV2.comPort.param.ContainsKey("MODE1")) { MainV2.comPort.setParam("MODE1", (float)Int32.Parse(CMB_fmode1.SelectedValue.ToString())); MainV2.comPort.setParam("MODE2", (float)Int32.Parse(CMB_fmode2.SelectedValue.ToString())); MainV2.comPort.setParam("MODE3", (float)Int32.Parse(CMB_fmode3.SelectedValue.ToString())); MainV2.comPort.setParam("MODE4", (float)Int32.Parse(CMB_fmode4.SelectedValue.ToString())); MainV2.comPort.setParam("MODE5", (float)Int32.Parse(CMB_fmode5.SelectedValue.ToString())); MainV2.comPort.setParam("MODE6", (float)Int32.Parse(CMB_fmode6.SelectedValue.ToString())); } if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2) // ac2 { float value = (float)(CB_simple1.Checked ? (int)SimpleMode.Simple1 : 0) + (CB_simple2.Checked ? (int)SimpleMode.Simple2 : 0) + (CB_simple3.Checked ? (int)SimpleMode.Simple3 : 0) + (CB_simple4.Checked ? (int)SimpleMode.Simple4 : 0) + (CB_simple5.Checked ? (int)SimpleMode.Simple5 : 0) + (CB_simple6.Checked ? (int)SimpleMode.Simple6 : 0); if (MainV2.comPort.MAV.param.ContainsKey("SIMPLE")) { MainV2.comPort.setParam("SIMPLE", value); } } } catch { CustomMessageBox.Show("Failed to set Flight modes"); } BUT_SaveModes.Text = "Complete"; }
private void Button_Click(object sender, RoutedEventArgs e) { var textbox = new TextBox(); var box = new CustomMessageBox { Caption = "Locale", Title = "Please enter a locale", LeftButtonContent = AppResources.Ok, RightButtonContent = AppResources.Cancel, Content = textbox, IsFullScreen = false }; box.Dismissed += (s, ee) => { if (ee.Result == CustomMessageBoxResult.LeftButton) { var locale = textbox.Text; var culture = new CultureInfo(locale); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } }; box.Show(); }
private void ButtonAddFriend_Click(object sender, EventArgs e) { string username = App.IsolatedStorage.UserAccount.UserName; string authToken = App.IsolatedStorage.UserAccount.AuthToken; var messageBox = new CustomMessageBox { Caption = "Add a Friend", Message = "Enter the Snapchat Username of the friend you want to add.", Content = new PhoneTextBox {Text = "", Hint = "Snapchat Username", Margin = new Thickness(0, 10, 20, 0)}, LeftButtonContent = "cancel", RightButtonContent = "done", IsFullScreen = false }; messageBox.Dismissed += async (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.RightButton: // rename var mb = ((CustomMessageBox) s1); if (mb == null) return; var textbox = ((PhoneTextBox) mb.Content); if (textbox == null) return; SetProgress("Sending Snapchat Friend Request...", true); FriendAction response = await Functions.Friend(textbox.Text, "add", username, authToken); HideProgress(true); Dispatcher.BeginInvoke(delegate { if (response == null) { // TODO: tell user shit failed } else if (!response.Logged) { // Logged Out // TODO: Sign Out } else if (response.Object != null) { // le worked try { App.IsolatedStorage.UserAccount.Friends.Add(response.Object); RefreshBindings(); MessageBox.Show("", "Success", MessageBoxButton.OK); } catch (Exception ex) { // TODO: tell user something bad happened } } // TODO: tell user shit failed }); break; case CustomMessageBoxResult.LeftButton: case CustomMessageBoxResult.None: default: break; } }; messageBox.Show(); }