コード例 #1
0
        private void OnCreateConditionGroup()
        {
            FilterConditionGroupViewModel cg = new FilterConditionGroupViewModel(this);

            cg.CreateConditionCommand.Execute();
            ConditionGroups.Add(cg);
        }
コード例 #2
0
        public void LoadFromString(string data)
        {
            isLoading = true;

            ConditionGroups.Clear();
            IEnumerable <string> lines      = data.Split('\n').Select(s => s.Trim('\r'));
            List <string>        lineBuffer = new List <string>();
            bool lineBufferIsExclude        = false;
            bool lineBufferIsEnabled        = true;
            bool haveName = false;

            foreach (string line in lines)
            {
                if (!haveName)
                {
                    // The first line contains the "quick filter" flag and filter name
                    string[] chunks = line.Split(new char[] { ',' }, 2);
                    if (chunks[0] == "qf")
                    {
                        QuickModifiedTime = DateTime.UtcNow.AddYears(-1);
                    }
                    DisplayName = chunks[1];
                    haveName    = true;
                }
                else
                {
                    string[] chunks = line.Split(new char[] { ',' }, 3);
                    if (chunks[0] == "or" || chunks[0] == "and not")
                    {
                        // New condition group starts
                        if (lineBuffer.Count > 0)
                        {
                            // Create condition group from buffer of previous lines
                            FilterConditionGroupViewModel grp = new FilterConditionGroupViewModel(this);
                            grp.LoadFromString(lineBuffer);
                            grp.IsExclude = lineBufferIsExclude;
                            grp.IsEnabled = lineBufferIsEnabled;
                            ConditionGroups.Add(grp);
                            lineBuffer.Clear();
                        }
                        // Remember type for the upcoming condition group
                        lineBufferIsExclude = chunks[0] == "and not";
                        lineBufferIsEnabled = chunks[1] == "on";
                    }
                    // Save line to buffer
                    lineBuffer.Add(line);
                }
            }
            // Create last condition group from buffer of previous lines
            FilterConditionGroupViewModel grp2 = new FilterConditionGroupViewModel(this);

            grp2.LoadFromString(lineBuffer);
            grp2.IsExclude = lineBufferIsExclude;
            grp2.IsEnabled = lineBufferIsEnabled;
            ConditionGroups.Add(grp2);

            isLoading = false;
        }
コード例 #3
0
        public FilterConditionGroupViewModel GetDuplicate(FilterViewModel newParent)
        {
            FilterConditionGroupViewModel newGroup = new FilterConditionGroupViewModel(newParent);

            newGroup.Conditions = new ObservableCollection <FilterConditionViewModel>(this.Conditions.Select(c => c.GetDuplicate(newGroup)));
            newGroup.IsExclude  = this.IsExclude;
            newGroup.IsEnabled  = this.IsEnabled;
            return(newGroup);
        }
コード例 #4
0
        public static FilterViewModel CreateNew()
        {
            FilterViewModel newFilter = new FilterViewModel();

            newFilter.DisplayName = DateTime.Now.ToString();
            FilterConditionGroupViewModel newGroup = new FilterConditionGroupViewModel(newFilter);

            newGroup.Conditions.Add(new FilterConditionViewModel(newGroup));
            newFilter.ConditionGroups.Add(newGroup);
            return(newFilter);
        }
コード例 #5
0
 public FilterConditionViewModel GetDuplicate(FilterConditionGroupViewModel newParent)
 {
     FilterConditionViewModel newCond = new FilterConditionViewModel(newParent);
     newCond.Column = this.Column;
     newCond.Comparison = this.Comparison;
     newCond.Value = this.Value;
     newCond.IsEnabled = this.IsEnabled;
     return newCond;
 }
コード例 #6
0
        public FilterConditionViewModel(FilterConditionGroupViewModel parentConditionGroup)
        {
            this.parentConditionGroup = parentConditionGroup;

            Comparison = FilterComparison.Contains;
            Value = "";
            IsEnabled = true;
        }
コード例 #7
0
 private void OnCreateConditionGroup()
 {
     FilterConditionGroupViewModel cg = new FilterConditionGroupViewModel(this);
     cg.CreateConditionCommand.Execute();
     ConditionGroups.Add(cg);
 }
コード例 #8
0
        public void LoadFromString(string data)
        {
            isLoading = true;

            ConditionGroups.Clear();
            IEnumerable<string> lines = data.Split('\n').Select(s => s.Trim('\r'));
            List<string> lineBuffer = new List<string>();
            bool lineBufferIsExclude = false;
            bool lineBufferIsEnabled = true;
            bool haveName = false;
            foreach (string line in lines)
            {
                if (!haveName)
                {
                    // The first line contains the "quick filter" flag and filter name
                    string[] chunks = line.Split(new char[] { ',' }, 2);
                    if (chunks[0] == "qf")
                        QuickModifiedTime = DateTime.UtcNow.AddYears(-1);
                    DisplayName = chunks[1];
                    haveName = true;
                }
                else
                {
                    string[] chunks = line.Split(new char[] { ',' }, 3);
                    if (chunks[0] == "or" || chunks[0] == "and not")
                    {
                        // New condition group starts
                        if (lineBuffer.Count > 0)
                        {
                            // Create condition group from buffer of previous lines
                            FilterConditionGroupViewModel grp = new FilterConditionGroupViewModel(this);
                            grp.LoadFromString(lineBuffer);
                            grp.IsExclude = lineBufferIsExclude;
                            grp.IsEnabled = lineBufferIsEnabled;
                            ConditionGroups.Add(grp);
                            lineBuffer.Clear();
                        }
                        // Remember type for the upcoming condition group
                        lineBufferIsExclude = chunks[0] == "and not";
                        lineBufferIsEnabled = chunks[1] == "on";
                    }
                    // Save line to buffer
                    lineBuffer.Add(line);
                }
            }
            // Create last condition group from buffer of previous lines
            FilterConditionGroupViewModel grp2 = new FilterConditionGroupViewModel(this);
            grp2.LoadFromString(lineBuffer);
            grp2.IsExclude = lineBufferIsExclude;
            grp2.IsEnabled = lineBufferIsEnabled;
            ConditionGroups.Add(grp2);

            isLoading = false;
        }
コード例 #9
0
 public static FilterViewModel CreateNew()
 {
     FilterViewModel newFilter = new FilterViewModel();
     newFilter.DisplayName = DateTime.Now.ToString();
     FilterConditionGroupViewModel newGroup = new FilterConditionGroupViewModel(newFilter);
     newGroup.Conditions.Add(new FilterConditionViewModel(newGroup));
     newFilter.ConditionGroups.Add(newGroup);
     return newFilter;
 }
コード例 #10
0
 public FilterConditionGroupViewModel GetDuplicate(FilterViewModel newParent)
 {
     FilterConditionGroupViewModel newGroup = new FilterConditionGroupViewModel(newParent);
     newGroup.Conditions = new ObservableCollection<FilterConditionViewModel>(this.Conditions.Select(c => c.GetDuplicate(newGroup)));
     newGroup.IsExclude = this.IsExclude;
     newGroup.IsEnabled = this.IsEnabled;
     return newGroup;
 }