using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Threading;
using Telerik.Windows.Controls;

namespace FileDialogsTest
{
    
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            var culture = new CultureInfo("de");

            System.Globalization.DateTimeFormatInfo dateTimeInfo =
new System.Globalization.DateTimeFormatInfo();
            dateTimeInfo.ShortDatePattern = "dd--MMM--yy";
            culture.DateTimeFormat = dateTimeInfo;
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            RadSaveFileDialog saveFileDialog = new RadSaveFileDialog();
            saveFileDialog.InitialDirectory = @"D:\test";
            saveFileDialog.FileName = "test.png";
            saveFileDialog.InitialSelectedLayout = Telerik.Windows.Controls.FileDialogs.LayoutType.Details;
            saveFileDialog.Owner = this;
            saveFileDialog.Loaded += SaveFileDialog_Loaded;
            var result = saveFileDialog.ShowDialog();
            if (result.HasValue && result.Value)
            {
                Debug.WriteLine(saveFileDialog.FileName);
            }
        }

        private void SaveFileDialog_Loaded(object sender, RoutedEventArgs e)
        {
            var dialog = sender as RadSaveFileDialog;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                var gridView = dialog.ChildrenOfType<RadGridView>().FirstOrDefault();
                if(gridView != null)
                {
                    gridView.IsLocalizationLanguageRespected = false;
                }
            }), DispatcherPriority.Loaded);
        }
    }
}
