private void gridView1_BeforePrintRow(object sender, DevExpress.XtraGrid.Views.Printing.CancelPrintRowEventArgs e) { if (e.RowHandle >= 0) { if (!(sender is GridView)) { return; } GridView gridView = ((GridView)sender); DataRowView dataRow = gridView.GetRow(e.RowHandle) as DataRowView; if (dataRow == null) { return; } if ((bool)dataRow["Name6"]) { GridViewInfo vi = (GridViewInfo)gridView.GetViewInfo(); PropertyInfo pi = typeof(BaseView).GetProperty("PrintInfo", BindingFlags.Instance | BindingFlags.NonPublic); GridViewPrintInfo printInfo = (GridViewPrintInfo)pi.GetValue(gridView, null); GridRowInfo gridRowInfo = vi.GetGridRowInfo(e.RowHandle); SizeF clientPageSize = (e.BrickGraphics as BrickGraphics).ClientPageSize; //Draw other cells TextBrick tb = new TextBrick(); tb.Style.Padding = new PaddingInfo(2, 0, 0, 0); tb.BackColor = gridView.Appearance.Row.BackColor; tb.Text = (string)dataRow["Name1"]; tb.HorzAlignment = HorzAlignment.Near; float textBrickHeight = vi.ColumnRowHeight; GridCellInfo info = vi.GetGridCellInfo(e.RowHandle, gridView.Columns[0]); RectangleF textBrickRect = new RectangleF(e.X, e.Y, printInfo.Columns[0].Bounds.Width, (int)textBrickHeight); e.BrickGraphics.DrawBrick(tb, textBrickRect); //Draw merged cells TextBrick mergedTextBreak = new TextBrick(); mergedTextBreak.Style.Padding = new PaddingInfo(2, 0, 0, 0); mergedTextBreak.BackColor = gridView.Appearance.Row.BackColor; mergedTextBreak.Text = (string)dataRow["Name2"]; mergedTextBreak.HorzAlignment = HorzAlignment.Near; GridCellInfo mergedInfo = vi.GetGridCellInfo(e.RowHandle, gridView.Columns[1]); RectangleF textMergedBrickRect = new RectangleF(printInfo.Columns[1].Bounds.X, e.Y, ((PrintColumnInfo)printInfo.Columns[printInfo.Columns.Count - 1]).Bounds.Right - printInfo.Columns[0].Bounds.Width, (int)textBrickHeight); e.BrickGraphics.DrawBrick(mergedTextBreak, textMergedBrickRect); e.Y += (int)textBrickHeight; e.Cancel = true; } } }
/// <summary> /// Gets the form detail. /// </summary> /// <returns></returns> protected override FrmXtraBaseCategoryDetail GetFormDetail() { GridViewInfo info = gridView.GetViewInfo() as GridViewInfo; GridCellInfo cellInfo = info.GetGridCellInfo(gridView.FocusedRowHandle, gridView.Columns["AccountingObjectCode"]); if (cellInfo == null && ActionMode != TSD.Enum.ActionModeEnum.AddNew) { return(null); } if (ActionMode == TSD.Enum.ActionModeEnum.AddNew) { var selectedObject = gridView.GetFocusedRow() as AccountingObjectModel; if (selectedObject == null) { return(new FrmXtraAccountingObjectDetail()); } else { return new FrmXtraAccountingObjectDetail() { AccountingObjectCategoryId = selectedObject.AccountingObjectCategoryId } }; } else { var selectedObject = gridView.GetFocusedRow() as AccountingObjectModel; return(new FrmXtraAccountingObjectDetail() { AccountingObjectCategoryId = selectedObject?.AccountingObjectCategoryId ?? 0 }); } }
private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) { Point pt = e.ControlMousePosition; GridView view = gridView1; GridHitInfo hi = view.CalcHitInfo(pt); GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo; if (viewInfo == null) { return; } if (hi.InColumnPanel && hi.Column != null) { viewInfo.GetColumnLeftCoord(hi.Column); int columnLeftCoord = viewInfo.GetColumnLeftCoord(hi.Column); DevExpress.XtraGrid.Drawing.GridColumnInfoArgs columnInfo = viewInfo.ColumnsInfo[hi.Column]; e.Info = new DevExpress.Utils.ToolTipControlInfo(hi.Column, string.Format("'{0}'; left coord:{1}", columnInfo.Caption, columnLeftCoord)); } if (hi.InRowCell) { GridCellInfo cellInfo = viewInfo.GetGridCellInfo(hi); e.Info = new DevExpress.Utils.ToolTipControlInfo(cellInfo, string.Format("{0}: ({1}, {2})", cellInfo.ViewInfo.DisplayText, cellInfo.RowHandle, cellInfo.Column)); } if (hi.InGroupPanel) { Rectangle clientBounds = viewInfo.GroupPanel.ViewInfo.ClientBounds; e.Info = new DevExpress.Utils.ToolTipControlInfo(viewInfo.GroupPanel, string.Format("Group Panel: {0}", clientBounds)); } }
private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e) { GridView view = (GridView)sender; GridViewInfo viewInfo = (GridViewInfo)view.GetViewInfo(); if (e.RowHandle == view.FocusedRowHandle) { e.Appearance.BackColor = viewInfo.PaintAppearance.FocusedRow.BackColor; e.Appearance.ForeColor = viewInfo.PaintAppearance.FocusedRow.ForeColor; } else { GridCellInfo cell = viewInfo.GetGridCellInfo(e.RowHandle, e.Column); if (cell == null) { return; } if (!cell.IsMerged) { return; } foreach (GridCellInfo ci in cell.MergedCell.MergedCells) { if (ci.RowHandle == view.FocusedRowHandle) { e.Appearance.BackColor = viewInfo.PaintAppearance.FocusedRow.BackColor; e.Appearance.ForeColor = viewInfo.PaintAppearance.FocusedRow.ForeColor; break; } } } }
private static void CheckGridViewClick(MouseEventArgs e, GridView view) { GridHitInfo hi = view.CalcHitInfo(e.Location); if (hi.InRowCell) { GridViewInfo vi = view.GetViewInfo() as GridViewInfo; GridCellInfo cellInfo = vi.GetGridCellInfo(hi); if (cellInfo == null) { return; } CheckEditViewInfo cInfo = cellInfo.ViewInfo as CheckEditViewInfo; if (cInfo == null) { return; } Rectangle r = cInfo.CheckInfo.GlyphRect; r.Offset(cellInfo.Bounds.Location); if (r.Contains(e.Location)) { ProcessCheckClick(e, view, hi); } } }
private void gridView1_MouseDown(object sender, MouseEventArgs e) { GridView view = sender as GridView; //根据鼠标位置获取点击信息 GridHitInfo hInfo = view.CalcHitInfo(e.X, e.Y); if (hInfo.InRowCell && hInfo.Column.FieldName == "Class") { //获取单元格信息 GridViewInfo vInfo = view.GetViewInfo() as GridViewInfo; GridCellInfo cInfo = vInfo.GetGridCellInfo(hInfo); //如果单元格为可合并的 if (cInfo is GridMergedCellInfo) { //MemoEdit控件属性 var edit = new MemoEdit(); edit.Bounds = cInfo.Bounds; edit.Text = cInfo.CellValue.ToString(); //控件名称 定义为 memoedit+列名+GroupIndex值 edit.Name = "memoedit_" + hInfo.Column.FieldName + "_" + dt.Rows[hInfo.RowHandle]["GroupIndex"]; //控件鼠标离开事件 edit.MouseLeave += Edit_MouseLeave1; //控件值改变事件 edit.EditValueChanged += Edit_EditValueChanged; //将控件添加到GridControl中 gridControl1.Controls.Add(edit); } } }
private GridCellInfo GetGridCellInfo(GridViewInfo viewInfo, GridCell cell) { GridCellInfo gridCellInfo = viewInfo.GetGridCellInfo(cell.RowHandle, cell.Column); gridCellInfo.State &= ~(GridRowCellState.Focused | GridRowCellState.FocusedCell | GridRowCellState.Selected); System.Reflection.MethodInfo method = viewInfo.GetType().GetMethod("UpdateCellAppearanceCore", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); method.Invoke(viewInfo, new object[] { gridCellInfo, true, true, null }); return(gridCellInfo); }
public void DrawMergedCell(MyMergedCell cell, PaintEventArgs e) { int delta = cell.Column1.VisibleIndex - cell.Column2.VisibleIndex; if (Math.Abs(delta) > 1) { return; } GridViewInfo vi = View.GetViewInfo() as GridViewInfo; GridCellInfo gridCellInfo1 = vi.GetGridCellInfo(cell.RowHandle, cell.Column1); GridCellInfo gridCellInfo2 = vi.GetGridCellInfo(cell.RowHandle, cell.Column2); if (gridCellInfo1 == null || gridCellInfo2 == null) { return; } Rectangle targetRect = Rectangle.Union(gridCellInfo1.Bounds, gridCellInfo2.Bounds); gridCellInfo1.Bounds = targetRect; gridCellInfo1.CellValueRect = targetRect; gridCellInfo2.Bounds = targetRect; gridCellInfo2.CellValueRect = targetRect; if (delta < 0) { gridCellInfo1 = gridCellInfo2; } if (gridCellInfo1.ViewInfo == null) //yjkim modify { return; } Rectangle bounds = gridCellInfo1.ViewInfo.Bounds; //bounds.Location = new System.Drawing.Point(bounds.Location.X + 1, bounds.Location.Y + 1); bounds.Width = targetRect.Width - 2; bounds.Height = targetRect.Height - 2; gridCellInfo1.ViewInfo.Bounds = bounds; gridCellInfo1.ViewInfo.CalcViewInfo(e.Graphics); IsCustomPainting = true; GraphicsCache cache = new GraphicsCache(e.Graphics); gridCellInfo1.Appearance.FillRectangle(cache, gridCellInfo1.Bounds); DrawRowCell(new GridViewDrawArgs(cache, vi, vi.ViewRects.Bounds), gridCellInfo1); IsCustomPainting = false;; }
private void grdViewOC_MouseDown(object sender, MouseEventArgs e) { if ((Control.ModifierKeys & Keys.Control) != Keys.Control) { GridView view = sender as GridView; GridHitInfo hi = view.CalcHitInfo(e.Location); if (hi.InRowCell) { if (hi.Column.RealColumnEdit.GetType() == typeof(RepositoryItemCheckEdit)) { view.FocusedRowHandle = hi.RowHandle; view.FocusedColumn = hi.Column; view.ShowEditor(); CheckEdit checkEdit = view.ActiveEditor as CheckEdit; CheckEditViewInfo checkInfo = (CheckEditViewInfo)checkEdit.GetViewInfo(); Rectangle glyphRect = checkInfo.CheckInfo.GlyphRect; GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo; Rectangle gridGlyphRect = new Rectangle(viewInfo.GetGridCellInfo(hi).Bounds.X + glyphRect.X, viewInfo.GetGridCellInfo(hi).Bounds.Y + glyphRect.Y, glyphRect.Width, glyphRect.Height); if (!gridGlyphRect.Contains(e.Location)) { view.CloseEditor(); if (!view.IsCellSelected(hi.RowHandle, hi.Column)) { view.SelectCell(hi.RowHandle, hi.Column); } else { view.UnselectCell(hi.RowHandle, hi.Column); } } else { checkEdit.Checked = !checkEdit.Checked; view.CloseEditor(); } (e as DevExpress.Utils.DXMouseEventArgs).Handled = true; } } } }
public static Rectangle GetGridCellRect(GridView view, int rowHandle, GridColumn column) { GridViewInfo info = GetGridViewInfo(view); GridCellInfo cell = info.GetGridCellInfo(rowHandle, column); if (cell != null) { return(cell.Bounds); } return(Rectangle.Empty); }
public Rectangle GetCellBounds(GridCell cell) { if (cell == null) { return(Rectangle.Empty); } GridViewInfo info = _View.GetViewInfo() as GridViewInfo; GridCellInfo cellInfo = info.GetGridCellInfo(cell.RowHandle, cell.Column); return(cellInfo.Bounds); }
public static GridCellInfo GetCellInfo(this GridView view, int rowHandle, GridColumn col) { GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo; GridCellInfo ci = viewInfo.GetGridCellInfo(rowHandle, col); if (ci == null) { return(null); } viewInfo.UpdateCellAppearance(ci); return(ci); }
//void SetMeasureUnits(params DateTimeMeasureUnit[] units) //{ // object prevUnit = String.IsNullOrEmpty(ChartDataMeasureUnit.SelectedItem.ToString()) ? null : Enum.Parse(typeof(DateTimeMeasureUnit), ChartDataMeasureUnit.SelectedItem.ToString()); // string prevItem = ""; // ChartDataMeasureUnit.Properties.Items.Clear(); // foreach (DateTimeMeasureUnit unit in units) // { // string unitName = Enum.GetName(typeof(DateTimeMeasureUnit), unit); // ChartDataMeasureUnit.Properties.Items.Add(unitName); // if (prevUnit != null && object.Equals(unit, (DateTimeMeasureUnit)prevUnit)) // prevItem = unitName; // } // if (!String.IsNullOrEmpty(prevItem)) // ChartDataMeasureUnit.SelectedItem = prevItem; // else // ChartDataMeasureUnit.SelectedIndex = 0; //} //private void cbChartDataMeasureUnit_SelectedIndexChanged(object sender, EventArgs e) //{ // XYDiagram diagram = null; // (XYDiagram)Chart.Diagram; // DateTimeMeasureUnit unit = (DateTimeMeasureUnit)Enum.Parse(typeof(DateTimeMeasureUnit), ChartDataMeasureUnit.SelectedItem.ToString()); // diagram.AxisX.DateTimeScaleOptions.GridAlignment = (DateTimeGridAlignment)unit; // diagram.AxisX.DateTimeScaleOptions.MeasureUnit = unit; // switch (unit) // { // case DateTimeMeasureUnit.Year: // diagram.AxisX.Label.TextPattern = "{A:yyyy}"; // break; // case DateTimeMeasureUnit.Quarter: // diagram.AxisX.Label.TextPattern = "{A:yyyy}"; // todo: fix // //diagram.AxisX.Label.DateTimeOptions.Format = DateTimeFormat.QuarterAndYear; // break; // case DateTimeMeasureUnit.Month: // diagram.AxisX.Label.TextPattern = "{A:yyyy}"; // todo: fix // //diagram.AxisX.DateTimeOptions.Format = DateTimeFormat.MonthAndYear; // break; // default: // break; // } //} /// <summary> /// Field grid cell clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FieldGrid_MouseClick(object sender, MouseEventArgs e) { GridHitInfo hi = FieldGridView.CalcHitInfo(e.Location); int ri = hi.RowHandle; if (ri < 0) { return; } PivotGridFieldMx f = Field = PivotGrid.Fields[ri] as PivotGridFieldMx; ResultsField rfld = f.ResultsField as ResultsField; AggregationDef agg = f.Aggregation; Mobius.Data.QueryColumn qc = rfld.QueryColumn; MetaColumn mc = qc.MetaColumn; GridColumn gc = hi.Column; if (gc == null) { return; } FieldGridRow = hi.RowHandle; FieldGridColumn = gc.AbsoluteIndex; GridViewInfo viewInfo = (GridViewInfo)FieldGridView.GetViewInfo(); GridCellInfo cellInfo = viewInfo.GetGridCellInfo(hi); Point menuLoc = new Point(cellInfo.Bounds.Left, cellInfo.Bounds.Bottom); menuLoc = FieldGrid.PointToScreen(menuLoc); if (gc.FieldName == "AggRoleCol") // show appropriate aggregation type menu { AggregationDefMenus.ShowRoleMenu(qc, f.Aggregation, menuLoc, AggregationRoleChanged); return; } else if (gc.FieldName == "AggTypeCol") // show appropriate aggregation type menu { AggregationDefMenus.ShowTypeMenu(qc, f.Aggregation, menuLoc, AggregationTypeChanged); return; } else if (gc.FieldName == "SourceColumnCol" || gc.FieldName == "SourceTableCol") { return; } }
Rectangle GetCellRect(GridView view, int rowHandle, GridColumn column) { // the GetGridViewInfo function can be found in article #2624 // GridViewInfo info = GetGridViewInfo(view); GridViewInfo info = (GridViewInfo)view.GetViewInfo(); GridCellInfo cell = info.GetGridCellInfo(rowHandle, column); if (cell != null) { return(cell.Bounds); } return(Rectangle.Empty); }
public void DrawMergedCell(MyMergedCell cell, PaintExEventArgs e) { int delta = cell.Column1.VisibleIndex - cell.Column2.VisibleIndex; if (Math.Abs(delta) > 1) { return; } GridViewInfo vi = View.GetViewInfo() as GridViewInfo; GridCellInfo gridCellInfo1 = vi.GetGridCellInfo(cell.RowHandle, cell.Column1); GridCellInfo gridCellInfo2 = vi.GetGridCellInfo(cell.RowHandle, cell.Column2); if (gridCellInfo1 == null || gridCellInfo2 == null) { return; } Rectangle targetRect = Rectangle.Union(gridCellInfo1.Bounds, gridCellInfo2.Bounds); gridCellInfo1.Bounds = targetRect; gridCellInfo1.CellValueRect = targetRect; gridCellInfo2.Bounds = targetRect; gridCellInfo2.CellValueRect = targetRect; if (delta < 0) { gridCellInfo1 = gridCellInfo2; } Rectangle bounds = gridCellInfo1.ViewInfo.Bounds; bounds.Width = targetRect.Width; bounds.Height = targetRect.Height; gridCellInfo1.ViewInfo.Bounds = bounds; gridCellInfo1.ViewInfo.CalcViewInfo(e.Cache.Graphics); IsCustomPainting = true; gridCellInfo1.Appearance.FillRectangle(e.Cache, gridCellInfo1.Bounds); DrawRowCell(new GridViewDrawArgs(e.Cache, vi, vi.ViewRects.Bounds), gridCellInfo1); IsCustomPainting = false; }
private void gridView1_MouseDown(object sender, MouseEventArgs e) { Point p; int ri, ci; GridHitInfo ghi = GridView.CalcHitInfo(e.Location); if (ghi.Column.AbsoluteIndex != 1) { return; } ri = ghi.RowHandle; QueryTable qt = Query.Tables[ri]; ContextMenuStrip colPopup = new ContextMenuStrip(); bool firstLabel = true; foreach (QueryColumn qc in qt.QueryColumns) { // get list of allowed field labels/names for each table if (!QueryTableControl.QueryColumnVisible(qc) || !qc.MetaColumn.IsSearchable) { continue; } if (firstLabel) { firstLabel = false; } string label = CriteriaEditor.GetUniqueColumnLabel(qc); ToolStripMenuItem mi = new ToolStripMenuItem(label, null, new System.EventHandler(SelectedField_Click)); mi.Tag = "T" + (ri + 1); colPopup.Items.Add(mi); } p = e.Location; GridViewInfo viewInfo = (GridViewInfo)GridView.GetViewInfo(); GridCellInfo cellInfo = viewInfo.GetGridCellInfo(ghi.RowHandle, ghi.Column); if (cellInfo != null) { p = new Point(cellInfo.Bounds.Left, cellInfo.Bounds.Bottom); } colPopup.Show(Instance.TableGrid, p); }
AppearanceObject GetCellAppearance(int gridRowHandle, GridColumn gridColumn) { GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo; GridCellInfo cellInfo = viewInfo.GetGridCellInfo(gridRowHandle, gridColumn); if (cellInfo == null) { cellInfo = new GridCellInfo(new GridColumnInfoArgs(gridColumn), new GridDataRowInfo(viewInfo, gridRowHandle, view.GetRowLevel(gridRowHandle)), Rectangle.Empty); } MethodInfo me = viewInfo.GetType().GetMethod("UpdateCellAppearance", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly); if (me != null) { me.Invoke(viewInfo, new object[] { cellInfo, true }); } viewInfo.UpdateCellAppearance(cellInfo); return(cellInfo.Appearance); }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { //if (e.KeyData == (Keys.Control| Keys.R)) //{ // _iSearch = 0; //} //if (!IsDieuXe) //{ // if (e.KeyData == Keys.Enter) // { // GridEnter(); // } // //else if (e.KeyData == Keys.D1 || e.KeyData == Keys.NumPad1) // //{ // // _iSearch = 0; // // GridDaDonDuocKhach(); // //} // return; //} if (e.KeyData == Keys.Enter) { GridEnter(); } if (e.KeyData == Keys.Apps) { GridViewInfo info = (GridViewInfo)gridView_Bookings.GetViewInfo(); GridCellInfo cell = info.GetGridCellInfo(gridView_Bookings.FocusedRowHandle, gridView_Bookings.FocusedColumn); if (cell != null && cell.Bounds != null) { cMenu.Show(shGridControl_Bookings, cell.Bounds.X + cell.Column.Width / 2, cell.Bounds.Y + cell.RowInfo.RowLineHeight / 2); } } //else if (e.KeyData == Keys.Delete) //{ // //_iSearch = 0; // //GridDelete(); //} //else if (e.KeyData == Keys.D1 || e.KeyData == Keys.NumPad1) //{ // _iSearch = 0; // GridDaDonDuocKhach(); //} }
private void GV_Main_MouseDown(object sender, MouseEventArgs e) { GridHitInfo hitInfo = GV_Main.CalcHitInfo(e.Location); if (hitInfo == null || hitInfo.Column == null) { return; } if (hitInfo.Column.FieldName == "XR005") { GridViewInfo info = (GridViewInfo)GV_Main.GetViewInfo(); if (info != null) { GridCellInfo cell = info.GetGridCellInfo(hitInfo.RowHandle, hitInfo.Column); if (cell != null) { int mGrade = ((e.X - cell.Bounds.X) / 32) + 1; if (e.Button == MouseButtons.Right) { mGrade = mGrade * -1; } GV_Main.SetRowCellValue(hitInfo.RowHandle, "XR005", mGrade); DXMouseEventArgs.GetMouseArgs(e).Handled = true; } } } else if (hitInfo.Column.FieldName == "XR006") { GV_Main.FocusedColumn = hitInfo.Column; GV_Main.FocusedRowHandle = hitInfo.RowHandle; ShowBosxMemo sbm = new ShowBosxMemo(); sbm.SetCanEdit = true; sbm.SetMemo = GV_Main.GetRowCellValue(hitInfo.RowHandle, "XR006").ToString(); if (sbm.ShowDialog() == DialogResult.OK) { GV_Main.SetRowCellValue(hitInfo.RowHandle, "XR006", sbm.GetReturn); } DXMouseEventArgs.GetMouseArgs(e).Handled = true; } }
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { try { if (e.Column == gridColumnFormName) { string name = gridView1.GetRowCellDisplayText(gridView1.FocusedRowHandle, "FileName"); var formToChoose = (from f in formsList where f.name == name select f).DefaultIfEmpty().First(); if (formToChoose != null) { formToChoose.form.BringToFront(); } } else if (e.Column == gridColumnCommands) { GridViewInfo viewInfo = gridView1.GetViewInfo() as GridViewInfo; GridHitInfo hitInfo = gridView1.CalcHitInfo(e.Location); GridCellInfo cell = viewInfo.GetGridCellInfo(hitInfo); if (cell == null || cell.Column == null || cell.Column.View == null) { return; } Point hitPoint = GetCellPoint(cell, e.Location); ButtonEditViewInfo buttonEditViewInfo = cell.ViewInfo as ButtonEditViewInfo; DevExpress.XtraEditors.Drawing.EditorButtonObjectInfoArgs buttonInfoByPoint = buttonEditViewInfo.ButtonInfoByPoint(hitPoint); if (buttonInfoByPoint != null) { repositoryItemButtonEdit1_ButtonClick(null, new DevExpress.XtraEditors.Controls.ButtonPressedEventArgs(buttonInfoByPoint.Button)); } } } catch (Exception ex) { MessageBox.Show(MiscStuff.GetAllMessages(ex)); } }
public Cursor GetDragCellCursor(GridHitInfo hitInfo, Point e) { GridViewInfo info = _View.GetViewInfo() as GridViewInfo; GridCellInfo cellinfo = info.GetGridCellInfo(hitInfo); Rectangle imageBounds = new Rectangle(new Point(0, 0), cellinfo.Bounds.Size); Rectangle totalBounds = new Rectangle(new Point(0, 0), info.Bounds.Size); Bitmap bitmap = new Bitmap(totalBounds.Width, totalBounds.Height); DevExpress.Utils.Drawing.GraphicsCache cache = new DevExpress.Utils.Drawing.GraphicsCache(Graphics.FromImage(bitmap)); GridViewDrawArgs args = new GridViewDrawArgs(cache, info, totalBounds); base.DrawRowCell(args, cellinfo); Bitmap result = new Bitmap(imageBounds.Width, imageBounds.Height); Graphics resultGraphics = Graphics.FromImage(result); float[][] matrixItems = { new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, 0.7f, 0 }, new float[] { 0, 0, 0, 0, 1 } }; ColorMatrix colorMatrix = new ColorMatrix(matrixItems); ImageAttributes imageAttributes = new ImageAttributes(); imageAttributes.SetColorMatrix( colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); resultGraphics.DrawImage(bitmap, imageBounds, cellinfo.Bounds.X, cellinfo.Bounds.Y, cellinfo.Bounds.Width, cellinfo.Bounds.Height, GraphicsUnit.Pixel, imageAttributes); resultGraphics.DrawIcon(Icon.FromHandle(Cursors.Default.Handle), 0, 0); return(CreateCursor(result)); }
Rectangle GetCellRect(GridView view, int rowHandle, GridColumn column) { GridViewInfo viewInfo = GetGridViewInfo(view); return(viewInfo.GetGridCellInfo(rowHandle, column).Bounds); }
private void ColGridView_MouseDown(object sender, MouseEventArgs e) { Point p; Rectangle rect; string txt; int qtCi, ri, ci; if (View == null) { return; } p = new Point(e.X, e.Y); GridHitInfo ghi = View.CalcHitInfo(p); if (ghi == null) { return; } ri = ghi.RowHandle; if (ghi.Column == null) { return; } GridColumn gc = ghi.Column; GridViewInfo viewInfo = View.GetViewInfo() as GridViewInfo; GridCellInfo gci = viewInfo.GetGridCellInfo(ghi); if (gci == null) { return; } ri = ghi.RowHandle; if (ri == GridControl.NewItemRowHandle) // click in virtual new row? { DataRow dr = ColGridDataTable.NewRow(); ColGridDataTable.Rows.Add(dr); DelayedCallback.Schedule(ClickedInNewRow, gc); // schedule callback for after grid rendered with new row return; } if (ri >= ColGridDataTable.Rows.Count) { return; } CurrentRow = ri; if (Lex.Eq(gc.Name, "CustomFormat")) // Show format col { MetaColumn mc = GetMetaColumnFromColGridDataTableRow(ColGridDataTable.Rows[ri]); if (mc == null) { return; } ColumnFormattingContextMenu.Show(ColGrid, p); this.Refresh(); return; } return; }
public void DrawMergedCell(MyMergedCell cell, PaintEventArgs e) { int delta = cell.Column1.VisibleIndex - cell.Column2.VisibleIndex; if (Math.Abs(delta) > 1) { return; } GridViewInfo vi = View.GetViewInfo() as GridViewInfo; GridCellInfo gridCellInfo1 = vi.GetGridCellInfo(cell.RowHandle, cell.Column1); GridCellInfo gridCellInfo2 = vi.GetGridCellInfo(cell.RowHandle, cell.Column2); if (gridCellInfo1 != null && gridCellInfo2 == null) { gridCellInfo2 = gridCellInfo1; } if (gridCellInfo1 == null || gridCellInfo2 == null) { return; } Rectangle targetRect = Rectangle.Union(gridCellInfo1.Bounds, gridCellInfo2.Bounds); gridCellInfo1.Bounds = targetRect; gridCellInfo1.CellValueRect = targetRect; gridCellInfo2.Bounds = targetRect; gridCellInfo2.CellValueRect = targetRect; if (delta < 0) { gridCellInfo1 = gridCellInfo2; } if (gridCellInfo1.ViewInfo == null) { return; } int prevX = gridCellInfo1.Bounds.X; Rectangle bounds = gridCellInfo1.ViewInfo.Bounds; bounds.Width = targetRect.Width; bounds.Height = targetRect.Height; gridCellInfo1.ViewInfo.Bounds = bounds; gridCellInfo1.ViewInfo.CalcViewInfo(e.Graphics); IsCustomPainting = true; GraphicsCache cache = new GraphicsCache(e.Graphics); int width = gridCellInfo1.Bounds.Width; if (gridCellInfo1.Bounds.Right >= vi.View.GridControl.Width) { width -= gridCellInfo1.Bounds.Right - vi.View.GridControl.Width + 2; } int cellX = 0; int columnIndent = vi.ColumnsInfo[0].Type == GridColumnInfoType.Indicator ? vi.ColumnsInfo[0].Bounds.Right : vi.ColumnsInfo[0].Bounds.X; cellX = Math.Max(gridCellInfo1.Bounds.X, columnIndent); if (vi.View.OptionsView.ShowIndicator && gridCellInfo1.Bounds.X < vi.ViewRects.IndicatorWidth) { width += gridCellInfo1.Bounds.X - vi.ViewRects.IndicatorWidth - 1; } gridCellInfo1.Bounds = new Rectangle(cellX, gridCellInfo1.Bounds.Y, width, gridCellInfo1.Bounds.Height); gridCellInfo1.Appearance.FillRectangle(cache, gridCellInfo1.Bounds); gridCellInfo1.CellValueRect.Location = new Point(gridCellInfo1.CellValueRect.Location.X + gridCellInfo1.Bounds.X - prevX, gridCellInfo1.CellValueRect.Location.Y); DrawRowCell(new GridViewDrawArgs(cache, vi, vi.ViewRects.Bounds), gridCellInfo1); IsCustomPainting = false;; }
public DialogResult ShowKeyboard(GridView view, int rowhandle, int columnindex) { if (view == null) { return(DialogResult.Abort); } DataRowView dr = (DataRowView)view.GetRow(rowhandle); DevExpress.XtraGrid.Columns.GridColumn col = view.Columns[columnindex]; Type type = col.ColumnType; object value = dr[columnindex]; GridViewInfo info = (GridViewInfo)view.GetViewInfo(); //GridCellInfo cell = info.GetGridCellInfo(rowhandle, col); GridCellInfo cell = info.GetGridCellInfo(rowhandle, col.AbsoluteIndex); //Tuugii Rectangle r; if (cell != null) { r = cell.Bounds; } else { r = Rectangle.Empty; } DialogResult res = DialogResult.OK; switch (type.Name) { case "String": frmKeyboard frm1 = new frmKeyboard(null); frm1.Location = GetVisiblePosition(r, frm1); frm1.Value = value == null ? "" : Convert.ToString(value); res = frm1.ShowDialog(); if (res == DialogResult.OK) { view.SetRowCellValue(rowhandle, col, frm1.Value); } break; case "DateTime": frmDatepad frm2 = new frmDatepad(null); frm2.Location = GetVisiblePosition(r, frm2); frm2.Value = value == null ? DateTime.Today : Convert.ToDateTime(value); res = frm2.ShowDialog(); if (res == DialogResult.OK) { view.SetRowCellValue(rowhandle, col, frm2.Value); } break; default: frmNumpad frm3 = new frmNumpad(null); frm3.Location = GetVisiblePosition(r, frm3); frm3.Value = value == null ? 0 : Convert.ToDecimal(value); res = frm3.ShowDialog(); if (res == DialogResult.OK) { view.SetRowCellValue(rowhandle, col, frm3.Value); } break; } return(res); }
private void GridView_MouseUp_Callback(object state) { ColumnMapMsx cm; QueryColumn qc; QnfEnum subColumn; DialogResult dr; string newSpotfireName; MouseEventArgs e = state as MouseEventArgs; if (e == null) return; Point p = new Point(e.X, e.Y); GridHitInfo gridHitInfo = FieldGridView.CalcHitInfo(p); GridViewInfo gridViewInfo = FieldGridView.GetViewInfo() as GridViewInfo; GridCellInfo gridCellInfo = gridViewInfo.GetGridCellInfo(gridHitInfo); int ri = gridHitInfo.RowHandle; if (ri < 0) return; GridColumn gc = gridHitInfo.Column; if (gc == null) return; int c = gc.AbsoluteIndex; if (SelectSingleColumn) // just do a simple single column selection { UpdateSelectSingleColumnData(ri); return; } DataRow dRow = FieldDataTable.Rows[ri]; //DataMap.ColumnMapList.Items[ri]; cm = dRow["ColumnMapMsxRefField"] as ColumnMapMsx; // get ColumnMap for current item if (cm == null) throw new Exception("Null ColumnMapMsxRefField"); //if (cm == null) qc = null; //else qc = cm.QueryColumn; qc = cm.QueryColumn; subColumn = cm.SubColumn; // Rename column if (gc == SpotfireColNameCol) { RenameColumn(ri); return; } // Commands checked below are only available if editing of the mapping is allowed if (!CanEditMapping) return; // Select which Mobius column maps to a Spotfire Column if (gc == MobiusTableNameCol || gc == MobiusColNameCol) // select Mobius column to match if defining mapping { string role = dRow["OriginalSpotfireColNameField"] as string; if (Lex.IsUndefined(role)) return; // can only assign cols with "roles" from the original template analysis string spotfireName = ""; FieldSelectorControl fieldSelector = new FieldSelectorControl(); fieldSelector.QueryColumn = qc; SelectColumnOptions flags = new SelectColumnOptions(); flags.ExcludeImages = true; flags.FirstTableKeyOnly = true; flags.SelectFromQueryOnly = true; flags.QnSubcolsToInclude = QnfEnum.Split | QnfEnum.Qualifier | QnfEnum.NumericValue | QnfEnum.NValue; // split QualifiedNumbers flags.IncludeNoneItem = true; flags.AllowedDataTypes = DataTableMapMsx.GetMetaColumnTypesCompatibleWithSpotfireColumn(cm.SpotfireColumn, allowCompoundId: (ri == 0)); p = FieldGrid.PointToScreen(p); if (CurrentMap.QueryTable != null) // select from single query table only dr = fieldSelector.SelectColumnFromQueryTable(CurrentMap.QueryTable, qc, flags, p.X, p.Y, out qc, out subColumn); else // select from any table in the query dr = fieldSelector.SelectColumnFromQuery(Query, qc, flags, p.X, p.Y, out qc, out subColumn); if (dr != DialogResult.OK) return; cm.QueryColumn = qc; // new query column mapped to if (qc != null) // assigning a new QueryColumn { dRow["MobiusTableNameField"] = qc.QueryTable.ActiveLabel; dRow["MobiusColNameField"] = qc.ActiveLabel; newSpotfireName = CurrentMap.AssignUniqueSpotfireColumnName(qc.ActiveLabel); dRow["SpotfireColNameField"] = newSpotfireName; // update grid cm.SpotfireColumnName = newSpotfireName; // store new name //if (Lex.Ne(cm.SpotfireColumnName, newSpotfireName)) // changing name? //{ // cm.NewSpotfireColumnName = newSpotfireName; // store new name //} cm.MobiusFileColumnName = qc.MetaTableDotMetaColumnName + ColumnMapParms.SpotfireExportExtraColNameSuffix; } else // set to none (e.g. null col) { dRow["MobiusTableNameField"] = ""; dRow["MobiusColNameField"] = ""; newSpotfireName = CurrentMap.AssignUniqueSpotfireColumnName("None"); dRow["SpotfireColNameField"] = newSpotfireName; // update grid cm.SpotfireColumnName = newSpotfireName; // update map //cm.NewSpotfireColumnName = newSpotfireName; // update map cm.MobiusFileColumnName = ""; // not mapped to a col } FieldGrid.RefreshDataSource(); SVM.RemapDataTable(CurrentMap); // update spotfire view accordingly UpdateFieldGridDataTable(); cm.NewSpotfireColumnName = ""; // clear new name used for rename (needed?) } return; }