/// <summary> /// 定时刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { #region 测试 int length = SPEED_MAX; if (this.skinFileTransfersItem1.TotalTransfersSize + length > skinFileTransfersItem1.FileSize) { this.skinFileTransfersItem1.TotalTransfersSize = 0; //换新文件 Model.FileModel fileModel = LastActionFileName(); if (fileModel != null) { skinFileTransfersItem1.FileName = fileModel.File_Name; skinFileTransfersItem1.FileSize = fileModel.File_Size; } } else { this.skinFileTransfersItem1.TotalTransfersSize += length; } #endregion #region 刷新左侧列表 bool thisTimeHaveFile = false; foreach (DataGridViewRow row in this.skinDataGridView10.Rows) { if (row.Cells[4].Value.ToString() == "已完成") { continue; } string key = row.Cells[0].Value.ToString(); if (IsActionEnd(key)) { row.Cells[4].Value = "已完成"; row.Cells[4].Style.ForeColor = Color.Red; } else { thisTimeHaveFile = true; } } if (!thisTimeHaveFile) { this.skinFileTransfersItem1.Enabled = false; this.skinFileTransfersItem1.Visible = false; if (fileTansfersContainer1.Controls.Count > 0) { SkinFileTransfersItem item = (SkinFileTransfersItem)fileTansfersContainer1.Controls[fileTansfersContainer1.Controls.Count - 1]; fileTansfersContainer1.RemoveItem(item); } this.fileTansfersContainer1.Visible = false; this.skinPictureBox1.Visible = true; this.skinLabel19.Visible = true; } #endregion }
/// <summary> /// 取消文件上传、文件下载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void item_CancelButtonClick(object sender, EventArgs e) { SkinFileTransfersItem item = sender as SkinFileTransfersItem; MessageBox.Show(string.Format( "取消了 {0} - {1},取消发送文件。", item.Text, item.FileName)); }
void item_SaveToButtonClick(object sender, EventArgs e) { SkinFileTransfersItem item = sender as SkinFileTransfersItem; MessageBox.Show(string.Format( "点击了 {0} - {1},保存文件到...。", item.Text, item.FileName)); }
/// <summary> /// 拒绝文件传输 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void item_RefuseButtonClick(object sender, EventArgs e) { SkinFileTransfersItem item = sender as SkinFileTransfersItem; MessageBox.Show(string.Format( "点击了 {0} - {1},拒绝接收文件。", item.Text, item.FileName)); }
private void FrmFileTransferNew_FormClosing(object sender, FormClosingEventArgs e) { this.timer1.Stop(); // 注意判断关闭事件reason来源于窗体按钮,否则用菜单退出时无法退出! if (e.CloseReason == CloseReason.UserClosing) { //取消"关闭窗口"事件 e.Cancel = true; this.skinFileTransfersItem1.Enabled = false; this.skinFileTransfersItem1.Visible = false; if (fileTansfersContainer1.Controls.Count > 0) { SkinFileTransfersItem item = (SkinFileTransfersItem)fileTansfersContainer1.Controls[fileTansfersContainer1.Controls.Count - 1]; fileTansfersContainer1.RemoveItem(item); } this.fileTansfersContainer1.Visible = false; this.skinPictureBox1.Visible = true; this.skinLabel19.Visible = true; this.Dispose(true); return; } }
/// <summary> /// 定时刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { //int length = _random.Next(800, 1500) * 1024; bool thisTimeHaveFile = false; foreach (DataGridViewRow row in this.skinDataGridView10.Rows) { if (row.Cells[4].Value.ToString() == "已完成") { continue; } string key = row.Cells[0].Value.ToString(); if (IsActionEnd(key)) { row.Cells[4].Value = "已完成"; row.Cells[4].Style.ForeColor = Color.Red; } else { #region 测试 //if (this.skinDataGridView10.Rows.Count > 100) //{ // if (fileTansfersContainer1.Controls.Count > 0) // { // SkinFileTransfersItem item = (SkinFileTransfersItem)fileTansfersContainer1.Controls[fileTansfersContainer1.Controls.Count - 1]; // int length = SPEED_MAX; // if (item.TotalTransfersSize + length > item.FileSize) // { // if (IsActionEnd(key)) // { // item.Visible = false; // thisTimeHaveFile = false; // fileTansfersContainer1.RemoveItem(item); // } // } // else // { // item.TotalTransfersSize += length; // } // } // return; //} #endregion thisTimeHaveFile = true; } } if (!thisTimeHaveFile) { this.fileTansfersContainer1.Visible = false; this.skinPictureBox1.Visible = true; this.skinLabel19.Visible = true; } if (fileTansfersContainer1.Controls.Count > 0) { SkinFileTransfersItem item = (SkinFileTransfersItem)fileTansfersContainer1.Controls[fileTansfersContainer1.Controls.Count - 1]; string key = item.Tag.ToString(); int length = SPEED_MAX; if (item.TotalTransfersSize + length > item.FileSize) { //item.TotalTransfersSize = 0; if (IsActionEnd(key)) { item.Visible = false; thisTimeHaveFile = false; fileTansfersContainer1.RemoveItem(item); } } else { item.TotalTransfersSize += length; } } else { this.fileTansfersContainer1.Visible = false; this.skinPictureBox1.Visible = true; this.skinLabel19.Visible = true; } //foreach (SkinFileTransfersItem item in fileTansfersContainer1.Controls) //{ // if (item.Tag == null) // { // item.Visible = false; // } // string key = item.Tag.ToString(); // int length = SPEED_MAX; // if (item.TotalTransfersSize + length > item.FileSize) // { // //item.TotalTransfersSize = 0; // if (IsActionEnd(key)) // { // item.Visible = false; // thisTimeHaveFile = false; // } // } // else // { // item.TotalTransfersSize += length; // } //} //if (!thisTimeHaveFile) //{ // this.fileTansfersContainer1.Visible = false; // this.skinPictureBox1.Visible = true; // this.skinLabel19.Visible = true; //} }