Exemplo n.º 1
0
        internal SourceFolder GetOrCreateItem(string path)
        {
            SourceFolder item = (from i in Items where string.Compare(i.Path, path, StringComparison.OrdinalIgnoreCase) == 0 select i).FirstOrDefault();

            if (item == null)
            {
                item = new SourceFolder()
                {
                    Path = path
                };
                this.items.Add(item);
            }
            return(item);
        }
Exemplo n.º 2
0
        private void OnLabelTextBoxFocussed(object sender, EventArgs e)
        {
            EditableTextBlock edit = sender as EditableTextBlock;

            if (edit != null)
            {
                if (edit.Label == SourceFolder.NewPath)
                {
                    Ookii.Dialogs.Wpf.VistaFolderBrowserDialog fd = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
                    if (fd.ShowDialog() == true)
                    {
                        SourceFolder item = edit.DataContext as SourceFolder;
                        item.Path = fd.SelectedPath;
                        sourceModel.EnsureNewItem();
                    }
                }
            }
        }
Exemplo n.º 3
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();
                    }
                }
            }
        }
Exemplo n.º 4
0
 internal void RemoveItem(SourceFolder item)
 {
     this.items.Remove(item);
 }