Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ironsides - Move implementation closer to Design's vision #3284

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
155 changes: 75 additions & 80 deletions tools/PI/DevHome.PI/Controls/ExpandedViewControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@

<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBlock
x:Uid="ExpandedViewHeaderTextBlock" x:Name="ExpandedViewTitleTextBlock" Text="{x:Bind viewModel.Title, Mode=OneWay}"
FontSize="{StaticResource SubtitleTextBlockFontSize}" FontWeight="Bold" FontFamily="Segoe UI"/>

<Grid Grid.Row="1" Margin="0,8,0,0">
<Grid Grid.Row="0" Margin="0,8,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width="Auto"/>
Expand Down Expand Up @@ -61,23 +57,7 @@
Visibility="{x:Bind viewModel.AppSettingsVisibility, Mode=OneWay}"
Command="{x:Bind viewModel.DetachFromProcessCommand}"/>
</StackPanel>
<Button
Grid.Row="1" x:Name="SettingsButton" Click="SettingsButton_Click"
BorderThickness="0" Background="Transparent" Margin="4,0,0,0"
HorizontalAlignment="Stretch" VerticalAlignment="Center" HorizontalContentAlignment="Left">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Text="&#xe713;" FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="{StaticResource CaptionTextBlockFontSize}"
HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBlock
Grid.Column="1" Text="{x:Bind viewModel.SettingsHeader, Mode=OneWay}"
Margin="12,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Grid>
</Button>

</Grid>

<toolkit:GridSplitter
Expand All @@ -92,69 +72,84 @@

<Frame x:Name="PageFrame"/>

<Expander
x:Name="ClipboardErrorExpander" Grid.Row="1"
</Grid>
</Grid>

<!-- Bottom section -->
<StackPanel Orientation="Vertical" Grid.Row="2">
<Expander
x:Name="ClipboardErrorExpander"
IsExpanded="False" ExpandDirection="Up"
HorizontalAlignment="Stretch" VerticalAlignment="Top" Padding="0,6"
HorizontalContentAlignment="Stretch">
<Expander.Header>
<TextBlock x:Uid="ClickboardErrorTextBlock" FontSize="{StaticResource CaptionTextBlockFontSize}"/>
</Expander.Header>
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource CaptionTextBlockFontSize}"/>
<Setter Property="Margin" Value="12,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="{StaticResource CaptionTextBlockFontSize}"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="0,8,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Grid.Resources>
<Expander.Header>
<TextBlock x:Uid="ClickboardErrorTextBlock" FontSize="{StaticResource CaptionTextBlockFontSize}"/>
</Expander.Header>
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource CaptionTextBlockFontSize}"/>
<Setter Property="Margin" Value="12,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="{StaticResource CaptionTextBlockFontSize}"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="0,8,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Grid.Resources>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Uid="HexLabelTextBlock"/>
<TextBox x:Name="ErrorHexTextBox" Grid.Column="1" Text="{x:Bind viewModel.ClipboardContentsHex, Mode=OneWay}"/>
<TextBlock x:Uid="DecLabelTextBlock" Grid.Row="1"/>
<TextBox x:Name="ErrorDecTextBox" Grid.Row="1" Grid.Column="1" Text="{x:Bind viewModel.ClipboardContentsDec, Mode=OneWay}"/>
<TextBlock x:Uid="CodeLabelTextBlock" Grid.Row="2"/>
<TextBox x:Name="ErrorCodeTextBox" Grid.Row="2" Grid.Column="1" Text="{x:Bind viewModel.ClipboardContentsCode, Mode=OneWay}"/>
<TextBlock x:Uid="HelpLabelTextBlock" Grid.Row="3"/>
<TextBox x:Name="ErrorHelpTextBox" Grid.Row="3" Grid.Column="1"
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Uid="HexLabelTextBlock"/>
<TextBox x:Name="ErrorHexTextBox" Grid.Column="1" Text="{x:Bind viewModel.ClipboardContentsHex, Mode=OneWay}"/>
<TextBlock x:Uid="DecLabelTextBlock" Grid.Row="1"/>
<TextBox x:Name="ErrorDecTextBox" Grid.Row="1" Grid.Column="1" Text="{x:Bind viewModel.ClipboardContentsDec, Mode=OneWay}"/>
<TextBlock x:Uid="CodeLabelTextBlock" Grid.Row="2"/>
<TextBox x:Name="ErrorCodeTextBox" Grid.Row="2" Grid.Column="1" Text="{x:Bind viewModel.ClipboardContentsCode, Mode=OneWay}"/>
<TextBlock x:Uid="HelpLabelTextBlock" Grid.Row="3"/>
<TextBox x:Name="ErrorHelpTextBox" Grid.Row="3" Grid.Column="1"
ScrollViewer.HorizontalScrollBarVisibility="Auto" Height="36" Text="{x:Bind viewModel.ClipboardContentsHelp, Mode=OneWay}"/>
</Grid>
</Expander>
</Grid>
</Expander>

