Пример #1
0
        private void filePicker_Loaded(object sender, RoutedEventArgs e)
        {
            if (App.ProfileManager.Profile.UseExperimentalFileExplorer)
            {
                if (Visibility == Visibility.Collapsed)
                {
                    Visibility = Visibility.Visible;
                }
                RaiseDialogOpenedEvent();
            }
            else
            {
                Visibility = Visibility.Collapsed;
                if (CommonFileDialog.IsPlatformSupported)
                {
                    bool isFolder = (DataContext as FilePickerViewModel).IsFolderSelect;
                    var  dialog   = new CommonOpenFileDialog()
                    {
                        IsFolderPicker   = isFolder,
                        InitialDirectory = (DataContext as FilePickerViewModel).SelectedFolder?.Path,
                        Title            = Title
                    };

                    dialog.Filters.Clear();

                    foreach (var filter in (DataContext as FilePickerViewModel).Filters)
                    {
                        dialog.Filters.Add(new CommonFileDialogFilter(filter.Description, filter.ToString()));
                    }

                    if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                    {
                        ClassicEntry entry = new ClassicEntry(dialog.FileName, isFolder);
                        (DataContext as FilePickerViewModel).SelectedEntry = entry;

                        btn_ok.IsEnabled = true;
                        Select_Click(btn_ok, e);
                        if (DialogHost.CloseDialogCommand.CanExecute(null, btn_ok))
                        {
                            DialogHost.CloseDialogCommand.Execute(null, btn_ok);
                        }
                    }
                    else
                    {
                        btn_abort.IsEnabled = true;
                        Abort_Click(btn_abort, e);
                        if (DialogHost.CloseDialogCommand.CanExecute(null, btn_abort))
                        {
                            DialogHost.CloseDialogCommand.Execute(null, btn_abort);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("If you see this message, please post an issue on the GitHub repo!\nIn the meantime you can activate the experimental file explorer via the settings.");
                }
            }
        }
Пример #2
0
 protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
 {
     base.OnElementChanged(e);
     if (e.NewElement != null)
     {
         entry = e.NewElement as ClassicEntry;
     }
     Control.Background = CreateBackground();
     InitStyles();
 }