From e8b8dc82ec42c965c4b2bd015403957d20d297a4 Mon Sep 17 00:00:00 2001 From: Jason Holmes Date: Thu, 6 Jun 2024 07:56:19 -0700 Subject: [PATCH 01/29] Update PI to open on the same monitor as the target application (#3138) * Update PI to open on the same monitor as the target application * Remove whitespace only changes --------- Co-authored-by: Jason Holmes <27746781+jaholme@users.noreply.github.com> --- tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs | 9 +++++---- tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs index fc42ab1acd..bee2761ad1 100644 --- a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs +++ b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs @@ -112,7 +112,7 @@ private void MainPanel_Loaded(object sender, RoutedEventArgs e) var dpiWindow = HwndExtensions.GetDpiForWindow(ThisHwnd); _dpiScale = dpiWindow / 96.0; - SetDefaultPosition(); + SetDefaultPosition(); SetRegionsForTitleBar(); } @@ -136,11 +136,12 @@ public void SetRegionsForTitleBar() } private void SetDefaultPosition() - { - _monitorRect = GetMonitorRectForWindow(ThisHwnd); + { + // If attached to an app it should show up on the monitor that the app is on + _monitorRect = GetMonitorRectForWindow(_viewModel.ApplicationHwnd ?? ThisHwnd); var screenWidth = _monitorRect.right - _monitorRect.left; this.Move( - (int)(((screenWidth - Width) / 2) * _dpiScale), + (int)(((screenWidth - Width) / 2) * _dpiScale) + _monitorRect.left, (int)(_WindowPositionOffsetY * _dpiScale)); // Get the saved settings for the ExpandedView size. On first run, this will be diff --git a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs index 56efd0a16d..28892be72d 100644 --- a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs +++ b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs @@ -15,6 +15,7 @@ using Microsoft.UI.Xaml.Media.Imaging; using Windows.Graphics; using Windows.Win32.Foundation; +using Windows.Win32.Graphics.Gdi; namespace DevHome.PI.ViewModels; @@ -75,7 +76,9 @@ public partial class BarWindowViewModel : ObservableObject private bool _isAlwaysOnTop = true; [ObservableProperty] - private PointInt32 _windowPosition; + private PointInt32 _windowPosition; + + internal HWND? ApplicationHwnd { get; private set; } public BarWindowViewModel() { @@ -98,7 +101,8 @@ public BarWindowViewModel() { ApplicationName = process.ProcessName; ApplicationPid = process.Id; - ApplicationIcon = TargetAppData.Instance.Icon; + ApplicationIcon = TargetAppData.Instance.Icon; + ApplicationHwnd = TargetAppData.Instance.HWnd; } CurrentSnapButtonText = IsSnapped ? _UnsnapButtonText : _SnapButtonText; From 099a2c728a467eba52d9650b31d48cbf2328bdbd Mon Sep 17 00:00:00 2001 From: adrastogi Date: Thu, 6 Jun 2024 09:29:01 -0700 Subject: [PATCH 02/29] Add verification instructions for Quickstart Playground (#3131) * Adding test instructions for Quickstart Playground feature * Additional test steps * Naming tweak; also add to main TestingScenarios markdown * Missed file * Restructure / reformat to ensure that the test script emits only the test case descriptions * PR feedback (Add a test case for validating the privacy / terms URLs) --------- Co-authored-by: Aditya Rastogi --- TestingScenarios.md | 2 +- .../TestingScenarios/QuickstartPlayground.md | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/QuickstartPlayground.md diff --git a/TestingScenarios.md b/TestingScenarios.md index 9421fede57..c99bcbc31d 100644 --- a/TestingScenarios.md +++ b/TestingScenarios.md @@ -12,4 +12,4 @@ These are the testing scenarios that need to be validated before shipping a new 1. [Managing Environments](tools/Environments/DevHome.Environments/TestingScenarios/ManageEnvironments.md) 1. [Creating Environment](tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/CreateEnvironment.md) 1. [Setting up an Environment](tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/SetupEnvironment.md) - +1. [Quickstart Playground](tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/QuickstartPlayground.md) diff --git a/tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/QuickstartPlayground.md b/tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/QuickstartPlayground.md new file mode 100644 index 0000000000..823a5feed5 --- /dev/null +++ b/tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/QuickstartPlayground.md @@ -0,0 +1,45 @@ +# Quickstart Playground Tests +If your code affects Quickstart Playground, please manually verify these scenarios. + +## Scenarios +Please make sure to verify all of these scenarios. These apply to both Windows 10 and Windows 11. + +### First Run and First Setup Experience +1. User receives Dev Home Azure Extension when Quickstart Playground is turned on + 1. Navigate to 'Settings -> Experimental features', and validate that Quickstart Playground is off by default. Then turn it on. + 1. Validate that the Dev Home Azure extension is brought down as part of turning on the feature. When the extension is ultimately installed, you should see a toast notification from the Store. +1. User can set up dependencies and API key for Quickstart Playground + 1. Navigate to the machine configuration page and you should see a button for the Quickstart Playground feature. Click on that entry. + 1. Select the Dev Container with OpenAI extension from the ComboBox. + 1. You should see a ContentDialog with an Adaptive Card guiding you to install any missing dependencies (i.e., Visual Studio Code, Docker Desktop, Remote Containers extension) + 1. Use the download links to set up any missing dependencies, accepting all defaults. + 1. If Docker Desktop was installed, you'll need to reboot the system, manually re-launch Dev Home, and navigate back to the Quickstart Playground page. + 1. Once all of the application dependencies have been set up, you will see another Adaptive Card for entering in the OpenAI API key. Enter your key into the PasswordTextBox shown to you by the card. +1. User does not see Dependency Checker in Quickstart Playground once all dependencies are configured + 1. Navigate away from the page and navigate back to validate that there are no additional Adaptive Cards displayed, thereby indicating that setup for the feature is complete. + +### Core Feature (Feature is Enabled and Configured) +1. User can generate a project in Quickstart Playground using a sample prompt + 1. From the left-hand navigation menu in the application, click on the Machine configuration entry. + 1. Click on the "Quickstart Playground" entry in the list and choose the Dev Container with OpenAI extension. + 1. You will see a TextBox where you can enter in a prompt for a project that you’d like to create. + 1. Try clicking on a sample prompt. You should see the text entered in the TextBox. + 1. Click the Generate button. This will use a language model from OpenAI to generate the project. + 1. Once the operation is completed, you will see a list of files organized by directory that correspond to the sample project generated by the tool. + 1. You should be able to click on a file to view a lightweight preview of its contents. + 1. You can choose to save the project, launch it in Visual Studio Code, Cancel out of the flow, or start again with a new prompt. + 1. Launch the project in Visual Studio Code. + 1. Visual Studio Code will prompt you to confirm if you trust the folder, which you can click on- and then from there the remote containers extension will ask you if you would like to re-open the project in the container + 1. If you don't have Docker already running, Visual Studio Code will start it as part of opening the project, and you can click on 'Show logs' in the notification to see what Docker is doing. + 1. Try building and running the project once Visual Studio Code has finished opening it in the container. +1. User can generate a project in Quickstart Playground using a custom prompt + 1. Enter in a new prompt into the TextBox and click Generate (e.g., "Create an environment for writing console apps in Rust"). + 1. Validate that the project gets produced successfully and can be opened in Visual Studio Code (similar steps as in the sample prompt test case) +1. User can locally save a project produced by Quickstart Playground + 1. Click the Save button in the Dev Home UI to validate that you can save a project to a location on the file system. +1. User can submit feedback on a Quickstart Playground project using the Like / Dislike buttons +1. User can click on the 'Generated based on example' link to view the project that was used a reference by Quickstart Playground. +1. User can click on and view the Privacy policy and Terms of Use for the Quickstart extension they've selected. +1. User can clear their API key + 1. Navigate to the settings for the Dev Home Azure Extension and click on the button to reset the API key. + 1. Verify that navigating back to the Quickstart Playground page prompts for the key to be re-entered. \ No newline at end of file From 26849beac5c36852e12f31954cb4b98b7ee5aee7 Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:38:20 +0100 Subject: [PATCH 03/29] Revert "Enable FailFastOnErrors for Debug builds" (#3137) --- src/App.xaml.cs | 4 ---- src/DevHome.csproj | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/App.xaml.cs b/src/App.xaml.cs index 59c4795656..83c4640db9 100644 --- a/src/App.xaml.cs +++ b/src/App.xaml.cs @@ -179,10 +179,6 @@ public App() UnhandledException += App_UnhandledException; AppInstance.GetCurrent().Activated += OnActivated; - -#if DEBUG - DebugSettings.FailFastOnErrors = true; -#endif } public void ShowMainWindow() diff --git a/src/DevHome.csproj b/src/DevHome.csproj index d9eeeba97a..cb46b0fbe7 100644 --- a/src/DevHome.csproj +++ b/src/DevHome.csproj @@ -154,10 +154,6 @@ $(DefineConstants);STABLE_BUILD - - $(DefineConstants);DEBUG - - From 4765c5910a23fa56f18c89163f5c338b1a801bb3 Mon Sep 17 00:00:00 2001 From: Felipe G Date: Thu, 6 Jun 2024 11:29:06 -0700 Subject: [PATCH 04/29] Announcing widget errors and warnings (#3023) * Announcing widget errors and warnings * Making code better * Making the classes into a list * Moving dictionary to outside of the recursion * Making dictionary static * Changing to var * suggestions * Only executing when there is a listener * Removing unused library --------- Co-authored-by: Felipe da Conceicao Guimaraes --- .../ViewModels/WidgetViewModel.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs b/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs index b654cb9b10..b2ae66ea40 100644 --- a/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs +++ b/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs @@ -2,6 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; using System.Threading.Tasks; using AdaptiveCards.ObjectModel.WinUI3; using AdaptiveCards.Rendering.WinUI3; @@ -16,6 +20,7 @@ using Microsoft.UI.Dispatching; using Microsoft.UI.Text; using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Automation.Peers; using Microsoft.UI.Xaml.Controls; using Microsoft.Windows.Widgets; using Microsoft.Windows.Widgets.Hosts; @@ -42,6 +47,7 @@ public partial class WidgetViewModel : ObservableObject private readonly DispatcherQueue _dispatcherQueue; private readonly WidgetAdaptiveCardRenderingService _renderingService; + private readonly IScreenReaderService _screenReaderService; private RenderedAdaptiveCard _renderedCard; @@ -98,9 +104,11 @@ public WidgetViewModel( WidgetSize widgetSize, ComSafeWidgetDefinition widgetDefinition, WidgetAdaptiveCardRenderingService adaptiveCardRenderingService, + IScreenReaderService screenReaderService, DispatcherQueue dispatcherQueue) { _renderingService = adaptiveCardRenderingService; + _screenReaderService = screenReaderService; _dispatcherQueue = dispatcherQueue; Widget = widget; @@ -185,6 +193,7 @@ await Task.Run(async () => { _renderedCard.Action += HandleAdaptiveAction; WidgetFrameworkElement = _renderedCard.FrameworkElement; + AnnounceWarnings(card.AdaptiveCard); } else { @@ -276,6 +285,8 @@ private Grid GetErrorCard(string error, string subError = null) }; sp.Children.Add(errorText); + var errorTextToAnnounce = errorText.Text; + if (subError is not null) { var subErrorText = new TextBlock @@ -287,8 +298,11 @@ private Grid GetErrorCard(string error, string subError = null) }; sp.Children.Add(subErrorText); + errorTextToAnnounce += $" {subErrorText.Text}"; } + _screenReaderService.Announce(errorTextToAnnounce); + grid.Children.Add(sp); return grid; } @@ -367,4 +381,62 @@ public void UnsubscribeFromWidgetUpdates() { Widget.WidgetUpdated -= HandleWidgetUpdated; } + + private void AnnounceWarnings(AdaptiveCard card) + { + if (!AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged)) + { + return; + } + + foreach (var element in card.Body) + { + SearchForWarning(element, false); + } + } + + // We are only interested in plain texts. Buttons, Actions, Images + // and textboxes are all ignored. Including ActionSets and ImageSets. + // We are treating any text inside a container with the "Warning" style + // as an actual warning to be announced. + // For now, the only types of containers widgets use are Containers and Columns. In the future, + // we may add Caroussels, Tables and Facts to this list. + // We just need to add the other controls in this dictionary + // with the correct function to access its children. + private static readonly Dictionary ContainerTypes = new() + { + { typeof(AdaptiveContainer), "get_Items" }, + { typeof(AdaptiveColumn), "get_Items" }, + { typeof(AdaptiveColumnSet), "get_Columns" }, + }; + + private void SearchForWarning(IAdaptiveCardElement element, bool isInsideWarningContainer) + { + if (element is AdaptiveTextBlock textBlock) + { + if (isInsideWarningContainer) + { + _screenReaderService.Announce(textBlock.Text); + } + + return; + } + + if (element is not IAdaptiveContainerBase) + { + return; + } + + var containerElement = element as IAdaptiveContainerBase; + + foreach (var containerType in ContainerTypes.Where(containerType => containerType.Key == containerElement.GetType())) + { + var itemsMethod = containerType.Key.GetMethod(containerType.Value, BindingFlags.Public | BindingFlags.Instance); + + foreach (var subelement in itemsMethod.Invoke(containerElement, null) as IEnumerable) + { + SearchForWarning((IAdaptiveCardElement)subelement, isInsideWarningContainer || (containerElement.Style == ContainerStyle.Warning)); + } + } + } } From c3008926e8b7c7d4958ff8f0271bfb41c49a43d8 Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:30:34 +0100 Subject: [PATCH 05/29] Keep About Settings page centered (#3145) --- .../DevHome.Settings/Views/AboutPage.xaml | 62 ++++++++++--------- .../DevHome.Settings/Views/AccountsPage.xaml | 2 +- .../DevHome.Settings/Views/LoginUIDialog.xaml | 6 +- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/settings/DevHome.Settings/Views/AboutPage.xaml b/settings/DevHome.Settings/Views/AboutPage.xaml index b486092cf2..6ac173b743 100644 --- a/settings/DevHome.Settings/Views/AboutPage.xaml +++ b/settings/DevHome.Settings/Views/AboutPage.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings/DevHome.Settings/Views/AccountsPage.xaml b/settings/DevHome.Settings/Views/AccountsPage.xaml index 5b65c8758b..7682d530ab 100644 --- a/settings/DevHome.Settings/Views/AccountsPage.xaml +++ b/settings/DevHome.Settings/Views/AccountsPage.xaml @@ -1,4 +1,4 @@ - - 360 - 408 - 360 + 360 + 408 + 360 408 0,0,0,0 0,0,0,0 From 93298de0f1d065a429956ca81b0eb92b81106cc1 Mon Sep 17 00:00:00 2001 From: Tim Kurtzman <49733346+timkur@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:35:06 -0700 Subject: [PATCH 06/29] Add remaining major UI elements to the bar (#3154) * Initial change * Update * Update * Missed change * PR feedback --- tools/PI/DevHome.PI/BarWindowHorizontal.xaml | 10 ++++- tools/PI/DevHome.PI/BarWindowVertical.xaml | 45 ++++++++++--------- tools/PI/DevHome.PI/BarWindowVertical.xaml.cs | 16 ++++++- tools/PI/DevHome.PI/Controls/PISeperator.xaml | 27 +++++++++++ .../DevHome.PI/Controls/PISeperator.xaml.cs | 42 +++++++++++++++++ tools/PI/DevHome.PI/DevHome.PI.csproj | 4 ++ .../ViewModels/BarWindowViewModel.cs | 14 ++++++ 7 files changed, 135 insertions(+), 23 deletions(-) create mode 100644 tools/PI/DevHome.PI/Controls/PISeperator.xaml create mode 100644 tools/PI/DevHome.PI/Controls/PISeperator.xaml.cs diff --git a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml index 9a905c2284..42423eb68f 100644 --- a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml +++ b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml @@ -68,10 +68,13 @@ + + + - + + - + diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml b/tools/PI/DevHome.PI/BarWindowVertical.xaml index 85c81b6a68..ea90dbec0b 100644 --- a/tools/PI/DevHome.PI/BarWindowVertical.xaml +++ b/tools/PI/DevHome.PI/BarWindowVertical.xaml @@ -27,25 +27,26 @@ - - - + + + + @@ -74,11 +75,13 @@ + - + + + diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs b/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs index 23b0daf43a..09ca5eb327 100644 --- a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs +++ b/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs @@ -16,7 +16,7 @@ using Windows.UI.WindowManagement; using Windows.Win32; using Windows.Win32.Foundation; -using Windows.Win32.UI.Accessibility; +using Windows.Win32.UI.WindowsAndMessaging; using WinRT.Interop; using WinUIEx; using static DevHome.PI.Helpers.WindowHelper; @@ -63,10 +63,24 @@ private void MainPanel_Loaded(object sender, RoutedEventArgs e) ThemeName t = ThemeName.Themes.First(t => t.Name == _settings.CurrentTheme); SetRequestedTheme(t.Theme); + RemoveThickFrameAttribute(); + // Regardless of what is set in the XAML, our initial window width is too big. Setting this to 70 (same as the XAML file) Width = 70; } + private void RemoveThickFrameAttribute() + { + // This is a workaround for this issue + // https://github.com/microsoft/microsoft-ui-xaml/issues/8947 + // + // This prevents a white strip to be at the top of our window (visible in dark mode). Unfortunately this workaround removes the rounded corners from the bar. + var style = PInvoke.GetWindowLong(ThisHwnd, WINDOW_LONG_PTR_INDEX.GWL_STYLE); + style &= ~(int)WINDOW_STYLE.WS_THICKFRAME; + _ = PInvoke.SetWindowLong(ThisHwnd, WINDOW_LONG_PTR_INDEX.GWL_STYLE, style); + PInvoke.SetWindowPos(ThisHwnd, HWND.Null, 0, 0, 0, 0, Windows.Win32.UI.WindowsAndMessaging.SET_WINDOW_POS_FLAGS.SWP_FRAMECHANGED | SET_WINDOW_POS_FLAGS.SWP_NOSIZE | SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOZORDER | SET_WINDOW_POS_FLAGS.SWP_NOOWNERZORDER); + } + private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (string.Equals(e.PropertyName, nameof(BarWindowViewModel.WindowPosition), StringComparison.OrdinalIgnoreCase)) diff --git a/tools/PI/DevHome.PI/Controls/PISeperator.xaml b/tools/PI/DevHome.PI/Controls/PISeperator.xaml new file mode 100644 index 0000000000..19033801a8 --- /dev/null +++ b/tools/PI/DevHome.PI/Controls/PISeperator.xaml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/tools/PI/DevHome.PI/Controls/PISeperator.xaml.cs b/tools/PI/DevHome.PI/Controls/PISeperator.xaml.cs new file mode 100644 index 0000000000..7b2b8a26d3 --- /dev/null +++ b/tools/PI/DevHome.PI/Controls/PISeperator.xaml.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +using Microsoft.Diagnostics.Tracing.Parsers.MicrosoftWindowsTCPIP; +using Microsoft.UI.System; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace DevHome.PI.Controls; + +public sealed partial class PISeperator : UserControl +{ + private Orientation _orientation = Orientation.Vertical; + + public Orientation Orientation + { + get => _orientation; + + set + { + _orientation = value; + + if (value == Orientation.Vertical) + { + SeparatorRectangleVertical.Visibility = Visibility.Visible; + SeparatorRectangleHorizontal.Visibility = Visibility.Collapsed; + } + else + { + SeparatorRectangleHorizontal.Visibility = Visibility.Visible; + SeparatorRectangleVertical.Visibility = Visibility.Collapsed; + } + } + } + + public PISeperator() + { + this.InitializeComponent(); + } +} diff --git a/tools/PI/DevHome.PI/DevHome.PI.csproj b/tools/PI/DevHome.PI/DevHome.PI.csproj index bba227fd8e..c42747b350 100644 --- a/tools/PI/DevHome.PI/DevHome.PI.csproj +++ b/tools/PI/DevHome.PI/DevHome.PI.csproj @@ -28,6 +28,7 @@ + @@ -156,6 +157,9 @@ Always + + MSBuild:Compile + MSBuild:Compile diff --git a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs index 28892be72d..4cfa31637c 100644 --- a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs +++ b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.ComponentModel; using System.Globalization; using CommunityToolkit.Mvvm.ComponentModel; @@ -54,6 +56,9 @@ public partial class BarWindowViewModel : ObservableObject [ObservableProperty] private Visibility _appBarVisibility = Visibility.Visible; + [ObservableProperty] + private Visibility _externalToolSeperatorVisibility = Visibility.Collapsed; + [ObservableProperty] private string _applicationName = string.Empty; @@ -108,6 +113,15 @@ public BarWindowViewModel() CurrentSnapButtonText = IsSnapped ? _UnsnapButtonText : _SnapButtonText; _snapHelper = new(); + + ((INotifyCollectionChanged)ExternalToolsHelper.Instance.FilteredExternalTools).CollectionChanged += FilteredExternalTools_CollectionChanged; + FilteredExternalTools_CollectionChanged(null, null); + } + + private void FilteredExternalTools_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs? e) + { + // Only show the seperator if we're showing pinned tools + ExternalToolSeperatorVisibility = ExternalToolsHelper.Instance.FilteredExternalTools.Count > 0 ? Visibility.Visible : Visibility.Collapsed; } partial void OnIsSnappedChanged(bool value) From 9db92955056f1be932ee500c876b6f62ff626c3b Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Thu, 6 Jun 2024 12:55:16 -0700 Subject: [PATCH 07/29] Remove internal service connection (#3165) --- build/azure-pipelines.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index e55c277094..a0254a5875 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -66,8 +66,6 @@ extends: - task: NuGetToolInstaller@1 - task: NuGetAuthenticate@1 - inputs: - nuGetServiceConnections: 'DevHomeInternal' - task: PowerShell@2 displayName: Build SDK @@ -109,8 +107,6 @@ extends: - task: NuGetToolInstaller@1 - task: NuGetAuthenticate@1 - inputs: - nuGetServiceConnections: 'DevHomeInternal' - task: PowerShell@2 displayName: Build Stub Packages @@ -139,8 +135,6 @@ extends: - task: NuGetToolInstaller@1 - task: NuGetAuthenticate@1 - inputs: - nuGetServiceConnections: 'DevHomeInternal' - task: PowerShell@2 displayName: Replace Stubbed Files From 092f7a69df44c7cb96d1e0c112e69c170baed6e3 Mon Sep 17 00:00:00 2001 From: Zarana Kiran Desai <78943958+zadesai@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:15:29 -0700 Subject: [PATCH 08/29] fix snapping/unsnapping when the bar window is moved (#3166) --- tools/PI/DevHome.PI/BarWindowVertical.xaml.cs | 4 ++-- .../DevHome.PI/ViewModels/BarWindowViewModel.cs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs b/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs index 09ca5eb327..f7f12219ba 100644 --- a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs +++ b/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs @@ -125,7 +125,7 @@ private void Window_PointerReleased(object sender, PointerRoutedEventArgs e) { if (DoesWindow1CoverTheRightSideOfWindow2(ThisHwnd, TargetAppData.Instance.HWnd)) { - _viewModel.IsSnapped = true; + _viewModel.SnapBarWindow(); } } } @@ -138,7 +138,7 @@ private void Window_PointerPressed(object sender, PointerRoutedEventArgs e) // Moving the window causes it to unsnap if (_viewModel.IsSnapped) { - _viewModel.IsSnapped = false; + _viewModel.UnsnapBarWindow(); } isWindowMoving = true; diff --git a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs index 4cfa31637c..bb550d7b4d 100644 --- a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs +++ b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs @@ -134,7 +134,7 @@ partial void OnBarOrientationChanged(Orientation value) if (value == Orientation.Horizontal) { // If we were snapped, unsnap - IsSnapped = false; + UnsnapBarWindow(); } else { @@ -168,6 +168,14 @@ public void SwitchLayout() } } + public void SnapBarWindow() + { + // First need to be in a Vertical layout + BarOrientation = Orientation.Vertical; + _snapHelper.Snap(); + IsSnapped = true; + } + public void UnsnapBarWindow() { _snapHelper.Unsnap(); @@ -182,11 +190,8 @@ public void ToggleSnap() UnsnapBarWindow(); } else - { - // First need to be in a Vertical layout - BarOrientation = Orientation.Vertical; - _snapHelper.Snap(); - IsSnapped = true; + { + SnapBarWindow(); } } From 51b856cbe8044a94d70e4876978223a0f9c2b3ff Mon Sep 17 00:00:00 2001 From: David Bennett Date: Thu, 6 Jun 2024 17:33:36 -0700 Subject: [PATCH 09/29] Change PI cpu usage to match widget usage (#3171) --- tools/PI/DevHome.PI/Models/PerfCounters.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/PI/DevHome.PI/Models/PerfCounters.cs b/tools/PI/DevHome.PI/Models/PerfCounters.cs index a5311ee387..1a1cb204e6 100644 --- a/tools/PI/DevHome.PI/Models/PerfCounters.cs +++ b/tools/PI/DevHome.PI/Models/PerfCounters.cs @@ -19,11 +19,11 @@ public partial class PerfCounters : ObservableObject, IDisposable public static readonly PerfCounters Instance = new(); private const string ProcessCategory = "Process"; - private const string ProcessorCategory = "Processor"; + private const string ProcessorCategory = "Processor Information"; private const string MemoryCategory = "Memory"; private const string DiskCategory = "PhysicalDisk"; - private const string CpuCounterName = "% Processor Time"; + private const string CpuCounterName = "% Processor Utility"; private const string RamCounterName = "Working Set - Private"; private const string SystemRamCounterName = "Committed Bytes"; private const string SystemDiskCounterName = "% Disk Time"; @@ -172,7 +172,7 @@ private void TimerCallback(object? state) { try { - CpuUsage = cpuCounter?.NextValue() / Environment.ProcessorCount ?? 0; + CpuUsage = (cpuCounter?.NextValue() ?? 0) / 100; GpuUsage = GetGpuUsage(gpuCounters); // Report app memory usage in MB From e0bb83eed07b9ab7609261c18a3259ccf066fc97 Mon Sep 17 00:00:00 2001 From: Darren Hoehna Date: Fri, 7 Jun 2024 10:39:54 -0700 Subject: [PATCH 10/29] Changing to auto (#3167) --- .../Environments/DevHome.Environments/Views/LandingPage.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Environments/DevHome.Environments/Views/LandingPage.xaml b/tools/Environments/DevHome.Environments/Views/LandingPage.xaml index a3242c6d34..825530112a 100644 --- a/tools/Environments/DevHome.Environments/Views/LandingPage.xaml +++ b/tools/Environments/DevHome.Environments/Views/LandingPage.xaml @@ -215,9 +215,9 @@ - + - + From 71c6700691f4e8fd2252379edc2ee465682a5800 Mon Sep 17 00:00:00 2001 From: gohellp <47943965+Gohellp@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:29:36 +0300 Subject: [PATCH 11/29] Allow SSH widget to show entries with multiple Host aliases (#2664) --- extensions/CoreWidgetProvider/Widgets/Assets/example_config | 4 ++++ extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/CoreWidgetProvider/Widgets/Assets/example_config b/extensions/CoreWidgetProvider/Widgets/Assets/example_config index 7e7ae4ffb0..47c7fe95b8 100644 --- a/extensions/CoreWidgetProvider/Widgets/Assets/example_config +++ b/extensions/CoreWidgetProvider/Widgets/Assets/example_config @@ -16,3 +16,7 @@ Host ubuntu_test Hostname 192.168.1.41 User ubuntussh Port 22 + +Host router rack_123_router + Hostname 192.168.2.100 + User admin diff --git a/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs b/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs index a92c6767d9..ef26c21d37 100644 --- a/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs @@ -17,7 +17,7 @@ internal sealed class SSHWalletWidget : CoreWidget { private static readonly string DefaultConfigFile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\.ssh\\config"; - private static readonly Regex HostRegex = new(@"^Host\s+(\S*)\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline); + private static readonly Regex HostRegex = new(@"^Host\s+(?:(\S*) ?)*?\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline); private FileSystemWatcher? FileWatcher { get; set; } From 72ac5476530f57ea656394423fd0215b10905444 Mon Sep 17 00:00:00 2001 From: Branden Bonaby <105318831+bbonaby@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:02:09 -0700 Subject: [PATCH 12/29] change default metadata to true so dots appear by default (#3163) --- common/Environments/CustomControls/CardHeader.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Environments/CustomControls/CardHeader.xaml.cs b/common/Environments/CustomControls/CardHeader.xaml.cs index aac684e5ac..8ec5361e11 100644 --- a/common/Environments/CustomControls/CardHeader.xaml.cs +++ b/common/Environments/CustomControls/CardHeader.xaml.cs @@ -41,5 +41,5 @@ public BitmapImage HeaderIcon private static readonly DependencyProperty ActionControlTemplateProperty = DependencyProperty.Register(nameof(ActionControlTemplate), typeof(DataTemplate), typeof(CardHeader), new PropertyMetadata(null)); private static readonly DependencyProperty HeaderCaptionProperty = DependencyProperty.Register(nameof(HeaderCaption), typeof(string), typeof(CardHeader), new PropertyMetadata(null)); private static readonly DependencyProperty HeaderIconProperty = DependencyProperty.Register(nameof(HeaderIcon), typeof(BitmapImage), typeof(CardHeader), new PropertyMetadata(null)); - private static readonly DependencyProperty OperationsVisibilityProperty = DependencyProperty.Register(nameof(HeaderCaption), typeof(bool), typeof(CardHeader), new PropertyMetadata(false)); + private static readonly DependencyProperty OperationsVisibilityProperty = DependencyProperty.Register(nameof(HeaderCaption), typeof(bool), typeof(CardHeader), new PropertyMetadata(true)); } From 99c8dc47107454642c2c6dea528e3564d6422e6e Mon Sep 17 00:00:00 2001 From: Branden Bonaby <105318831+bbonaby@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:02:43 -0700 Subject: [PATCH 13/29] re-add creation error messages (#3149) --- .../CreateComputeSystemOperationViewModel.cs | 7 ++++--- .../ViewModels/LandingPageViewModel.cs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/Environments/DevHome.Environments/ViewModels/CreateComputeSystemOperationViewModel.cs b/tools/Environments/DevHome.Environments/ViewModels/CreateComputeSystemOperationViewModel.cs index f456773e79..117289ff47 100644 --- a/tools/Environments/DevHome.Environments/ViewModels/CreateComputeSystemOperationViewModel.cs +++ b/tools/Environments/DevHome.Environments/ViewModels/CreateComputeSystemOperationViewModel.cs @@ -108,9 +108,10 @@ private void UpdateStatusIfCompleted(CreateComputeSystemResult createComputeSyst } else { - // Reset text in UI card and show the error notification info bar to tell the user the operation failed - UpdateUiMessage(string.Empty); - OnErrorReceived(_stringResource.GetLocalized("FailureMessageForCreateComputeSystem", createComputeSystemResult.Result.DisplayMessage)); + // Reset text in UI card to show error and show the error notification info bar to tell the user the operation failed + var errorMsg = _stringResource.GetLocalized("FailureMessageForCreateComputeSystem", createComputeSystemResult.Result.DisplayMessage); + UpdateUiMessage(errorMsg); + OnErrorReceived(errorMsg); State = ComputeSystemState.Unknown; StateColor = CardStateColor.Failure; } diff --git a/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs b/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs index 3237cae9fb..382aeac508 100644 --- a/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs +++ b/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs @@ -281,8 +281,16 @@ private void SetupCreateComputeSystemOperationForUI() foreach (var operation in curOperations) { // this is a new operation so we need to create a view model for it. - ComputeSystemCards.Insert(0, new CreateComputeSystemOperationViewModel(_computeSystemManager, _stringResource, _mainWindow, RemoveComputeSystemCard, AddNewlyCreatedComputeSystem, operation)); - ComputeSystemCards.Last().ComputeSystemErrorReceived += OnComputeSystemOperationError; + var operationViewModel = new CreateComputeSystemOperationViewModel( + _computeSystemManager, + _stringResource, + _mainWindow, + RemoveComputeSystemCard, + AddNewlyCreatedComputeSystem, + operation); + + operationViewModel.ComputeSystemErrorReceived += OnComputeSystemOperationError; + ComputeSystemCards.Insert(0, operationViewModel); _log.Information($"Found new create compute system operation for provider {operation.ProviderDetails.ComputeSystemProvider}, with name {operation.EnvironmentName}"); } From f5ca2252f35ee2ee0a966847a4b174963c387fae Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:42:08 +0100 Subject: [PATCH 14/29] Project Ironsides Separator (#3177) --- tools/PI/DevHome.PI/Controls/PISeperator.xaml | 2 +- .../DevHome.PI/Controls/PISeperator.xaml.cs | 4 +- tools/PI/DevHome.PI/DevHome.PI.csproj | 13 ++-- .../ViewModels/AppDetailsPageViewModel.cs | 70 +++++++++---------- .../ViewModels/BarWindowViewModel.cs | 24 +++---- tools/PI/DevHome.PI/{ => Views}/BarWindow.cs | 3 +- .../{ => Views}/BarWindowHorizontal.xaml | 10 +-- .../{ => Views}/BarWindowHorizontal.xaml.cs | 4 +- .../{ => Views}/BarWindowVertical.xaml | 8 +-- .../{ => Views}/BarWindowVertical.xaml.cs | 0 .../DevHome.PI/{ => Views}/PrimaryWindow.xaml | 0 .../{ => Views}/PrimaryWindow.xaml.cs | 1 + 12 files changed, 68 insertions(+), 71 deletions(-) rename tools/PI/DevHome.PI/{ => Views}/BarWindow.cs (98%) rename tools/PI/DevHome.PI/{ => Views}/BarWindowHorizontal.xaml (95%) rename tools/PI/DevHome.PI/{ => Views}/BarWindowHorizontal.xaml.cs (99%) rename tools/PI/DevHome.PI/{ => Views}/BarWindowVertical.xaml (96%) rename tools/PI/DevHome.PI/{ => Views}/BarWindowVertical.xaml.cs (100%) rename tools/PI/DevHome.PI/{ => Views}/PrimaryWindow.xaml (100%) rename tools/PI/DevHome.PI/{ => Views}/PrimaryWindow.xaml.cs (95%) diff --git a/tools/PI/DevHome.PI/Controls/PISeperator.xaml b/tools/PI/DevHome.PI/Controls/PISeperator.xaml index 19033801a8..76f216add3 100644 --- a/tools/PI/DevHome.PI/Controls/PISeperator.xaml +++ b/tools/PI/DevHome.PI/Controls/PISeperator.xaml @@ -1,6 +1,6 @@ true false $(DefineConstants);DISABLE_XAML_GENERATED_MAIN - @@ -28,7 +27,7 @@ - + @@ -99,16 +98,11 @@ - - - - - @@ -157,7 +151,7 @@ Always - + MSBuild:Compile @@ -189,6 +183,9 @@ MSBuild:Compile + + + 7 diff --git a/tools/PI/DevHome.PI/ViewModels/AppDetailsPageViewModel.cs b/tools/PI/DevHome.PI/ViewModels/AppDetailsPageViewModel.cs index 9255b094e6..b67ab68db2 100644 --- a/tools/PI/DevHome.PI/ViewModels/AppDetailsPageViewModel.cs +++ b/tools/PI/DevHome.PI/ViewModels/AppDetailsPageViewModel.cs @@ -18,18 +18,18 @@ namespace DevHome.PI.ViewModels; public partial class AppDetailsPageViewModel : ObservableObject { - private static readonly ILogger _log = Log.ForContext("SourceContext", nameof(AppDetailsPageViewModel)); - + private static readonly ILogger _log = Log.ForContext("SourceContext", nameof(AppDetailsPageViewModel)); + [ObservableProperty] private AppRuntimeInfo appInfo; - [ObservableProperty] + [ObservableProperty] private Visibility runAsAdminVisibility = Visibility.Collapsed; - [ObservableProperty] + [ObservableProperty] private Visibility processRunningParamsVisibility = Visibility.Collapsed; - private Process? targetProcess; + private Process? targetProcess; public AppDetailsPageViewModel() { @@ -52,18 +52,18 @@ public void UpdateTargetProcess(Process process) AppInfo = new(); try - { - AppInfo.ProcessId = targetProcess.Id; - - if (process.HasExited) - { - AppInfo.Visibility = Visibility.Collapsed; - ProcessRunningParamsVisibility = Visibility.Collapsed; - } + { + AppInfo.ProcessId = targetProcess.Id; + + if (process.HasExited) + { + AppInfo.Visibility = Visibility.Collapsed; + ProcessRunningParamsVisibility = Visibility.Collapsed; + } else - { - AppInfo.Visibility = Visibility.Visible; - ProcessRunningParamsVisibility = Visibility.Visible; + { + AppInfo.Visibility = Visibility.Visible; + ProcessRunningParamsVisibility = Visibility.Visible; AppInfo.IsRunningAsSystem = TargetAppData.Instance.IsRunningAsSystem; AppInfo.IsRunningAsAdmin = TargetAppData.Instance.IsRunningAsAdmin; AppInfo.BasePriority = targetProcess.BasePriority; @@ -88,17 +88,17 @@ public void UpdateTargetProcess(Process process) catch (Win32Exception ex) { // This can throw if the process is running elevated and we are not. - _log.Error(ex, "Unable to construct an AppInfo for target process."); - if (ex.NativeErrorCode == (int)Windows.Win32.Foundation.WIN32_ERROR.ERROR_ACCESS_DENIED) - { - // Hide properties that cannot be retrieved when the target app is elevated and PI is not. - AppInfo.Visibility = Visibility.Collapsed; - - // Only show the button when not running as admin. This is possible when the target app is a system app. - if (!RuntimeHelper.IsCurrentProcessRunningAsAdmin()) - { - RunAsAdminVisibility = Visibility.Visible; - } + _log.Error(ex, "Unable to construct an AppInfo for target process."); + if (ex.NativeErrorCode == (int)Windows.Win32.Foundation.WIN32_ERROR.ERROR_ACCESS_DENIED) + { + // Hide properties that cannot be retrieved when the target app is elevated and PI is not. + AppInfo.Visibility = Visibility.Collapsed; + + // Only show the button when not running as admin. This is possible when the target app is a system app. + if (!RuntimeHelper.IsCurrentProcessRunningAsAdmin()) + { + RunAsAdminVisibility = Visibility.Visible; + } } } } @@ -113,14 +113,14 @@ private void TargetApp_PropertyChanged(object? sender, PropertyChangedEventArgs UpdateTargetProcess(TargetAppData.Instance.TargetProcess); } } - } - - [RelayCommand] - private void RunAsAdmin() - { - if (targetProcess is not null) - { - CommonHelper.RunAsAdmin(targetProcess.Id, nameof(AppDetailsPageViewModel)); + } + + [RelayCommand] + private void RunAsAdmin() + { + if (targetProcess is not null) + { + CommonHelper.RunAsAdmin(targetProcess.Id, nameof(AppDetailsPageViewModel)); } } } diff --git a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs index bb550d7b4d..738c325254 100644 --- a/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs +++ b/tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs @@ -57,7 +57,7 @@ public partial class BarWindowViewModel : ObservableObject private Visibility _appBarVisibility = Visibility.Visible; [ObservableProperty] - private Visibility _externalToolSeperatorVisibility = Visibility.Collapsed; + private Visibility _externalToolSeparatorVisibility = Visibility.Collapsed; [ObservableProperty] private string _applicationName = string.Empty; @@ -81,8 +81,8 @@ public partial class BarWindowViewModel : ObservableObject private bool _isAlwaysOnTop = true; [ObservableProperty] - private PointInt32 _windowPosition; - + private PointInt32 _windowPosition; + internal HWND? ApplicationHwnd { get; private set; } public BarWindowViewModel() @@ -106,7 +106,7 @@ public BarWindowViewModel() { ApplicationName = process.ProcessName; ApplicationPid = process.Id; - ApplicationIcon = TargetAppData.Instance.Icon; + ApplicationIcon = TargetAppData.Instance.Icon; ApplicationHwnd = TargetAppData.Instance.HWnd; } @@ -120,8 +120,8 @@ public BarWindowViewModel() private void FilteredExternalTools_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs? e) { - // Only show the seperator if we're showing pinned tools - ExternalToolSeperatorVisibility = ExternalToolsHelper.Instance.FilteredExternalTools.Count > 0 ? Visibility.Visible : Visibility.Collapsed; + // Only show the separator if we're showing pinned tools + ExternalToolSeparatorVisibility = ExternalToolsHelper.Instance.FilteredExternalTools.Count > 0 ? Visibility.Visible : Visibility.Collapsed; } partial void OnIsSnappedChanged(bool value) @@ -169,10 +169,10 @@ public void SwitchLayout() } public void SnapBarWindow() - { - // First need to be in a Vertical layout - BarOrientation = Orientation.Vertical; - _snapHelper.Snap(); + { + // First need to be in a Vertical layout + BarOrientation = Orientation.Vertical; + _snapHelper.Snap(); IsSnapped = true; } @@ -190,7 +190,7 @@ public void ToggleSnap() UnsnapBarWindow(); } else - { + { SnapBarWindow(); } } @@ -251,7 +251,7 @@ private void TargetApp_PropertyChanged(object? sender, PropertyChangedEventArgs _dispatcher.TryEnqueue(() => { - // The App status bar is only visibile if we're attached to a process + // The App status bar is only visible if we're attached to a process AppBarVisibility = process is null ? Visibility.Collapsed : Visibility.Visible; if (process is not null) diff --git a/tools/PI/DevHome.PI/BarWindow.cs b/tools/PI/DevHome.PI/Views/BarWindow.cs similarity index 98% rename from tools/PI/DevHome.PI/BarWindow.cs rename to tools/PI/DevHome.PI/Views/BarWindow.cs index b0bf1b0d78..d03207f469 100644 --- a/tools/PI/DevHome.PI/BarWindow.cs +++ b/tools/PI/DevHome.PI/Views/BarWindow.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.ComponentModel; using DevHome.Common.Extensions; -using DevHome.PI.Helpers; using DevHome.PI.Models; using DevHome.PI.Properties; using DevHome.PI.ViewModels; @@ -15,7 +14,7 @@ using Windows.Win32.Foundation; using WinUIEx; -namespace DevHome.PI; +namespace DevHome.PI.Views; public partial class BarWindow { diff --git a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml b/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml similarity index 95% rename from tools/PI/DevHome.PI/BarWindowHorizontal.xaml rename to tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml index 42423eb68f..b97370237a 100644 --- a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml +++ b/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml @@ -34,7 +34,7 @@ - + - + diff --git a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs b/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml.cs similarity index 99% rename from tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs rename to tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml.cs index bee2761ad1..a7c1619dbb 100644 --- a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs +++ b/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml.cs @@ -112,7 +112,7 @@ private void MainPanel_Loaded(object sender, RoutedEventArgs e) var dpiWindow = HwndExtensions.GetDpiForWindow(ThisHwnd); _dpiScale = dpiWindow / 96.0; - SetDefaultPosition(); + SetDefaultPosition(); SetRegionsForTitleBar(); } @@ -136,7 +136,7 @@ public void SetRegionsForTitleBar() } private void SetDefaultPosition() - { + { // If attached to an app it should show up on the monitor that the app is on _monitorRect = GetMonitorRectForWindow(_viewModel.ApplicationHwnd ?? ThisHwnd); var screenWidth = _monitorRect.right - _monitorRect.left; diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml b/tools/PI/DevHome.PI/Views/BarWindowVertical.xaml similarity index 96% rename from tools/PI/DevHome.PI/BarWindowVertical.xaml rename to tools/PI/DevHome.PI/Views/BarWindowVertical.xaml index ea90dbec0b..54d7607260 100644 --- a/tools/PI/DevHome.PI/BarWindowVertical.xaml +++ b/tools/PI/DevHome.PI/Views/BarWindowVertical.xaml @@ -75,12 +75,12 @@ - + - + - + diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs b/tools/PI/DevHome.PI/Views/BarWindowVertical.xaml.cs similarity index 100% rename from tools/PI/DevHome.PI/BarWindowVertical.xaml.cs rename to tools/PI/DevHome.PI/Views/BarWindowVertical.xaml.cs diff --git a/tools/PI/DevHome.PI/PrimaryWindow.xaml b/tools/PI/DevHome.PI/Views/PrimaryWindow.xaml similarity index 100% rename from tools/PI/DevHome.PI/PrimaryWindow.xaml rename to tools/PI/DevHome.PI/Views/PrimaryWindow.xaml diff --git a/tools/PI/DevHome.PI/PrimaryWindow.xaml.cs b/tools/PI/DevHome.PI/Views/PrimaryWindow.xaml.cs similarity index 95% rename from tools/PI/DevHome.PI/PrimaryWindow.xaml.cs rename to tools/PI/DevHome.PI/Views/PrimaryWindow.xaml.cs index bda525fea1..d314669466 100644 --- a/tools/PI/DevHome.PI/PrimaryWindow.xaml.cs +++ b/tools/PI/DevHome.PI/Views/PrimaryWindow.xaml.cs @@ -7,6 +7,7 @@ using DevHome.PI.Helpers; using DevHome.PI.Models; using DevHome.PI.Properties; +using DevHome.PI.Views; using DevHome.Telemetry; using Microsoft.UI.Xaml; using Windows.System; From c1f8ad5366c6e3f29642c43a8fb37b835d0dc62c Mon Sep 17 00:00:00 2001 From: Zarana Kiran Desai <78943958+zadesai@users.noreply.github.com> Date: Mon, 10 Jun 2024 09:48:51 -0700 Subject: [PATCH 15/29] update the system CPU counter name (#3182) --- tools/PI/DevHome.PI/Models/PerfCounters.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/PI/DevHome.PI/Models/PerfCounters.cs b/tools/PI/DevHome.PI/Models/PerfCounters.cs index 1a1cb204e6..b666b69156 100644 --- a/tools/PI/DevHome.PI/Models/PerfCounters.cs +++ b/tools/PI/DevHome.PI/Models/PerfCounters.cs @@ -23,8 +23,9 @@ public partial class PerfCounters : ObservableObject, IDisposable private const string MemoryCategory = "Memory"; private const string DiskCategory = "PhysicalDisk"; - private const string CpuCounterName = "% Processor Utility"; + private const string CpuCounterName = "% Processor Time"; private const string RamCounterName = "Working Set - Private"; + private const string SystemCpuCounterName = "% Processor Utility"; private const string SystemRamCounterName = "Committed Bytes"; private const string SystemDiskCounterName = "% Disk Time"; @@ -76,7 +77,7 @@ public PerfCounters() ThreadPool.QueueUserWorkItem((o) => { - systemCpuCounter = new PerformanceCounter(ProcessorCategory, CpuCounterName, "_Total", true); + systemCpuCounter = new PerformanceCounter(ProcessorCategory, SystemCpuCounterName, "_Total", true); systemRamCounter = new PerformanceCounter(MemoryCategory, SystemRamCounterName, true); systemDiskCounter = new PerformanceCounter(DiskCategory, SystemDiskCounterName, "_Total", true); UpdateTargetProcess(TargetAppData.Instance.TargetProcess); @@ -172,7 +173,7 @@ private void TimerCallback(object? state) { try { - CpuUsage = (cpuCounter?.NextValue() ?? 0) / 100; + CpuUsage = cpuCounter?.NextValue() / Environment.ProcessorCount ?? 0; GpuUsage = GetGpuUsage(gpuCounters); // Report app memory usage in MB From 4d2976920edc8b6dcabdbc19b2176556d4945894 Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:01:38 +0100 Subject: [PATCH 16/29] Add Preview button to SSH Widget (#3168) --- .../CoreWidgetProvider/Helpers/Resources.cs | 1 + .../Strings/en-US/Resources.resw | 4 ++ .../Widgets/SSHWalletWidget.cs | 31 ++++++----- .../SSHWalletConfigurationTemplate.json | 53 +++++++++++++------ 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/extensions/CoreWidgetProvider/Helpers/Resources.cs b/extensions/CoreWidgetProvider/Helpers/Resources.cs index 85e5659de3..715cc0002e 100644 --- a/extensions/CoreWidgetProvider/Helpers/Resources.cs +++ b/extensions/CoreWidgetProvider/Helpers/Resources.cs @@ -88,6 +88,7 @@ public static string[] GetWidgetResourceIdentifiers() "CPUUsage_Widget_Template/CPU_Speed", "CPUUsage_Widget_Template/Processes", "CPUUsage_Widget_Template/End_Process", + "Widget_Template_Button/Preview", "Widget_Template_Button/Save", "Widget_Template_Button/Cancel", ]; diff --git a/extensions/CoreWidgetProvider/Strings/en-US/Resources.resw b/extensions/CoreWidgetProvider/Strings/en-US/Resources.resw index 332c784dbd..2e1a45870a 100644 --- a/extensions/CoreWidgetProvider/Strings/en-US/Resources.resw +++ b/extensions/CoreWidgetProvider/Strings/en-US/Resources.resw @@ -162,6 +162,10 @@ End process + + Preview + Shown in Widget, Button text + Save Shown in Widget, Button text diff --git a/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs b/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs index ef26c21d37..5bf8176f53 100644 --- a/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs @@ -166,29 +166,32 @@ private void HandleCheckPath(WidgetActionInvokedArgs args) Page = WidgetPageState.Loading; UpdateWidget(); - // This is the action when the user clicks the submit button after entering a path while in - // the Configure state. Page = WidgetPageState.Configure; var data = args.Data; var dataObject = JsonSerializer.Deserialize(data, SourceGenerationContext.Default.DataPayload); - if (dataObject != null && dataObject.ConfigFile != null) - { - var updateRequestOptions = new WidgetUpdateRequestOptions(Id) - { - Data = GetConfiguration(dataObject.ConfigFile), - CustomState = ConfigFile, - Template = GetTemplateForPage(Page), - }; - WidgetManager.GetDefault().UpdateWidget(updateRequestOptions); + var chosenPath = string.Empty; + + if (dataObject == null) + { + return; + } + else if (dataObject.ConfigFile != null) + { + // The user clicked the Preview button in the Configure state. + chosenPath = dataObject.ConfigFile; + } + else if (dataObject.FilePath != null) + { + // The user used the File Picker to select a file in the Configure state. + chosenPath = dataObject.FilePath; } - // This is the action when the user uses the File Picker to select a file "filePath" in the Configure state. - if (dataObject != null && dataObject.FilePath != null) + if (!string.IsNullOrEmpty(chosenPath)) { var updateRequestOptions = new WidgetUpdateRequestOptions(Id) { - Data = GetConfiguration(dataObject.FilePath), + Data = GetConfiguration(chosenPath), CustomState = ConfigFile, Template = GetTemplateForPage(Page), }; diff --git a/extensions/CoreWidgetProvider/Widgets/Templates/SSHWalletConfigurationTemplate.json b/extensions/CoreWidgetProvider/Widgets/Templates/SSHWalletConfigurationTemplate.json index c4a104aa3f..3fc7eb1c8b 100644 --- a/extensions/CoreWidgetProvider/Widgets/Templates/SSHWalletConfigurationTemplate.json +++ b/extensions/CoreWidgetProvider/Widgets/Templates/SSHWalletConfigurationTemplate.json @@ -15,6 +15,42 @@ "placeholder": "${$root.configuration.currentOrDefaultConfigFile}", "value": "${$root.configuration.currentOrDefaultConfigFile}" }, + { + "type": "ColumnSet", + "spacing": "Medium", + "columns": [ + { + "type": "Column", + "width": "stretch" + }, + { + "type": "Column", + "width": "auto", + "items": [ + { + "type": "Container", + "items": [ + { + "type": "ActionSet", + "actions": [ + { + "type": "Action.Execute", + "title": "%Widget_Template_Button/Preview%", + "verb": "CheckPath", + "associatedInputs": "Auto" + } + ] + } + ] + } + ] + }, + { + "type": "Column", + "width": "stretch" + } + ] + }, { "type": "Container", "items": [ @@ -33,21 +69,6 @@ { "type": "Container", "items": [ - { - "type": "TextBlock", - "text": "%SSH_Widget_Template/ConfigFilePath%", - "wrap": true, - "spacing": "Medium", - "size": "Small", - "isSubtle": true - }, - { - "type": "TextBlock", - "text": "${configFile}", - "wrap": true, - "size": "medium", - "spacing": "None" - }, { "type": "TextBlock", "text": "%SSH_Widget_Template/NumOfHosts%", @@ -71,7 +92,7 @@ }, { "type": "ColumnSet", - "spacing": "ExtraLarge", + "spacing": "Large", "columns": [ { "type": "Column", From f00c94fa779ed6373dc8de605020df8a7d83f830 Mon Sep 17 00:00:00 2001 From: Tim Kurtzman <49733346+timkur@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:03:14 -0700 Subject: [PATCH 17/29] Ironsides - Add detach from target process (#3173) * Add detach from target process * Updates * code review feedback * Updated to using a bind for the separator --- .../Controls/ExpandedViewControl.xaml | 42 +++++++++++-------- .../DevHome.PI/Strings/en-us/Resources.resw | 16 +++++-- .../ViewModels/BarWindowViewModel.cs | 12 ++++-- .../ExpandedViewControlViewModel.cs | 15 +++++++ .../DevHome.PI/Views/BarWindowHorizontal.xaml | 21 +++++++--- .../DevHome.PI/Views/BarWindowVertical.xaml | 23 +++++++--- 6 files changed, 94 insertions(+), 35 deletions(-) diff --git a/tools/PI/DevHome.PI/Controls/ExpandedViewControl.xaml b/tools/PI/DevHome.PI/Controls/ExpandedViewControl.xaml index c8e51c0f08..e66356ceaa 100644 --- a/tools/PI/DevHome.PI/Controls/ExpandedViewControl.xaml +++ b/tools/PI/DevHome.PI/Controls/ExpandedViewControl.xaml @@ -5,7 +5,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:models="using:DevHome.PI.Models" + xmlns:controls="using:DevHome.PI.Controls" mc:Ignorable="d"> @@ -30,22 +30,30 @@ - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/tools/PI/DevHome.PI/Pages/WinLogsPage.xaml b/tools/PI/DevHome.PI/Pages/WinLogsPage.xaml index e510c2b100..fedbc207df 100644 --- a/tools/PI/DevHome.PI/Pages/WinLogsPage.xaml +++ b/tools/PI/DevHome.PI/Pages/WinLogsPage.xaml @@ -42,12 +42,12 @@ diff --git a/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml b/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml index e8153fa497..37c572f1dd 100644 --- a/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml +++ b/tools/PI/DevHome.PI/Views/BarWindowHorizontal.xaml @@ -13,7 +13,6 @@ TaskBarIcon="Images/pi.ico" Closed="WindowEx_Closed"> - @@ -47,7 +46,7 @@