Beispiel #1
0
        private static void OnFolderPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            FolderPicker s        = (FolderPicker)sender;
            Folder       oldValue = (Folder)e.OldValue;
            Folder       newValue = (Folder)e.NewValue;

            if (oldValue != null)
            {
                oldValue.PropertyChanged -= s.Folder_PropertyChanged;
            }
            if (newValue != null)
            {
                newValue.PropertyChanged += s.Folder_PropertyChanged;
            }

            if (newValue != null)
            {
                s.UpdateCbxSubfolder();

                s.tbxPath.Text       = newValue.OriginalPath;
                s.tbxPath.Foreground = newValue.Exists ? s.tbxPathForeground : errorBrush;

                switch (s.AutoRefreshSelection)
                {
                case AutoRefreshSelectionType.Visible:
                    s.cbxAutoRefresh.IsChecked = newValue.AutoRefresh;
                    break;

                case AutoRefreshSelectionType.Collapsed:
                    s.cbxAutoRefresh.IsChecked = newValue.AutoRefresh;
                    break;

                case AutoRefreshSelectionType.ForceTrue:
                    newValue.AutoRefresh = true;
                    break;

                case AutoRefreshSelectionType.ForceFalse:
                    newValue.AutoRefresh = false;
                    break;
                }
            }
            else
            {
                (bool isVisible, bool?isChecked) = GetCbxSubfolderProperties(s.SubTypeSelection, oldValue.SubType);

                s.cbxSubfolder.Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
                s.cbxSubfolder.IsChecked  = isChecked;
                s.tbxPath.Foreground      = errorBrush;
                s.tbxPath.Text            = string.Empty;
            }

            FolderChangedArgs args = new FolderChangedArgs(oldValue, newValue);

            s.FolderChanged?.Invoke(s, args);
        }
Beispiel #2
0
        private static void OnSubTypeSelectionPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            FolderPicker           s        = (FolderPicker)sender;
            SubfolderSelectionType oldValue = (SubfolderSelectionType)e.OldValue;
            SubfolderSelectionType newValue = (SubfolderSelectionType)e.NewValue;

            if (s.Folder != null)
            {
                s.UpdateCbxSubfolder();
            }
            else
            {
                SubfolderType subType = GetSubfolderType(oldValue, s.cbxSubfolder.IsChecked);
                (bool isVisible, bool?isChecked) = GetCbxSubfolderProperties(newValue, subType);

                s.cbxSubfolder.Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
                s.cbxSubfolder.IsChecked  = isChecked;
            }
        }