Skip to content

Commit 52d142c

Browse files
committed
One-time binding for main window width
1 parent b87237f commit 52d142c

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
1313
Name="FlowMainWindow"
1414
Title="Flow Launcher"
15-
Width="{Binding MainWindowWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
15+
Width="{Binding MainWindowWidth, Mode=OneTime}"
1616
MinWidth="400"
1717
MinHeight="30"
1818
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
@@ -30,7 +30,6 @@
3030
PreviewKeyUp="OnKeyUp"
3131
ResizeMode="CanResize"
3232
ShowInTaskbar="False"
33-
SizeChanged="Window_SizeChanged"
3433
SizeToContent="Height"
3534
Topmost="True"
3635
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public partial class MainWindow
4545
private MainViewModel _viewModel;
4646
private bool _animating;
4747
private bool isArrowKeyPressed = false;
48-
private double WindowWidthForSave;
4948

5049
private MediaPlayer animationSoundWMP;
5150
private SoundPlayer animationSoundWPF;
@@ -121,6 +120,8 @@ private void OnResizeEnd()
121120
_settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount));
122121
}
123122
}
123+
124+
_viewModel.MainWindowWidth = Width;
124125
FlowMainWindow.SizeToContent = SizeToContent.Height;
125126
}
126127

@@ -154,9 +155,6 @@ private void OnPaste(object sender, DataObjectPastingEventArgs e)
154155
private async void OnClosing(object sender, CancelEventArgs e)
155156
{
156157
_notifyIcon.Visible = false;
157-
/* In this timing, window alreayd closed and it effect to window size. So at this point, whenever the window changes,
158-
we recall the width we've stored as a variable and specify it in the settings. This way, the existing window size will be recalled on the next run.*/
159-
_settings.WindowSize = WindowWidthForSave;
160158
App.API.SaveAppAllSettings();
161159
e.Cancel = true;
162160
await PluginManager.DisposePluginsAsync();
@@ -834,10 +832,5 @@ private void QueryTextBox_KeyUp(object sender, KeyEventArgs e)
834832
be.UpdateSource();
835833
}
836834
}
837-
838-
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
839-
{
840-
WindowWidthForSave = Width;
841-
}
842835
}
843836
}

0 commit comments

Comments
 (0)