private void SelectAudio_Click(object sender, RoutedEventArgs e) { // 选择文件 OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Mp3|*.mp3|Wave|*.wav|MIDI|*.midi|所有文件|*.*"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { AudioPath = dlg.FileName; try { Player.Load(dlg.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error); // AudioName.Text = "请选择正确的音频文件"; return; } AudioName.Text = dlg.FileName; AudioProgress.Maximum = Player.TotalTime.TotalSeconds; AudioProgress.Value = 0; SetPanalUsable(true); TotalTime.Content = Time2String(Player.TotalTime); Pause.Content = "Play"; Timer.Start(); } }
private void LoginBtn_OnClick(object sender, RoutedEventArgs e) { try { var data = $"{ LoginTBox.Text },{ PasswordTBox.Text },old"; var response = Arg.Client.Connect(Arg.Ip, Arg.Port, data); if (response.Code == StatusCodes.NotAccount) { MessageBox.Show( "Введенное вами имя пользователя не принадлежит аккаунту. Проверьте свое имя пользователя и повторите попытку.", "Ошибка Входа", MessageBoxButton.OK, MessageBoxImage.Error); } else if (response.Code == StatusCodes.OK) { Arg.Username = LoginTBox.Text; Close(); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private void RegisterBtn_OnClick(object sender, RoutedEventArgs e) { try { var data = $"{ LoginTBox.Text },{ PasswordTBox.Text },new"; var response = Arg.Client.Connect(Arg.Ip, Arg.Port, data); if (response.Code == StatusCodes.ExistAccount) { MessageBox.Show( "Это имя пользователя уже занято. Попробуйте другое.", "Ошибка Регистрации", MessageBoxButton.OK, MessageBoxImage.Error); } else if (response.Code == StatusCodes.OK) { Arg.Username = LoginTBox.Text; Close(); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
/// <summary> /// 代码另存为 /// </summary> public void CodeSaveAs(string activeTabName, ref string code) { var saveFileDialog = new SaveFileDialog { Filter = "Python files|*.py", FilterIndex = 2, RestoreDirectory = true, FileName = "Untitled-1.py" }; if (saveFileDialog.ShowDialog() == true) { FileSystemWatcher.Path = Path.GetDirectoryName(saveFileDialog.FileName); FileSystemWatcher.EnableRaisingEvents = true; if (FileNameDic.Values.Contains(saveFileDialog.FileName)) { MessageBox.Show(Properties.Langs.Lang.ScriptIsOpen); return; } using (var sw = new StreamWriter(saveFileDialog.FileName)) { sw.Write(code); Messenger.Default.Send(saveFileDialog.FileName, MessageToken.UpdateScriptName); FileNameDic[activeTabName] = saveFileDialog.FileName; var path = saveFileDialog.FileName.Replace('\\', '/'); _editorUiInfo.Browser.ExecuteJavascript("setFileInfo", activeTabName, path, Path.GetFileName(saveFileDialog.FileName)); } } }
private void Downqueue_StateChangedEvent(TaskState state, object message) { Dispatcher.Invoke(() => { try { switch (state) { case TaskState.Prepared: DownProgress.Minimum = 0; DownProgress.Maximum = 1; break; case TaskState.Loading: DownName.Text = $"正在升级:{Downqueue.Caption}"; Console.WriteLine(Downqueue.Progress); DownProgress.Value = Math.Round(Downqueue.Progress, 2); DownPercent.Text = $"{(int) (Downqueue.Progress * 100)}%"; break; case TaskState.Paused: break; case TaskState.Broken: Console.WriteLine(((Exception)message).Message); MessageBox.Show(((Exception)message).Message, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error); Close(); break; case TaskState.Finished: if (Downqueue != null) { SignoutDowner(); } DownName.Text = "升级完成"; DownProgress.Value = 1; DownPercent.Text = "100%"; //var programPath = $@"{Function.Instance.InstallPath}\Launcher.exe"; //if (File.Exists(programPath)) //{ // Process.Start(programPath); //} Close(); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } } catch { // ignored } }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ConfigHelper.Instance.SetWindowDefaultStyle(); DispatcherUnhandledException += (s, args) => { MessageBox.Show(args.Exception.ToString()); args.Handled = true; }; }
public static bool Save(ref string info) { try { File.WriteAllText(_saveInfoPath, info); return(true); } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }
private void DiscoverDecMethod_Click(object sender, RoutedEventArgs e) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (AssemblyLocation.Text != string.Empty) { Utils.DiscoverMethod(new string[] { AssemblyLocation.Text, DecName.Text, ParamsC.Text }, new Logger(StringLogger)); } else { MessageBox.Show("Load Assembly First !", "-_-", MessageBoxButton.OK, MessageBoxImage.Error); } })); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MessageBoxResult result; result = MessageBox.Show("您确定要退出吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { // TODO: 这里做保存工作 } else { e.Cancel = true; } }
private void RemoveButton_Click(object sender, RoutedEventArgs e) { Application.Current.MainWindow.Dispatcher.BeginInvoke(new Action(() => { if (ProtectionsToUse.SelectedItem != null) { ProtectionsToUse.Items.Remove(ProtectionsToUse.SelectedItem); } else { MessageBox.Show("Error Select Item First !", "Error..", MessageBoxButton.OK, MessageBoxImage.Error); } })); }
private void Exit_Click(object sender, RoutedEventArgs e) { MessageBoxResult result; result = MessageBox.Show("您确定要退出吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { // TODO: 这里做保存工作 Close(); } else { return; } }
private void AddButton_Click(object sender, RoutedEventArgs e) { Application.Current.MainWindow.Dispatcher.BeginInvoke(new Action(() => { if (UserProtectionList.SelectedItem != null) { ProtectionsToUse.Items.Add(new ListBoxItem() { Content = UserProtectionList.Text }); UserProtectionList.Text = string.Empty; } else { MessageBox.Show("Error Protection Is Empty !", "Error..", MessageBoxButton.OK, MessageBoxImage.Error); } })); }
private void SaveFunc() { if (DataView.Items.Count == 0) { MessageBox.Show("内容不能为空", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //int i = CheckTimeFormat(); //if (i >= 0) //{ // DataView.SelectedIndex = i; // DataView.ScrollIntoView(DataView.SelectedItem); // MessageBox.Show("时间格式错误", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); // return; //} if (LrcPath == null) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "LRC文件|*.Lrc|文本文件|*.txt"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LrcPath = dlg.FileName; FormatSaveFunc(LrcPath); Title = "Lrc Edit -" + LrcPath; } } else { int a = CheckTimeFormat(); //if (a >= 0) //{ // DataView.SelectedIndex = a; // DataView.ScrollIntoView(DataView.SelectedItem); // MessageBox.Show("时间格式错误", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); // return; //} //else //{ FormatSaveFunc(LrcPath); //e} } }
public void Delete() { if (MessageBox.Show("Remove task?", "Info", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } foreach (var item in ItemList) { if (item.GetType() == typeof(TrackTask)) { ((TrackTask)item).Cancel(); } else if (item.GetType() == typeof(VideoTask)) { ((VideoTask)item).Cancel(); } } VMParent.DeleteTask(this); }
private void StartButton_Click(object sender, RoutedEventArgs e) { if (AssemblyLocation.Text == string.Empty) { MessageBox.Show("No Assembly Loaded !", "-_-"); return; } Context Context = null; List <string> TempProtects = new List <string>(); TempProtects.Clear(); /*Application.Current.Dispatcher.BeginInvoke(new Action(() => {*/ Context = new Context(AssemblyLocation.Text, new Logger[] { GetLog, new Logger(StringLogger) }); Context.Log.Clear(); foreach (var ListItem in ProtectionsToUse.Items) { TempProtects.Add((string)((ListBoxItem)ListItem).Content); } /*}));*/ new Thread(new ThreadStart(() => { try { foreach (var Protection in TempProtects) { foreach (var ProtectExecute in ProtectionsAvailable) { if (ProtectExecute.Name.Equals(Protection)) { Context.Log.Info($"Executing : {ProtectExecute.Name}"); ProtectExecute.Execute(Context); Context.Log.Info($"Executed : {ProtectExecute.Name} Successfly !"); } } } Context.SaveContext(); } catch (Exception ex) { MessageBox.Show($"Error : {ex.Message}", "Uhm -_-", MessageBoxButton.OK, MessageBoxImage.Error); } })).Start(); }
private void Card_MouseDown(object sender, MouseButtonEventArgs e) { if (MessageBox.Show(new MessageBoxInfo() { IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.AskGeometry, Message = "¿Descartar este registro?", Caption = "Atención", Button = MessageBoxButton.YesNo, //YesContent = "No", //NoContent = "Sí" }) == MessageBoxResult.Yes) { var region = this.RegionManager.Regions["ContentRegion"]; object ordersView = region.ActiveViews.FirstOrDefault(x => x is ApplicantRegister); if (ordersView != null) { region.Remove(ordersView); } this.RegionManager.RequestNavigate("ContentRegion", nameof(LogIn)); } }
private void TryGetFileHash() { try { var fixWebClient = new WebClient(); var webStream = fixWebClient.OpenRead($"{Function.SERVER_URL}{FILEHASH_PATH}"); var webStreamReader = new StreamReader(webStream, Encoding.UTF8); _FileHashGroup = webStreamReader.ReadToEnd(); webStreamReader.Close(); webStream.Close(); } catch (Exception exception) { //bool? dialogResult = false; //m_MessageDialog = new MessageForm(Properties.Resources.WMW_VERSION_LOSING, MessageFormType.Error, // () => // { // // Retry // m_MessageDialog.DialogResult = false; // }, // () => // { // // Quit // m_MessageDialog.DialogResult = true; // Application.Current.Shutdown(); // } //); //dialogResult = m_MessageDialog.ShowDialog(); //if (!(dialogResult.HasValue && dialogResult.Value)) //{ // TryGetFileHash(); //} Console.WriteLine(exception.Message); MessageBox.Show(exception.Message, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// 弹出窗口 /// </summary> /// <param name="notify">类型</param> /// <param name="msg">文本信息</param> /// <returns></returns> public static bool Show(Notify notify, string msg, bool Host = true) { MessageBoxImage Icon = MessageBoxImage.None; switch (notify) { case Notify.Error: Icon = MessageBoxImage.Error; break; case Notify.Warning: Icon = MessageBoxImage.Warning; break; case Notify.Info: Icon = MessageBoxImage.Information; break; case Notify.Question: Icon = MessageBoxImage.Question; break; } if (notify != Notify.Question) { MessageBox.Show(msg, "温馨提示", MessageBoxButton.OK, Icon); } else { var dr = MessageBox.Show(msg, "温馨提示", MessageBoxButton.YesNo, Icon); if (dr == MessageBoxResult.Yes) { return(true); } } return(false); }