2024-02-28 02:44:21 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using MSFSPopoutPanelManager.DomainModel.Profile;
|
|
|
|
|
using MSFSPopoutPanelManager.MainApp.ViewModel;
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls.Primitives;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace MSFSPopoutPanelManager.MainApp.AppUserControl
|
|
|
|
|
{
|
|
|
|
|
public partial class ProfileCard
|
|
|
|
|
{
|
|
|
|
|
private readonly ProfileCardViewModel _viewModel;
|
|
|
|
|
|
|
|
|
|
public ProfileCard()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_viewModel = App.AppHost.Services.GetRequiredService<ProfileCardViewModel>();
|
|
|
|
|
Loaded += (_, _) => { DataContext = _viewModel; };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleButtonEditProfileTitle_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is ToggleButton { IsChecked: not null } toggleButton && (bool)toggleButton.IsChecked)
|
|
|
|
|
{
|
|
|
|
|
TxtBoxProfileTitle.Dispatcher.BeginInvoke(new Action(() => TxtBoxProfileTitle.Focus()));
|
|
|
|
|
TxtBoxProfileTitle.Dispatcher.BeginInvoke(new Action(() => TxtBoxProfileTitle.SelectAll()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TxtBoxProfileTitle_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Key != Key.Enter)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ToggleButtonEditProfileTitle.IsChecked = false;
|
|
|
|
|
Keyboard.ClearFocus();
|
|
|
|
|
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(RootCard), RootCard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void IncludeInGamePanel_TargetUpdated(object sender, DataTransferEventArgs e)
|
|
|
|
|
{
|
2024-09-17 14:42:07 +00:00
|
|
|
|
_viewModel.IncludeInGamePanelUpdatedCommand?.Execute(null);
|
2024-02-28 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddHudBar_TargetUpdated(object sender, DataTransferEventArgs e)
|
|
|
|
|
{
|
2024-09-17 14:42:07 +00:00
|
|
|
|
_viewModel.AddHudBarUpdatedCommand?.Execute(null);
|
2024-02-28 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddRefocusDisplay_TargetUpdated(object sender, DataTransferEventArgs e)
|
|
|
|
|
{
|
2024-09-17 14:42:07 +00:00
|
|
|
|
_viewModel.RefocusDisplayUpdatedCommand?.Execute(null);
|
2024-02-28 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddNumPad_TargetUpdated(object sender, DataTransferEventArgs e)
|
|
|
|
|
{
|
2024-09-17 14:42:07 +00:00
|
|
|
|
_viewModel.AddNumPadUpdatedCommand?.Execute(null);
|
|
|
|
|
}
|
2024-02-28 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ValueConversion(typeof(DateTime), typeof(String))]
|
|
|
|
|
public class StringToHudBarTypeConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return value?.ToString()?.Replace("_", " ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
var data = value.ToString();
|
|
|
|
|
return Enum.Parse<HudBarType>(data.Replace(" ", "_"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|