<commit_before>﻿using ArcGISRuntime.Samples.Shared.Managers;
using ArcGISRuntime.Samples.Shared.Models;
using System.Windows;
using System.Windows.Controls;

namespace ArcGISRuntime
{
    public partial class ScreenshotTab : UserControl
    {
        public ScreenshotTab()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            ScreenshotEnabledCheckBox.IsChecked = ScreenshotManager.ScreenshotSettings.ScreenshotEnabled;
            SourcePathText.Text = ScreenshotManager.ScreenshotSettings.SourcePath;
            WidthEntryBox.Text = ScreenshotManager.ScreenshotSettings.Width.HasValue ? ScreenshotManager.ScreenshotSettings.Width.ToString() : null;
            HeightEntryBox.Text = ScreenshotManager.ScreenshotSettings.Height.HasValue ? ScreenshotManager.ScreenshotSettings.Height.ToString() : null;

            ScreenshotEnabledCheckBox.Checked += SaveData_Event;
            ScreenshotEnabledCheckBox.Unchecked += SaveData_Event;
            SourcePathText.TextChanged += SaveData_Event;
            WidthEntryBox.TextChanged += SaveData_Event;
            HeightEntryBox.TextChanged += SaveData_Event;
        }

        private void SaveData_Event(object sender, RoutedEventArgs e)
        {
            ScreenshotSettings screenshotSettings = new ScreenshotSettings();
            screenshotSettings.ScreenshotEnabled = ScreenshotEnabledCheckBox.IsChecked.HasValue ? ScreenshotEnabledCheckBox.IsChecked.Value : false;
            screenshotSettings.SourcePath = SourcePathText.Text;

            if (int.TryParse(WidthEntryBox.Text, out int width))
            {
                screenshotSettings.Width = width;
            }
            else
            {
                screenshotSettings.Height = null;
            }

            if (int.TryParse(HeightEntryBox.Text, out int height))
            {
                screenshotSettings.Height = height;
            }
            else
            {
                screenshotSettings.Height = null;
            }

            ScreenshotManager.SaveScreenshotSettings(screenshotSettings);
        }
    }
}
<commit_msg>WinUI Screenshot Settings - Scale Factor data persistence fix (#1035)<commit_after>﻿using ArcGISRuntime.Samples.Shared.Managers;
using ArcGISRuntime.Samples.Shared.Models;
using System.Windows;
using System.Windows.Controls;

namespace ArcGISRuntime
{
    public partial class ScreenshotTab : UserControl
    {
        public ScreenshotTab()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            ScreenshotEnabledCheckBox.IsChecked = ScreenshotManager.ScreenshotSettings.ScreenshotEnabled;
            SourcePathText.Text = ScreenshotManager.ScreenshotSettings.SourcePath;
            WidthEntryBox.Text = ScreenshotManager.ScreenshotSettings.Width.HasValue ? ScreenshotManager.ScreenshotSettings.Width.ToString() : null;
            HeightEntryBox.Text = ScreenshotManager.ScreenshotSettings.Height.HasValue ? ScreenshotManager.ScreenshotSettings.Height.ToString() : null;

            ScreenshotEnabledCheckBox.Checked += SaveData_Event;
            ScreenshotEnabledCheckBox.Unchecked += SaveData_Event;
            SourcePathText.TextChanged += SaveData_Event;
            WidthEntryBox.TextChanged += SaveData_Event;
            HeightEntryBox.TextChanged += SaveData_Event;
        }

        private void SaveData_Event(object sender, RoutedEventArgs e)
        {
            ScreenshotSettings screenshotSettings = new ScreenshotSettings();

            // Do not overwrite the saved WinUI setting. 
            if (ScreenshotManager.ScreenshotSettings.ScaleFactor.HasValue)
            {
                screenshotSettings.ScaleFactor = ScreenshotManager.ScreenshotSettings.ScaleFactor.Value;
            }

            screenshotSettings.ScreenshotEnabled = ScreenshotEnabledCheckBox.IsChecked.HasValue ? ScreenshotEnabledCheckBox.IsChecked.Value : false;
            screenshotSettings.SourcePath = SourcePathText.Text;

            if (int.TryParse(WidthEntryBox.Text, out int width))
            {
                screenshotSettings.Width = width;
            }
            else
            {
                screenshotSettings.Height = null;
            }

            if (int.TryParse(HeightEntryBox.Text, out int height))
            {
                screenshotSettings.Height = height;
            }
            else
            {
                screenshotSettings.Height = null;
            }

            ScreenshotManager.SaveScreenshotSettings(screenshotSettings);
        }
    }
}

{'fraction_non_alphanumeric': 0.06958762886597938, 'fraction_numerical': 0.000859106529209622, 'mean_word_length': 2.314590747330961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736156', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1155, 'n_words': 181}