Skip to content

Commit

Permalink
Improvements to tutorial screenshot taking (#3153)
Browse files Browse the repository at this point in the history
* Add functionality to save screenshots in pause for screenshot form

* Remove uncessary space changes

* Add auto screenshot mode

* Undo massive changes in form editing

* Update save screenshot to use a checkbox

* Update location of checkbox

* Implement graph screenshots, form targetting, dia tutorial, and preview feature

* - fixes and extensions based automating screenshots for AbsoluteQuantTutorialTest and MethodEditTutorialTest

* - fixes for targets view clipping and statement completion

* - update screenshots for English MethodEdit based on test changes

* - add one extra pixel to ClipSelectionStatus to capture statusbar border

* - more fixes to PauseAndContinueForm and SkylineTester

* - fixes to MethodRefinementTutorialTest to get it to work with auto-screenshot mode
- fixes to auto-screenshot mode
- removed an unused using clause

* - fixed MethodRefinementTutorialTest figure 13 to avoid spectrum graph overlap

* - updated MethodRefine tutorial screenshot images

* - checkpoint commit for TestGroupedStudies1Tutorial screenshots

* Checkpoint commit for ExistingExperimentsTutorial. Update screenshots of graphs, trees, and 2 others that should have included the main window.#

* - more fixes to GroupedStudies1TutorialTest

* - more fixes for GroupedStudies1TutorialTest

* - switch GroupedStudies1Views to .data directory from .zip file

* Add controls to preview form. Run pause/preview forms in new thread

* Hide preview window while taking screenshot, fix focus/activation of window

* * Support trimming horizontal whitespace from SequenceTree
* Execute screenshot processing delegates on the active window's UI thread
* Prevent test framework from setting icon on dialogs that aren't resizable - ex: PeptideSettingsUI

Tests run:
Screenshots appear as expected in ExistingExperiementsTutorialTest and MethodEditTutorialTest

* Switch ExistingExperimentsViews to .data directory from .zip file

* Fix timing issues with preview form. Fix PauseAndContinueForm to come to front. Fix Thread exception in ScreenshotManager

* - more fixes for TestGroupedStudies1Tutorial
- added TestFunctional.ForceMzmlInScreenShots property to force using mzML in screenshot mode

* - more screenshot fixes for TestGroupedStudies1Tutorial

* - add red arrow annotations to 3 figures in TestGroupedStudies1Tutorial

* - added utility function to show a left arrow cursor on a screenshot - currently unused
- fixed TestFunction.ClipTargets to use TreeNodeMS.BoundsMS for right-side white space clipping
- fixed ScreenshotPreviewForm to detect errors saving and show a message box - especially when the PNG file is locked
- fixed y-scale on GroupedStudies s-95 fold-change bar graph

* - add support for docking window drag-drop screenshots

* * Change PeptideSettingsUI to support selecting a library by name
* Fix Existing Experiments Tutorial to select correct library - fixes screenshot 1

* Update ExistingExperimentsTutorial screenshots.

* - fixed non-screenshot mode for GroupedStudies1TutorialTest

* - try telling Git that .view and .sky are text file types

* - remove .view files accidentally added as binary

* - add back .view files hopefully as text

* - attempted fixes to get TeamCity closer to passing
- exception handling added to PauseAndContinueForm during file save

* - remove old view files for 4 tutorials

* - add back .view files as UTF-8 BOM and UTF-16 to UTF-8 converter

* - have Utf16to8 update the XML text from UTF-16 to UTF-8

* - removed use of async and await in favor of cleaner thread use
- improved screenshot form activation to hide selection and cursor in TextBoxes
- reduced 3 second wait for automated screenshots to 1 second
- fixd closing ScreenshotPreviewForm to always activate PauseAndContinueForm
- moved Utf16to8 .view file converter from scripts into Skyline/Executables/DevTools
- cleaned up Interop use moving control related methods into FormUtil

* - removed unnecessary InteropServices using clauses

* - add disk failure icon

* Revert the line in .gitattributes saying that .view files are text because that messes up on files which are UTF-8.
(also, revert the lines about .sky and .skyl because they're not necessary)

* Improved thread handling and usability of preview form

* * Update TestMSMS tutorial. Screenshot #20 was manually generated using data not available to the test and is a placeholder for now. Will add data and update the test in a future checkin.
* Add processShot helper in TestFunctional to mark a bitmap as a "placeholder".

* Add resizing of images to fit panel if auto size is disabled

* Fix two peak area graph screenshot calls inadvertently reverted during code review this morning.

* Add ability to skip to future screenshot

* Convert TargetedMSMS tutorials from .zip to .view files. Convert .views from UTF-16 to UTF-8 BOM.

* Convert CustomReportsTutorial from .zip to .view files. Convert .view files from UTF-16 to UTF-8 BOM.

Tests run: used TestRunner to make sure tutorial runs from start-to-end

* - clean up IsRecordMode us and PauseAndContinueForm use in record mode
- improve ScreenshotPreviewForm to clarify thread use and encapsulation and add progress UI
- clean up PauseAndContinueForm and ScreenshotManager to better localize responsibilities and clarify API use

* - fix simple PauseTest() cases for NREs and form layout

* - remove missing using clause from TargetedMsmsTutorialTest

* Fix scaling bug. Make preview form not move if on separate screen

* Fix continue loading next screenshot when it doesn't exist

---------

Co-authored-by: brendanx67 <[email protected]>
Co-authored-by: Eddie O'Neil <[email protected]>
Co-authored-by: Brendan MacLean <[email protected]>
Co-authored-by: Brendan MacLean <[email protected]>
Co-authored-by: Nicholas Shulman <[email protected]>
  • Loading branch information
6 people authored Nov 15, 2024
1 parent 1c6cff4 commit 50da7cb
Show file tree
Hide file tree
Showing 165 changed files with 8,603 additions and 802 deletions.
2 changes: 2 additions & 0 deletions pwiz_tools/Shared/Common/DataBinding/Controls/NavBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ public ToolStripDropDownButton ReportsButton
get { return navBarButtonViews; }
}

public int Separator2Position => bindingNavigatorSeparator2.Bounds.Left;

private void navBarButtonCluster_ButtonClick(object sender, EventArgs e)
{
if (null != BindingListSource.ClusteringSpec && !BindingListSource.IsComplete &&
Expand Down
1 change: 1 addition & 0 deletions pwiz_tools/Shared/CommonUtil/CommonApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class CommonApplicationSettings
private static string _programNameAndVersion;
public static bool Offscreen { get; set; }
public static bool FunctionalTest { get; set; }
public static int PauseSeconds { get; set; }
/// <summary>
/// Whether the class name of the form should be displayed in form titles
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion pwiz_tools/Shared/CommonUtil/SystemUtil/CommonFormEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public static bool TestMode
{
get { return CommonApplicationSettings.FunctionalTest; }
}
public static bool PauseMode
{
get { return CommonApplicationSettings.PauseSeconds != 0; }
}
public static bool Offscreen
{
get { return CommonApplicationSettings.Offscreen; }
Expand Down Expand Up @@ -68,7 +72,9 @@ protected override void OnLoad(EventArgs e)

protected override bool ShowWithoutActivation
{
get { return TestMode || Offscreen; }
// Avoid activating forms during test mode or when off screen, but not when
// pausing to show Skyline as it normally functions.
get { return (TestMode || Offscreen) && !PauseMode; }
}

protected override void Dispose(bool disposing)
Expand Down
36 changes: 36 additions & 0 deletions pwiz_tools/Shared/CommonUtil/SystemUtil/FormUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using pwiz.Common.Collections;

namespace pwiz.Common.SystemUtil
{
public enum ScrollDirection { horz = 0, vert = 1 }

public static class FormUtil
{
/// <summary>
Expand Down Expand Up @@ -195,5 +198,38 @@ public static void RemoveTabPage(TabPage tabPage, ToolTip toolTipControl)
{
RemoveTabPage(tabPage, ImmutableList.Singleton(toolTipControl));
}

[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);

public static void SetForegroundWindow(this Control control)
{
SetForegroundWindow(control.Handle);
}

[DllImport("user32.dll")]
private static extern bool HideCaret(IntPtr hWnd);

public static void HideCaret(this Control control)
{
HideCaret(control.Handle);
}

[DllImport("user32.dll", SetLastError = true)]
private static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);

public static void SetScrollPos(this Control control, ScrollDirection sd, int pos)
{
SetScrollPos(control.Handle, (int)sd, pos, true);
}

public static Control GetFocus(this Control control)
{
if (control.Focused)
return control;
return (
from Control childControl in control.Controls
select GetFocus(childControl)).FirstOrDefault(focus => focus != null);
}
}
}
39 changes: 39 additions & 0 deletions pwiz_tools/Shared/Lib/DigitalRune.Windows.Docking.XML

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

Binary file modified pwiz_tools/Shared/Lib/DigitalRune.Windows.Docking.dll
Binary file not shown.
1 change: 1 addition & 0 deletions pwiz_tools/Skyline/Controls/PopupPickList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ public void ToggleItem(int iChange)
public void SetItemChecked(int i, bool checkItem)
{
SetItemCheckedInternal(i, checkItem);
pickListMulti.SelectedIndex = i;
pickListMulti.Invalidate(pickListMulti.GetItemRectangle(i));

UpdateSelectAll();
Expand Down
7 changes: 6 additions & 1 deletion pwiz_tools/Skyline/Controls/SequenceTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ public bool IsTipVisible
get { return _nodeTip.Visible; }
}

public Rectangle TipRect
{
get { return _nodeTip.Visible ? _nodeTip.Bounds : Rectangle.Empty; }
}

[Browsable(true)]
public event EventHandler<PickedChildrenEventArgs> PickedChildrenEvent;

Expand Down Expand Up @@ -1247,7 +1252,7 @@ private void BeginEditNode(TreeNode node, bool commitOnLoseFocus)
disableCompletion = false;
}
}
_editTextBox = new StatementCompletionTextBox(DocumentContainer)
_editTextBox = new StatementCompletionTextBox(DocumentContainer, commitOnLoseFocus)
{AutoSizeWidth = true, DisableCompletion = disableCompletion};
_editTextBox.Attach(textBox);
textBox.KeyDown += textBox_KeyDown;
Expand Down
16 changes: 13 additions & 3 deletions pwiz_tools/Skyline/Controls/StatementCompletionTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ public class StatementCompletionTextBox
private readonly IDocumentUIContainer _documentUiContainer;
private readonly ImageList _imageList = new ImageList() {TransparentColor = Color.Magenta};
private ProteomeDb _proteomeDb;
private bool _hideOnLoseFocus;

// Don't let the name take more than half the space for item display
private const int MAX_NAME_LENGTH = 40;

public StatementCompletionTextBox(IDocumentUIContainer documentUiContainer)
public StatementCompletionTextBox(IDocumentUIContainer documentUiContainer, bool hideOnLoseFocus = true)
{
MatchTypes = ProteinMatchTypes.ALL;
_documentUiContainer = documentUiContainer;
_imageList.Images.Add(Resources.Protein);
_imageList.Images.Add(Resources.Peptide);
_hideOnLoseFocus = hideOnLoseFocus;
}

public void Attach(TextBox textBox)
Expand All @@ -69,7 +71,8 @@ public void Attach(TextBox textBox)
TextBox.KeyDown += TextBox_KeyDown;
TextBox.TextChanged += TextBox_TextChanged;
TextBox.GotFocus += TextBox_GotFocus;
TextBox.LostFocus += TextBox_LostFocus;
if (_hideOnLoseFocus)
TextBox.LostFocus += TextBox_LostFocus;
TextBox.LocationChanged += TextBox_LocationChanged;
}

