Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pwiz_tools/Skyline/Alerts/KeyValueGridDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,19 @@ public static void Show<TValue>(IWin32Window parent, string title, IDictionary<s
}

var activeScreen = parent == null ? Screen.PrimaryScreen : Screen.FromHandle(parent.Handle);
int defaultHeight = Math.Min(3 * activeScreen.Bounds.Height / 4, layout.GetRowHeights().Sum() + 50);
int defaultHeight = Math.Min(3 * activeScreen.Bounds.Height / 4,
layout.GetRowHeights().Sum() + DpiUtil.Scale(parent as Control, 50));

using (var dlg = new MultiButtonMsgDlg(layout, Resources.OK, ctlTextRepresentation.ToString()))
{
dlg.Text = title;
dlg.ClientSize = new Size(400, defaultHeight);
// 96-DPI width literal scaled for high DPI; row heights are font-relative (issue #4599).
dlg.ClientSize = new Size(DpiUtil.Scale(dlg, 400), defaultHeight);
dlg.StartPosition = FormStartPosition.CenterParent;
dlg.ShowInTaskbar = false;
dlg.MinimumSize = dlg.Size;
layout.Size = dlg.ClientSize;
layout.Height -= 35;
layout.Height -= DpiUtil.Scale(dlg, 35);

var result = parent == null ? dlg.ShowParentlessDialog() : dlg.ShowWithTimeout(parent, title);
if (result == DialogResult.Cancel)
Expand Down
59 changes: 37 additions & 22 deletions pwiz_tools/Skyline/Controls/FilesTree/FilesTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using pwiz.Skyline.Model;
using pwiz.Skyline.Model.Files;
using pwiz.Skyline.Properties;
using pwiz.Skyline.Util;

// ReSharper disable WrongIndentSize
namespace pwiz.Skyline.Controls.FilesTree
Expand Down Expand Up @@ -74,30 +75,41 @@ public FilesTree()
_timerUpdate = new System.Windows.Forms.Timer { Interval = UPDATE_DELAY_MS };
_timerUpdate.Tick += OnUpdateTimer;

// Icons size is 16x16
// Icons are 16x16 at 96 DPI; AddNodeImage pre-scales them to the DPI-sized
// ImageList.ImageSize (issue #4599).
ImageList = new ImageList
{
TransparentColor = Color.Magenta,
ColorDepth = ColorDepth.Depth32Bit
ColorDepth = ColorDepth.Depth32Bit
};
if (DpiUtil.GetFactor(this) > 1)
{
ImageList.TransparentColor = Color.Transparent;
ImageList.ImageSize = DpiUtil.ScaleSize(this, ImageList.ImageSize);
}

ImageList.Images.Add(Resources.Blank); // 1bpp
ImageList.Images.Add(Resources.Folder); // 32bpp
ImageList.Images.Add(Resources.FolderMissing); // 32bpp
ImageList.Images.Add(Resources.File); // 8bpp
ImageList.Images.Add(Resources.FileMissing); // 32bpp
ImageList.Images.Add(Resources.Replicate); // 24bpp
ImageList.Images.Add(Resources.ReplicateMissing); // 24bpp // CONSIDER: improve icon?
ImageList.Images.Add(Resources.DataProcessing); // 8bpp
ImageList.Images.Add(Resources.PeptideLib); // 4bpp
ImageList.Images.Add(Resources.Skyline_FilesTree); // 24bpp
ImageList.Images.Add(Resources.AuditLog); // 32bpp
ImageList.Images.Add(Resources.CacheFile); // 32bpp
ImageList.Images.Add(Resources.ViewFile); // 32bpp
ImageList.Images.Add(Resources.ProtDB); // 32bpp
ImageList.Images.Add(Resources.ImsDB); // 32bpp
ImageList.Images.Add(Resources.OptDB); // 32bpp
ImageList.Images.Add(Resources.IrtCalculator); // 32bpp
AddNodeImage(Resources.Blank); // 1bpp
AddNodeImage(Resources.Folder); // 32bpp
AddNodeImage(Resources.FolderMissing); // 32bpp
AddNodeImage(Resources.File); // 8bpp
AddNodeImage(Resources.FileMissing); // 32bpp
AddNodeImage(Resources.Replicate); // 24bpp
AddNodeImage(Resources.ReplicateMissing); // 24bpp // CONSIDER: improve icon?
AddNodeImage(Resources.DataProcessing); // 8bpp
AddNodeImage(Resources.PeptideLib); // 4bpp
AddNodeImage(Resources.Skyline_FilesTree); // 24bpp
AddNodeImage(Resources.AuditLog); // 32bpp
AddNodeImage(Resources.CacheFile); // 32bpp
AddNodeImage(Resources.ViewFile); // 32bpp
AddNodeImage(Resources.ProtDB); // 32bpp
AddNodeImage(Resources.ImsDB); // 32bpp
AddNodeImage(Resources.OptDB); // 32bpp
AddNodeImage(Resources.IrtCalculator); // 32bpp
}

