public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); Grid grid = (Grid)sender.Grid; //RowSelection rowSelection = ; var row = grid.Rows[sender.Position.Row]; var cell = grid[sender.Position.Row, sender.Position.Column]; Serie serie = (Serie)cell.Tag; StrengthTrainingItem item = (StrengthTrainingItem)row.Tag; if (string.IsNullOrEmpty((string)sender.Value)) {//this cell has been cleaned (doesn't contain any value) so we have to remove existing Serie object if (serie != null) { item.RemoveSerie(serie); cell.Tag = null; cell.ToolTipText = null; } } else { if (!string.IsNullOrEmpty((string)sender.Value) && serie == null) {//user added new serie so we have to create Serie object serie = new Serie(); cell.Tag = serie; item.AddSerie(serie); } serie.SetFromString((string)sender.Value); } parent.UpdateCellsReadOnlyMode(row); }
public override void OnMouseEnter(SourceGrid.CellContext sender, EventArgs e) { base.OnMouseEnter(sender, e); DefaultView = sender.Cell.View as SourceGrid.Cells.Views.Cell; sender.Cell.View = MouseEnterView; sender.Grid.InvalidateCell(sender.Position); }
void _grid_ZValueChanged(SG.CellContext sender) { //AOutput.Write(sender.DisplayText); //AOutput.Write(_inSetGrid); if (_noeventGridValueChanged) { return; } _noeventGridValueChanged = true; var g = sender.Grid as ParamGrid; var pos = sender.Position; switch (pos.Column) { case 0: if (g == _grid2 && g.ZGetRowKey(pos.Row) == nameof(AFFlags.UIA)) { _uiaUserChecked = _IsChecked2(pos.Row); _ShowTreeInfo("Please capture the AO again.\r\nNeed it when changed the 'UI Automation' option."); _cCapture.Checked = true; } break; case 1: break; } _noeventGridValueChanged = false; _UpdateCodeBox(); }
private void clickEvent_Click(object sender, EventArgs e) { SourceGrid.CellContext context = (SourceGrid.CellContext)sender; if (context.Grid.Handle == grid1Frez.Handle) { //ToDo ???можно заменить на public void CeptureCell() и закрыть private все поля в классе Step //а метод CeptureCell() будет загонять в поле IData и LCells необходимые значения s1.IData.Cv = Convert.ToSingle(grid1Frez[context.Position.Row, 4].Value); s1.IData.qv = Convert.ToSingle(grid1Frez[context.Position.Row, 5].Value); s1.IData.xv = Convert.ToSingle(grid1Frez[context.Position.Row, 6].Value); s1.IData.yv = Convert.ToSingle(grid1Frez[context.Position.Row, 7].Value); s1.IData.uv = Convert.ToSingle(grid1Frez[context.Position.Row, 8].Value); s1.IData.pv = Convert.ToSingle(grid1Frez[context.Position.Row, 9].Value); s1.IData.mv = Convert.ToSingle(grid1Frez[context.Position.Row, 10].Value); s1.LCells.grid1 = context; } if (context.Grid.Handle == grid2Frez.Handle) { s1.IData.z = Convert.ToSingle(context.Value); s1.LCells.grid2 = context; } if (context.Grid.Handle == grid3Frez.Handle) { s1.IData.Kv = Convert.ToSingle(context.Value); s1.LCells.grid3 = context; } if (context.Grid.Handle == grid4Frez.Handle) { s1.IData.Kp = Convert.ToSingle(context.Value); s1.LCells.grid4 = context; } if (context.Grid.Handle == grid5Frez.Handle) { s1.IData.Cp = Convert.ToSingle(grid5Frez[context.Position.Row, 2].Value); s1.IData.xp = Convert.ToSingle(grid5Frez[context.Position.Row, 3].Value); s1.IData.yp = Convert.ToSingle(grid5Frez[context.Position.Row, 4].Value); s1.IData.up = Convert.ToSingle(grid5Frez[context.Position.Row, 5].Value); s1.IData.qp = Convert.ToSingle(grid5Frez[context.Position.Row, 6].Value); s1.IData.wp = Convert.ToSingle(grid5Frez[context.Position.Row, 7].Value); s1.LCells.grid5 = context; MyRowSelector(context); } //Выделение ячеек (они unselectable) if (context.Grid.Handle == grid5Frez.Handle) { MyRowSelector(context); } if (context.Grid.Handle == grid1Frez.Handle) { MyRowSelector_4(context); } if ((context.Grid.Handle != grid1Frez.Handle) && (context.Grid.Handle != grid5Frez.Handle)) { //следующий код необходим для верного выделения (click-drop) иначе //click на одной ячейке, select на другой.(+unselectable) //+решения проблеммы shift+arrow т.е. выделение только при событии click MyCellSelector(context); } }
public override void OnDoubleClick(SourceGrid.CellContext sender, EventArgs e) { int col = sender.Position.Column; int row = sender.Position.Row; Owner.TransformGridToModel(ref col, ref row); Owner.FireDoubleClick(col, row); }
public override void OnDoubleClick(SourceGrid.CellContext sender, EventArgs e) { if (sender.Position.Row > 0) { SourceGridUtilities.RowTag rt = (SourceGridUtilities.RowTag)Grid.Rows[sender.Position.Row].Tag; idocEmployee Customer = new idocEmployee(rt.Key.ToString(), Client); Customer.Show(); } }
public override void OnMouseUp(SourceGrid.CellContext sender, MouseEventArgs e) { var position = Owner._grid.PositionAtPoint(e.Location); int col = position.Column; int row = position.Row; Owner.TransformGridToModel(ref col, ref row); Owner.FireMouseUp(col, row, e); }
/// <summary> /// Выделяет ячейку /// </summary> public static void CellSelector(SourceGrid.CellContext context) { if (context.Grid != null) { SourceGrid.Range range = new SourceGrid.Range(new SourceGrid.Position(0, 0), new SourceGrid.Position(context.Grid.Rows.Count, context.Grid.Columns.Count)); context.Grid.Selection.SelectRange(range, false); context.Grid.Selection.SelectCell(context.Position, true); } }
override void OnMouseLeave(SourceGrid.CellContext sender, EventArgs e) { cellView = new SourceGrid.Cells.Views.Cell(); cellView.Background = new DevAge.Drawing.VisualElements.BackgroundSolid(Color.White); DevAge.Drawing.ContentAlignment ca = new DevAge.Drawing.ContentAlignment(); ca = DevAge.Drawing.ContentAlignment.MiddleCenter; cellView.TextAlignment = ca; sender.Cell.View = cellView; sender.Grid.InvalidateCell(sender.Position); }
public override void OnDoubleClick(CellContext sender, EventArgs e) { base.OnClick(sender, e); Grid grilla = sender.Grid as Grid; ARP_SOA mensa = grilla.Rows[sender.Position.Row].Tag as ARP_SOA; using (Tabla_ARP f = new Tabla_ARP()) { f.Inicializar(mensa); f.ShowDialog(); } }
public override void OnDoubleClick(CellContext sender, EventArgs e) { base.OnClick(sender, e); Grid grilla = sender.Grid as Grid; MensajeCableSOA mensa = grilla.Rows[sender.Position.Row].Tag as MensajeCableSOA; using (FrameForm f=new FrameForm()) { f.Inicializar(mensa); f.ShowDialog(); } }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); if (internalChange) { return; } internalChange = true; try { Grid grid = (Grid)sender.Grid; var row = grid.Rows[sender.Position.Row]; var cell = grid[sender.Position.Row, sender.Position.Column]; var value = (string)sender.Value; SerieDTO serie = (SerieDTO)cell.Tag; var item = (StrengthTrainingItemDTO)row.Tag; bool serieDeleted = false; if (string.IsNullOrEmpty(value)) {//this cell has been cleaned (doesn't contain any value) so we have to remove existing Serie object if (serie != null) { item.RemoveSerie(serie); cell.Tag = null; cell.ToolTipText = null; serieDeleted = true; } } else { if (!string.IsNullOrEmpty(value) && serie == null) {//user added new serie so we have to create Serie object serie = new SerieDTO(); cell.Tag = serie; item.AddSerie(serie); } serie.SetFromString(value); } if (serieDeleted) { rebuildRow(row); } parent.UpdateCellsReadOnlyMode(row); } finally { internalChange = false; } }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); Grid grid1 = (Grid)sender.Grid; StrengthTrainingItemDTO entry = null; var row = grid1.Rows[sender.Position.Row]; if (row == null) { return; } if (row.Tag == null) { entry = new StrengthTrainingItemDTO(); row.Tag = entry; strengthEntry.AddEntry(entry); parent.AddEmptyRow(parent.GetSeriesNumber()); } else { entry = (StrengthTrainingItemDTO)row.Tag; } Guid newId = (Guid)sender.Value; if (newId == Guid.Empty) { sender.Value = entry.ExerciseId; return; } entry.ExerciseId = newId; parent.UpdateCellsReadOnlyMode(row); if (!(grid1[row.Index, usrStrengthTrainingSourceGridBase.DeleteRowColumnIndex] is SourceGrid.Cells.Button)) { grid1[row.Index, usrStrengthTrainingSourceGridBase.ExerciseColumnIndex].View.ForeColor = Color.Black; if (parent.ReadOnly) { return; } var bnCol1 = new SourceGrid.Cells.Button(null); bnCol1.Image = StrengthTrainingResources.Delete; bnCol1.ToolTipText = StrengthTrainingEntryStrings.DeleteThisEntryBtn; var ctrButton1 = new SourceGrid.Cells.Controllers.Button(); ctrButton1.Executed += new EventHandler(deleteRowBtn_Execute); bnCol1.View = new SourceGrid.Cells.Views.Button(); bnCol1.AddController(ctrButton1); grid1[row.Index, usrStrengthTrainingSourceGridBase.DeleteRowColumnIndex] = bnCol1; } }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); SuplementsGrid grid1 = (SuplementsGrid)sender.Grid; SuplementItemDTO entry = null; var row = grid1.Rows[sender.Position.Row]; if (row == null) { return; } if (row.Tag == null) { entry = new SuplementItemDTO(); row.Tag = entry; suplementEntry.AddItem(entry); parent.AddEmptyRow(); if (SuplementsSettings.Default.SetCurrentTime) { entry.Time = DateTime.Now; entry.Time = DateHelper.MoveToNewDate(entry.Time, suplementEntry.TrainingDay.TrainingDate); } } else { entry = (SuplementItemDTO)row.Tag; } entry.SuplementId = (Guid)sender.Value; //grid1[row.Index, SuplementsGrid.DosageTypeColumn].Value = DosageType.Grams; var selectedItem = from t in ((SourceGrid.Cells.Editors.ComboBox)grid1[row.Index, SuplementsGrid.DosageTypeColumn].Editor).Control.Items.Cast <ComboBoxItem>() where (DosageType)t.Tag == DosageType.Grams select t; grid1[row.Index, SuplementsGrid.DosageTypeColumn].Value = selectedItem.SingleOrDefault(); grid1[row.Index, SuplementsGrid.SuplementTypeColumn].View.ForeColor = Color.Black; grid1[row.Index, SuplementsGrid.TimeColumn].Value = entry.Time; grid1[row.Index, SuplementsGrid.DosageColumn].Value = entry.Dosage; parent.UpdateCellsReadOnlyMode(row); if (!parent.ReadOnly && !(grid1[row.Index, SuplementsGrid.DeleteButtonColumn] is SourceGrid.Cells.Button)) { var bnCol1 = new SourceGrid.Cells.Button(null); bnCol1.Image = SuplementsResources.Delete; bnCol1.ToolTipText = SuplementsEntryStrings.DeleteThisEntryTip; var ctrButton1 = new SourceGrid.Cells.Controllers.Button(); ctrButton1.Executed += new EventHandler(deleteRowBtn_Execute); bnCol1.View = new SourceGrid.Cells.Views.Button(); bnCol1.AddController(ctrButton1); grid1[row.Index, SuplementsGrid.DeleteButtonColumn] = bnCol1; } }
protected override void PrepareView(SourceGrid.CellContext context) { base.PrepareView(context); if (Math.IEEERemainder(context.Position.Row, 2) == 0) { Background = SecondBackground; } else { Background = FirstBackground; } }
public System.Drawing.Image GetImage(SourceGrid.CellContext cellContext) { SourceGrid.DataGrid dg = (SourceGrid.DataGrid)cellContext.Grid; int dsRow = dg.Rows.IndexToDataSourceIndex(cellContext.Position.Row); PropertyDescriptor property = dg.DataSource.GetItemProperty(imageProperty, StringComparison.InvariantCultureIgnoreCase); byte[] buffer = (byte[])dg.DataSource.GetItemValue(dsRow, property); using (System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer)) { return(System.Drawing.Image.FromStream(stream)); } }
/// <summary> /// ѕереопределенное отображение ¤чеек дл¤ раскраски /// </summary> protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics, SourceGrid.CellContext cellContext, System.Drawing.RectangleF drawRectangle) { //if (cellContext.DisplayText != "") cellContext.Cell.View.BackColor = ColorCalcRGB(cellContext.DisplayText); //base.PaintCell(graphics, cellContext, drawRectangle); if (drawRectangle.Width > 0 && drawRectangle.Height > 0 && cellContext.CanBeDrawn()) { cellContext.Cell.View.DrawCell(cellContext, graphics, drawRectangle); } }
public override void OnMouseDown(SourceGrid.CellContext sender, MouseEventArgs e) { base.OnMouseDown(sender, e); if (e.Button == MouseButtons.Left) { LinearAudioPlayer.LinkGridController.mode++; if (LinearAudioPlayer.LinkGridController.mode == EnuMode.OVER) { LinearAudioPlayer.LinkGridController.mode = EnuMode.NOWPLAYING; } LinearAudioPlayer.LinkGridController.reloadGrid(); } }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); Grid grid1 = (Grid)sender.Grid; var row = grid1.Rows[sender.Position.Row]; if (row == null) { return; } MapperEntry entry = null; if (row.Tag == null) { entry = new MapperEntry(); row.Tag = entry; parent.AddEmptyRow(); parent.MapperData.Entries.Add(entry); } else { entry = (MapperEntry)row.Tag; } Guid newId = (Guid)sender.Value; if (sender.Position.Column == ExerciseMapperWindow.FromExerciseColumn) { entry.FromExerciseId = newId; } else { entry.ToExerciseId = newId; } parent.UpdateCellsReadOnlyMode(row); grid1[row.Index, sender.Position.Column].View.ForeColor = Color.Black; if (!(grid1[row.Index, ExerciseMapperWindow.DeleteColumn] is SourceGrid.Cells.Button)) { var bnCol1 = new SourceGrid.Cells.Button(null); bnCol1.Image = StrengthTrainingResources.Delete; bnCol1.ToolTipText = StrengthTrainingEntryStrings.DeleteThisEntryBtn; var ctrButton1 = new SourceGrid.Cells.Controllers.Button(); ctrButton1.Executed += new EventHandler(ctrButton1_Executed); bnCol1.View = new SourceGrid.Cells.Views.Button(); bnCol1.AddController(ctrButton1); grid1[row.Index, usrStrengthTrainingSourceGridBase.DeleteRowColumnIndex] = bnCol1; } }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); int row = sender.Position.Row; SourceGrid.Cells.Cell cell = (SourceGrid.Cells.Cell)sender.Cell; var art = _form.GetArtFromTable(row); var isForce = _form.UpdateArtEntity(art, row); _form.gridArt[row, Const.Columns.Art.FullName].Value = art.FullName; _form.CheckArtSort(sender.Position, isForce); }
int _MeasureColumnWidth(int column) { //This code taken from MeasureColumnWidth and modified to skip col-spanned cells etc. int wid = 10; for (int r = 0, n = this.RowsCount; r < n; r++) { var cell = this[r, column]; if (cell == null || cell.ColumnSpan != 1) { continue; } var cellContext = new SG.CellContext(this, new SG.Position(r, column), cell); Size cellSize = cellContext.Measure(default);
void _grid_ZValueChanged(SG.CellContext sender) { //AOutput.Write(sender.DisplayText); //AOutput.Write(_inSetGrid); if (_noeventGridValueChanged) { return; } _noeventGridValueChanged = true; var g = sender.Grid as ParamGrid; var pos = sender.Position; switch (pos.Column) { case 0: if (g == _grid) { bool on = (sender.Cell as SG.Cells.CheckBox).Checked.GetValueOrDefault(); switch (g.ZGetRowKey(pos.Row)) { case "nameC": if (on) { g.ZCheckIfExists("id", false); } break; case "id": if (on) { g.ZCheck("nameC", false); } break; case "Control": g.ZShowRows(on, pos.Row + 1, -1); _grid2.ZShowRows(on, _grid2.ZFindRow("Control"), 4); break; } } break; case 1: break; } _noeventGridValueChanged = false; _FormatCode(); }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); Grid grid = (Grid)sender.Grid; var row = grid.Rows[sender.Position.Row]; if (row.Tag == null) { return; } ICommentable entry = (ICommentable)row.Tag; entry.Comment = (string)sender.Value; }
override void OnMouseEnter(SourceGrid.CellContext sender, EventArgs e) { cellView = new SourceGrid.Cells.Views.Cell(); cellView.Background = new DevAge.Drawing.VisualElements.BackgroundSolid(Color.LightGreen); DevAge.Drawing.ContentAlignment ca = new DevAge.Drawing.ContentAlignment(); ca = DevAge.Drawing.ContentAlignment.MiddleCenter; cellView.TextAlignment = ca; for (int c = 0; c < sender.Grid.Columns.Count; c++) { if (Convert.ToString(sender.Grid.GetCell(new Position(sender.Position.Row, c)).GetType()) != "SourceGrid.Cells.Cell") { //sender.Grid.GetCell(new Position(sender.Position.Row, c)).View.TextAlignment = ca; sender.Grid.GetCell(new Position(sender.Position.Row, c)).View = cellView; sender.Grid.InvalidateCell(new Position(sender.Position.Row, c)); } } }
/// <summary> /// Выделяет строку /// </summary> public static void RowSelector(SourceGrid.CellContext context) { if (context.Grid != null) { int c = 0; for (c = 0; c < context.Grid.Columns.Count; c++) { if (!(context.Grid.GetCell(context.Position.Row, c) is ColumnHeader || context.Grid.GetCell(context.Position.Row, c) is SourceGrid.Cells.RowHeader)) { break; } } SourceGrid.Range r1 = new SourceGrid.Range(new SourceGrid.Position(context.Position.Row, c), new SourceGrid.Position(context.Position.Row, context.Grid.Columns.Count)); SourceGrid.Range r2 = new SourceGrid.Range(new SourceGrid.Position(0, 0), new SourceGrid.Position(context.Grid.Rows.Count, context.Grid.Columns.Count)); context.Grid.Selection.SelectRange(r2, false); context.Grid.Selection.SelectRange(r1, true); } }
public object GetValue(CellContext CellContext) { if (_Value == null) return ""; if (_Value.GetType().IsArray) { string ReturnString = ""; foreach (object I in _Value as Array) { if (ReturnString != "") ReturnString += "\r\n"; ReturnString += I.ToString(); } return ReturnString; } else return _Value.ToString(); }
public virtual object GetValue(CellContext cellContext) { AddressInstance adr = (cellContext.Grid as FRomGrid).DataSource.Address; //Порядковый номер с нуля int n = cellContext.Position.Row - cellContext.Grid.FixedRows; //Если фиксированных больше одной и сейчас проходим по первой, //заполняем ее порядковым номером if (cellContext.Grid.FixedColumns > 1 && cellContext.Position.Column == 0) return n + 1; if (adr.YMapConstName.Length != 0) { From f = (cellContext.Grid as FRomGrid).DataSource.GetFRom(); return f.GetMap(adr.YMapConstName)[n, 0, ViewEnum.Scale]; } else return n + 1; }
public string GetToolTipText(SourceGrid.CellContext cellContext) { SourceGrid.DataGrid grid = (SourceGrid.DataGrid)cellContext.Grid; DataRowView row = (DataRowView)grid.Rows.IndexToDataSourceRow(cellContext.Position.Row); if (row != null) { if (bool.Equals(row["Selected"], true)) { return("Row " + cellContext.Position.Row.ToString() + " is selected"); } else { return("Row " + cellContext.Position.Row.ToString() + " is NOT selected"); } } else { return(string.Empty); } }
public void SetValue(CellContext cellContext, object p_Value) { //Выдергиваю текущее значение Map map = (cellContext.Grid as FRom.Grid.FRomGrid).DataSource; object oldValue = map[ cellContext.Position.Column - cellContext.Grid.FixedColumns, cellContext.Position.Row - cellContext.Grid.FixedRows, null]; SourceGrid.ValueChangeEventArgs valArgs = new SourceGrid.ValueChangeEventArgs(oldValue, p_Value); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); map[ cellContext.Position.Column - cellContext.Grid.FixedColumns, cellContext.Position.Row - cellContext.Grid.FixedRows, null] = p_Value; if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
/// <summary> /// Implementation of the required IToolTipText method /// </summary> /// <param name="cellContext">The cell for which an tool tip is desired</param> /// <returns>The text, which may be an empty string</returns> public string GetToolTipText(SourceGrid.CellContext cellContext) { SourceGrid.DataGrid grid = (SourceGrid.DataGrid)cellContext.Grid; DataRowView row = (DataRowView)grid.Rows.IndexToDataSourceRow(cellContext.Position.Row); if (row != null) { if (FCallerForm.EvaluateBoundImage(FCallerContext, row)) { // There is an image in this row/column if (FImageEnum == BoundGridImage.DisplayImageEnum.Inactive) { if (FCallerContext == BoundGridImage.AnnotationContextEnum.CostCentreCode) { return(Catalog.GetString("This Cost Centre code is no longer active")); } else if (FCallerContext == BoundGridImage.AnnotationContextEnum.AccountCode) { return(Catalog.GetString("This Bank Account code is no longer active")); } else if (FCallerContext == BoundGridImage.AnnotationContextEnum.AnalysisTypeCode) { return(Catalog.GetString("This Analysis Attribute type is no longer active")); } else if (FCallerContext == BoundGridImage.AnnotationContextEnum.AnalysisAttributeValue) { return(Catalog.GetString("This Analysis Attribute value is no longer active")); } else if (FCallerContext == BoundGridImage.AnnotationContextEnum.RetiredUser) { return(Catalog.GetString("This user has been retired")); } } } } return(string.Empty); }
public override void OnDoubleClick(CellContext sender, EventArgs e) { base.OnClick(sender, e); Grid grilla = sender.Grid as Grid; EncapsulacionSOA mensa = grilla.Rows[sender.Position.Row].Tag as EncapsulacionSOA; if (mensa.EsEncapsulacion) { using (Encapsulacion f = new Encapsulacion()) { f.Inicializar(mensa); f.ShowDialog(); } } else { using (DesEncapsulacion f = new DesEncapsulacion()) { f.Inicializar(mensa); f.ShowDialog(); } } }
public void SetValue(CellContext cellContext, object value) { DataGrid grid = (DataGrid)cellContext.Grid; PropertyDescriptor prop = grid.Columns[cellContext.Position.Column].PropertyColumn; object oldValue = GetValue(cellContext); //[email protected]: if value is the same, //no need to trigger value changed event or to write back to datasource. string oldText = oldValue == null ? string.Empty : oldValue.ToString(); string newText = value == null ? string.Empty : value.ToString(); if (newText == oldText) { return; } ValueChangeEventArgs valArgs = new ValueChangeEventArgs(oldValue, value); if (cellContext.Grid != null) { cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); } //[email protected]: ValueChanging event will be used for validation //If operation cancelled then return without setting database. i.e., reject changes if (valArgs.Cancel) { return; } grid.DataSource.SetEditValue(prop, valArgs.NewValue); if (cellContext.Grid != null) { cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); } }
public object GetValue(CellContext cellContext) { DataGrid grid = (DataGrid)cellContext.Grid; System.Data.DataRowView row = grid.Rows.IndexToDataSourceRow(cellContext.Position.Row); //Convert DbNull to null if (row == null) { return(null); } else { object tmp = row[m_Column]; if (System.DBNull.Value == tmp) { return(null); } else { return(tmp); } } }
/// <summary> /// get the correct tooltip for the current cell /// </summary> /// <param name="ACellContext"></param> /// <returns>tooltip text</returns> public string GetToolTipText(SourceGrid.CellContext ACellContext) { string ReturnValue = ""; DataRowView TheRow; TSgrdDataGrid TheGrid; TheGrid = (TSgrdDataGrid)(SourceGrid.DataGrid)ACellContext.Grid; TheRow = (DataRowView)TheGrid.Rows.IndexToDataSourceRow(ACellContext.Position.Row); // MessageBox.Show('TToolTipModel.GetToolTipText. Row: ' + Convert.ToString(ACellContext.Position.Row 1) ); if (TheRow != null) { try { // Create a ToolTip if (TheGrid.ToolTipTextDelegate != null) { // MessageBox.Show('TToolTipModel.GetToolTipText. Inquiring ToolTip Text...'); ReturnValue = TheGrid.ToolTipTextDelegate((short)ACellContext.Position.Column, (short)(ACellContext.Position.Row - 1)); // MessageBox.Show("TToolTipModel.GetToolTipText. ToolTip Text: " + ReturnValue); return(ReturnValue); } } catch (Exception E) { MessageBox.Show("Exception in TToolTipModel.GetToolTipText: " + E.ToString()); } } else { ReturnValue = ""; } return(ReturnValue); }
public virtual void SetValue(CellContext cellContext, object p_Value) { throw new ApplicationException("Not supported"); }
/// <summary> /// Measures the current row when drawn with the specified cells. /// </summary> /// <param name="row"></param> /// <param name="useColumnWidth">True to fix the column width when calculating the required height of the row.</param> /// <param name="StartCol">Start column to measure</param> /// <param name="EndCol">End column to measure</param> /// <returns>Returns the required height</returns> public int MeasureRowHeight(int row, bool useColumnWidth, int StartCol, int EndCol) { int min = Grid.MinimumHeight; if ((GetAutoSizeMode(row) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize) return min; for (int c = StartCol; c <= EndCol; c++) { Cells.ICellVirtual cell = Grid.GetCell(row, c); if (cell != null) { Position cellPosition = new Position(row, c); Size maxLayout = Size.Empty; //Use the width of the actual cell (considering spanned cells) if (useColumnWidth) maxLayout.Width = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Width; CellContext cellContext = new CellContext(Grid, cellPosition, cell); Size cellSize = cellContext.Measure(maxLayout); if (cellSize.Height > min) min = cellSize.Height; } } return min; }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(CellContext other) { return (Position == other.Position && Cell == other.Cell && Grid == other.Grid); }
static CellContext() { Empty = new CellContext(null, Position.Empty, null); }
/// <summary> /// Fired when the cell in the drag events change. For internal use only. /// </summary> /// <param name="cell"></param> /// <param name="pDragEventArgs"></param> public virtual void ChangeDragCell(CellContext cell, DragEventArgs pDragEventArgs) { if (cell.Position != mDragCellPosition) { if (mDragCellPosition.IsEmpty() == false) Controller.OnDragLeave(new CellContext(this, mDragCellPosition, GetCell(mDragCellPosition)), pDragEventArgs); if (cell.Position.IsEmpty() == false) Controller.OnDragEnter(cell, pDragEventArgs); mDragCellPosition = cell.Position; } }
/// <summary> /// Clear all the selected cells with a valid Model. /// </summary> public virtual void ClearValues(RangeRegion region) { PositionCollection positions = region.GetCellsPositions(); foreach (Position pos in positions) { CellContext cellContext = new CellContext(this, pos); if (cellContext.Cell != null) { if (cellContext.Cell.Editor != null) cellContext.Cell.Editor.ClearCell(cellContext); } } }
public CellContextEventArgs(CellContext pCellContext) { mCellContext = pCellContext; }
public override void OnValueChanging(CellContext sender, DevAge.ComponentModel.ValueEventArgs e) { base.OnValueChanging (sender, e); //BeginEdit on the row, set the Cancel = true if failed to start editing. bool success = ((DataGrid)sender.Grid).BeginEditRow(sender.Position.Row); if (success == false) throw new SourceGridException("Failed to editing row " + sender.Position.Row.ToString()); }
public object GetValue(CellContext cellContext) { DataGrid dataGrid = (DataGrid)cellContext.Grid; if (dataGrid.DataSource != null && dataGrid.DataSource.AllowNew && cellContext.Position.Row == (dataGrid.Rows.Count - 1)) return "*"; else return null; }
public object GetValue(CellContext cellContext) { Map map = (cellContext.Grid as FRom.Grid.FRomGrid).DataSource; return map[cellContext.Position.Column - cellContext.Grid.FixedColumns, cellContext.Position.Row - cellContext.Grid.FixedRows, null]; }
public virtual object GetValue(CellContext cellContext) { return cellContext.Position.Column - cellContext.Grid.FixedColumns; }
public ValidatingCellEventArgs(CellContext pCellContext, object p_NewValue) : base(pCellContext) { m_NewValue = p_NewValue; }
public virtual void SetValue(CellContext cellContext, object p_Value) { DevAge.ComponentModel.ValueEventArgs valArgs = new DevAge.ComponentModel.ValueEventArgs(p_Value); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); Array array = ((ArrayGrid)cellContext.Grid).DataSource; array.SetValue(valArgs.Value, cellContext.Position.Row - cellContext.Grid.FixedRows, cellContext.Position.Column - cellContext.Grid.FixedColumns); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
public virtual object GetValue(CellContext cellContext) { return cellContext.Position.Row - cellContext.Grid.FixedRows; }
public object GetValue(CellContext cellContext) { DataGrid grid = (DataGrid)cellContext.Grid; PropertyDescriptor prop = grid.Columns[cellContext.Position.Column].PropertyColumn; //Convert DbNull to null int dataIndex = grid.Rows.IndexToDataSourceIndex(cellContext.Position.Row); //Check if the row is not outside the valid range (for example to handle the new row) if (dataIndex >= grid.DataSource.Count) return null; else { object tmp = grid.DataSource.GetItemValue(dataIndex, prop); if (System.DBNull.Value == tmp) return null; else return tmp; } }
public CellCancelEventArgs(CellContext pCellContext) : base(pCellContext) { }
protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics, CellContext cellContext, RectangleF drawRectangle) { Range cellRange = PositionToCellRange(cellContext.Position); if (cellRange.ColumnsCount == 1 && cellRange.RowsCount == 1) { base.PaintCell(graphics, cellContext, drawRectangle); } else //Row/Col Span > 1 { // I draw the merged cell only if not already drawn otherwise // drawing the same cell can cause some problem when using // special drawing code (for example semi transparent background) if (mDrawnRange.Contains(cellRange) == false) { Rectangle spanRect = RangeToRectangle(cellRange); base.PaintCell(graphics, cellContext, spanRect); mDrawnRange.Add(cellRange); } } }
/// <summary> /// Process Delete, Ctrl+C, Ctrl+V, Up, Down, Left, Right, Tab keys /// </summary> /// <param name="e"></param> public virtual void ProcessSpecialGridKey(KeyEventArgs e) { if (e.Handled) return; bool enableArrows,enableTab,enablePageDownUp; enableArrows = enableTab = enablePageDownUp = false; if ( (SpecialKeys & GridSpecialKeys.Arrows) == GridSpecialKeys.Arrows) enableArrows = true; if ( (SpecialKeys & GridSpecialKeys.PageDownUp) == GridSpecialKeys.PageDownUp) enablePageDownUp = true; if ( (SpecialKeys & GridSpecialKeys.Tab) == GridSpecialKeys.Tab) enableTab = true; bool enableEscape = false; if ( (SpecialKeys & GridSpecialKeys.Escape) == GridSpecialKeys.Escape) enableEscape = true; bool enableEnter = false; if ( (SpecialKeys & GridSpecialKeys.Enter) == GridSpecialKeys.Enter) enableEnter = true; // AlanP: March 2014 - Work out which is the first column that is displayed after any fixed columns // We use firstActiveColumn in multiple places below int firstActiveColumn = this.FixedColumns; while ((firstActiveColumn < this.Columns.Count - 1) && !((ColumnInfoCollection)this.Columns)[firstActiveColumn].Visible) { firstActiveColumn++; } #region Processing keys // AlanP: Nov 2013. Made some changes to the behaviours of ENTER and Esc so we move to the next editable cell // Also there was a bug in the code that checked if a cell IsEditing // AlanP: Aug 2014. We have 2 styles of grid. The main one for displaying data tables and a spacialised one for Local Partner Data // The specialised one uses Controllers, where the standard one uses optional Editors CellContext focusCellContext = new CellContext(this, Selection.ActivePosition); ICellVirtual contextCell = focusCellContext.Cell; //if (focusCellContext.Cell != null && focusCellContext.IsEditing()) // AlanP: Nov 2013. Replcaed the line above with this because focusCellContext.IsEditing() returns false for a reason I don't understand. bool isEditorEditing = (contextCell != null && contextCell.Editor != null && contextCell.Editor.IsEditing); bool useSimplifiedTabEnter = ((SpecialKeys & GridSpecialKeys.SimplifiedTabEnter) == GridSpecialKeys.SimplifiedTabEnter); //Escape if (e.KeyCode == Keys.Escape && enableEscape) { if (isEditorEditing) { if (focusCellContext.EndEdit(true)) { // Move to next editable cell if there is one bool bFound = false; do { Selection.MoveActiveCell(0, 1, 0, int.MinValue); ICellVirtual nextContextCell = (new CellContext(this, Selection.ActivePosition)).Cell; bFound = (nextContextCell != null && nextContextCell.Editor != null && nextContextCell.Editor.EditableMode != EditableMode.None); } while (Selection.ActivePosition.Column != firstActiveColumn && !bFound); e.Handled = true; } } } //Enter if (e.KeyCode == Keys.Enter && enableEnter) { // This is the main special key for dealing with edit-in-place in OpenPetra // Pressing ENTER always completes an outstanding edit if (isEditorEditing) { focusCellContext.EndEdit(false); } if (useSimplifiedTabEnter) { return; } bool isLastColumn = (Selection.ActivePosition.Column == this.Columns.Count - 1); bool isFirstColumn = (Selection.ActivePosition.Column == firstActiveColumn); if (isFirstColumn) { // If we are on the first column and columns exist to the right then ENTER moves us to the next editable cell // or back to column 0 if there are no more editable cells if (!isLastColumn) { bool bFound = false; do { Selection.MoveActiveCell(0, 1, 0, int.MinValue); ICellVirtual nextContextCell = (new CellContext(this, Selection.ActivePosition)).Cell; bFound = (nextContextCell != null && nextContextCell.Editor != null && nextContextCell.Editor.EditableMode != EditableMode.None); } while (Selection.ActivePosition.Column != firstActiveColumn && !bFound); e.Handled = bFound; } else { e.Handled = false; } } else { // If we are NOT on the first column we go somewhere else depending on SHIFT or CTRL if (e.Modifiers == Keys.Shift) { // Go down 1 row in the current column and then ultimately back to column 0 on the last row this.Selection.MoveActiveCell(1, 0, 0, int.MinValue); } else if (e.Modifiers == Keys.Control) { // Go down 1 row in column 0 this.Selection.MoveActiveCell(1, -this.Selection.ActivePosition.Column, 0, int.MinValue); } else { // Neither SHIFT nor CTRL so go across to the right in the current row to the next editable control // or go back to column 0 in the current row bool bFound = false; do { Selection.MoveActiveCell(0, 1, 0, int.MinValue); ICellVirtual nextContextCell = (new CellContext(this, Selection.ActivePosition)).Cell; bFound = (nextContextCell != null && nextContextCell.Editor != null && nextContextCell.Editor.EditableMode != EditableMode.None); } while (Selection.ActivePosition.Column != firstActiveColumn && !bFound); } e.Handled = true; } return; } //Tab if (e.KeyCode == Keys.Tab && enableTab) { // All we need to do is close down any edit // Pressing TAB always completes an outstanding edit if (isEditorEditing) { focusCellContext.EndEdit(false); } if (useSimplifiedTabEnter) { // Carry on below... } else { // There is no controller on the cell (we have a controller on the special grid on LocalData screen) // That screen behaves differently. // For all normal grids be sure to go back to column 0 in the current row if (Selection.ActivePosition.Column != firstActiveColumn) { this.Selection.Focus(new Position(Selection.ActivePosition.Row, firstActiveColumn), true); } return; } } #endregion #region Navigate keys: arrows, tab and PgDown/Up var shiftPressed = e.Modifiers == Keys.Shift; var resetSelection = shiftPressed == false; // AlanP: Sep 2013. We need this because the first time we press SHIFT we may be on any row in the grid // This ensures that, if m_firstCellShiftSelected has never been set, it gets the current position before any move if (shiftPressed && (m_firstCellShiftSelected.Row < this.FixedRows)) { m_firstCellShiftSelected = Selection.ActivePosition; } if (e.KeyCode == Keys.Down && enableArrows) { Selection.MoveActiveCell(1, 0, resetSelection); e.Handled = true; } else if (e.KeyCode == Keys.Up && enableArrows) { Selection.MoveActiveCell(-1, 0, resetSelection); e.Handled = true; } else if (e.KeyCode == Keys.Right && enableArrows && SelectionMode == GridSelectionMode.Column) { // AlanP: Jan 2014 support left and right when in column selection mode only // (actually our column mode screens cannot take advantage of this feature because the ActivePosition has intentionally been set to -1,-1) Selection.MoveActiveCell(0, 1, resetSelection); e.Handled = true; } else if (e.KeyCode == Keys.Left && enableArrows && SelectionMode == GridSelectionMode.Column) { Selection.MoveActiveCell(0, -1, resetSelection); e.Handled = true; } else if (e.KeyCode == Keys.Tab && enableTab) { //If the tab failed I automatically select the next control in the form (SelectNextControl) if (e.Modifiers == Keys.Shift) // backward { if (Selection.MoveActiveCell(0, -1, -1, int.MaxValue) == false) FindForm().SelectNextControl(this, false, true, true, true); e.Handled = true; } else //forward { if (Selection.MoveActiveCell(0, 1, 1, int.MinValue) == false) FindForm().SelectNextControl(this, true, true, true, true); e.Handled = true; } } else if ( (e.KeyCode == Keys.PageUp || e.KeyCode == Keys.PageDown) && enablePageDownUp) { //MICK(18): I commented out this part - focusing is done within my CustomScrollPageDown() and CustomScrollPageUp() //Point focusPoint = PositionToRectangle(Selection.ActivePosition).Location; //focusPoint.Offset(1, 1); //in modo da entrare nella cella if (e.KeyCode == Keys.PageDown) CustomScrollPageDown(); else if (e.KeyCode == Keys.PageUp) CustomScrollPageUp(); //MICK(18): I commented out this part - focusing is done within my CustomScrollPageDown() and CustomScrollPageUp() //Position newPosition = PositionAtPoint(focusPoint); //if (Selection.CanReceiveFocus(newPosition)) // Selection.Focus(newPosition, true); e.Handled = true; } //ALAN - July 2013. I added '&& e.handled' to the if clause // This fixed several buggy behaviours // Pressing SHIFT on its own caused a cascade of Focus events and selection_changed events - the knock-on effects were amazing! // 1. Just pressing SHIFT would cause multiple highlighted rows to become just one highlighted row // 2. SHIFT+mouse click did not work. if (shiftPressed && e.Handled && !useSimplifiedTabEnter) { // AlanP: Sep 2013 Inhibit the change event on this one Selection.ResetSelection(true, true); // This fires the selection_changed event, then we are done Selection.SelectRange(new Range(m_firstCellShiftSelected, Selection.ActivePosition), true); } #endregion #region Clipboard RangeRegion selRegion = (ClipboardUseOnlyActivePosition ? new RangeRegion(Selection.ActivePosition) : Selection.GetSelectionRegion()); //Paste if (e.Control && e.KeyCode == Keys.V) { PerformPaste(selRegion); e.Handled = true; } //Copy else if (e.Control && e.KeyCode == Keys.C) { PerformCopy(selRegion); e.Handled = true; } //Cut else if (e.Control && e.KeyCode == Keys.X) { PerformCut(selRegion); e.Handled = true; } //Delete else if (e.KeyCode == Keys.Delete) { PerformDelete(selRegion); e.Handled = true; } #endregion }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); FParentClass.ChangedRowEvent(sender.Position.Row - 1); }
protected virtual void OnRangePaint(RangePaintEventArgs e) { Rectangle drawRectangle = RangeToRectangle(e.DrawingRange); System.Drawing.Drawing2D.GraphicsState state = e.GraphicsCache.Graphics.Save(); try { e.GraphicsCache.Graphics.SetClip(drawRectangle); int top = drawRectangle.Top; int width; int height; foreach (var r in m_Rows.HiddenRowsCoordinator.LoopVisibleRows(e.DrawingRange.Start.Row, e.DrawingRange.End.Row - e.DrawingRange.Start.Row)) //for (int r = e.DrawingRange.Start.Row; r <= e.DrawingRange.End.Row; r++) { if (Rows.IsRowVisible(r) == false) throw new SourceGridException("Incorrect internal state. This rows must have been visible"); height = Rows.GetHeight(r); int left = drawRectangle.Left; for (int c = e.DrawingRange.Start.Column; c <= e.DrawingRange.End.Column; c++) { width = Columns.GetWidth(c); if (Columns.IsColumnVisible(c) == false) continue; Position position = new Position(r, c); Cells.ICellVirtual cell = GetCell(position); if (cell != null) { Rectangle drawRect = new Rectangle(left, top, width, height); //Draw the cell only if inside the ClipRectangle if (e.GraphicsCache.ClipRectangle.IsEmpty || e.GraphicsCache.ClipRectangle.IntersectsWith(drawRect)) { CellContext cellContext = new CellContext(this, position, cell); PaintCell(e.GraphicsCache, cellContext, drawRect); } } left += width; } top += height; } //Draw the decorators foreach (SourceGrid.Decorators.DecoratorBase dec in Decorators) { if (dec.IntersectWith(e.DrawingRange)) dec.Draw(e); } if (RangePaint != null) RangePaint(this, e); } finally { e.GraphicsCache.Graphics.Restore(state); } }
public void SetValue(CellContext cellContext, object p_Value) { //Convert the null value to DbNull if (p_Value == null) p_Value = System.DBNull.Value; DevAge.ComponentModel.ValueEventArgs valArgs = new DevAge.ComponentModel.ValueEventArgs(p_Value); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); DataGrid grid = (DataGrid)cellContext.Grid; PropertyDescriptor prop = grid.Columns[cellContext.Position.Column].PropertyColumn; int dataIndex = grid.Rows.IndexToDataSourceIndex(cellContext.Position.Row); grid.DataSource.SetEditValue(prop, valArgs.Value); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
/// <summary> /// Draw the specified Cell /// </summary> protected virtual void PaintCell(DevAge.Drawing.GraphicsCache graphics, CellContext cellContext, RectangleF drawRectangle) { if (drawRectangle.Width > 0 && drawRectangle.Height > 0 && cellContext.CanBeDrawn() ) { cellContext.Cell.View.DrawCell(cellContext, graphics, drawRectangle); } }
public void SetValue(CellContext cellContext, object p_Value) { throw new ApplicationException("Not supported"); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); //verifico che l'eventuale edit sia terminato altrimenti esco if (Selection.ActivePosition.IsEmpty() == false) { CellContext focusCell = new CellContext(this, Selection.ActivePosition); if (focusCell.Cell != null && focusCell.IsEditing()) { if (focusCell.EndEdit(false) == false) return; } } //scateno eventi di MouseDown Position position = PositionAtPoint(new Point(e.X, e.Y)); if (position.IsEmpty() == false) { Cells.ICellVirtual cellMouseDown = GetCell(position); if (cellMouseDown != null) { // AlanP: Nov 2013. Added this if/else clause to set the position to the first column unless the click is on an editable cell if (cellMouseDown.Editor != null && cellMouseDown.Editor.EditableMode == EditableMode.Focus) { // The position is ok CellContext newFocusCell = new CellContext(this, position); newFocusCell.StartEdit(); } else if (position.Row >= this.FixedRows) { // AlanP: Jan 2014. Added this test that we are doing full row selection because on some grids we do column selection if (this.SelectionMode == GridSelectionMode.Row) { // always imagine that the click was on the first column // AlanP: March 2014 - the column is now the first VISIBLE column (in the normal sense, not visible in the display window) // AP screens may or may not display a checkbox column in column 0 int column = this.FixedColumns; while (column < this.Columns.Count - 1 && !((ColumnInfoCollection)this.Columns)[column].Visible) { column++; } position = new Position(position.Row, column); } } ChangeMouseDownCell(position, position); //Cell.OnMouseDown CellContext cellContext = new CellContext(this, position, cellMouseDown); Controller.OnMouseDown(cellContext, e); } } else ChangeMouseDownCell(Position.Empty, Position.Empty); }
public override void OnEditStarting(CellContext sender, CancelEventArgs e) { base.OnEditStarting (sender, e); //BeginEdit on the row, set the Cancel = true if failed to start editing. bool success = ((DataGrid)sender.Grid).BeginEditRow(sender.Position.Row); e.Cancel = !success; }
/// <summary> /// Measures the current column when drawn with the specified cells. /// </summary> /// <param name="column"></param> /// <param name="useRowHeight">True to fix the row height when measure the column width.</param> /// <param name="StartRow">Start row to measure</param> /// <param name="EndRow">End row to measure</param> /// <returns>Returns the required width</returns> public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow) { int min = Grid.MinimumWidth; if ((GetAutoSizeMode(column) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize) return min; for (int r = StartRow; r <= EndRow; r++) { Cells.ICellVirtual cell = Grid.GetCell(r, column); if (cell != null) { Position cellPosition = new Position(r, column); Size maxLayout = Size.Empty; //Use the width of the actual cell (considering spanned cells) if (useRowHeight) maxLayout.Height = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Height; CellContext cellContext = new CellContext(Grid, cellPosition, cell); Size cellSize = cellContext.Measure(maxLayout); if (cellSize.Width > min) min = cellSize.Width; } } return min; }