Expand All @@ -94,7 +97,8 @@ public void Detach()
TextBox.KeyDown -= TextBox_KeyDown;
TextBox.TextChanged -= TextBox_TextChanged;
TextBox.GotFocus -= TextBox_GotFocus;
TextBox.LostFocus -= TextBox_LostFocus;
if (_hideOnLoseFocus)
TextBox.LostFocus -= TextBox_LostFocus;
TextBox.LocationChanged -= TextBox_LocationChanged;
TextBox = null;
}
Expand Down Expand Up @@ -687,6 +691,12 @@ public void OnSelectionMade(StatementCompletionItem statementCompletionItem)
}
}

public void SelectWithoutChoosing(int index)
{
StatementCompletionForm.ListView.FocusedItem =
StatementCompletionForm.ListView.Items[index];
}

public event Action<StatementCompletionItem> SelectionMade;
public event Action TextBoxLoseFocus;
}
Expand Down
7 changes: 2 additions & 5 deletions pwiz_tools/Skyline/Controls/TreeViewMS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using pwiz.Common.SystemUtil;
using pwiz.Skyline.Model;
using pwiz.Skyline.Properties;
using pwiz.Skyline.Util;
Expand Down Expand Up @@ -210,12 +210,9 @@ public void UpdateTopNode()
TreeStateRestorer.UpdateTopNode();
}

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);

