public FilterM GetSelectionFilter() { if (MyListView.SelectedItems.Count > 0) { bool more = false; FilterM f = (MyListView.SelectedItems[0] as FilterVM).M; for (int i = 1; i < MyListView.SelectedItems.Count; ++i) { f = FilterM.Combine(f, (MyListView.SelectedItems[i] as FilterVM).M); more = true; } if (!more) { f = f.Clone(); } f.SearchString = MySearchTextBox.Text; return(f); } return(null); }
private bool SyncClockGroupMToFilterM(string oldGName, ClockGroupM g, FilterM f) { if (!f.IsBaseFilter && g.Name == f.GroupNames.FirstOrDefault()) { f.DisplayString = g.Name; f.IsSelected = g.IsSelected; f.IsBaseFilter = false; f.MyConstantImageSource = g.Icon; f.MyEmptyImageSource = MyClocks.FiltersVM.MyEmptyFolderIcon; f.MyNonEmptyImageSource = MyClocks.FiltersVM.MyNonEmptyFolderIcon; f.GroupNames.Clear(); f.GroupNames.Add(g.Name); f.UpdateItemCount(); } else { if (!f.GroupNames.Contains(oldGName)) { return(false); } var ng = new ObservableCollection <string>(f.GroupNames); ng.Remove(oldGName); ng.Add(g.Name); f.GroupNames = ng; f.DisplayString = g.Name; } return(true); }
public FilterVM(FilterM m) { M = m; M.PropertyChanged += M_PropertyChanged; SynchronizeFromModel(); PropertyChanged += FilterVM_PropertyChanged; }
internal FilterM Clone() { var f = new FilterM(Clocks, ""); f.ShowActive = ShowActive; f.ShowInactive = ShowInactive; f.ShowTimers = ShowTimers; f.ShowAlarms = ShowAlarms; f.GroupNames = new List <string>(GroupNames); f.SearchString = SearchString; return(f); }
public FilterM ClockGroupVMToFilterM(ClockGroupVM vm) { var f = new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model, $"{MyClocks.GroupsVM.VMs.IndexOf(vm) + 1}") { ShowActive = true, ShowInactive = true, ShowAlarms = true, ShowTimers = true }; return(f); }
internal void DoSearch() { if (AppliedFilter != null) { FilterM f = AppliedFilter.Clone(); f.SearchString = MySearchTextBox.Text; AppliedFilter = f; } else { var f = new FilterM(MyDataFile.ClockVMCollection.Model); f.SearchString = MySearchTextBox.Text; AppliedFilter = f; } }
// TODO: in this class, Equals and ==, != operators etc. should // also compare the Groups collection of each CLock. public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } FilterM f1 = this, f2 = obj as FilterM; return(f1.ShowActive == f2.ShowActive && f1.ShowInactive == f2.ShowInactive && f1.ShowTimers == f2.ShowTimers && f1.ShowAlarms == f2.ShowAlarms && f1.SearchString == f2.SearchString && f1.GroupNames.Except(f2.GroupNames).Count() == 0 && f2.GroupNames.Except(f1.GroupNames).Count() == 0); }
internal static FilterM Combine(FilterM f, FilterM f2) { FilterM c = f.Clone(); c.ShowActive |= f2.ShowActive; c.ShowInactive |= f2.ShowInactive; c.ShowTimers |= f2.ShowTimers; c.ShowAlarms |= f2.ShowAlarms; c.GroupNames = Utils.AddEnumerablesDistinct(c.GroupNames, f2.GroupNames).ToList(); string ss1 = c.SearchString; string ss2 = f2.SearchString; c.SearchString = ss1.Trim() + " " + ss2.Trim(); return(c); }
/// <summary> /// Requires f (the filter) to not be null. /// </summary> /// <param name="f"></param> /// <param name="td"></param> /// <returns></returns> internal static bool ClockSatisfiesFilter(FilterM f, ClockM td) { bool r = false; if (!f.ShowActive || !f.ShowInactive) { if (f.ShowActive) { if (td is AlarmData ad && !ad.Enabled) { r = true; } else if (td is TimerData tdd && !tdd.Running) { r = true; } else { //r |= false; } }
public void Init() { MyClocks.Filters.Initialize(); MyModel.Ms.CollectionChanged += MyModel_Ms_CollectionChanged; VMs = new ObservableCollection <FilterVM>(); VMs.CollectionChanged += VMs_CollectionChanged; MyClocks.GroupsVM.VMs.CollectionChanged += GroupsVMs_CollectionChanged; var v1 = new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model, "") { ShowActive = true, ShowInactive = true, ShowTimers = true, ShowAlarms = true, DisplayString = "All", MyConstantImageSource = new BitmapImage( new Uri("/Resources/show-all-icon.png", UriKind.Relative)), IsBaseFilter = true }; MyModel.Ms.Add(v1); MyModel.Ms.Add(new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model, "") { ShowActive = true, ShowInactive = false, ShowTimers = true, ShowAlarms = true, DisplayString = "Active", MyConstantImageSource = new BitmapImage( new Uri("/Resources/on filter.ico", UriKind.Relative)), IsBaseFilter = true }); MyModel.Ms.Add(new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model, "") { ShowActive = false, ShowInactive = true, ShowTimers = true, ShowAlarms = true, DisplayString = "Inactive", MyConstantImageSource = new BitmapImage( new Uri("/Resources/off filter.ico", UriKind.Relative)), IsBaseFilter = true }); MyModel.Ms.Add(new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model, "") { ShowActive = true, ShowInactive = true, ShowTimers = true, ShowAlarms = false, DisplayString = "Timers", MyConstantImageSource = new BitmapImage( new Uri("/Resources/timers filter (clepsidra 4).ico", UriKind.Relative)), IsBaseFilter = true }); MyModel.Ms.Add(new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model, "") { ShowActive = true, ShowInactive = true, ShowTimers = false, ShowAlarms = true, DisplayString = "Alarms", MyConstantImageSource = (DrawingImage)App.Current.MainWindow.FindResource("alarmClockDrawingImage"), IsBaseFilter = true }); }
public static bool ClockGroupVMEqualsWithinTargetToFilterM(ClockGroupVM vm, FilterM m) { return(m.GroupNames.Count > 0 && m.ShowsGroup(vm.Name)); }