Skip to content

Commit

Permalink
Skyline: More improvements for auto-screenshot mode consistency (#3312)
Browse files Browse the repository at this point in the history
- Fixed ScreenshotInfo Regex to recognize all tutorial folders
- Improved BaseFileDialogNE Look in field to hopefully be consistent and better laid out
- Fixed DiaUmpireTutorialTest to scroll FASTA paths to the end and other fixes
- Added suffixes to tests ending in Tutorial that were not associated with folders in Documentation/Tutorials
  • Loading branch information
brendanx67 authored Jan 3, 2025
1 parent d5bb1c3 commit 64137c6
Show file tree
Hide file tree
Showing 15 changed files with 3,441 additions and 2,882 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public bool IsCurrent(ScreenshotFile screenshot, ImageSource currentSource)

internal class ScreenshotFile
{
private static readonly Regex PATTERN = new Regex(@"\\(\w+)\\(\w\w-?[A-Z]*)\\s-(\d\d)\.png");
private static readonly Regex PATTERN = new Regex(@"\\([a-zA-Z\-]+)\\(\w\w-?[A-Z]*)\\s-(\d\d)\.png");

public static bool IsMatch(string filePath)
{
Expand Down
19 changes: 18 additions & 1 deletion pwiz_tools/Skyline/FileUI/BaseFileDialogNE.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 34 additions & 13 deletions pwiz_tools/Skyline/FileUI/BaseFileDialogNE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public BaseFileDialogNE(string[] sourceTypes, IList<RemoteAccount> remoteAccount

sourceTypeComboBox.Items.AddRange(sourceTypes.Cast<object>().ToArray());
sourceTypeComboBox.SelectedIndex = 0;
// Create a new image list for the list view that is the default size (16x16)
ImageList imageList = new ImageList{ColorDepth = ColorDepth.Depth32Bit};
imageList.Images.AddRange(lookInImageList.Images.Cast<Image>().ToArray());
listView.SmallImageList = imageList;
listView.LargeImageList = imageList;
// Use the small image list 16x16 to avoid scaling at runtime which produces color inconsistencies
listView.SmallImageList = lookInImageListSmall;
listView.LargeImageList = lookInImageListSmall;

// ExportImages(listView.SmallImageList, string.Empty);

TreeView tv = new TreeView { Indent = 8 };
_remoteIndex = lookInComboBox.Items.Count;
Expand Down Expand Up @@ -104,6 +104,26 @@ public BaseFileDialogNE(string[] sourceTypes, IList<RemoteAccount> remoteAccount
_specificDataSourceFilter = specificDataSourceFilter;
}

// private void ExportImages(ImageList imageList, string suffix)
// {
// try
// {
// string saveFolder = @"C:\proj\Scratch\pwiz_tools\Skyline\Resources\ImageList";
// Directory.CreateDirectory(saveFolder);
//
// for (int i = 0; i < imageList.Images.Count; i++)
// {
// Image image = imageList.Images[i];
// string filePath = Path.Combine(saveFolder, $"{(ImageIndex)i}{suffix}.png");
// image.Save(filePath, ImageFormat.Png);
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e);
// }
// }

public void RestoreState(string documentPath, OpenDataSourceState state)
{
if (state != null)
Expand Down Expand Up @@ -997,13 +1017,14 @@ private void lookInComboBox_DrawItem( object sender, DrawItemEventArgs e )
if( e.Index < 0 || e.Index >= lookInComboBox.Items.Count)
return;

TreeNode node = (TreeNode) lookInComboBox.Items[e.Index];
var node = (TreeNode) lookInComboBox.Items[e.Index];
var textSize = TextRenderer.MeasureText(node.Text, lookInComboBox.Font);

int x, y, indent;
if( ( e.State & DrawItemState.ComboBoxEdit ) == DrawItemState.ComboBoxEdit )
int x, indent;
int y = e.Bounds.Y + (e.Bounds.Height - 16) / 2;
if ( ( e.State & DrawItemState.ComboBoxEdit ) == DrawItemState.ComboBoxEdit )
{
x = 2;
y = 2;
x = 3; // Any less and the image gets clipped
indent = 0;
}
else
Expand All @@ -1012,13 +1033,13 @@ private void lookInComboBox_DrawItem( object sender, DrawItemEventArgs e )
e.DrawFocusRectangle();

x = node.TreeView.Indent / 2;
y = e.Bounds.Y;
indent = node.TreeView.Indent * node.Level;
}

Image image = lookInImageList.Images[node.ImageIndex];
var image = lookInImageListSmall.Images[node.ImageIndex];
e.Graphics.DrawImage( image, x + indent, y, 16, 16 );
e.Graphics.DrawString( node.Text, lookInComboBox.Font, new SolidBrush(lookInComboBox.ForeColor), x + indent + 16, y );
int textY = e.Bounds.Y + (e.Bounds.Height - textSize.Height) / 2; // Vertically center the text
e.Graphics.DrawString( node.Text, lookInComboBox.Font, new SolidBrush(lookInComboBox.ForeColor), x + indent + 16, textY );
}

private void lookInComboBox_MeasureItem( object sender, MeasureItemEventArgs e )
Expand Down
Loading

0 comments on commit 64137c6

Please sign in to comment.