private void MainForm_Load(object sender, EventArgs e) { //进行一些初始化工作。 isRec = false; bnpf = null; nowBytesLabel.Text = ""; recTimeLabel.Text = ""; nowTimeLabel.Text = ""; infoTxtBox.AppendText("[INFO " + DateTime.Now.ToString("HH:mm:ss") + "] 开始读取配置信息。\n"); this.config = new Config(); //显示更新说明。 if (config.Version != Version.VER) { MessageBox.Show("BiliRoku已经更新到 " + Version.VER + "\n\n更新说明:\n" + Version.DESC); config.Version = Version.VER; } //读取配置并填入文本框 if (config.RoomId != null) { this.roomidTxtBox.Text = config.RoomId; } if (config.SaveLocation != null) { this.saveFileDialog1.FileName = config.SaveLocation; this.savepathTxtBox.Text = this.saveFileDialog1.FileName; } infoTxtBox.AppendText("[INFO " + DateTime.Now.ToString("HH:mm:ss") + "] 启动成功。\n"); }
private void startBtn_Click(object sender, EventArgs e) { if (isRec) { startBtn.Text = "停止中..."; startBtn.Enabled = false; downloadFlv.Stop(); isRec = false; infoTxtBox.AppendText("[INFO " + DateTime.Now.ToString("HH:mm:ss") + "] 已停止。\n"); startBtn.Text = "开始"; startBtn.Enabled = true; } else { startBtn.Text = "启动中..."; startBtn.Enabled = false; //检查必填字段 string roomid = roomidTxtBox.Text; if (roomid == "") { MessageBox.Show("请输入房间号。", "错误"); startBtn.Text = "开始"; startBtn.Enabled = true; return; } string savepath = saveFileDialog1.FileName; if (savepath == "") { MessageBox.Show("请选择保存路径。", "错误"); startBtn.Text = "开始"; startBtn.Enabled = true; return; } infoTxtBox.AppendText("[INFO " + DateTime.Now.ToString("HH:mm:ss") + "] 开始解析...\n"); //开始解析url bnpf = new BiliNamaPathFind(); if (bnpf.Init(roomid, infoTxtBox)) { downloadFlv = new DownloadFlv(); downloadFlv.SetInfos(infoTxtBox, nowBytesLabel, recTimeLabel, nowTimeLabel); if (downloadFlv.Start(bnpf.trueURL, savepath)) { isRec = true; startBtn.Text = "停止"; startBtn.Enabled = true; } else { infoTxtBox.AppendText("[ERROR " + DateTime.Now.ToString("HH:mm:ss") + "] 已停止。\n"); startBtn.Text = "开始"; startBtn.Enabled = true; } } else { infoTxtBox.AppendText("[ERROR " + DateTime.Now.ToString("HH:mm:ss") + "] 已停止。\n"); startBtn.Text = "开始"; startBtn.Enabled = true; } } }