Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
Expand Down Expand Up @@ -43,6 +43,11 @@ public string Language
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; }
public double SettingWindowLeft { get; set; }

public int CustomExplorerIndex { get; set; } = 0;

[JsonIgnore]
Expand Down Expand Up @@ -220,4 +225,4 @@ public enum ColorSchemes
Light,
Dark
}
}
}
9 changes: 5 additions & 4 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@
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"
WindowStartupLocation="CenterScreen"
Top="{Binding SettingWindowTop, Mode=TwoWay}"
WindowStartupLocation="Manual"
mc:Ignorable="d">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
Expand Down Expand Up @@ -1114,7 +1116,6 @@
<!--#endregion-->
<ContentControl
x:Name="PluginSettingControl"
MaxHeight="550"
Margin="0"
Padding="1"
VerticalAlignment="Stretch"
Expand Down
38 changes: 37 additions & 1 deletion Flow.Launcher/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public partial class SettingWindow

public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
{
InitializeComponent();
settings = viewModel.Settings;
DataContext = viewModel;
this.viewModel = viewModel;
API = api;
InitializePosition();
InitializeComponent();
}

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

private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -243,6 +245,8 @@ private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)

private void OnClosed(object sender, EventArgs e)
{
settings.SettingWindowTop = Top;
settings.SettingWindowLeft = Left;
viewModel.Save();
}

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

private void OnCloseButtonClick(object sender, RoutedEventArgs e)
{

Close();
}

Expand Down Expand Up @@ -350,6 +355,36 @@ private void ItemSizeChanged(object sender, SizeChangedEventArgs e)
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)
{
if (e.ChangedButton == MouseButton.Left)
Expand All @@ -360,6 +395,7 @@ private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs
API.ChangeQuery($"{actionKeyword} uninstall {id}");
API.ShowMainWindow();
}

}
}
}
26 changes: 25 additions & 1 deletion Flow.Launcher/ViewModel/SettingWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async void UpdateApp()
{
await _updater.UpdateAppAsync(App.API, false);
}

public bool AutoUpdates
{
get => Settings.AutoUpdates;
Expand Down Expand Up @@ -406,6 +406,30 @@ public bool UseSound
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
Expand Down