<Grid Grid.Row="2">
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource CaptionTextBlockFontSize}"/>
<Setter Property="Margin" Value="12,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</StackPanel.Resources>
<TextBlock x:Uid="ExpandedViewTargetAppPidTextBox" Visibility="{x:Bind viewModel.PerfMarkersVisibility, Mode=OneWay}" Text="{x:Bind viewModel.ApplicationPid, Mode=OneWay}"/>
<TextBlock x:Uid="ExpandedViewAppCpuPerf" Visibility="{x:Bind viewModel.PerfMarkersVisibility, Mode=OneWay}" Text="{x:Bind viewModel.CpuUsage, Mode=OneWay}"/>
<TextBlock x:Uid="ExpandedViewAppMemoryPerf" Visibility="{x:Bind viewModel.PerfMarkersVisibility, Mode=OneWay}" Text="{x:Bind viewModel.RamUsage, Mode=OneWay}"/>
<TextBlock x:Uid="ExpandedViewAppDiskPerf" Visibility="{x:Bind viewModel.PerfMarkersVisibility, Mode=OneWay}" Text="{x:Bind viewModel.DiskUsage, Mode=OneWay}"/>
</StackPanel>
</Grid>
<!-- Bottom status bar -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource CaptionTextBlockFontSize}"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="Button">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
</Grid.Resources>
<StackPanel Orientation="Horizontal" Grid.Column="0" Spacing="10" Visibility="{x:Bind viewModel.PerfMarkersVisibility, Mode=OneWay}">
<TextBlock x:Uid="ExpandedViewTargetAppPidTextBox" Text="{x:Bind viewModel.ApplicationPid, Mode=OneWay}"/>
<TextBlock x:Uid="ExpandedViewAppCpuPerf" Text="{x:Bind viewModel.CpuUsage, Mode=OneWay}"/>
<TextBlock x:Uid="ExpandedViewAppMemoryPerf" Text="{x:Bind viewModel.RamUsage, Mode=OneWay}"/>
<TextBlock x:Uid="ExpandedViewAppDiskPerf" Text="{x:Bind viewModel.DiskUsage, Mode=OneWay}"/>
</StackPanel>

<Button HorizontalAlignment="Right" Grid.Column="1" Click="SettingsButton_Click">
<TextBlock Text="&#xe713;" FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="{StaticResource CaptionTextBlockFontSize}" />
</Button>
</Grid>
</Grid>
</StackPanel>
</Grid>
</UserControl>
32 changes: 28 additions & 4 deletions tools/PI/DevHome.PI/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -514,19 +514,19 @@
<comment>Description of the error code</comment>
</data>
<data name="TargetAppPidTextFormat" xml:space="preserve">
<value>pid: {0}</value>
<value>PID: {0}</value>
<comment>Locked={"{0}"} Showing a process identifier. {0} is an integer</comment>
</data>
<data name="CpuPerfTextFormat" xml:space="preserve">
<value>cpu: {0:0.0}%</value>
<value>{0:0.0}% CPU usage</value>
<comment>Locked={"{0:0.0}"} Showing CPU utilization. {0} is a percentage 0-100</comment>
</data>
<data name="MemoryPerfTextFormat" xml:space="preserve">
<value>memory: {0:N2} MB</value>
<value>{0:N2} MB Memory used</value>
<comment>Locked={"{0:N2}"} Showing RAM utilization. MB stands for megabytes. {0} is a number.</comment>
</data>
<data name="DiskPerfTextFormat" xml:space="preserve">
<value>dsk: {0:N0} MB/s</value>
<value>{0:N0} MB/s Disk utilization</value>
<comment>Locked={"{0:N0}"} Showing disk utilization. MB/s stands for megabytes per second. {0} is a number.</comment>
</data>
<data name="CpuPerfNotAvailableText" xml:space="preserve">
Expand Down Expand Up @@ -1013,4 +1013,28 @@
<value>Collapse the large content panel</value>
<comment>The tooltip for a button which collapses the large content panel.</comment>
</data>
<data name="AppName.ToolTipService.ToolTip" xml:space="preserve">
<value>Name of the attached app</value>
<comment>Refers to the app's name in the bar</comment>
</data>
<data name="ClipboardMonitor.ToolTipService.ToolTip" xml:space="preserve">
<value>Open the Clipboard Monitor window</value>
<comment>Tooltip that tells users what the Clipboard Monitor button will do</comment>
</data>
<data name="ClipboardMonitorLabel.Text" xml:space="preserve">
<value>Clipboard Monitor</value>
<comment>A text label for the Clipboard Monitor button</comment>
</data>
<data name="Insights.ToolTipService.ToolTip" xml:space="preserve">
<value>See insights that Project Ironsides has gained</value>
<comment>Tooltip that tells users what the Insights button will do</comment>
</data>
<data name="InsightsLabel.Text" xml:space="preserve">
<value>Insights</value>
<comment>A text label for the Insights button</comment>
</data>
<data name="ProcessesLabel.Text" xml:space="preserve">
<value>Processes</value>
<comment>A text label for the Processes button</comment>
</data>
</root>
21 changes: 20 additions & 1 deletion tools/PI/DevHome.PI/ViewModels/BarWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public partial class BarWindowViewModel : ObservableObject
[ObservableProperty]
private bool _isAppBarVisible = true;