private void AddNodeImage(Image image)
{
ImageList.Images.Add(DpiUtil.ScaleImageForList(this, image, Color.Magenta));
}

[Browsable(false)]
Expand Down Expand Up @@ -590,11 +602,14 @@ private void RepositionEditTextBox()
var node = ((TreeNodeMS)SelectedNode).BoundsMS;
_editTextBox.Location = new Point(Location.X + node.Location.X, Location.Y + node.Location.Y);

const int minWidth = 80;
// 96-DPI literals scaled for high DPI (issue #4599).
int minWidth = DpiUtil.Scale(this, 80);
var maxWidth = Bounds.Width - 1 - node.Left;

var size = TextRenderer.MeasureText(_editTextBox.Text, _editTextBox.Font, new Size(_editTextBox.Height, maxWidth));
var dx = size.Width + 8;
// MeasureText's proposedSize is (width, height); the arguments were transposed,
// a latent bug even at 96 DPI (issue #4599).
var size = TextRenderer.MeasureText(_editTextBox.Text, _editTextBox.Font, new Size(maxWidth, _editTextBox.Height));
var dx = size.Width + DpiUtil.Scale(this, 8);
dx = Math.Max(dx, minWidth);
dx = Math.Min(dx, maxWidth);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public CreateMatchExpressionDlg(VolcanoPlotFormattingDlg formattingDlg, object[]
// Hide the filter options
groupBox1.Hide();
// Expand the data grid
dataGridView1.Location = new Point(12, 51);
dataGridView1.Size = new Size(465, 252);
// 96-DPI literals scaled for high DPI (issue #4599).
dataGridView1.Location = new Point(DpiUtil.Scale(this, 12), DpiUtil.Scale(this, 51));
dataGridView1.Size = new Size(DpiUtil.Scale(this, 465), DpiUtil.Scale(this, 252));
}
FilterRows();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private VolcanoPlotFormattingDlg(bool hasFoldChangeResults, IEnumerable<MatchRgb
createExpressionBtn.Resizable = DataGridViewTriState.False;
createExpressionBtn.Text = @"...";
createExpressionBtn.UseColumnTextForButtonValue = true;
createExpressionBtn.Width = createExpressionBtn.MinimumWidth = 20;
createExpressionBtn.Width = createExpressionBtn.MinimumWidth = DpiUtil.Scale(this, 20);
_createExprButtonIndex = 1;
regexColorRowGrid1.Columns.Insert(_createExprButtonIndex, createExpressionBtn);

Expand Down Expand Up @@ -180,6 +180,7 @@ private VolcanoPlotFormattingDlg(bool hasFoldChangeResults, IEnumerable<MatchRgb
layoutLabelsBox.Checked = Settings.Default.GroupComparisonAvoidLabelOverlap;

// Tooltips/accessible names for the delete/reorder toolbar (image-only buttons).
DpiUtil.ScaleToolStripImages(toolStripFormatting);
btnDeleteRule.Text = GroupComparisonStrings.VolcanoPlotFormattingDlg_Delete_rule;
btnMoveRuleUp.Text = GroupComparisonStrings.VolcanoPlotFormattingDlg_Move_rule_up;
btnMoveRuleDown.Text = GroupComparisonStrings.VolcanoPlotFormattingDlg_Move_rule_down;
Expand Down Expand Up @@ -716,6 +717,22 @@ BindingList<MatchRgbHexColor> ColorGrid<MatchRgbHexColor>.IColorGridOwner.GetCur
return _bindingList;
}

protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (DpiUtil.GetFactor(this) > 1)
{
// The form's autoscale skips the nested ColorGrid container's SIZE on
// .NET Framework 4.7.2 (its position does scale), leaving the grid at its
// 96-DPI resource size inside the scaled dialog. Setting the size in the
// constructor corrupts the anchor snapshot, so scale it here, after all
// scaling and layout. Scaling the still-unscaled size directly stays
// correct for localized resx geometry (ja sizes the grid 638x235 vs the
// English 606x235) (issue #4599).
regexColorRowGrid1.Size = DpiUtil.ScaleSize(this, regexColorRowGrid1.Size);
}
}

