private void Rescale() { this._dpiScaleFactor = HighDPIUtils.GetDpiFactor(); if (this._dpiScaleFactor == 1) { return; } float fudgedDpiScaleFactor = _dpiScaleFactor * HighDPIUtils.PrimaryFudgeFactor; this.Scale(new SizeF(fudgedDpiScaleFactor, fudgedDpiScaleFactor)); this.Font = new Font(this.Font.FontFamily, this.Font.Size * fudgedDpiScaleFactor, this.Font.Style); //foreach (Control c in HighDPIUtils.GetChildInControl(this)) //.OfType<Button>()) //{ // if (c is SplitContainer) // { // c.Font = new Font(c.Font.FontFamily, // c.Font.Size * scaleFactor, // c.Font.Style); // } //} pnlHeader.Font = new Font(pnlHeader.Font.FontFamily, pnlHeader.Font.Size * fudgedDpiScaleFactor, pnlHeader.Font.Style); scDifferenceResults.Font = new Font(scDifferenceResults.Font.FontFamily, scDifferenceResults.Font.Size * fudgedDpiScaleFactor, scDifferenceResults.Font.Style); // set up splitter distance/widths/visibility spltSourceTarget.SplitterDistance = Convert.ToInt32(Convert.ToDouble(spltSourceTarget.Width) * 0.5); scDifferenceResults.SplitterDistance = Convert.ToInt32(Convert.ToDouble(scDifferenceResults.Height) * 0.74); scObjectDefinitions.SplitterDistance = Convert.ToInt32(Convert.ToDouble(scObjectDefinitions.Width) * 0.5); scDifferenceResults.IsSplitterFixed = false; pnlHeader.Height = Convert.ToInt32(toolStrip1.Height * 2.3); // Convert.ToInt32(pnlHeader.Height * fudgedDpiScaleFactor * 0.68); txtSource.Width = Convert.ToInt32(Convert.ToDouble(scObjectDefinitions.Panel1.Width) * 0.8); txtSource.Left = Convert.ToInt32(txtSource.Left * fudgedDpiScaleFactor * 0.9); txtTarget.Width = Convert.ToInt32(Convert.ToDouble(scObjectDefinitions.Panel2.Width) * 0.8); txtTarget.Left = Convert.ToInt32(txtTarget.Left * fudgedDpiScaleFactor * 0.9); txtSourceObjectDefinition.Width = scObjectDefinitions.Panel1.Width; txtSourceObjectDefinition.Height = Convert.ToInt32(Convert.ToDouble(scObjectDefinitions.Panel1.Height) * 0.86); txtTargetObjectDefinition.Width = scObjectDefinitions.Panel2.Width; txtTargetObjectDefinition.Height = Convert.ToInt32(Convert.ToDouble(scObjectDefinitions.Panel2.Height) * 0.86); if (_dpiScaleFactor > 1) { HighDPIUtils.ScaleStreamedImageListByDpi(TreeGridImageList); } treeGridComparisonResults.ResetColumnWidths(fudgedDpiScaleFactor); if (_comparison != null && _bismNormalizerPackage.ValidationOutput != null) { _bismNormalizerPackage.ValidationOutput.Rescale(fudgedDpiScaleFactor); } }
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { TreeGridNode node = this.OwningNode; if (node == null) { return; } Image image = node.Image; if (this._imageHeight == 0 && image != null) { this.UpdateStyle(); } // paint the cell normally base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); float dpiFactor = HighDPIUtils.GetDpiFactor(); int scaleBack = (dpiFactor > 1 ? Convert.ToInt32(dpiFactor) : 0); // TO_DO: Indent width needs to take image size into account Rectangle glyphRect = new Rectangle(cellBounds.X + this.GlyphMargin - scaleBack, cellBounds.Y - scaleBack, INDENT_WIDTH, cellBounds.Height - 1); int glyphHalf = glyphRect.Width / 2; //TO_DO: This painting code needs to be rehashed to be cleaner int level = this.Level; //TO_DO: Rehash this to take different Imagelayouts into account. This will speed up drawing // for images of the same size (ImageLayout.None) if (image != null) { Point pp; if (_imageHeight > cellBounds.Height) { pp = new Point(glyphRect.X + this.glyphWidth, cellBounds.Y + _imageHeightOffset); } else { pp = new Point(glyphRect.X + this.glyphWidth, (cellBounds.Height / 2 - _imageHeight / 2) + cellBounds.Y); } // Graphics container to push/pop changes. This enables us to set clipping when painting // the cell's image -- keeps it from bleeding outsize of cells. System.Drawing.Drawing2D.GraphicsContainer gc = graphics.BeginContainer(); { graphics.SetClip(cellBounds); graphics.DrawImageUnscaled(image, pp); } graphics.EndContainer(gc); } // Paint tree lines if (node._grid.ShowLines) { using (Pen linePen = new Pen(SystemBrushes.ControlDark, 1.0f)) { linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; bool isLastSibling = node.IsLastSibling; bool isFirstSibling = node.IsFirstSibling; if (node.Level == 1) { // the Root nodes display their lines differently if (isFirstSibling && isLastSibling) { // only node, both first and last. Just draw horizontal line graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); } else if (isLastSibling) { // last sibling doesn't draw the line extended below. Paint horizontal then vertical graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2); } else if (isFirstSibling) { // first sibling doesn't draw the line extended above. Paint horizontal then vertical graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.X + 4, cellBounds.Bottom); } else { // normal drawing draws extended from top to bottom. Paint horizontal then vertical graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom); } } else { if (isLastSibling) { // last sibling doesn't draw the line extended below. Paint horizontal then vertical graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2); } else { // normal drawing draws extended from top to bottom. Paint horizontal then vertical graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom); } // paint lines of previous levels to the root TreeGridNode previousNode = node.Parent; int horizontalStop = (glyphRect.X + 4) - INDENT_WIDTH; while (!previousNode.IsRoot) { if (previousNode.HasChildren && !previousNode.IsLastSibling) { // paint vertical line graphics.DrawLine(linePen, horizontalStop, cellBounds.Top, horizontalStop, cellBounds.Bottom); } previousNode = previousNode.Parent; horizontalStop = horizontalStop - INDENT_WIDTH; } } } } //Commented out after found KPI Lake performance issue // if (dpiFactor > 1) dpiFactor = dpiFactor * HighDPIUtils.PrimaryFudgeFactor; // float size = 10 * dpiFactor; //if (node.HasChildren || node._grid.VirtualNodes) //{ // if (((TreeGridView)this.DataGridView).ImageList.Images.Count > 0) // { // // Paint node glyphs // if (node.IsExpanded) // { // graphics.DrawImage(((TreeGridView)this.DataGridView).ImageList.Images[10], glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, size, size); // } // else // { // graphics.DrawImage(((TreeGridView)this.DataGridView).ImageList.Images[9], glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, size, size); // } // } //} }