Esempio n. 1
0
        private void DeleteGroup_Click(object sender, RoutedEventArgs e)
        {
            var arr = new FilterVM[MyListView.SelectedItems.Count];

            MyListView.SelectedItems.CopyTo(arr, 0);

            for (int i = arr.Length - 1; i >= 0; --i)
            {
                var fd = arr[i];
                if (MyFilters.IndexOf(fd) >= 5)
                {
                    string s = fd.DisplayString;
                    MyDataFile.ClockVMCollection.Model.Groups.Remove(s);
                }
            }
        }
Esempio n. 2
0
        private void MyModel_Ms_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (!SynchDisabled3)
            {
                SynchDisabled3 = true;

                Utils.SynchronizeCollectionChange(MyModel.Ms, e, VMs,
                                                  afterAddition: null,
                                                  prepareDeletion: null,
                                                  equalsWithinTargetTo: new Func <FilterM, FilterVM, bool>((FilterM m, FilterVM vm) =>
                {
                    return(object.ReferenceEquals(vm.M, m));
                }),
                                                  toTarget: new Func <FilterM, FilterVM>((FilterM m) =>
                {
                    foreach (FilterVM vm in VMs)
                    {
                        if (object.ReferenceEquals(vm.M, m))
                        {
                            return(vm);
                        }
                    }

                    var rv = new FilterVM(m)
                    {
                        DisplayString         = m.DisplayString,
                        MyConstantImageSource = m.MyConstantImageSource,
                        MyEmptyImageSource    = m.MyEmptyImageSource,
                        MyNonEmptyImageSource = m.MyNonEmptyImageSource,
                        Items = m.Items
                    };

                    if (!m.IsBaseFilter)
                    {
                        rv.MyEmptyImageSource    = MyEmptyFolderIcon;
                        rv.MyNonEmptyImageSource = MyNonEmptyFolderIcon;
                        rv.DisplayString         = m.GroupNames.FirstOrDefault();
                    }

                    return(rv);
                }));

                SynchDisabled3 = false;
            }

            //    if (!SynchDisabled2)
            //    {
            //        SynchDisabled2 = true;

            //        Utils.SynchronizeCollectionChange(MyModel.Ms, e, MyClocks.GroupsVM.VMs,
            //            afterAddition: null,
            //            prepareDeletion: null,
            //            equalsWithinTargetTo: new Func<FilterM, ClockGroupVM, bool>((FilterM fm, ClockGroupVM gm) =>
            //            {
            //                return fm.SearchString == gm.Name;

            //            }),
            //            toTarget: new Func<FilterM, ClockGroupVM>((FilterM m) =>
            //            {
            //                if (m.GroupNames.Count != 1)
            //                {
            //                    return null;
            //                }

            //                //return new FilterVM()
            //                //{
            //                // //DisplayString = m.
            //                // MyFilter = m
            //                //};
            //                var gm = new ClockGroupVM(new ClockGroupM()
            //                {
            //                    Name = m.GroupNames[0],
            //                    IsSelected = m.IsSelected,
            //                    Icon = m.MyImageSource
            //                });

            //                //var f = new FilterM(MyClocks.MyDataFile.ClockVMCollection.Model,
            //                //    $"{MyModel.Ms.IndexOf(m) + 1}")
            //                //{
            //                //    ShowActive = true,
            //                //    ShowInactive = true,
            //                //    ShowAlarms = true,
            //                //    ShowTimers = true
            //                //};

            //                return gm;
            //            }),
            //            startingIndexInSource: 5,
            //            startingIndexInTarget: 0);

            //        SynchDisabled2 = false;
            //    }
        }