private void UpdateAdvancedColumns()
{
_symbolCombo.Visible = _pointSizeCombo.Visible =
Expand Down
12 changes: 8 additions & 4 deletions pwiz_tools/Skyline/Controls/PopupPickList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public PopupPickList(IChildPicker picker, string childHeading, bool okOnDeactiva
{
InitializeComponent();

Size = SizeAll;
// The fixed popup size, the owner-drawn row height and the toolbar glyphs are
// 96-DPI designs that AutoScaleMode.Font does not touch (issue #4599).
Size = DpiUtil.ScaleSize(this, SizeAll);
pickListMulti.ItemHeight = DpiUtil.Scale(this, pickListMulti.ItemHeight);
DpiUtil.ScaleToolStripImages(toolStrip1);

cbItems.Text = childHeading;

Expand Down Expand Up @@ -108,7 +112,7 @@ public PopupPickList(IChildPicker picker, string childHeading, bool okOnDeactiva
// Resize to hide space for the checkbox
var anchorList = pickListMulti.Anchor;
pickListMulti.Anchor = anchorList & ~AnchorStyles.Bottom;
Height = pickListMulti.Bottom + 8;
Height = pickListMulti.Bottom + DpiUtil.Scale(this, 8);
pickListMulti.Anchor = anchorList;
}
else
Expand Down Expand Up @@ -541,13 +545,13 @@ private void pickListMulti_DrawItem(object sender, DrawItemEventArgs e)
var imgPeak = _picker.GetPickPeakImage(choice.Choice);
if (imgPeak != null)
{
g.DrawImageUnscaled(imgPeak, bounds.Left, bounds.Top, imgPeak.Width, bounds.Height);
DpiUtil.DrawImageCentered(g, imgPeak, bounds.Left, bounds.Top, bounds.Height);
bounds.X += imgPeak.Width + MARGIN_RIGHT_IMAGE;
bounds.Width -= imgPeak.Width + MARGIN_RIGHT_IMAGE;
}

var imgType = _picker.GetPickTypeImage(choice.Choice);
g.DrawImageUnscaled(imgType, bounds.Left, bounds.Top, imgType.Width, bounds.Height);
DpiUtil.DrawImageCentered(g, imgType, bounds.Left, bounds.Top, bounds.Height);
bounds.X += imgType.Width + MARGIN_RIGHT_IMAGE;
bounds.Width -= imgType.Width + MARGIN_RIGHT_IMAGE;

Expand Down
4 changes: 2 additions & 2 deletions pwiz_tools/Skyline/Controls/SeqNode/PeptideTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ protected override int WidthCustom

var lastTextSequence = _textSequences[_textSequences.Length - 1];
return lastTextSequence.Position + lastTextSequence.Width +
TreeViewMS.PADDING*2;
TreeViewMS.TextPadding*2;
}
}

Expand Down Expand Up @@ -433,7 +433,7 @@ public static void DrawPeptideText(PeptideDocNode nodePep,
Rectangle rectDraw = new Rectangle(0, bounds.Y, 0, bounds.Height);
foreach (var textSequence in textSequences)
{
rectDraw.X = textSequence.Position + bounds.X + TreeViewMS.PADDING;
rectDraw.X = textSequence.Position + bounds.X + DpiUtil.Scale(g, TreeViewMS.PADDING);
rectDraw.Width = textSequence.Width;
// Use selection highlight color, if the background is highlight.
if (backColor != SystemColors.Highlight)
Expand Down
20 changes: 12 additions & 8 deletions pwiz_tools/Skyline/Controls/SeqNode/SrmTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,17 @@ public override void DrawNodeCustom(Graphics g, int rightEdge)
{
// Draw the peptide color rectangle: white background to erase text underneath,
// black border, and the peptide color in the interior.
const int imgWidth = TreeViewMS.IMG_WIDTH, imgHeight = TreeViewMS.IMG_WIDTH;
const int colorRectWidth = imgWidth;
const int colorRectHeight = imgHeight;
rightEdge -= imgWidth + 3;
var treeView = TreeViewMS;
int imgWidth = treeView.ImgWidth, imgHeight = treeView.ImgWidth;
int colorRectWidth = imgWidth;
int colorRectHeight = imgHeight;
rightEdge -= imgWidth + treeView.TextPadding;
int top = BoundsMS.Top + (BoundsMS.Height - imgHeight) / 2;
var backgroundRect = new Rectangle(rightEdge - 2, top, colorRectWidth + 7, colorRectHeight);
var backgroundRect = new Rectangle(rightEdge - DpiUtil.Scale(g, 2), top,
colorRectWidth + DpiUtil.Scale(g, 7), colorRectHeight);
g.FillRectangle(Brushes.White, backgroundRect);
var colorRect = new Rectangle(rightEdge, top, colorRectWidth - 2, colorRectHeight - 3);
var colorRect = new Rectangle(rightEdge, top,
colorRectWidth - DpiUtil.Scale(g, 2), colorRectHeight - DpiUtil.Scale(g, 3));
g.FillRectangle(new SolidBrush(color.Value), colorRect);

// Draw red outline around selected peptide if the tree isn't focused.
Expand Down Expand Up @@ -250,11 +253,12 @@ protected void DrawAnnotationIndicator(Graphics g)
zoomFactor = 1;
if (Equals(Settings.Default.TextZoom, TreeViewMS.XLRG_TEXT_FACTOR))
zoomFactor = 2;
int annotationWidth = DpiUtil.Scale(g, ANNOTATION_WIDTH + zoomFactor);
g.FillPolygon(Model.Annotations.ColorBrush, new[]
{
new Point(bounds.Right, bounds.Top),
new Point(bounds.Right - (ANNOTATION_WIDTH + zoomFactor), bounds.Top),
new Point(bounds.Right, bounds.Top + ANNOTATION_WIDTH + zoomFactor)
new Point(bounds.Right - annotationWidth, bounds.Top),
new Point(bounds.Right, bounds.Top + annotationWidth)
});
}
}
Expand Down
Loading