示例#1
0
        /// <summary>
        /// Save selected filetypes as preset filter.
        /// </summary>
        void SavePreset()
        {
            if (!(String.IsNullOrWhiteSpace(_savePresetText) ||
                  String.IsNullOrEmpty(_savePresetText)))
            {
                if (_presets.PresetExists(_savePresetText))
                {
                    MessageBox.Show("Preset already exists.");
                }
                else
                {
                    try
                    {
                        _presets.AddPreset(_savePresetText, _fgOrganiser.SelectedFileTypes);
                    }
                    catch (ArgumentException AEx)
                    {
                        _logger.LogError(AEx.Message + "\n" + AEx.StackTrace);
                    }

                    SavePresetText = String.Empty;
                    OnPropertyChanged("PresetNames");
                }
            }
        }
示例#2
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.";
            }
        }
示例#3
0
        public void PresetTypeExistsTest()
        {
            PresetFilters target     = new PresetFilters();
            string        presetName = "AreYouMockingMe";
            List <string> types      = new List <string>()
            {
                "Yes"
            };

            target.AddPreset(presetName, types);

            Assert.IsTrue(target.PresetTypeExists(presetName, "Yes"), "Added type does not appear to exist");
        }
示例#4
0
        public void PresetExistsTest()
        {
            PresetFilters target     = new PresetFilters();
            string        presetName = "MockedYouOut";
            List <string> types      = new List <string>()
            {
                "Mocking"
            };

            target.AddPreset(presetName, types);

            Assert.IsTrue(target.PresetExists(presetName), "Added preset does not appear to exist");
        }
示例#5
0
        public void AddPresetTest()
        {
            bool condition = false;

            PresetFilters target     = new PresetFilters();
            string        presetName = null;
            List <string> types      = null;

            try
            {
                target.AddPreset(presetName, types);
            }
            catch (ArgumentException AEx)
            {
                condition = true;
            }

            Assert.IsTrue(condition);

            condition = true;

            presetName = "MockPreset";
            types      = new List <string>()
            {
                "mp3"
            };

            try
            {
                target.AddPreset(presetName, types);
            }
            catch (ArgumentException AEx)
            {
                condition = false;
            }

            Assert.IsTrue(condition);
        }
示例#6
0
        public void RemovePresetTypeTest()
        {
            PresetFilters target     = new PresetFilters();
            string        presetName = "MockingBird";
            List <string> types      = new List <string>()
            {
                "MockING"
            };

            target.AddPreset(presetName, types);
            target.RemovePresetType(presetName, "MockING");

            Assert.IsFalse(target.PresetTypeExists(presetName, "MockING"), "Added type does not appear to exist");
        }
示例#7
0
        public void GetPresetTypesTest()
        {
            PresetFilters target     = new PresetFilters();
            string        presetName = "MockedOut";
            List <string> types      = new List <string>()
            {
                "Mocking"
            };

            target.AddPreset(presetName, types);

            List <string> returnTypes = target.GetPresetTypes(presetName);

            Assert.IsTrue(returnTypes.Contains("Mocking"), "Added type has not been found");
        }
示例#8
0
        public void EditPresetsTest()
        {
            PresetFilters target = new PresetFilters();

            string        presetName = "MockedUp";
            List <string> types      = new List <string>()
            {
                "Mocking"
            };

            target.AddPreset(presetName, types);

            List <string> newTypes = new List <string>()
            {
                "Mark"
            };
            string newName = "Marking";

            target.EditPresets(presetName, newName, newTypes);

            Assert.IsTrue(target.PresetExists("Marking"), "Preset name has not been changed");
            Assert.IsTrue(target.PresetTypeExists("Marking", "Mark"), "New types have not been added");
        }