示例#1
0
        public MainViewModel()
        {
            var configuration = Configuration.GetConfiguration("defaultconfig.json");

            Config.CollectionTarget       = configuration.CollectionConnectionString;
            Config.DeletedTarget          = configuration.DeletedConnectionString;
            collectionHistory             = new CollectionHistory();
            deletedHisotry                = new DeleteHisotry();
            deletedHisotry.DeletedHistory = new List <string>();
            MyFiles.Clear();
            history = new DirectoryHistory(FilePath);
            foreach (var logicalDrive in Directory.GetLogicalDrives())
            {
                DirectoriesAndFiles.Add(new DirectoryViewModel(logicalDrive));
            }

            history.HistoryChanged += History_HistoryChanged;

            CompressCollectionCommand = new DelegateCommand(CompressCollection);
            OpenCommand            = new DelegateCommand(Open);
            CompressCommand        = new DelegateCommand(Compress);
            DecompressCommand      = new DelegateCommand(Decompress);
            DeleteFileCommand      = new DelegateCommand(DeleteFile);
            AddToCollectionCommand = new DelegateCommand(AddToCollection);
            MoveBackCommand        = new DelegateCommand(MoveBack, CanMoveBack);
            MoveForwardCommand     = new DelegateCommand(MoveForward, CanMoveForward);
            MoveForwardCommand     = new DelegateCommand(MoveForward, CanMoveForward);
        }
示例#2
0
        private void OpenDirectory()
        {
            DirectoriesAndFiles.Clear();

            if (Name == "Мой компьютер")
            {
                foreach (var logicalDrive in Directory.GetLogicalDrives())
                {
                    DirectoriesAndFiles.Add(new DirectoryViewModel(logicalDrive));
                }

                return;
            }

            var directoryInfo = new DirectoryInfo(FilePath);

            foreach (var directory in directoryInfo.GetDirectories())
            {
                DirectoriesAndFiles.Add(new DirectoryViewModel(directory));
            }

            foreach (var fileInfo in directoryInfo.GetFiles())
            {
                DirectoriesAndFiles.Add(new FileViewModel(fileInfo));
            }
        }
        private void OpenDirectory()
        {
            DirectoriesAndFiles.Clear();

            if (Name == "My computer")
            {
                foreach (var drive in Directory.GetLogicalDrives())
                {
                    DirectoriesAndFiles.Add(new DirectoryViewModel(drive));
                }
            }
            else
            {
                var directoryInfo = new DirectoryInfo(FilePath);

                foreach (var directory in directoryInfo.GetDirectories())
                {
                    DirectoriesAndFiles.Add(new DirectoryViewModel(directory));
                }

                foreach (var file in directoryInfo.GetFiles())
                {
                    DirectoriesAndFiles.Add(new FileViewModel(file));
                }
            }
        }
示例#4
0
 public MainViewModel()
 {
     OpenCommand = new DelegateCommand(Open);
     foreach (var logicalDrive in Directory.GetLogicalDrives())
     {
         DirectoriesAndFiles.Add(new DirectoryViewModel(logicalDrive));
     }
 }
        public DirectoryTabItemViewModel()
        {
            _history = new DirectoryHistory("My computer", "My computer");

            Name     = _history.Current.DirectoryName;
            FilePath = _history.Current.DirectoryPath;

            Open        = new DelegateCommand(OnOpen);
            MoveBack    = new DelegateCommand(OnMoveBack, OnCanMoveBack);
            MoveForward = new DelegateCommand(OnMoveForward, OnCanMoveForward);

            foreach (var drive in Environment.GetLogicalDrives())
            {
                DirectoriesAndFiles.Add(new DirectoryViewModel(drive));
            }
        }
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var directoryInfo = e.Argument as DirectoryInfo;

            var bw = sender as BackgroundWorker;

            try
            {
                var directories = directoryInfo.EnumerateDirectories();

                //var allCount = directories.Count();

                foreach (var directory in directories)
                {
                    if (bw.CancellationPending)
                    {
                        e.Cancel = true;

                        return;
                    }

                    _synchronizationHelper.InvokeAsync(() =>
                    {
                        DirectoriesAndFiles.Add(new DirectoryViewModel(directory));
                    }).Wait();
                }

                foreach (var fileInfo in directoryInfo.GetFiles())
                {
                    if (bw.CancellationPending)
                    {
                        e.Cancel = true;

                        return;
                    }

                    _synchronizationHelper.InvokeAsync(() => { DirectoriesAndFiles.Add(new FileViewModel(fileInfo)); })
                    .Wait();
                }
            }
            catch (Exception ex)
            {
                //TODO: Try Exception
            }
        }
        private void RunWorker()
        {
            DirectoriesAndFiles.Clear();

            if (Name == "Мой компьютер")
            {
                foreach (var logicalDrive in Directory.GetLogicalDrives())
                {
                    DirectoriesAndFiles.Add(new DirectoryViewModel(logicalDrive));
                }

                return;
            }

            var directoryInfo = new DirectoryInfo(FilePath);

            _backgroundWorker.RunWorkerAsync(directoryInfo);
        }
示例#8
0
        private void Open(object parameter)
        {
            if (parameter is DirectoryViewModel dirViewModel)
            {
                FilePath = dirViewModel.FullName;
                DirectoriesAndFiles.Clear();

                var dirInfo = new DirectoryInfo(FilePath);
                foreach (var dir in dirInfo.GetDirectories())
                {
                    DirectoriesAndFiles.Add(new DirectoryViewModel(dir));
                }
                foreach (var fileInfo in dirInfo.GetFiles())
                {
                    DirectoriesAndFiles.Add(new FileViewModel(fileInfo));
                }
            }
        }
示例#9
0
        private void OpenDirectory()
        {
            DirectoriesAndFiles.Clear();
            var directoryInfo = new DirectoryInfo(FilePath);

            foreach (var directory in directoryInfo.GetDirectories())
            {
                if (!directory.Attributes.HasFlag(FileAttributes.Hidden))
                {
                    DirectoriesAndFiles.Add(new DirectoryViewModel(directory));
                }
            }

            foreach (var fileInfo in directoryInfo.GetFiles())
            {
                DirectoriesAndFiles.Add(new FileViewModel(fileInfo));
            }
        }