protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight) { if (beingEdited && editedRow == rowNum) { Point mousePos = this.DataGridTableStyle.DataGrid.PointToClient(Control.MousePosition); DataGrid dg = this.DataGridTableStyle.DataGrid; bool isClickInCell = ((Control.MouseButtons == MouseButtons.Left) && dg.GetCellBounds(dg.CurrentCell).Contains(mousePos)); bool changing = dg.Focused && (isClickInCell || GetKeyState(VK_SPACE) < 0); // click or spacebar if (changing && !lockValue) { saveValue = !saveValue; lockValue = false; if (BoolValueChanged != null) { //fire the event - ensures immediate reaction to checkbox changes BoolValueChangedEventArgs e = new BoolValueChangedEventArgs(rowNum, _column, saveValue); BoolValueChanged(this, e); } } lockValue = false; } base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); }
protected override bool Commit(System.Windows.Forms.CurrencyManager dataSource, int rowNum) { bool ret = true; try { if (editedRow == rowNum) { beingEdited = false; lockValue = true; if (BoolValueChanged != null) { //fire the event - ensures sync when commit is made. BoolValueChangedEventArgs e = new BoolValueChangedEventArgs(rowNum, _column, saveValue); BoolValueChanged(this, e); } ret = base.Commit(dataSource, rowNum); editedRow = -1; lockValue = false; beingEdited = false; } else { ret = base.Commit(dataSource, rowNum); } } catch (Exception e) { #if DEBUG LibSys.StatusBar.Error("MyDataGridBoolColumn:Commit() exception " + e.Message); #endif editedRow = -1; lockValue = false; beingEdited = false; } return(ret); }
private void HandleCustomMapShowChanges(object sender, BoolValueChangedEventArgs e) { #if DEBUG string str = "Show changed: row " + e.Row + " value " + e.BoolValue; #endif int column = 0; DataTable table = m_geotiffDS.Tables[0]; int row = e.Row; long geotiffId = (long)((int)geotiffDataGrid[row, column]); CustomMap cm = CustomMapsCache.getCustomMapById(geotiffId); #if DEBUG str += " " + row + "=" + geotiffId + " "; #endif if(cm != null) { cm.Enabled = e.BoolValue; PutOnMap(); } #if DEBUG LibSys.StatusBar.Trace(str); //messageLabel.Text = str; #endif }
private void HandleTrackShowChanges(object sender, BoolValueChangedEventArgs e) { #if DEBUG string str = "Bool changed: row " + e.Row + " value " + e.BoolValue; #endif int column = 0; DataTable table = m_tracksDS.Tables[0]; int row = e.Row; long trackId = (long)((int)tracksDataGrid[row, column]); Track trk = WaypointsCache.getTrackById(trackId); #if DEBUG str += " " + row + "=" + trackId + " "; #endif if(trk != null) { trk.Enabled = e.BoolValue; PutOnMap(); } #if DEBUG LibSys.StatusBar.Trace(str); //messageTrkLabel.Text = str; #endif }
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight) { if(beingEdited && editedRow == rowNum) { Point mousePos = this.DataGridTableStyle.DataGrid.PointToClient(Control.MousePosition); DataGrid dg = this.DataGridTableStyle.DataGrid; bool isClickInCell = ((Control.MouseButtons == MouseButtons.Left) && dg.GetCellBounds(dg.CurrentCell).Contains(mousePos)); bool changing = dg.Focused && ( isClickInCell || GetKeyState(VK_SPACE) < 0 ); // click or spacebar if(changing && !lockValue) { saveValue = !saveValue; lockValue = false; if(BoolValueChanged != null) { //fire the event - ensures immediate reaction to checkbox changes BoolValueChangedEventArgs e = new BoolValueChangedEventArgs(rowNum, _column, saveValue); BoolValueChanged(this, e); } } lockValue = false; } base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); }
protected override bool Commit(System.Windows.Forms.CurrencyManager dataSource, int rowNum) { bool ret = true; try { if(editedRow == rowNum) { beingEdited = false; lockValue = true; if(BoolValueChanged != null) { //fire the event - ensures sync when commit is made. BoolValueChangedEventArgs e = new BoolValueChangedEventArgs(rowNum, _column, saveValue); BoolValueChanged(this, e); } ret = base.Commit(dataSource, rowNum); editedRow = -1; lockValue = false; beingEdited = false; } else { ret = base.Commit(dataSource, rowNum); } } catch (Exception e) { #if DEBUG LibSys.StatusBar.Error("MyDataGridBoolColumn:Commit() exception " + e.Message); #endif editedRow = -1; lockValue = false; beingEdited = false; } return ret; }
private void HandleEarthquakeShowChanges(object sender, BoolValueChangedEventArgs e) { /* string str = "Bool changed: row " + e.Row + " value " + e.BoolValue; int column = 0; DataTable table = m_eqDS.Tables[0]; int row = e.Row; long eqId = (long)((int)eqDataGrid[row, column]); Earthquake eq = EarthquakesCache.getEarthquakeById(eqId); str += " " + row + "=" + eqId + " "; if(eq != null) { eq.Enabled = e.BoolValue; PutOnMap(); } LibSys.StatusBar.Trace(str); messageLabel.Text = str; */ }