• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thorstenalpers / CleanMyPosts / 15184035747

22 May 2025 10:18AM UTC coverage: 22.575% (-0.7%) from 23.225%
15184035747

push

github

thorstenalpers
Save the window location and restore it

86 of 366 branches covered (23.5%)

Branch coverage included in aggregate %.

0 of 36 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

277 of 1242 relevant lines covered (22.3%)

0.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/UI/Views/ShellWindow.xaml.cs
1
using System.Windows;
2
using System.Windows.Controls;
3
using CleanMyPosts.UI.Contracts.Services;
4
using CleanMyPosts.UI.Contracts.Views;
5
using CleanMyPosts.UI.Models;
6
using CleanMyPosts.UI.ViewModels;
7
using MahApps.Metro.Controls;
8

9
namespace CleanMyPosts.UI.Views;
10

11
public partial class ShellWindow : MetroWindow, IShellWindow
12
{
13
    private readonly IUserSettingsService _userSettingsService;
14
    private bool _settingsLoaded = false;
15

NEW
16
    public ShellWindow(ShellViewModel viewModel, IUserSettingsService userSettingsService)
×
17
    {
NEW
18
        _userSettingsService = userSettingsService ?? throw new ArgumentNullException(nameof(userSettingsService));
×
19
        InitializeComponent();
×
20
        DataContext = viewModel;
×
21

NEW
22
        Loaded += OnLoaded;
×
NEW
23
        Closing += OnClosing;
×
NEW
24
    }
×
25

26
    private void OnLoaded(object sender, RoutedEventArgs e)
27
    {
NEW
28
        var settings = _userSettingsService.GetWindowSettings();
×
29

30
        // Basic screen bounds check
NEW
31
        if (settings.Left >= 0 && settings.Top >= 0)
×
32
        {
NEW
33
            Left = settings.Left;
×
NEW
34
            Top = settings.Top;
×
35
        }
36

NEW
37
        Width = settings.Width;
×
NEW
38
        Height = settings.Height;
×
NEW
39
        WindowState = settings.WindowState;
×
40

NEW
41
        _settingsLoaded = true;
×
NEW
42
    }
×
43

44
    private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
45
    {
NEW
46
        if (!_settingsLoaded)
×
47
        {
NEW
48
            return;
×
49
        }
50

NEW
51
        var settings = new WindowSettings
×
NEW
52
        {
×
NEW
53
            Top = Top,
×
NEW
54
            Left = Left,
×
NEW
55
            Width = Width,
×
NEW
56
            Height = Height,
×
NEW
57
            WindowState = this.WindowState
×
NEW
58
        };
×
59

NEW
60
        _userSettingsService.SaveWindowsSettings(settings);
×
UNCOV
61
    }
×
62

63
    public Frame GetNavigationFrame()
64
        => shellFrame;
×
65

66
    public void ShowWindow()
67
        => Show();
×
68

69
    public void CloseWindow()
70
        => Close();
×
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc