Skip to content

Commit 6361516

Browse files
authored
Merge branch 'dev' into ProgressBarDispatcher
2 parents bfee170 + 69c03cf commit 6361516

File tree

4 files changed

+74
-8
lines changed

4 files changed

+74
-8
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
44
using System.Drawing;
@@ -43,6 +43,11 @@ public string Language
4343
public bool UseSound { get; set; } = true;
4444
public bool FirstLaunch { get; set; } = true;
4545

46+
public double SettingWindowWidth { get; set; } = 1000;
47+
public double SettingWindowHeight { get; set; } = 700;
48+
public double SettingWindowTop { get; set; }
49+
public double SettingWindowLeft { get; set; }
50+
4651
public int CustomExplorerIndex { get; set; } = 0;
4752

4853
[JsonIgnore]
@@ -220,4 +225,4 @@ public enum ColorSchemes
220225
Light,
221226
Dark
222227
}
223-
}
228+
}

Flow.Launcher/SettingWindow.xaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@
1313
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
1414
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
1515
Title="{DynamicResource flowlauncher_settings}"
16-
Width="1000"
17-
Height="700"
16+
Width="{Binding SettingWindowWidth, Mode=TwoWay}"
17+
Height="{Binding SettingWindowHeight, Mode=TwoWay}"
1818
MinWidth="900"
1919
MinHeight="600"
2020
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
2121
Closed="OnClosed"
2222
Icon="Images\app.ico"
23+
Left="{Binding SettingWindowLeft, Mode=TwoWay}"
2324
Loaded="OnLoaded"
2425
MouseDown="window_MouseDown"
2526
ResizeMode="CanResize"
2627
StateChanged="Window_StateChanged"
27-
WindowStartupLocation="CenterScreen"
28+
Top="{Binding SettingWindowTop, Mode=TwoWay}"
29+
WindowStartupLocation="Manual"
2830
mc:Ignorable="d">
2931
<WindowChrome.WindowChrome>
3032
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
@@ -1114,7 +1116,6 @@
11141116
<!--#endregion-->
11151117
<ContentControl
11161118
x:Name="PluginSettingControl"
1117-
MaxHeight="550"
11181119
Margin="0"
11191120
Padding="1"
11201121
VerticalAlignment="Stretch"

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ public partial class SettingWindow
3838

3939
public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
4040
{
41-
InitializeComponent();
4241
settings = viewModel.Settings;
4342
DataContext = viewModel;
4443
this.viewModel = viewModel;
4544
API = api;
45+
InitializePosition();
46+
InitializeComponent();
4647
}
4748

4849
#region General
@@ -55,6 +56,7 @@ private void OnLoaded(object sender, RoutedEventArgs e)
5556
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
5657
HwndTarget hwndTarget = hwndSource.CompositionTarget;
5758
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
59+
InitializePosition();
5860
}
5961

6062
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
@@ -243,6 +245,8 @@ private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
243245

244246
private void OnClosed(object sender, EventArgs e)
245247
{
248+
settings.SettingWindowTop = Top;
249+
settings.SettingWindowLeft = Left;
246250
viewModel.Save();
247251
}
248252

@@ -320,6 +324,7 @@ private void OnMaximizeRestoreButtonClick(object sender, RoutedEventArgs e)
320324

321325
private void OnCloseButtonClick(object sender, RoutedEventArgs e)
322326
{
327+
323328
Close();
324329
}
325330

@@ -350,6 +355,36 @@ private void ItemSizeChanged(object sender, SizeChangedEventArgs e)
350355
Plugins.ScrollIntoView(Plugins.SelectedItem);
351356
}
352357

358+
public void InitializePosition()
359+
{
360+
if (settings.SettingWindowTop >= 0 && settings.SettingWindowLeft >= 0)
361+
{
362+
Top = settings.SettingWindowTop;
363+
Left = settings.SettingWindowLeft;
364+
}
365+
else
366+
{
367+
Top = WindowTop();
368+
Left = WindowLeft();
369+
}
370+
}
371+
public double WindowLeft()
372+
{
373+
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
374+
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
375+
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
376+
var left = (dip2.X - this.ActualWidth) / 2 + dip1.X;
377+
return left;
378+
}
379+
380+
public double WindowTop()
381+
{
382+
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
383+
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
384+
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
385+
var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20;
386+
return top;
387+
}
353388
private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e)
354389
{
355390
if (e.ChangedButton == MouseButton.Left)
@@ -360,6 +395,7 @@ private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs
360395
API.ChangeQuery($"{actionKeyword} uninstall {id}");
361396
API.ShowMainWindow();
362397
}
398+
363399
}
364400
}
365401
}

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async void UpdateApp()
5151
{
5252
await _updater.UpdateAppAsync(App.API, false);
5353
}
54-
54+
5555
public bool AutoUpdates
5656
{
5757
get => Settings.AutoUpdates;
@@ -406,6 +406,30 @@ public bool UseSound
406406
set => Settings.UseSound = value;
407407
}
408408

409+
public double SettingWindowWidth
410+
{
411+
get => Settings.SettingWindowWidth;
412+
set => Settings.SettingWindowWidth = value;
413+
}
414+
415+
public double SettingWindowHeight
416+
{
417+
get => Settings.SettingWindowHeight;
418+
set => Settings.SettingWindowHeight = value;
419+
}
420+
421+
public double SettingWindowTop
422+
{
423+
get => Settings.SettingWindowTop;
424+
set => Settings.SettingWindowTop = value;
425+
}
426+
427+
public double SettingWindowLeft
428+
{
429+
get => Settings.SettingWindowLeft;
430+
set => Settings.SettingWindowLeft = value;
431+
}
432+
409433
public Brush PreviewBackground
410434
{
411435
get

0 commit comments

Comments
 (0)