public void Populate(JMMServerBinary.Contract_GroupFilter contract) { this.GroupFilterID = contract.GroupFilterID; this.GroupFilterName = contract.GroupFilterName; this.ApplyToSeries = contract.ApplyToSeries; this.BaseCondition = contract.BaseCondition; this.PredefinedCriteria = ""; this.FilterConditions.Clear(); GroupCount = 0; SeriesCount = 0; if (contract.FilterConditions != null) { foreach (JMMServerBinary.Contract_GroupFilterCondition gfc_con in contract.FilterConditions) { FilterConditions.Add(new GroupFilterConditionVM(gfc_con)); } } //SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(); SortCriteriaList.Clear(); string sortCriteriaRaw = contract.SortingCriteria; if (!string.IsNullOrEmpty(sortCriteriaRaw)) { string[] scrit = sortCriteriaRaw.Split('|'); foreach (string sortpair in scrit) { string[] spair = sortpair.Split(';'); if (spair.Length != 2) { continue; } int stype = 0; int sdir = 0; int.TryParse(spair[0], out stype); int.TryParse(spair[1], out sdir); if (stype > 0 && sdir > 0) { GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria(); gfsc.GroupFilterID = this.GroupFilterID; gfsc.SortType = (GroupFilterSorting)stype; gfsc.SortDirection = (GroupFilterSortDirection)sdir; SortCriteriaList.Add(gfsc); } } } //FilterConditions = new List<GroupFilterConditionVM>(FilterConditions.OrderBy(p => p.ConditionTypeString)); }
private void InitializeConditions(Collection <FilterCondition> conditions) { foreach (var condition in conditions.Where(c => !(c is ScriptFilterCondition))) { FilterConditionViewModel itemViewModel = new FilterConditionViewModel(requiredValues, condition); itemViewModel.PropertyChanged += ItemViewModel_PropertyChanged; FilterConditions.Add(itemViewModel); } scriptFilterCondition = conditions.OfType <ScriptFilterCondition>().FirstOrDefault(); if (scriptFilterCondition == null) { scriptFilterCondition = new ScriptFilterCondition(); scriptFilterCondition.ScriptType = FilterStyleScriptType; conditions.Add(scriptFilterCondition); } }
public void GroupSelected(FilterOperator filterOperator, FilterConditionsViewModel parentFilterConditions = null) { var isRootFilter = parentFilterConditions == null; var selectedConditions = SelectedConditions; if (selectedConditions.Count() > 1 && FilterOperator != filterOperator) { var newFilterCondition = CreateFilterCondition(); newFilterCondition.FilterOperator = filterOperator; foreach (var item in selectedConditions) { Conditions.Remove(item); newFilterCondition.Conditions.Insert(0, item); } FilterConditions.Add(newFilterCondition); } foreach (var item in FilterConditions.ToArray()) { item.GroupSelected(filterOperator, this); } }
public void Populate(JMMServerBinary.Contract_GroupFilter contract) { this.GroupFilterID = contract.GroupFilterID; this.FilterName = contract.GroupFilterName; this.ApplyToSeries = contract.ApplyToSeries; this.BaseCondition = contract.BaseCondition; this.isLocked = contract.Locked.HasValue && contract.Locked == 1; this.FilterType = contract.FilterType; this.PredefinedCriteria = ""; this.InvisibleInClients = contract.InvisibleInClients; this.GroupFilterParentId = contract.ParentGroupFilterID; this.Groups = contract.Groups.ToDictionary(a => a.Key, a => new HashSet <int>(a.Value)); this.Series = contract.Series.ToDictionary(a => a.Key, a => new HashSet <int>(a.Value)); this.Childs = new HashSet <int>(contract.Childs); this.AllowDeletion = true; this.AllowEditing = true; if (this.isLocked) { this.AllowDeletion = false; this.AllowEditing = false; } if (this.FilterType == (int)GroupFilterType.ContinueWatching) { this.AllowDeletion = false; } this.IsSystemGroupFilter = false; this.IsNotSystemGroupFilter = true; //this.FilterConditions = new ObservableCollection<GroupFilterConditionVM>(); this.FilterConditions.Clear(); if (contract.FilterConditions != null) { foreach (JMMServerBinary.Contract_GroupFilterCondition gfc_con in contract.FilterConditions) { FilterConditions.Add(new GroupFilterConditionVM(gfc_con)); } } //SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(); SortCriteriaList.Clear(); string sortCriteriaRaw = contract.SortingCriteria; if (!string.IsNullOrEmpty(sortCriteriaRaw)) { string[] scrit = sortCriteriaRaw.Split('|'); foreach (string sortpair in scrit) { string[] spair = sortpair.Split(';'); if (spair.Length != 2) { continue; } int stype = 0; int sdir = 0; int.TryParse(spair[0], out stype); int.TryParse(spair[1], out sdir); if (stype > 0 && sdir > 0) { GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria(); gfsc.GroupFilterID = this.GroupFilterID; gfsc.SortType = (GroupFilterSorting)stype; gfsc.SortDirection = (GroupFilterSortDirection)sdir; SortCriteriaList.Add(gfsc); } } } //Update GroupCount //SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(SortCriteriaList.OrderBy(p => p.GroupFilterSortingString)); //FilterConditions = new ObservableCollection<GroupFilterConditionVM>(FilterConditions.OrderBy(p => p.ConditionTypeString)); }
private void AddCondition(FilterConditionUserControl condition) { condition.Removing += RemoveCondition; condition.PropertyChanged += ChangeControlProperty; FilterConditions.Add(condition); }