using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using IReaper.Properties;
using WeifenLuo.WinFormsUI.Docking;
using System.Threading;
namespace IReaper.FileData{
public partial class FilePanel : iReaperDockContent
{
CourseFileDataCollection result;
public FilePanel()
{
InitializeComponent();
//
this.result = new RunningCourseFileDataCollection(false);
RunningCourseFileDataCollection runnings = Core.CoreData[CoreDataType.CurrentViewedFiles] as RunningCourseFileDataCollection;
this.courseFileDataBindingSource.DataSource = runnings;
runnings.ListChanged += runnings_ListChanged;
//
Running.DownloadEngine.AfterDownloadInvoked += new EventHandler(DownloadEngine_AfterDownloadInvoked);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DownloadEngine_AfterDownloadInvoked(object sender, EventArgs e)
{
if (DockPanel.ActiveAutoHideContent != this)
{
this.BeginInvoke(new ThreadStart(delegate()
{
DockHandler.Pane.Activate();
this.Activate();
}));
}
}
private CourseFileDataCollection GetSelectedCourseFiles()
{
DataGridViewSelectedRowCollection rows = this.runningCourseFileDataGridView.SelectedRows;
result.Clear();
foreach (DataGridViewRow r in rows)
{
CourseFileData data = r.DataBoundItem as CourseFileData;
if (data == null)
{ continue; }
result.Add(data);
}
return result;
}
private void UpdateSelectedFiles(object sender, EventArgs e)
{
Core.CoreData[CoreDataType.CurrentSelectedFiles] = this.GetSelectedCourseFiles();
}
private void runnings_ListChanged(object sender, ListChangedEventArgs e)
{
//
if (e.ListChangedType == ListChangedType.ItemAdded)
{
this.BeginInvoke(new System.Threading.ThreadStart(delegate()
{
this.runningCourseFileDataGridView.CurrentCell = this.runningCourseFileDataGridView[0, e.NewIndex];
}));
}
}
private void OnCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
if (e.RowIndex < 0)
{ return; }
this.fileDataGridContextMenu1.Files = this.GetSelectedCourseFiles();
e.ContextMenuStrip = this.fileDataGridContextMenu1;
}
}
}
|