/// <summary> /// Initialize a new instance of the PaletteTreeStateRedirect class. /// </summary> /// <param name="redirect">inheritance redirection instance.</param> /// <param name="back">Storage for back values.</param> /// <param name="backInherit">inheritance for back values.</param> /// <param name="border">Storage for border values.</param> /// <param name="borderInherit">inheritance for border values.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteTreeStateRedirect(PaletteRedirect redirect, PaletteBack back, PaletteBackInheritRedirect backInherit, PaletteBorder border, PaletteBorderInheritRedirect borderInherit, NeedPaintHandler needPaint) : base(redirect, back, backInherit, border, borderInherit, needPaint) { Debug.Assert(redirect != null); // Remember the redirect reference _redirect = redirect; // Create the item redirector Node = new PaletteTripleRedirect(redirect, PaletteBackStyle.ButtonListItem, PaletteBorderStyle.ButtonListItem, PaletteContentStyle.ButtonListItem, needPaint); }
/// <summary> /// Initialize a new instance of the PaletteDataGridViewTripleRedirect class. /// </summary> /// <param name="redirect">inheritance redirection instance.</param> /// <param name="backStyle">Initial background style.</param> /// <param name="borderStyle">Initial border style.</param> /// <param name="contentStyle">Initial content style.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteDataGridViewTripleRedirect(PaletteRedirect redirect, PaletteBackStyle backStyle, PaletteBorderStyle borderStyle, PaletteContentStyle contentStyle, NeedPaintHandler needPaint) { Debug.Assert(redirect != null); // Store the provided paint notification delegate NeedPaint = needPaint; // Store the inherit instances _backInherit = new PaletteBackInheritRedirect(redirect, backStyle); _borderInherit = new PaletteBorderInheritRedirect(redirect, borderStyle); _contentInherit = new PaletteContentInheritRedirect(redirect, contentStyle); // Create storage that maps onto the inherit instances Back = new PaletteBack(_backInherit, needPaint); Border = new PaletteBorder(_borderInherit, needPaint); Content = new PaletteDataGridViewContentCommon(_contentInherit, needPaint); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridDefaultGroup"/> class. /// </summary> public OutlookGridDefaultGroup() { val = null; column = null; if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) { height = StaticValues._2013GroupRowHeight; // special height for office 2013 } else { height = StaticValues._defaultGroupRowHeight; // default height } rows = new List <OutlookGridRow>(); children = new OutlookGridGroupCollection(); formatStyle = ""; oneItemText = LanguageManager.Instance.GetStringGB("OneItem"); XXXItemsText = LanguageManager.Instance.GetStringGB("XXXItems"); allowHiddenWhenGrouped = true; sortBySummaryCount = false; back = new PaletteBack(null, null); }
/// <summary> /// the main difference with a Group row and a regular row is the way it is painted on the control. /// the Paint method is therefore overridden and specifies how the Group row is painted. /// Note: this method is not implemented optimally. It is merely used for demonstration purposes /// </summary> /// <param name="graphics"></param> /// <param name="clipBounds"></param> /// <param name="rowBounds"></param> /// <param name="rowIndex"></param> /// <param name="rowState"></param> /// <param name="isFirstDisplayedRow"></param> /// <param name="isLastVisibleRow"></param> protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow) { if (isGroupRow) { KryptonOutlookGrid grid = (KryptonOutlookGrid)DataGridView; int rowHeadersWidth = grid.RowHeadersVisible ? grid.RowHeadersWidth : 0; int groupLevelIndentation = group.Level * StaticValues._groupLevelMultiplier; int gridwidth = grid.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); Rectangle myRowBounds = rowBounds; myRowBounds.Width = gridwidth; PaletteBack paletteBack = group.Back; paletteBack.SetInherit(grid.StateNormal.DataCell.Back); IPaletteBorder paletteBorder = grid.StateNormal.DataCell.Border; PaletteState state = PaletteState.Normal; if (grid.PreviousSelectedGroupRow == rowIndex && (KryptonManager.CurrentGlobalPalette.GetRenderer() != KryptonManager.RenderOffice2013)) { state = PaletteState.CheckedNormal; } using (RenderContext renderContext = new RenderContext(grid, graphics, myRowBounds, grid.Renderer)) { using (GraphicsPath path = grid.Renderer.RenderStandardBorder.GetBackPath(renderContext, myRowBounds, paletteBorder, VisualOrientation.Top, PaletteState.Normal)) { //Back IDisposable unused = grid.Renderer.RenderStandardBack.DrawBack(renderContext, myRowBounds, path, paletteBack, VisualOrientation.Top, state, null); // We never save the memento for reuse later if (unused != null) { unused.Dispose(); unused = null; } } } // Draw the botton : solid line for 2007 palettes or dot line for 2010 palettes, full background for 2013 if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010) { using (Pen focusPen = new Pen(Color.Gray)) { focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; graphics.DrawLine(focusPen, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - 1, gridwidth + 1, rowBounds.Bottom - 1); } } else if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) { using (SolidBrush br = new SolidBrush(Color.FromArgb(225, 225, 225))) { graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - StaticValues._2013GroupRowHeight, gridwidth + 1, StaticValues._2013GroupRowHeight - 1); } } else { using (SolidBrush br = new SolidBrush(paletteBorder.GetBorderColor1(state))) { graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - 2, gridwidth + 1, 2); } } //Draw right vertical bar if (grid.CellBorderStyle == DataGridViewCellBorderStyle.SingleVertical || grid.CellBorderStyle == DataGridViewCellBorderStyle.Single) { using (SolidBrush br = new SolidBrush(paletteBorder.GetBorderColor1(state))) { graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + gridwidth, rowBounds.Top, 1, rowBounds.Height); } } //Set the icon and lines according to the renderer if (group.Collapsed) { if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) { graphics.DrawImage(Properties.Resources.CollapseIcon2010, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); } else { graphics.DrawImage(Properties.Resources.ExpandIcon, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); } } else { if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) { graphics.DrawImage(Properties.Resources.ExpandIcon2010, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); } else { graphics.DrawImage(Properties.Resources.CollapseIcon, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); } } //Draw image group int imageoffset = 0; if (group.GroupImage != null) { if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) { graphics.DrawImage(group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._2013OffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide); imageoffset = StaticValues._ImageOffsetwidth; } else { graphics.DrawImage(group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._defaultOffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide); imageoffset = StaticValues._ImageOffsetwidth; } } //Draw text, using the current grid font int offsetText = rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + imageoffset + groupLevelIndentation; if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) { TextRenderer.DrawText(graphics, group.Text, grid.GridPalette.GetContentShortTextFont(PaletteContentStyle.LabelBoldControl, state), new Rectangle(offsetText, rowBounds.Bottom - StaticValues._2013OffsetHeight, rowBounds.Width - offsetText, rowBounds.Height), grid.GridPalette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalControl, state), TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPrefix); } else { TextRenderer.DrawText(graphics, group.Text, grid.GridPalette.GetContentShortTextFont(PaletteContentStyle.LabelBoldControl, state), new Rectangle(offsetText, rowBounds.Bottom - StaticValues._defaultOffsetHeight, rowBounds.Width - offsetText, rowBounds.Height), grid.GridPalette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalControl, state), TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPrefix); } ////Debug Hits ////ExpandCollaspe icon //graphics.DrawRectangle(new Pen(Color.Red), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * 15, rowBounds.Bottom - 18, 11, 11)); ////Image //if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) // graphics.DrawRectangle(new Pen(Color.Blue), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._2013OffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide)); //else // graphics.DrawRectangle(new Pen(Color.Blue), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._defaultOffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide)); } else { base.Paint(graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow); } }
/// <summary> /// Initialize a new instance of the PaletteTreeState class. /// </summary> /// <param name="inherit">Source for inheriting values.</param> /// <param name="back">Reference to back storage.</param> /// <param name="border">Reference to border storage.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteTreeState(PaletteTreeStateRedirect inherit, PaletteBack back, PaletteBorder border, NeedPaintHandler needPaint) : base(inherit, back, border, needPaint) =>