Пример #1
0
        private void OnCloseClick(object sender, RoutedEventArgs e)
        {
            FrameworkElement f = sender as FrameworkElement;

            if (f != null)
            {
                SourceFolder item = f.DataContext as SourceFolder;
                if (item != null)
                {
                    if (!item.IsNew())
                    {
                        sourceModel.RemoveItem(item);
                    }
                }
                else
                {
                    DriveItem drive = f.DataContext as DriveItem;
                    if (drive != null)
                    {
                        var removed  = Settings.Instance.Targets.RemoveTargetDrive(drive.RootDirectory);
                        var selected = (from i in removed where string.Compare(i, Settings.Instance.BackupPath, StringComparison.CurrentCultureIgnoreCase) == 0 select i).Any();
                        if (selected)
                        {
                            // pick a different backup folder then.
                            if (Settings.Instance.Targets.TargetPaths.Count > 0)
                            {
                                Settings.Instance.BackupPath = Settings.Instance.Targets.TargetPaths[0];
                            }
                            else
                            {
                                Settings.Instance.BackupPath = null;
                            }
                        }
                        UpdateDriveSelection();
                        UpdateFolderSelection();
                    }
                }
            }
        }