public void ScrollLeft()
{
SetScrollPos(Handle, 0, 0, true);
this.SetScrollPos(ScrollDirection.horz, 0);
}

protected override void OnMouseDown(MouseEventArgs e)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pwiz_tools/Skyline/Documentation/Tutorials/MethodEdit/en/s-13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pwiz_tools/Skyline/Documentation/Tutorials/MethodEdit/en/s-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pwiz_tools/Skyline/Documentation/Tutorials/MethodRefine/en/s-12.png
9 changes: 9 additions & 0 deletions pwiz_tools/Skyline/Documentation/Tutorials/shared/skyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ function addFigureAltText()
anchor.setAttribute('id', anchorId);
img.parentNode.parentNode.insertBefore(anchor, img.parentNode);

// If it is a screenshot path add a second bookmark anchor
const match = img.src.match(/\/(s-\d+)/);
if (match) {
anchor = document.createElement('a');
anchor.setAttribute('name', match[1]);
anchor.setAttribute('id', match[1]);
img.parentNode.parentNode.insertBefore(anchor, img.parentNode);
}

figureCounter++
}
});
Expand Down
15 changes: 15 additions & 0 deletions pwiz_tools/Skyline/EditUI/PasteDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@ private DataGridView ActiveGridView
}
}

public void SelectCell(int row, int column)
{
ActiveGridView.CurrentCell = ActiveGridView.Rows[row].Cells[column];
}

