コード例 #1
0
 private void CellPaintEventHandler(object sender, object e)
 {
     try
     {
         int lRowNumber = (int)(long)e.GetType().InvokeMember("RowNumber", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public, null, e, null);
         Microsoft.SqlServer.Management.UI.Grid.GridColumn oCol = (Microsoft.SqlServer.Management.UI.Grid.GridColumn)e.GetType().InvokeMember("GridColumn", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public, null, e, null);
         int iColumnIndex = oCol.ColumnIndex;
         Microsoft.SqlServer.Management.UI.Grid.DlgGridControl grid2 = (Microsoft.SqlServer.Management.UI.Grid.DlgGridControl)sender;
         Microsoft.SqlServer.Management.UI.Grid.GridCell       cell  = grid2.GetCellInfo(lRowNumber, iColumnIndex);
         TriStatePerspectiveGridCell cell2 = cell as TriStatePerspectiveGridCell;
         if (cell2 != null && cell2.OverrideBkBrush != null)
         {
             int iSelectedRow = 0;
             int iSelectedCol = 0;
             grid2.GetSelectedCell(out iSelectedRow, out iSelectedCol);
             if (iSelectedCol == iColumnIndex && iSelectedRow == lRowNumber && cell2.OverrideBkBrush.Color != System.Drawing.Color.Red)
             {
                 return; //to avoid this selected cell looking funny when it's not highlighted but selected
             }
             System.Drawing.Graphics  g    = (System.Drawing.Graphics)e.GetType().InvokeMember("Graphics", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public, null, e, null);
             System.Drawing.Rectangle rect = (System.Drawing.Rectangle)e.GetType().InvokeMember("CellRectangle", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public, null, e, null);
             rect.X      += 1;
             rect.Y      += 2;
             rect.Width  -= 2;
             rect.Height -= 3;
             g.DrawRectangle(new System.Drawing.Pen(cell2.OverrideBkBrush.Color, (float)2), rect);
         }
     }
     catch { }
 }
コード例 #2
0
        private void HighlightCell(bool bHighlight, object[] columns, object cell, int j)
        {
            System.Drawing.SolidBrush brush = null;
            if (bHighlight)
            {
                brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            }
            else
            {
                System.Reflection.BindingFlags getpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                brush = (System.Drawing.SolidBrush)columns[j + 1].GetType().InvokeMember("BkBrush", getpropertyflags, null, columns[j + 1], null);
            }

#if !(YUKON || KATMAI)
            //do this a new way that will work with VS2012 SSDT2012 and it's new usage of BkBrush to setup the new color scheme
            if (_IsMetroOrGreater)
            {
                if (!(cell is TriStatePerspectiveGridCell))
                {
                    if (bHighlight) //only switch to a TriStatePerspectiveGridCell if we need to highlight
                    {
                        TriStatePerspectiveGridCell newcell = new TriStatePerspectiveGridCell((Microsoft.SqlServer.Management.UI.Grid.GridCell)cell);
                        columns[j] = newcell;
                        cell       = newcell;
                        newcell.OverrideBkBrush = brush;
                    }
                }
                else
                {
                    lock (cell)
                    {
                        TriStatePerspectiveGridCell newcell = (TriStatePerspectiveGridCell)cell;
                        newcell.OverrideBkBrush = brush;
                    }
                }
                return;
            }
#endif
            System.Reflection.BindingFlags setpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
            lock (cell)
            {
                cell.GetType().InvokeMember("BkBrush", setpropertyflags, null, cell, new object[] { brush });
            }
        }
コード例 #3
0
        private void HighlightCell(bool bHighlight, object[] columns, object cell, int j)
        {
            System.Drawing.SolidBrush brush = null;
            if (bHighlight)
            {
                brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            }
            else
            {
                System.Reflection.BindingFlags getpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                brush = (System.Drawing.SolidBrush)columns[j + 1].GetType().InvokeMember("BkBrush", getpropertyflags, null, columns[j + 1], null);
            }

#if DENALI || SQL2014
            //do this a new way that will work with VS2012 SSDT2012 and it's new usage of BkBrush to setup the new color scheme
            if (_IsMetroOrGreater)
            {
                if (!(cell is TriStatePerspectiveGridCell))
                {
                    if (bHighlight) //only switch to a TriStatePerspectiveGridCell if we need to highlight
                    {
                        TriStatePerspectiveGridCell newcell = new TriStatePerspectiveGridCell((Microsoft.SqlServer.Management.UI.Grid.GridCell)cell);
                        columns[j] = newcell;
                        cell = newcell;
                        newcell.OverrideBkBrush = brush;
                    }
                }
                else
                {
                    lock (cell)
                    {
                        TriStatePerspectiveGridCell newcell = (TriStatePerspectiveGridCell)cell;
                        newcell.OverrideBkBrush = brush;
                    }
                }
                return;
            }
#endif
            System.Reflection.BindingFlags setpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
            lock (cell)
            {
                cell.GetType().InvokeMember("BkBrush", setpropertyflags, null, cell, new object[] { brush });
            }
        }