[ObservableProperty]
private bool _isProcessChooserVisible = false;

[ObservableProperty]
private Visibility _externalToolSeparatorVisibility = Visibility.Collapsed;

Expand Down Expand Up @@ -106,7 +109,10 @@ public BarWindowViewModel()
SystemDiskUsage = CommonHelper.GetLocalizedString("DiskPerfPercentUsageTextFormatNoLabel", PerfCounters.Instance.SystemDiskUsage);

var process = TargetAppData.Instance.TargetProcess;
IsAppBarVisible = process is not null;

// Show either the process chooser, or the app bar. Not both
IsProcessChooserVisible = process is null;
timkur marked this conversation as resolved.
Show resolved Hide resolved
IsAppBarVisible = !IsProcessChooserVisible;
if (process != null)
{
ApplicationName = process.ProcessName;
Expand Down Expand Up @@ -232,6 +238,16 @@ public void ProcessChooser()
barWindow?.NavigateTo(typeof(ProcessListPageViewModel));
}

[RelayCommand]
public void LaunchInsights()
{
ToggleExpandedContentVisibility();

// And navigate to the appropriate page
var barWindow = Application.Current.GetService<PrimaryWindow>().DBarWindow;
barWindow?.NavigateTo(typeof(InsightsPageViewModel));
}

[RelayCommand]
public void ManageExternalToolsButton()
{
Expand Down Expand Up @@ -277,6 +293,9 @@ private void TargetApp_PropertyChanged(object? sender, PropertyChangedEventArgs
ApplicationPid = process.Id;
ApplicationName = process.ProcessName;
}

// Conversely, the process chooser is only visible if we're not attached to a process
IsProcessChooserVisible = process is null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: how about we assign IsProcessChooserVisible before IsAppBarVisible and then set IsAppBarVisible = !IsProcessChooserVisible, keeping it consistent with the constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I do the opposite... I'm not sure what you mean by keeping it consistent with the constructor. Can you elaborate?

    IsProcessChooserVisible = process is null;
    IsAppBarVisible = !IsProcessChooserVisible;

I did update the code, since immediately thereafter I was checking for "if (process is not null)" and it was more clear to say "if (IsAppBarVisible)"...

});
}
else if (e.PropertyName == nameof(TargetAppData.Icon))
Expand Down
13 changes: 8 additions & 5 deletions tools/PI/DevHome.PI/ViewModels/ExpandedViewControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ private void AddPagesIfNecessary(Process? process)
if (!Links.Contains(processListNavLink))
{
Links.Add(processListNavLink);
Links.Add(watsonNavLink);
Links.Add(insightsNavLink);
}

// If App Details is missing, add all other pages.
Expand All @@ -210,9 +212,12 @@ private void AddPagesIfNecessary(Process? process)
Links.Insert(0, appDetailsNavLink);
Links.Insert(1, resourceUsageNavLink);
Links.Insert(2, modulesNavLink);
Links.Insert(3, watsonNavLink);
Links.Insert(4, winLogsNavLink);
Links.Insert(6, insightsNavLink);

// Process List #3
// Watson #4
Links.Insert(5, winLogsNavLink);

// Insights #6;
}
}
}
Expand All @@ -225,9 +230,7 @@ private void RemoveAppSpecificPages()
Links.Remove(appDetailsNavLink);
Links.Remove(resourceUsageNavLink);
Links.Remove(modulesNavLink);
Links.Remove(watsonNavLink);
Links.Remove(winLogsNavLink);
Links.Remove(insightsNavLink);
}

public void NavigateTo(Type viewModelType)
Expand Down
Loading
Loading