コード例 #1
0
        public void LoadFilterHandler()
        {
            SPOListFilter newFilter = SPOSettings.LoadFilter();

            if (newFilter != null)
            {
                Filter = newFilter;
            }
        }
コード例 #2
0
        public static void SaveAsDefaultFilter(SPOListFilter filter)
        {
            Properties.Settings.Default.DefaultListFilter =
                Serializer.SerializeToXmlString(filter, Encoding.Unicode);
            Properties.Settings.Default.Save();

            SIEEMessageBox.Show(
                "Done.", "Save default list filter",
                System.Windows.MessageBoxImage.Information);
        }
コード例 #3
0
        public static void SaveFilterAs(SPOListFilter filter)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter           = "Filter files (*.xml)|*.xml|All files (*.*)|*.*";
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Serializer.SerializeToXmlFile(filter, dlg.FileName, Encoding.Unicode);
            }
        }
コード例 #4
0
        public void t03_ListFilters()
        {
            List <SPOList> testList = new List <SPOList>()
            {
                new SPOList()
                {
                    BaseType = 0, TemplateType = 100, Title = "List 1"
                },
                new SPOList()
                {
                    BaseType = 1, TemplateType = 100, Title = "List 2"
                },
                new SPOList()
                {
                    BaseType = 1, TemplateType = 101, Title = "Library 1"
                },
                new SPOList()
                {
                    BaseType = 1, TemplateType = 5000, Title = "Library 2"
                },
                new SPOList()
                {
                    BaseType = 1, TemplateType = 5005, Title = "Library 3"
                },
            };
            SPOListFilter listFilter = new SPOListFilter();

            // Test Base type filters
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            listFilter.ValidBaseTypes.Add(new SPOListFilter.BaseType()
            {
                Type = 1
            });
            Assert.AreEqual(testList.Where(n => n.BaseType == 1).Count(), listFilter.Filter(testList).Count);
            listFilter.ValidBaseTypes.Add(new SPOListFilter.BaseType()
            {
                Type = 0
            });
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            listFilter.ValidBaseTypes.Clear();

            // Test Template type filters
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            listFilter.TypeTemplateRanges.Add(new SPOListFilter.TypeTemplateRange()
            {
                From = 100, To = 100,
            });
            Assert.AreEqual(testList.Where(n => n.TemplateType == 100).Count(), listFilter.Filter(testList).Count);
            listFilter.TypeTemplateRanges.Add(new SPOListFilter.TypeTemplateRange()
            {
                From = 5000, To = 5005,
            });
            Assert.AreEqual(4, listFilter.Filter(testList).Count);
            listFilter.TypeTemplateRanges.Add(new SPOListFilter.TypeTemplateRange()
            {
                From = 0, To = 10000,
            });
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            listFilter.TypeTemplateRanges.Clear();

            // Test Title filters
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            listFilter.TitleFilters.Add(new SPOListFilter.TitleFilter()
            {
                Pattern = "List", Exclude = true
            });
            Assert.AreEqual(3, listFilter.Filter(testList).Count);
            listFilter.TitleFilters.Clear();
            listFilter.TitleFilters.Add(new SPOListFilter.TitleFilter()
            {
                Pattern = "List", Exclude = false
            });
            Assert.AreEqual(2, listFilter.Filter(testList).Count);
            listFilter.TitleFilters.Clear();

            // Combinations
            Assert.AreEqual(testList.Count, listFilter.Filter(testList).Count);
            listFilter.ValidBaseTypes.Add(new SPOListFilter.BaseType()
            {
                Type = 1
            });
            Assert.AreEqual(4, listFilter.Filter(testList).Count);
            listFilter.TypeTemplateRanges.Add(new SPOListFilter.TypeTemplateRange()
            {
                From = 101, To = 5000,
            });
            Assert.AreEqual(2, listFilter.Filter(testList).Count);
            listFilter.TitleFilters.Add(new SPOListFilter.TitleFilter()
            {
                Pattern = "Library 3", Exclude = true
            });
            Assert.AreEqual(2, listFilter.Filter(testList).Count);
            listFilter.TitleFilters.Clear();
            listFilter.TitleFilters.Add(new SPOListFilter.TitleFilter()
            {
                Pattern = "List", Exclude = true
            });
            Assert.AreEqual(2, listFilter.Filter(testList).Count);
            listFilter.TitleFilters.Add(new SPOListFilter.TitleFilter()
            {
                Pattern = "Library", Exclude = false
            });
            Assert.AreEqual(2, listFilter.Filter(testList).Count);
        }
コード例 #5
0
 public FilterViewModel(SPOListFilter Filter)
 {
     this.Filter = Filter;
 }