mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Remember Settingwindow Size and Location
This commit is contained in:
parent
05044ae00d
commit
e42c2b6020
4 changed files with 72 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
|
|
@ -43,6 +43,11 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public bool UseSound { get; set; } = true;
|
||||
public bool FirstLaunch { get; set; } = true;
|
||||
|
||||
public double SettingWindowWidth { get; set; } = 1000;
|
||||
public double SettingWindowHeight { get; set; } = 700;
|
||||
public double SettingWindowTop { get; set; } = 0;
|
||||
public double SettingWindowLeft { get; set; } = 0;
|
||||
|
||||
public int CustomExplorerIndex { get; set; } = 0;
|
||||
|
||||
[JsonIgnore]
|
||||
|
|
@ -220,4 +225,4 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
Light,
|
||||
Dark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,17 +13,19 @@
|
|||
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
|
||||
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
|
||||
Title="{DynamicResource flowlauncher_settings}"
|
||||
Width="1000"
|
||||
Height="700"
|
||||
Width="{Binding SettingWindowWidth, Mode=TwoWay}"
|
||||
Height="{Binding SettingWindowHeight, Mode=TwoWay}"
|
||||
MinWidth="900"
|
||||
MinHeight="600"
|
||||
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
|
||||
Closed="OnClosed"
|
||||
Icon="Images\app.ico"
|
||||
Left="{Binding SettingWindowLeft, Mode=TwoWay}"
|
||||
Loaded="OnLoaded"
|
||||
MouseDown="window_MouseDown"
|
||||
ResizeMode="CanResize"
|
||||
StateChanged="Window_StateChanged"
|
||||
Top="{Binding SettingWindowTop, Mode=TwoWay}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<WindowChrome.WindowChrome>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using Flow.Launcher.ViewModel;
|
|||
using Microsoft.Win32;
|
||||
using ModernWpf;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
@ -48,6 +49,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InitializePosition();
|
||||
RefreshMaximizeRestoreButton();
|
||||
// Fix (workaround) for the window freezes after lock screen (Win+L)
|
||||
// https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf
|
||||
|
|
@ -242,6 +244,8 @@ namespace Flow.Launcher
|
|||
|
||||
private void OnClosed(object sender, EventArgs e)
|
||||
{
|
||||
settings.SettingWindowTop = Top;
|
||||
settings.SettingWindowLeft = Left;
|
||||
viewModel.Save();
|
||||
}
|
||||
|
||||
|
|
@ -319,6 +323,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void OnCloseButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
@ -348,5 +353,36 @@ namespace Flow.Launcher
|
|||
{
|
||||
Plugins.ScrollIntoView(Plugins.SelectedItem);
|
||||
}
|
||||
|
||||
public void InitializePosition()
|
||||
{
|
||||
if (settings.SettingWindowTop == 0 && settings.SettingWindowLeft == 0)
|
||||
{
|
||||
Top = WindowTop();
|
||||
Left = WindowLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
Top = settings.SettingWindowTop;
|
||||
Left = settings.SettingWindowLeft;
|
||||
}
|
||||
}
|
||||
public double WindowLeft()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
var left = (dip2.X - this.ActualWidth) / 2 + dip1.X;
|
||||
return left;
|
||||
}
|
||||
|
||||
public double WindowTop()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||
var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20;
|
||||
return top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
await _updater.UpdateAppAsync(App.API, false);
|
||||
}
|
||||
|
||||
|
||||
public bool AutoUpdates
|
||||
{
|
||||
get => Settings.AutoUpdates;
|
||||
|
|
@ -385,6 +385,30 @@ namespace Flow.Launcher.ViewModel
|
|||
set => Settings.UseSound = value;
|
||||
}
|
||||
|
||||
public double SettingWindowWidth
|
||||
{
|
||||
get => Settings.SettingWindowWidth;
|
||||
set => Settings.SettingWindowWidth = value;
|
||||
}
|
||||
|
||||
public double SettingWindowHeight
|
||||
{
|
||||
get => Settings.SettingWindowHeight;
|
||||
set => Settings.SettingWindowHeight = value;
|
||||
}
|
||||
|
||||
public double SettingWindowTop
|
||||
{
|
||||
get => Settings.SettingWindowTop;
|
||||
set => Settings.SettingWindowTop = value;
|
||||
}
|
||||
|
||||
public double SettingWindowLeft
|
||||
{
|
||||
get => Settings.SettingWindowLeft;
|
||||
set => Settings.SettingWindowLeft = value;
|
||||
}
|
||||
|
||||
public Brush PreviewBackground
|
||||
{
|
||||
get
|
||||
|
|
|
|||
Loading…
Reference in a new issue