Exemplo n.º 1
0
        /// <summary>
        /// Remove selected filetypes from collection of available types.
        /// </summary>
        void NewPresetRemoveTypes(object selectedItems)
        {
            IList selectedItemList = (IList)selectedItems;
            var   selectedTypes    = selectedItemList.Cast <string>();

            GUIDispatcherUpdates.RemoveItemsFromCollection(_newPresetFileTypes, selectedTypes.ToList());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Ascertain(recursively) root directory's subdirectory structure, updating
        /// appropriate collections where needed.
        /// </summary>
        void UpdateDirectoryStructure()
        {
            if (_subdirCheckboxChecked)
            {
                if (_previousDirectory != _currentDirectory ||
                    _fgOrganiser.AvailableFileTypes.Count == 0)
                {
                    // Show the wait grid while updating structure.
                    WaitGridZIndex      = "Visible";
                    WaitGridText        = "Loading directories";
                    WaitImageVisibility = "Visible";

                    // Add delegate to threadpool
                    ThreadPool.QueueUserWorkItem(
                        delegate
                    {
                        GUIDispatcherUpdates.ClearCollection(_fgOrganiser.RootDirectory.Subdirectories);
                        OrganiserBase.TraverseDirectories(_fgOrganiser.RootDirectory, _fgOrganiser.AvailableFileTypes);
                        _fgOrganiser.SelectedFileTypes.AddRange(_fgOrganiser.AvailableFileTypes);

                        // Hide waitgrid when finished updating.
                        WaitGridZIndex = "Hidden";
                    });
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method for saving a new preset.
        /// </summary>
        void SaveNewPreset()
        {
            if (!String.IsNullOrEmpty(_newPresetName) &&
                !String.IsNullOrWhiteSpace(_newPresetName))
            {
                if (_newPresetFileTypes.Count > 0)
                {
                    if (!_presets.PresetExists(_newPresetName))
                    {
                        _presets.AddPreset(_newPresetName, GUIDispatcherUpdates.CollectionAsList(_newPresetFileTypes));

                        NewPresetName = String.Empty;

                        _newPresetFileTypes = null;
                        OnPropertyChanged("NewPresetFileTypes");

                        OnPropertyChanged("PresetNames");
                    }
                    else
                    {
                        NewPresetErrorText = "Preset filter name currently exists.";
                    }
                }
                else
                {
                    NewPresetErrorText = "Filetypes must exist.";
                }
            }
            else
            {
                NewPresetErrorText = "Preset filter name can't be empty or whitespace.";
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Callback for running organisation thread.
        /// </summary>
        void DoWork()
        {
            _canWork = true;

            //Run as long as user does not change _canWork value.
            while (_canWork)
            {
                //If the user has chosen to include sub-directories in
                //the organisation. retrieve all directories contained
                //in the root directory and pass to the MoveFiles instance.
                //Otherwise, just add the root directory to the directory list.
                if (base._organiseSubDirectories)
                {
                    OrganiserBase.TraverseDirectories(RootDirectory);
                }

                base.Organise();
                GUIDispatcherUpdates.ClearCollection(RootDirectory.Subdirectories);

                if (_canWork)
                {
                    _sleeping = true;
                    Thread.Sleep(60000);
                    _sleeping = false;
                }
                else
                {
                    base._organisationThread.Abort();
                }
            }


            base._isWorking = false;
        }
Exemplo n.º 5
0
        public DirectoryModel CreateAndAddSubdirectory(string path)
        {
            DirectoryModel subdirectory = new DirectoryModel();

            subdirectory.Path = path;
            GUIDispatcherUpdates.AddItemToCollection(Subdirectories, subdirectory);

            return(subdirectory);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Add type to list of filetypes for currently selected
 /// preset types.
 /// </summary>
 void NewPresetAddType()
 {
     if ((!String.IsNullOrEmpty(_newPresetType) || !String.IsNullOrWhiteSpace(_newPresetType)) &&
         !GUIDispatcherUpdates.CollectionContainsItem(_newPresetFileTypes, _newPresetType))
     {
         GUIDispatcherUpdates.AddItemToCollection(_newPresetFileTypes, _newPresetType);
         NewPresetType = String.Empty;
     }
     else
     {
         NewPresetErrorText = "Filetype can't be empty or whitespace.";
     }
 }
Exemplo n.º 7
0
        public static void PopulateFileTypes(string[] files, ObservableCollection <string> availableFileTypes)
        {
            if (files.Count() > 0)
            {
                foreach (string file in files)
                {
                    // If current file has a filetype, add to list of available filetypes
                    // otherwise add the abstract "FILE" filetype to represent any files
                    // without filetypes.

                    string fileType = System.IO.Path.GetExtension(file).Length > 0 ? System.IO.Path.GetExtension(file).Substring(1) : "FILE";

                    if (!availableFileTypes.Contains(fileType))
                    {
                        GUIDispatcherUpdates.AddItemToCollection(availableFileTypes, fileType);
                    }
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Add type to list of filetypes for currently selected
 /// preset types.
 /// </summary>
 void PresetEditAddType()
 {
     if ((!String.IsNullOrEmpty(_presetEditType) || !String.IsNullOrWhiteSpace(_presetEditType)))
     {
         if (!GUIDispatcherUpdates.CollectionContainsItem(_presetEditFileTypes, _presetEditType))
         {
             GUIDispatcherUpdates.AddItemToCollection(_presetEditFileTypes, _presetEditType);
             PresetEditType = String.Empty;
         }
         else
         {
             EditPresetErrorText = "Filetype already exists.";
         }
     }
     else
     {
         EditPresetErrorText = "Filetype can't be empty or whitespace.";
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Method to set EditPrest grid to be hidden.
        /// </summary>
        void SavePresetEdits()
        {
            if (!String.IsNullOrEmpty(_presetEditTempName) &&
                !String.IsNullOrWhiteSpace(_presetEditTempName))
            {
                if (_presetEditFileTypes.Count > 0)
                {
                    if (_selectedPreset == _presetEditTempName ||
                        (!(_selectedPreset == _presetEditTempName) && !_presets.PresetExists(_presetEditTempName)))
                    {
                        // Save changes into presets object.
                        _presets.EditPresets(_selectedPreset,
                                             _presetEditTempName,
                                             GUIDispatcherUpdates.CollectionAsList(_presetEditFileTypes));

                        // Update collection for ListBox that shows preset names
                        GUIDispatcherUpdates.UpdateCollectionItem(_presetNames, _selectedPreset, PresetEditTempName);

                        OnPropertyChanged("PresetNames");

                        SelectedPreset = _presetEditTempName;
                    }
                    else
                    {
                        EditPresetErrorText = "Preset filter name currently exists.";
                    }
                }
                else
                {
                    EditPresetErrorText = "Filetypes must exist for preset to be saved.";
                }
            }
            else
            {
                EditPresetErrorText = "Filetype can't be empty or whitespace.";
            }
        }
Exemplo n.º 10
0
 public void ClearLists()
 {
     // Clear fileType lists to be ready for next organisation.
     _selectedFileTypes.Clear();
     GUIDispatcherUpdates.ClearCollection(_availableFileTypes);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Update GUI to show filetypes for newly selected
 /// preset.
 /// </summary>
 private void UpdateFileTypes()
 {
     GUIDispatcherUpdates.ClearCollection(_presetEditFileTypes);
     GUIDispatcherUpdates.AddItemsToCollection(_presetEditFileTypes, _presets.GetPresetTypes(_selectedPreset));
 }