<commit_before>﻿using Azi.Tools;
using Microsoft.WindowsAPICodePack.Dialogs;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Azi.ACDDokanNet.Gui
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ViewModel Model => (ViewModel)DataContext;
        public MainWindow()
        {
            InitializeComponent();
        }

        private async void mountButton_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new MountWaitBox(this);
            var cs = new System.Threading.CancellationTokenSource();
            dlg.Cancellation = cs;
            dlg.Show();
            await Model.Mount(cs.Token);
            dlg.Close();
            Activate();
        }

        private async void unmountButton_Click(object sender, RoutedEventArgs e)
        {
            await Model.Unmount();
        }

        private void ChangeCacheDir(object sender, RoutedEventArgs e)
        {
            var path = Environment.ExpandEnvironmentVariables(Model.CacheFolder);
            using (var dlg = new CommonOpenFileDialog
            {
                Title = "Select Cache Folder",
                IsFolderPicker = true,
                InitialDirectory = path,

                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems = false,
                DefaultDirectory = path,
                EnsureFileExists = true,
                EnsurePathExists = true,
                EnsureReadOnly = false,
                EnsureValidNames = true,
                Multiselect = false,
                ShowPlacesList = true
            })
            {
                if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    Model.CacheFolder = dlg.FileName;
                }
            }
        }

        private async void logoutButton_Click(object sender, RoutedEventArgs e)
        {
            await Model.Unmount();
            App.Current.ClearCredentials();
        }

        private void ClearSmallFilesCache(object sender, RoutedEventArgs e)
        {
            try
            {
                App.Current.ClearCache();
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = true;
            Hide();
        }

        private void exportLog_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(Properties.Resources.LogWarning);

            Log.Info("Version " + Model.Version);
            using (var dlg = new CommonOpenFileDialog
            {
                Title = "Export Log",
                DefaultExtension=".evtx",
                DefaultFileName="ACDDokanNetLog.evtx",
                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems = false,
                EnsureValidNames = true,
                Multiselect = false,
                ShowPlacesList = true
            })
            {
                if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    Log.Export(dlg.FileName);
                }
            }
        }

        private void openIssue_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("https://github.com/Rambalac/AmazonCloudDriveApi/issues/new");
        }
    }<commit_msg>Fixed Save dialog for log export<commit_after>﻿using Azi.Tools;
using Microsoft.WindowsAPICodePack.Dialogs;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Azi.ACDDokanNet.Gui
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ViewModel Model => (ViewModel)DataContext;
        public MainWindow()
        {
            InitializeComponent();
        }

        private async void mountButton_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new MountWaitBox(this);
            var cs = new System.Threading.CancellationTokenSource();
            dlg.Cancellation = cs;
            dlg.Show();
            await Model.Mount(cs.Token);
            dlg.Close();
            Activate();
        }

        private async void unmountButton_Click(object sender, RoutedEventArgs e)
        {
            await Model.Unmount();
        }

        private void ChangeCacheDir(object sender, RoutedEventArgs e)
        {
            var path = Environment.ExpandEnvironmentVariables(Model.CacheFolder);
            using (var dlg = new CommonOpenFileDialog
            {
                Title = "Select Cache Folder",
                IsFolderPicker = true,
                InitialDirectory = path,

                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems = false,
                DefaultDirectory = path,
                EnsureFileExists = true,
                EnsurePathExists = true,
                EnsureReadOnly = false,
                EnsureValidNames = true,
                Multiselect = false,
                ShowPlacesList = true
            })
            {
                if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    Model.CacheFolder = dlg.FileName;
                }
            }
        }

        private async void logoutButton_Click(object sender, RoutedEventArgs e)
        {
            await Model.Unmount();
            App.Current.ClearCredentials();
        }

        private void ClearSmallFilesCache(object sender, RoutedEventArgs e)
        {
            try
            {
                App.Current.ClearCache();
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = true;
            Hide();
        }

        private void exportLog_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(Properties.Resources.LogWarning);

            Log.Info("Version " + Model.Version);
            using (var dlg = new CommonSaveFileDialog
            {
                Title = "Export Log",
                DefaultExtension=".evtx",
                DefaultFileName="ACDDokanNetLog.evtx",
                AddToMostRecentlyUsedList = false,
                EnsureValidNames = true,
                ShowPlacesList = true,
                RestoreDirectory=true,
            })
            {
                if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    Log.Export(dlg.FileName);
                }
            }
        }

        private void openIssue_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("https://github.com/Rambalac/AmazonCloudDriveApi/issues/new");
        }
    }
{'fraction_non_alphanumeric': 0.08069722401549387, 'fraction_numerical': 0.0, 'mean_word_length': 1.5984568936598458, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '2996450', 'n_tokens_mistral': 1968, 'n_tokens_neox': 1895, 'n_words': 404}