public void SetColumnWidths(params int[] columnWidths)
{
for (int i = 0; i < columnWidths.Length; i++)
{
int width = columnWidths[i];
if (width != -1)
ActiveGridView.Columns[i].Width = width;
}
}

public void ShowError(PasteError pasteError)
{
_noErrors = false;
Expand Down
6 changes: 6 additions & 0 deletions pwiz_tools/Skyline/EditUI/UniquePeptidesDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,12 @@ public DataGridView GetDataGridView()
return dataGridView1;
}

public int SplitHeight
{
get { return splitContainer1.SplitterDistance; }
set { splitContainer1.SplitterDistance = value; }
}

public void SelectUnique(UniquenessType uniquenessType)
{
SelectPeptidesWithNumberOfMatchesAtOrBelowThreshold(1, uniquenessType);
Expand Down
25 changes: 25 additions & 0 deletions pwiz_tools/Skyline/Executables/DevTools/Utf16to8/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Text;

if (args.Length < 2)
{
Console.WriteLine("Usage: Utf16to8 <sourceFile> <destinationFile>");
return;
}

string sourceFile = args[0];
string destinationFile = args[1];

try
{
// Read all text from the source file with UTF-16 encoding (default for StreamReader with UTF-16 files)
string content = File.ReadAllText(sourceFile, Encoding.Unicode).Replace("UTF-16", "UTF-8");

// Write the content to the destination file in UTF-8 encoding with BOM
File.WriteAllText(destinationFile, content, new UTF8Encoding(true));

Console.WriteLine($"Converted {Path.GetFileName(sourceFile)} to UTF-8 with BOM.");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
10 changes: 10 additions & 0 deletions pwiz_tools/Skyline/Executables/DevTools/Utf16to8/Utf16to8.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions pwiz_tools/Skyline/Executables/DevTools/Utf16to8/Utf16to8.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utf16to8", "Utf16to8.csproj", "{22EEA8E7-EDEC-4972-8936-2B36A5E33CDA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{22EEA8E7-EDEC-4972-8936-2B36A5E33CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22EEA8E7-EDEC-4972-8936-2B36A5E33CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22EEA8E7-EDEC-4972-8936-2B36A5E33CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22EEA8E7-EDEC-4972-8936-2B36A5E33CDA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AF22AE3B-295D-4B6A-A0B6-03DFACB15193}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Utf16to8/1.0.0": {
"runtime": {
"Utf16to8.dll": {}
}
}
}
},
"libraries": {
"Utf16to8/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 50da7cb

Please sign in to comment.