public CCoupleValeurEtValeurDisplay GetValeur(int nCol) { CCoupleValeurEtValeurDisplay data = null; m_dicValeurs.TryGetValue(nCol, out data); return(data); }
private void FillMenuFiltre(int nColIndex, C2iWndDataGridColumn colonne) { m_nColIndexForFiltre = nColIndex; foreach (ToolStripItem item in new ArrayList(m_menuFiltreSpecial.DropDownItems)) { m_menuFiltreSpecial.DropDownItems.Remove(item); if (item != m_valueSelector) { item.Dispose(); } } m_menuFiltreSpecial.DropDownItems.Clear(); CGridFilterForWndDataGrid filtreActif = null; m_dicFiltre.TryGetValue(nColIndex, out filtreActif); IWndIncluableDansDataGrid wnd = colonne.Control as IWndIncluableDansDataGrid; if (wnd != null) { foreach (CGridFilterForWndDataGrid filtre in wnd.GetPossibleFilters()) { CGridFilterForWndDataGrid filtreToSet = filtre; if (filtreActif != null && filtreActif.GetType() == filtre.GetType()) { filtreToSet = filtreActif; } ToolStripMenuItem itemFiltre = new ToolStripMenuItem(filtreToSet.Label); itemFiltre.Tag = filtreToSet; itemFiltre.Click += new EventHandler(itemFiltre_Click); itemFiltre.Checked = filtreToSet == filtreActif; m_menuFiltreSpecial.DropDownItems.Add(itemFiltre); } } IEnumerable <object> source = m_listeObjetsOriginale; if (source != null) { CGridFilterListeValeurs filtreListe = filtreActif as CGridFilterListeValeurs; List <CCoupleValeurEtValeurDisplay> lstValeurs = new List <CCoupleValeurEtValeurDisplay>(); if (filtreListe == null) { source = m_grid.DataSource as IEnumerable <object>; } foreach (object obj in source) { CCoupleValeurEtValeurDisplay valeur = m_cache.GetValeur(obj, nColIndex, false); if (valeur != null) { lstValeurs.Add(valeur); } } m_valueSelector.Selector.FillWithValues(lstValeurs.ToArray(), filtreListe); if (!m_menuFiltre.Items.Contains(m_valueSelector)) { m_menuFiltre.Items.Add(m_valueSelector); } } }
public void SetValeur(int nCol, string strVal, object valeur) { if (strVal == null & m_dicValeurs.ContainsKey(nCol)) { m_dicValeurs.Remove(nCol); } else { m_dicValeurs[nCol] = new CCoupleValeurEtValeurDisplay(strVal, valeur); } }
private void GetDataThread(object data) { CThreadData d = data as CThreadData; if (d != null) { IWndIncluableDansDataGrid ctrl = null; if (m_dicControles.TryGetValue(d.ColumnIndex, out ctrl)) { CCoupleValeurEtValeurDisplay dTmp = GetValeurHorsCache(d.Objet, d.ColumnIndex, d.Cache); m_grid.OnDataArrivé(d.Objet, d.ColumnIndex); } } }
protected override void Paint( Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { bool bStandardPaint = true; object element = null; if (DataGridView != null) { IList source = DataGridView.DataSource as IList; element = source[rowIndex]; } IWndIncluableDansDataGridADrawCustom ctrlDraw = m_2iWndForGrid as IWndIncluableDansDataGridADrawCustom; if (ctrlDraw != null) { bStandardPaint = ctrlDraw.Paint( graphics, clipBounds, cellBounds, element); } if (bStandardPaint) { CCoupleValeurEtValeurDisplay data = m_datas.GetValeur(element, ColumnIndex, m_wndCol != null && m_wndCol.MultiThread); if (data != null) { if (data.StringValue == CGridDataCache.c_strWaitingData) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, "", errorText, cellStyle, advancedBorderStyle, paintParts); graphics.DrawImageUnscaled(Properties.Resources.Loading, new Point(cellBounds.Left, cellBounds.Top)); } else { base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, data.StringValue, errorText, cellStyle, advancedBorderStyle, paintParts); } } } }
public CCoupleValeurEtValeurDisplay GetValeur(object objet, int nColonne, bool bMultiThread) { if (objet == null) { return(new CCoupleValeurEtValeurDisplay("", null)); } CObjetDataCache cache = null; try { if (!m_cache.TryGetValue(objet, out cache)) { cache = new CObjetDataCache(objet); m_cache[objet] = cache; } } finally { if (cache == null) { cache = new CObjetDataCache(objet); m_cache[objet] = cache; } } CCoupleValeurEtValeurDisplay data = cache.GetValeur(nColonne); if (data != null) { return(data); } if (bMultiThread) { cache.SetValeur(nColonne, c_strWaitingData, null); CThreadData thread = new CThreadData(objet, nColonne, cache); lock (typeof(CLockThread)) { m_listeThreadToStart.Add(thread); } return(new CCoupleValeurEtValeurDisplay(c_strWaitingData, null)); } else { data = GetValeurHorsCache(objet, nColonne, cache); return(data); } }
private void m_menuCopier_Click(object sender, EventArgs e) { List <DataGridViewCell> lst = new List <DataGridViewCell>(); if (!(m_grid.DataSource is List <object>)) { return; } foreach (DataGridViewCell ce in m_grid.SelectedCells) { if (ce.ColumnIndex >= 0 && ce.RowIndex > 0) { lst.Add(ce); } } if (lst.Count == 0) { return; } lst.Sort((x, y) => x.RowIndex == y.RowIndex ? x.ColumnIndex.CompareTo(y.ColumnIndex) : x.RowIndex.CompareTo(y.RowIndex)); int nMinLine = lst.Min(c => c.RowIndex); int nMinCol = lst.Min(c => c.ColumnIndex); int nMaxLine = lst.Max(c => c.RowIndex); int nMaxCol = lst.Max(c => c.ColumnIndex); StringBuilder bl = new StringBuilder(); DataGridViewCell cell = lst[0]; int nCell = 0; for (int n = nMinLine; n <= nMaxLine; n++) { object obj = null; if (n >= 0 && n < ((List <object>)m_grid.DataSource).Count) { obj = ((List <object>)m_grid.DataSource)[n]; } if (obj != null) { for (int c = nMinCol; c <= nMaxCol; c++) { string strVal = ""; if (cell.RowIndex == n && cell.ColumnIndex == c) { CCoupleValeurEtValeurDisplay data = m_cache.GetValeur(obj, c, false); if (data != null) { strVal = data.StringValue; } nCell++; if (nCell < lst.Count) { cell = lst[nCell]; } else { cell = null; } } bl.Append(strVal); if (c < nMaxCol) { bl.Append('\t'); } if (cell == null) { break; } } } if (n < nMaxLine) { bl.Append(System.Environment.NewLine); } if (cell == null) { break; } } Clipboard.SetDataObject(bl.ToString()); }
private void Filtrer() { List <object> lst = m_listeObjetsOriginale; if (lst == null) { return; } using (CWaitCursor waiter = new CWaitCursor()) { bool bCancel = false; foreach (KeyValuePair <int, CGridFilterForWndDataGrid> kv in m_dicFiltre) { if (kv.Value != null) { CGridFilterForWndDataGrid filter = kv.Value; C2iWndDataGridColumn col = m_wndGrid.GetColumn(kv.Key); IWndIncluableDansDataGrid ctrl = col.Control as IWndIncluableDansDataGrid; if (ctrl != null) { List <object> lst2 = new List <object>(); foreach (object obj in lst) { int nVal = (int)Keys.Escape; nVal = GetKeyState((int)Keys.Escape); if (nVal < 0) { bCancel = true; break; } CCoupleValeurEtValeurDisplay dataVal = m_cache.GetValeur(obj, kv.Key, col.MultiThread); if (dataVal != null && filter.IsValueIn(dataVal.ObjectValue)) { lst2.Add(obj); } } lst = lst2; } } if (bCancel) { break; } } if (bCancel) { lst = m_listeObjetsOriginale; MessageBox.Show(I.T("Filter has been canceled|20019")); } } if (m_nColumnSort != null) { try { lst.Sort(new CGridSorter(m_nColumnSort.Value, m_bSortAsc, m_cache)); } catch { } } m_grid.DataSource = lst; foreach (DataGridViewColumn col in m_grid.Columns) { CDataGridViewCustomCellFor2iWnd cell = col.CellTemplate as CDataGridViewCustomCellFor2iWnd; } }