1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-22 13:50:14 +00:00
msfs-popout-panel-manager/WpfApp/UserControlPanelSelection.xaml.cs
2022-02-06 13:24:59 -05:00

115 lines
4.9 KiB
C#

using MSFSPopoutPanelManager.WpfApp.ViewModel;
using System.Windows;
using System.Windows.Controls;
namespace MSFSPopoutPanelManager.WpfApp
{
/// <summary>
/// Interaction logic for UserControlPanelSelection.xaml
/// </summary>
public partial class UserControlPanelSelection : UserControl
{
private PanelSelectionViewModel _panelSelectionViewModel;
public UserControlPanelSelection(PanelSelectionViewModel panelSelectionViewModel)
{
InitializeComponent();
_panelSelectionViewModel = panelSelectionViewModel;
this.DataContext = panelSelectionViewModel;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
_panelSelectionViewModel.Initialize();
}
private void AddProfile_Click(object sender, RoutedEventArgs e)
{
AddProfileDialog dialog = new AddProfileDialog(_panelSelectionViewModel.DataStore.UserProfiles);
dialog.Owner = Application.Current.MainWindow;
dialog.Topmost = true;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if ((bool)dialog.ShowDialog())
{
_panelSelectionViewModel.AddProfileCommand.Execute(new AddProfileCommandParameter() { ProfileName = dialog.ProfileName, CopyProfileId = dialog.SelectedCopyProfileId });
}
}
private void DeleteProfile_Click(object sender, RoutedEventArgs e)
{
ConfirmationDialog dialog = new ConfirmationDialog("Confirm Delete", "Are you sure you want to delete the selected profile?");
dialog.Owner = Application.Current.MainWindow;
dialog.Topmost = true;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if ((bool)dialog.ShowDialog())
{
_panelSelectionViewModel.DeleteProfileCommand.Execute(null);
}
}
private void StartPanelSelection_Click(object sender, RoutedEventArgs e)
{
if (_panelSelectionViewModel.DataStore.ActiveUserProfile.PanelSourceCoordinates.Count > 0)
{
ConfirmationDialog dialog = new ConfirmationDialog("Confirm Overwrite", "WARNING! Are you sure you want to overwrite existing saved panel locations and all saved setttings for this profile?");
dialog.Owner = Application.Current.MainWindow;
dialog.Topmost = true;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if ((bool)dialog.ShowDialog())
{
_panelSelectionViewModel.StartPanelSelectionCommand.Execute(null);
}
}
else
{
_panelSelectionViewModel.StartPanelSelectionCommand.Execute(null);
}
}
private void SaveAutoPanningCamera_Click(object sender, RoutedEventArgs e)
{
if (_panelSelectionViewModel.DataStore.ActiveUserProfile.PanelSourceCoordinates.Count > 0)
{
ConfirmationDialog dialog = new ConfirmationDialog("Confirm Overwrite Auto Panning Camera", "WARNING! Are you sure you want to overwrite existing Auto Panning camera angle?");
dialog.Owner = Application.Current.MainWindow;
dialog.Topmost = true;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if ((bool)dialog.ShowDialog())
{
_panelSelectionViewModel.SaveAutoPanningCameraCommand.Execute(null);
}
}
}
private void AddBinding_Click(object sender, RoutedEventArgs e)
{
ConfirmationDialog dialog = new ConfirmationDialog("Confirm Add Binding", $"Are you sure you want to bind the selected profile to the following plane? \n{_panelSelectionViewModel.DataStore.CurrentMsfsPlaneTitle}");
dialog.Owner = Application.Current.MainWindow;
dialog.Topmost = true;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if ((bool)dialog.ShowDialog())
{
_panelSelectionViewModel.AddProfileBindingCommand.Execute(null);
}
}
private void DeleteBinding_Click(object sender, RoutedEventArgs e)
{
ConfirmationDialog dialog = new ConfirmationDialog("Confirm Delete Binding", $"Are you sure you want to delete the following binding for the selected profile? \n{_panelSelectionViewModel.DataStore.ActiveUserProfile.BindingPlaneTitle}");
dialog.Owner = Application.Current.MainWindow;
dialog.Topmost = true;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if ((bool)dialog.ShowDialog())
{
_panelSelectionViewModel.DeleteProfileBindingCommand.Execute(null);
}
}
}
}