private void buttonSaveAsRoomAdvert_Click(object sender, EventArgs e) { var passwordBox = new PasswordBox(); if (passwordBox.Show("确定要设置为房间广告?") == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误!", "修改房间广告"); return; } var count = _conn.ExecuteScalar <int>( "select count(*) from AdvertMovie where RoomId = @RoomId", new { RoomId = int.Parse(textBoxRoomId.Text) }); if (count != 0) { _conn.Execute("update AdvertMovie set AdvertMovie = @AdvertMovie where RoomId = @RoomId", new { AdvertMovie = textBoxAdvertMovie.Text, RoomId = int.Parse(textBoxRoomId.Text) }); } else { _conn.Execute("insert into AdvertMovie(RoomId, AdvertMovie) values(@RoomId, @AdvertMovie)", new { RoomId = int.Parse(textBoxRoomId.Text), AdvertMovie = textBoxAdvertMovie.Text }); } ShowAdvertMovies(); }
private void btnAddMoviesToRoom_Click(object sender, EventArgs e) { var passwordBox = new PasswordBox(); if (passwordBox.Show("确认要把电影添加到房间: " + RoomId, "添加电影") == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误!", "添加房间电影"); return; } try { btnAddMoviesToRoom.Enabled = false; foreach (var item in lbSearchedMovies.SelectedIndices) { AddMovieToRoom(_searchedMovies.ElementAt((int)item)); } ShowRoomMovies(RoomId); } finally { btnAddMoviesToRoom.Enabled = true; } }
private void btnDeleteRoomMovies_Click(object sender, EventArgs e) { var passwordBox = new PasswordBox(); if (passwordBox.Show("确定要删除所选的电影? ") == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误!", "删除房间电影"); return; } try { btnDeleteRoomMovies.Enabled = false; foreach (var item in lbRoomMovies.SelectedIndices) { DeleteRoomMovie(_roomMovies.ElementAt((int)item)); } ShowRoomMovies(RoomId); } finally { btnDeleteRoomMovies.Enabled = true; } }
public void StartCollect() { if (IsCollecting) { var passwordBox = new PasswordBox(); if (passwordBox.Show("房间{0}正在收集中!\n如果要取消收集, 请输入密码!", RoomId) == DialogResult.Cancel) { Environment.Exit(0); } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误", "开始收集"); Environment.Exit(0); } } ConnectBarrageServer(); IsCollecting = true; _stopCollect = false; var messageText = ""; while (!_stopCollect) { try { TryKeepLive(); if (_douyuSocket.TryGetMessage(out messageText)) { ProcessMessage(messageText); } else { MyApplication.Delay(100); } //throw new SocketException(); } catch (Exception ex) { LogService.Error("获取&处理消息异常!", ex); if (ex is SocketException || ex is ObjectDisposedException) { try { LogService.Error("开始重新连接!"); if (_douyuSocket != null) { _douyuSocket.Disconnect(); } ConnectBarrageServer(); } catch (Exception reconnectEx) { LogService.Error("断线重连失败!", reconnectEx); LogService.Error("等待3秒"); MyApplication.Delay(3000); } } } } IsCollecting = false; }
private void buttonSave_Click(object sender, EventArgs e) { var passwordBox = new PasswordBox(); if (passwordBox.Show("确定要修改设置: " + labelSettingName.Text) == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误!", "修改程式设置"); return; } _conn.Execute("update AppSetting set Value = @Value where Name = @Name", new { Name = labelSettingName.Text, Value = textBoxSettingValue.Text }); ShowAppSettings(); }
private void btnImportToBlacklist_Click(object sender, EventArgs e) { var passwordBox = new PasswordBox(); if (passwordBox.Show("确定添加到黑名单?") == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误", "添加黑名单"); return; } foreach (var i in lbSearchedMovies.SelectedIndices) { ImportToBlacklist((int)i); } ShowMovieBlacklist(txtSearchedBlacklist.Text); MessageBox.Show("导入完成!", "导入黑名单"); }
private void lbSearchedMovies_DoubleClick(object sender, EventArgs e) { if (lbSearchedMovies.SelectedIndex < 0) { return; } var passwordBox = new PasswordBox(); if (passwordBox.Show("确定要添加到黑名单?") == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误", "添加黑名单"); return; } ImportToBlacklist(lbSearchedMovies.SelectedIndex); ShowMovieBlacklist(txtSearchedBlacklist.Text); }
private void lbMovieBlacklist_DoubleClick(object sender, EventArgs e) { if (lbMovieBlacklist.SelectedIndex == -1) { return; } var movie = _blacklist.ElementAt(lbMovieBlacklist.SelectedIndex); var passwordBox = new PasswordBox(); if (passwordBox.Show("确定要将{0}从黑名单中移除?", movie.MovieFile) == DialogResult.Cancel) { return; } if (passwordBox.Password != "123456") { MessageBox.Show("密码错误", "移除黑名单"); return; } _connection.Execute("delete from MovieBlacklist where MovieId = @MovieId", new { MovieId = movie.Id }); ShowMovieBlacklist(txtSearchedBlacklist.Text); }
private void ConnectButton_Click(object sender, EventArgs e) { switch (LoginContext) { case IsLogedIn.No: if (LoginBox.Text == "" || LoginBox.Text == "Entrez un identifiant") { LoginBox.Text = "Entrez un identifiant"; LoginBox.Focus(); } else { RestRequest Request = new RestRequest($"ranking/search/{LoginBox.Text}/false/true/false"); Request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; ConnectButton.Text = "..."; var SearchResponse = Client.Execute <SearchResults>(Request).Data; if (SearchResponse.success) { if (SearchResponse.results.Count == 0) { MessageBox.Show("Aucun compte ne correspond à cet identifiant"); } else { LoginBox.Text = SearchResponse.results[0].name; Size = new Size(400, 350); LoginBox.Enabled = false; LoginBox.Font = new Font(LoginBox.Font, FontStyle.Bold); LoginBox.Size = new Size(LoginBox.PreferredSize.Width - 5, LoginBox.PreferredSize.Height); LoginBox.Location = new Point((Size.Width - LoginBox.Size.Width) / 2, 225); LoginContext = IsLogedIn.LoginOk; label1.Text = "Mot de passe :"; label1.Location = new Point(12, 278); PasswordBox.Show(); File.WriteAllBytes(Path.Combine(Directory.GetCurrentDirectory(), LoginBox.Text + "_image.jpg"), new RestClient((SearchResponse.results[0].image.StartsWith("http") ? "" : "http://www.leekwars.com/") + SearchResponse.results[0].image).DownloadData(new RestRequest())); ImageBox.ImageLocation = Path.Combine(Directory.GetCurrentDirectory(), LoginBox.Text + "_image.jpg"); ImageBox.Show(); ConnectButton.Location = new Point(200, 315); ChangeButton.Show(); TokenCheckbox.Show(); PasswordBox.Focus(); } } else { MessageBox.Show("Une erreur est survenue"); } ConnectButton.Text = "Connexion"; } break; case IsLogedIn.LoginOk: if (PasswordBox.Text == "" || PasswordBox.Text == "Entrez un mot de passe") { PasswordBox.Text = "Entrez un mot de passe"; PasswordBox.Focus(); } else { RestRequest Request = new RestRequest($"farmer/login-token/{LoginBox.Text}/{PasswordBox.Text}"); Request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; ConnectButton.Text = "..."; var LoginResponse = Client.Execute <Login>(Request).Data; if (LoginResponse.success) { if (TokenCheckbox.Checked) { MessageBox.Show(LoginResponse.token, "Token"); } LoginContext = IsLogedIn.PassWordOk; var GUI = new GUI(LoginResponse); GUI.Show(); Hide(); } else { MessageBox.Show("Mauvais mot de passe"); PasswordBox.Focus(); } } ConnectButton.Text = "Connexion"; break; } }