Ejemplo n.º 1
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!Wizard.DrivesLoaded)
            {
                Wizard.DiskDrives = new ObservableCollection <LviDrive>();

                var winDir = Environment.GetFolderPath(Environment.SpecialFolder.System);

                DrivesCollection.AddRange(DriveInfo.GetDrives()
                                          .Where(driveInfo => driveInfo.IsReady && driveInfo.DriveType == DriveType.Fixed)
                                          .Select(
                                              driveInfo =>
                                              new LviDrive(winDir.Contains(driveInfo.Name), driveInfo.Name, driveInfo.DriveFormat,
                                                           Utils.ConvertSizeToString(driveInfo.TotalSize),
                                                           Utils.ConvertSizeToString(driveInfo.TotalFreeSpace), driveInfo)));

                if (Settings.Default.diskCleanerIncludedFolders == null)
                {
                    Settings.Default.diskCleanerIncludedFolders = new StringCollection
                    {
                        Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.User),
                        Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.Machine),
                        Environment.GetFolderPath(Environment.SpecialFolder.Recent),
                        Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
                    };
                }
            }

            OnPropertyChanged(nameof(DrivesCollection));

            // Excluded Dirs
            ExcFoldersCollection.AddRange(
                Settings.Default.diskCleanerExcludedDirs.Cast <string>()
                .Select(excludeDir => new LviFolder {
                Folder = excludeDir
            }));
            //this.listViewExcludeFolders.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            // Excluded Files
            ExcFilesCollection.AddRange(
                Settings.Default.diskCleanerExcludedFileTypes.Cast <string>()
                .Select(excludeFile => new LviFile {
                File = excludeFile
            }));
            //this.listViewFiles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            // Included Folders
            IncFoldersCollection.AddRange(
                Settings.Default.diskCleanerIncludedFolders.Cast <string>()
                .Select(includedFolder => new LviFolder {
                Folder = includedFolder
            }));
            //this.listViewIncFolders.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Ejemplo n.º 2
0
        private void buttonRemIncFolder_Click(object sender, RoutedEventArgs e)
        {
            if (ListViewIncFolders.SelectedItems.Count == 0)
            {
                MessageBox.Show(Application.Current.MainWindow, "No folder was selected", Utils.ProductName,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            if (
                MessageBox.Show(Application.Current.MainWindow, "Are you sure?", Utils.ProductName,
                                MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                IncFoldersCollection.Remove(ListViewIncFolders.SelectedItems[0] as LviFolder);
            }
        }
Ejemplo n.º 3
0
        private void UpdateOptions()
        {
            // Included Folders
            Settings.Default.diskCleanerIncludedFolders.Clear();
            Settings.Default.diskCleanerIncludedFolders.AddRange(
                IncFoldersCollection.Select(lvi => lvi.Folder).ToArray());

            // Excluded Folders
            Settings.Default.diskCleanerExcludedDirs.Clear();
            Settings.Default.diskCleanerExcludedDirs.AddRange(
                ExcFoldersCollection.Select(lvi => lvi.Folder).ToArray());

            // Excluded Files
            Settings.Default.diskCleanerExcludedFileTypes.Clear();
            Settings.Default.diskCleanerExcludedFileTypes.AddRange(
                ExcFilesCollection.Select(lvi => lvi.File).ToArray());
        }
Ejemplo n.º 4
0
 private void addIncFolder_AddIncFolder(object sender, AddIncFolderEventArgs e)
 {
     IncFoldersCollection.Add(new LviFolder {
         Folder = e.FolderPath
     });
 }