mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
UI - Avoid opening the main window multiple times from tray
Profiling - Thread safety and use high precision counters Profiling - Profile timed updates Timed updates - Added argument to give timed updates a name Plugins - Affix plugin folders with a part of the plugin GUID Debugger - Added 95th percentile column to profiling Debugger - Fix scrolling in performance profile tab when hovering over datagrids
This commit is contained in:
1 parent
4ab8459927
commit
1660519bee
14 files changed
+315
-185
No files matched your search
+8
@@ -9,6 +9,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs.Performance
|
||||
private string _last;
|
||||
private string _max;
|
||||
private string _min;
|
||||
private string _percentile;
|
||||
|
||||
public PerformanceDebugMeasurementViewModel(ProfilingMeasurement measurement)
|
||||
{
|
||||
@@ -41,12 +42,19 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs.Performance
|
||||
set => SetAndNotify(ref _max, value);
|
||||
}
|
||||
|
||||
public string Percentile
|
||||
{
|
||||
get => _percentile;
|
||||
set => SetAndNotify(ref _percentile, value);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
Last = Measurement.GetLast().TotalMilliseconds + " ms";
|
||||
Average = Measurement.GetAverage().TotalMilliseconds + " ms";
|
||||
Min = Measurement.GetMin().TotalMilliseconds + " ms";
|
||||
Max = Measurement.GetMax().TotalMilliseconds + " ms";
|
||||
Percentile = Measurement.GetPercentile(0.95).TotalMilliseconds + " ms";
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -27,6 +27,7 @@
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding Min}" Header="Min" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding Max}" Header="Max" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding Average}" Header="Average" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding Percentile}" Header="95th percentile" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</StackPanel>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
If you are having performance issues, below you can find out which plugin might be the culprit.
|
||||
</TextBlock>
|
||||
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
||||
<ItemsControl ItemsSource="{Binding Items}" Margin="0 0 10 0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Debug.Tabs.Performance
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for PerformanceDebugView.xaml
|
||||
/// </summary>
|
||||
public partial class PerformanceDebugView : UserControl
|
||||
{
|
||||
public PerformanceDebugView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
ScrollViewer scv = (ScrollViewer)sender;
|
||||
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,7 @@
|
||||
<tb:TaskbarIcon IconSource="{Binding Icon}"
|
||||
MenuActivation="LeftOrRightClick"
|
||||
PopupActivation="DoubleClick"
|
||||
DoubleClickCommand="{s:Action TrayBringToForeground}"
|
||||
TrayBalloonTipClicked="{s:Action OnTrayBalloonTipClicked}">
|
||||
DoubleClickCommand="{s:Action TrayBringToForeground}">
|
||||
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border Background="{DynamicResource MaterialDesignToolTipBackground}" CornerRadius="2" Padding="5">
|
||||
|
||||
@@ -26,10 +26,11 @@ namespace Artemis.UI.Screens
|
||||
private readonly IKernel _kernel;
|
||||
private readonly ThemeWatcher _themeWatcher;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private ImageSource _icon;
|
||||
private bool _openingMainWindow;
|
||||
private RootViewModel _rootViewModel;
|
||||
private SplashViewModel _splashViewModel;
|
||||
private TaskbarIcon _taskBarIcon;
|
||||
private ImageSource _icon;
|
||||
|
||||
public TrayViewModel(IKernel kernel,
|
||||
IWindowManager windowManager,
|
||||
@@ -55,7 +56,7 @@ namespace Artemis.UI.Screens
|
||||
_themeWatcher.AppsThemeChanged += _themeWatcher_AppsThemeChanged;
|
||||
|
||||
ApplyColorSchemeSetting();
|
||||
ApplyTryIconTheme(_themeWatcher.GetSystemTheme());
|
||||
ApplyTrayIconTheme(_themeWatcher.GetSystemTheme());
|
||||
|
||||
windowService.ConfigureMainWindowProvider(this);
|
||||
bool autoRunning = Bootstrapper.StartupArguments.Contains("--autorun");
|
||||
@@ -63,7 +64,9 @@ namespace Artemis.UI.Screens
|
||||
bool showOnAutoRun = settingsService.GetSetting("UI.ShowOnStartup", true).Value;
|
||||
|
||||
if (autoRunning && !showOnAutoRun || minimized)
|
||||
{
|
||||
coreService.Initialized += (_, _) => updateService.AutoUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowSplashScreen();
|
||||
@@ -71,36 +74,55 @@ namespace Artemis.UI.Screens
|
||||
}
|
||||
}
|
||||
|
||||
public void TrayBringToForeground()
|
||||
{
|
||||
if (IsMainWindowOpen)
|
||||
{
|
||||
Execute.PostToUIThread(FocusMainWindow);
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the shared UI when first showing the window
|
||||
if (!UI.Shared.Bootstrapper.Initialized)
|
||||
UI.Shared.Bootstrapper.Initialize(_kernel);
|
||||
|
||||
Execute.OnUIThreadSync(() =>
|
||||
{
|
||||
_splashViewModel?.RequestClose();
|
||||
_splashViewModel = null;
|
||||
_rootViewModel = _kernel.Get<RootViewModel>();
|
||||
_rootViewModel.Closed += RootViewModelOnClosed;
|
||||
_windowManager.ShowWindow(_rootViewModel);
|
||||
});
|
||||
|
||||
OnMainWindowOpened();
|
||||
}
|
||||
|
||||
public ImageSource Icon
|
||||
{
|
||||
get => _icon;
|
||||
set => SetAndNotify(ref _icon, value);
|
||||
}
|
||||
|
||||
public void TrayBringToForeground()
|
||||
{
|
||||
if (_openingMainWindow)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_openingMainWindow = true;
|
||||
|
||||
if (IsMainWindowOpen)
|
||||
{
|
||||
Execute.OnUIThreadSync(() =>
|
||||
{
|
||||
FocusMainWindow();
|
||||
_openingMainWindow = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the shared UI when first showing the window
|
||||
if (!UI.Shared.Bootstrapper.Initialized)
|
||||
UI.Shared.Bootstrapper.Initialize(_kernel);
|
||||
|
||||
Execute.OnUIThreadSync(() =>
|
||||
{
|
||||
_splashViewModel?.RequestClose();
|
||||
_splashViewModel = null;
|
||||
_rootViewModel = _kernel.Get<RootViewModel>();
|
||||
_rootViewModel.Closed += RootViewModelOnClosed;
|
||||
_windowManager.ShowWindow(_rootViewModel);
|
||||
|
||||
IsMainWindowOpen = true;
|
||||
_openingMainWindow = false;
|
||||
});
|
||||
|
||||
OnMainWindowOpened();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_openingMainWindow = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void TrayActivateSidebarItem(string sidebarItem)
|
||||
{
|
||||
TrayBringToForeground();
|
||||
@@ -122,14 +144,6 @@ namespace Artemis.UI.Screens
|
||||
_taskBarIcon = (TaskbarIcon) ((ContentControl) view).Content;
|
||||
}
|
||||
|
||||
public void OnTrayBalloonTipClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsMainWindowOpen)
|
||||
TrayBringToForeground();
|
||||
else
|
||||
FocusMainWindow();
|
||||
}
|
||||
|
||||
private void FocusMainWindow()
|
||||
{
|
||||
// Wrestle the main window to the front
|
||||
@@ -158,10 +172,15 @@ namespace Artemis.UI.Screens
|
||||
|
||||
private void RootViewModelOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
if (_rootViewModel != null)
|
||||
lock (this)
|
||||
{
|
||||
_rootViewModel.Closed -= RootViewModelOnClosed;
|
||||
_rootViewModel = null;
|
||||
if (_rootViewModel != null)
|
||||
{
|
||||
_rootViewModel.Closed -= RootViewModelOnClosed;
|
||||
_rootViewModel = null;
|
||||
}
|
||||
|
||||
IsMainWindowOpen = false;
|
||||
}
|
||||
|
||||
OnMainWindowClosed();
|
||||
@@ -187,7 +206,7 @@ namespace Artemis.UI.Screens
|
||||
ChangeMaterialColors(ApplicationColorScheme.Light);
|
||||
}
|
||||
|
||||
private void ApplyTryIconTheme(ThemeWatcher.WindowsTheme theme)
|
||||
private void ApplyTrayIconTheme(ThemeWatcher.WindowsTheme theme)
|
||||
{
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
@@ -215,7 +234,7 @@ namespace Artemis.UI.Screens
|
||||
|
||||
private void _themeWatcher_SystemThemeChanged(object sender, WindowsThemeEventArgs e)
|
||||
{
|
||||
ApplyTryIconTheme(e.Theme);
|
||||
ApplyTrayIconTheme(e.Theme);
|
||||
}
|
||||
|
||||
private void ColorSchemeOnSettingChanged(object sender, EventArgs e)
|
||||
@@ -231,10 +250,7 @@ namespace Artemis.UI.Screens
|
||||
|
||||
public bool OpenMainWindow()
|
||||
{
|
||||
if (IsMainWindowOpen)
|
||||
Execute.OnUIThread(FocusMainWindow);
|
||||
else
|
||||
TrayBringToForeground();
|
||||
TrayBringToForeground();
|
||||
return _rootViewModel.ScreenState == ScreenState.Active;
|
||||
}
|
||||
|
||||
@@ -250,13 +266,11 @@ namespace Artemis.UI.Screens
|
||||
|
||||
protected virtual void OnMainWindowOpened()
|
||||
{
|
||||
IsMainWindowOpen = true;
|
||||
MainWindowOpened?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnMainWindowClosed()
|
||||
{
|
||||
IsMainWindowOpen = false;
|
||||
MainWindowClosed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user