| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 
 |  
private void Data_FilteredChanged(object sender, List<Mark> e)
{
	DataSource = null;
	Rows.Clear();
 
	var bindingList = new BindingList<Mark>(_data.FilteredData);
	var source = new BindingSource(bindingList, null);
 
	SuspendLayout();
	ClearSelection();
	DataSource = source;
	ResumeLayout(true);
 
	Task.Run( () => ColorCells(); ); //Fait planter si le thread n'est pas encore arreté si cette fonction est rappellé
}
 
public void ColorCells()
{
	//Si Data_FilteredChanged a été appelé avant la fin de la fonction tout le reste planter
	// le mark dans le foreach se retrouve à null et la suite plante
 
	if ( Rows.Count == 0 )
		return;
 
	CtrlrCheck ctlCheck = new CtrlrCheck();
 
	Mark mark;
	foreach ( DataGridViewRow row in Rows ) //TODO : Parrallele foreach
	{
		mark = Rows[ row.Index ].DataBoundItem as Mark;
		mark.Chk = ctlCheck.GetCheck( mark );
 
		if ( InvokeRequired )
		{
			if ( mark == null )
				break;
 
			BeginInvoke( (MethodInvoker)delegate
			{
				row.Cells[ 0 ].Style.BackColor = row.Cells[ 0 ].Style.SelectionBackColor = CheckColor( row, mark );
				row.DefaultCellStyle.ForeColor = ColorParticular( mark );//FIXME : Ne color pas les markpages particulier...				
			} );
		}
	}
} | 
Partager