private void PART_ComboBoxMedia_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((string)PART_ComboBoxMedia.SelectedItem == resources.GetString("LOCGameIconTitle"))
            {
                LmImageToolsSelected = LmImageToolsIcon;
            }
            if ((string)PART_ComboBoxMedia.SelectedItem == resources.GetString("LOCGameCoverImageTitle"))
            {
                LmImageToolsSelected = LmImageToolsCover;
            }
            if ((string)PART_ComboBoxMedia.SelectedItem == resources.GetString("LOCGameBackgroundTitle"))
            {
                LmImageToolsSelected = LmImageToolsBackground;
            }

            ImageProperty imageProperty = LmImageToolsSelected.GetOriginalImageProperty();

            PART_ImageOriginalSize.Content = imageProperty.Width + " x " + imageProperty.Height;

            PART_GridOriginalContener.Children.Clear();
            cropToolControl           = new CropToolControl();
            cropToolControl.Name      = "PART_ImageOriginal";
            cropToolControl.MaxWidth  = PART_GridOriginalContener.ActualWidth;
            cropToolControl.MaxHeight = PART_GridOriginalContener.ActualHeight;

            cropToolControl.SetImage(LmImageToolsSelected.GetOriginalBitmapImage());
            PART_GridOriginalContener.Children.Add(cropToolControl);

            cropToolControl.ShowText(false);

            if (LmImageToolsSelected.GetEditedBitmapImage() != null)
            {
                PART_ImageEditedSize.Content = LmImageToolsSelected.GetEditedBitmapImage().PixelWidth + " x " + LmImageToolsSelected.GetEditedBitmapImage().PixelHeight;
                PART_ImageEdited.Source      = LmImageToolsSelected.GetEditedBitmapImage();

                if ((string)PART_ComboBoxMedia.SelectedItem == resources.GetString("LOCGameIconTitle"))
                {
                    PART_BtSetIcon.IsEnabled = false;
                }
                else
                {
                    PART_BtSetIcon.IsEnabled = !((string)PART_ComboBoxMedia.SelectedItem).IsNullOrEmpty();
                }
            }
            else
            {
                PART_ImageEditedSize.Content = string.Empty;
                PART_ImageEdited.Source      = null;

                PART_BtSetIcon.IsEnabled = false;
            }


            // Reset crop area
            PART_CropWishedWidth.Text  = string.Empty;
            PART_CropWishedHeight.Text = string.Empty;
        }
        private void PART_BtSetIcon_Click(object sender, RoutedEventArgs e)
        {
            if (LmImageToolsIcon == null)
            {
                if ((string)PART_ComboBoxMedia.SelectedItem == resources.GetString("LOCGameCoverImageTitle"))
                {
                    LmImageToolsIcon = new LmImageTools(_PlayniteApi.Database.GetFullFilePath(_GameMenu.CoverImage));
                }
                if ((string)PART_ComboBoxMedia.SelectedItem == resources.GetString("LOCGameBackgroundTitle"))
                {
                    LmImageToolsIcon = new LmImageTools(_PlayniteApi.Database.GetFullFilePath(_GameMenu.BackgroundImage));
                }

                ((ObservableCollection <string>)PART_ComboBoxMedia.ItemsSource).Add(resources.GetString("LOCGameIconTitle"));
            }


            LmImageToolsIcon.SetImageEdited(LmImageToolsSelected.GetEditedImage());
            PART_BtReset_Click(null, null);
        }
        public LmImageEditor(IPlayniteAPI PlayniteApi, Game GameMenu)
        {
            _PlayniteApi = PlayniteApi;
            _GameMenu    = GameMenu;


            InitializeComponent();


            ObservableCollection <string> ListMedia = new ObservableCollection <string>();

            if (!_GameMenu.Icon.IsNullOrEmpty())
            {
                LmImageToolsIcon = new LmImageTools(_PlayniteApi.Database.GetFullFilePath(_GameMenu.Icon));
                ListMedia.Add(resources.GetString("LOCGameIconTitle"));
            }
            if (!_GameMenu.CoverImage.IsNullOrEmpty())
            {
                LmImageToolsCover = new LmImageTools(_PlayniteApi.Database.GetFullFilePath(_GameMenu.CoverImage));
                ListMedia.Add(resources.GetString("LOCGameCoverImageTitle"));
            }
            if (!_GameMenu.BackgroundImage.IsNullOrEmpty())
            {
                LmImageToolsBackground = new LmImageTools(_PlayniteApi.Database.GetFullFilePath(_GameMenu.BackgroundImage));
                ListMedia.Add(resources.GetString("LOCGameBackgroundTitle"));
            }


            PART_ComboBoxMedia.ItemsSource = ListMedia;

            cropSizes.Sort((x, y) => x.Name.CompareTo(y.Name));
            PART_ComboBoxCropSize.ItemsSource = cropSizes;

            fileSizes.Sort((x, y) => x.Name.CompareTo(y.Name));
            PART_ComboBoxFileSize.ItemsSource = fileSizes;
        }