Skip to content

Commit

Permalink
Merge pull request #3 from intcooper/fix/first_start
Browse files Browse the repository at this point in the history
Bug fix: the main window is now automatically opened on the first start.
  • Loading branch information
rguida authored May 21, 2024
2 parents bef3c84 + 5e2ec0b commit c12c752
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 10 additions & 2 deletions MMExNotifier/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ protected override void OnStartup(StartupEventArgs e)
var view = new MainWindow();
var viewModel = new MainViewModel(appConfiguration, new NotificationService(new ToastNotification()), new DatabaseService(appConfiguration));

view.Hide();
view.DataContext = viewModel;
viewModel.OnClose += (s, e) => Application.Current.Dispatcher.Invoke(() => view.Close());
viewModel.OnOpen += (s, e) => Application.Current.Dispatcher.Invoke(() => { if (view.Visibility != Visibility.Visible) view.ShowDialog(); });
viewModel.OnClose += (s, e) => view.Dispatcher.Invoke(() => view.Close());
viewModel.OnOpen += (s, e) => view.Dispatcher.Invoke(() =>
{
if (view.Visibility != Visibility.Visible)
{
view.Visibility = Visibility.Visible;
view.Show();
}
});
viewModel.Activate();
}
}
Expand Down
11 changes: 5 additions & 6 deletions MMExNotifier/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Icon="pack://application:,,,/Resources/MMExNotifier.png"
ResizeMode="CanResizeWithGrip"
Visibility="Hidden"
WindowBackdropType="Mica"
WindowCornerPreference="Round"
WindowStartupLocation="Manual"
Expand Down Expand Up @@ -278,11 +277,6 @@
</Button>
</Grid>

<CheckBox
Margin="20"
Content="Run MMExNotifier on Windows logon"
IsChecked="{Binding Path=AppSettings.RunAtLogon}" />

<Grid Margin="20,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -327,6 +321,11 @@
Content="days ahead" />
</Grid>

<CheckBox
Margin="20"
Content="Run MMExNotifier on Windows logon"
IsChecked="{Binding Path=AppSettings.RunAtLogon}" />

</StackPanel>
</Border>
</Grid>
Expand Down

0 comments on commit c12c752

Please sign in to comment.