mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #1368 from onesounds/RememberSizeSettingWindow
Remember Setting window Size and Location
This commit is contained in:
commit
69c03cf1cd
4 changed files with 74 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
@ -43,6 +43,11 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
public bool UseSound { get; set; } = true;
|
public bool UseSound { get; set; } = true;
|
||||||
public bool FirstLaunch { 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; }
|
||||||
|
public double SettingWindowLeft { get; set; }
|
||||||
|
|
||||||
public int CustomExplorerIndex { get; set; } = 0;
|
public int CustomExplorerIndex { get; set; } = 0;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
|
@ -220,4 +225,4 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
Light,
|
Light,
|
||||||
Dark
|
Dark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,20 @@
|
||||||
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
|
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
|
||||||
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
|
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
|
||||||
Title="{DynamicResource flowlauncher_settings}"
|
Title="{DynamicResource flowlauncher_settings}"
|
||||||
Width="1000"
|
Width="{Binding SettingWindowWidth, Mode=TwoWay}"
|
||||||
Height="700"
|
Height="{Binding SettingWindowHeight, Mode=TwoWay}"
|
||||||
MinWidth="900"
|
MinWidth="900"
|
||||||
MinHeight="600"
|
MinHeight="600"
|
||||||
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
|
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
|
||||||
Closed="OnClosed"
|
Closed="OnClosed"
|
||||||
Icon="Images\app.ico"
|
Icon="Images\app.ico"
|
||||||
|
Left="{Binding SettingWindowLeft, Mode=TwoWay}"
|
||||||
Loaded="OnLoaded"
|
Loaded="OnLoaded"
|
||||||
MouseDown="window_MouseDown"
|
MouseDown="window_MouseDown"
|
||||||
ResizeMode="CanResize"
|
ResizeMode="CanResize"
|
||||||
StateChanged="Window_StateChanged"
|
StateChanged="Window_StateChanged"
|
||||||
WindowStartupLocation="CenterScreen"
|
Top="{Binding SettingWindowTop, Mode=TwoWay}"
|
||||||
|
WindowStartupLocation="Manual"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<WindowChrome.WindowChrome>
|
<WindowChrome.WindowChrome>
|
||||||
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
|
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
|
||||||
|
|
@ -1114,7 +1116,6 @@
|
||||||
<!--#endregion-->
|
<!--#endregion-->
|
||||||
<ContentControl
|
<ContentControl
|
||||||
x:Name="PluginSettingControl"
|
x:Name="PluginSettingControl"
|
||||||
MaxHeight="550"
|
|
||||||
Margin="0"
|
Margin="0"
|
||||||
Padding="1"
|
Padding="1"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,12 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
|
public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
|
||||||
settings = viewModel.Settings;
|
settings = viewModel.Settings;
|
||||||
DataContext = viewModel;
|
DataContext = viewModel;
|
||||||
this.viewModel = viewModel;
|
this.viewModel = viewModel;
|
||||||
API = api;
|
API = api;
|
||||||
|
InitializePosition();
|
||||||
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region General
|
#region General
|
||||||
|
|
@ -55,6 +56,7 @@ namespace Flow.Launcher
|
||||||
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
|
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
|
||||||
HwndTarget hwndTarget = hwndSource.CompositionTarget;
|
HwndTarget hwndTarget = hwndSource.CompositionTarget;
|
||||||
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
|
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
|
||||||
|
InitializePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
|
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -243,6 +245,8 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private void OnClosed(object sender, EventArgs e)
|
private void OnClosed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
settings.SettingWindowTop = Top;
|
||||||
|
settings.SettingWindowLeft = Left;
|
||||||
viewModel.Save();
|
viewModel.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,6 +324,7 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private void OnCloseButtonClick(object sender, RoutedEventArgs e)
|
private void OnCloseButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -350,6 +355,36 @@ namespace Flow.Launcher
|
||||||
Plugins.ScrollIntoView(Plugins.SelectedItem);
|
Plugins.ScrollIntoView(Plugins.SelectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InitializePosition()
|
||||||
|
{
|
||||||
|
if (settings.SettingWindowTop >= 0 && settings.SettingWindowLeft >= 0)
|
||||||
|
{
|
||||||
|
Top = settings.SettingWindowTop;
|
||||||
|
Left = settings.SettingWindowLeft;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Top = WindowTop();
|
||||||
|
Left = WindowLeft();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e)
|
private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ChangedButton == MouseButton.Left)
|
if (e.ChangedButton == MouseButton.Left)
|
||||||
|
|
@ -360,6 +395,7 @@ namespace Flow.Launcher
|
||||||
API.ChangeQuery($"{actionKeyword} uninstall {id}");
|
API.ChangeQuery($"{actionKeyword} uninstall {id}");
|
||||||
API.ShowMainWindow();
|
API.ShowMainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
{
|
{
|
||||||
await _updater.UpdateAppAsync(App.API, false);
|
await _updater.UpdateAppAsync(App.API, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AutoUpdates
|
public bool AutoUpdates
|
||||||
{
|
{
|
||||||
get => Settings.AutoUpdates;
|
get => Settings.AutoUpdates;
|
||||||
|
|
@ -406,6 +406,30 @@ namespace Flow.Launcher.ViewModel
|
||||||
set => Settings.UseSound = value;
|
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
|
public Brush PreviewBackground
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue