Ejemplo n.º 1
0
        void AdaptiveSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (var item in e.RemovedItems)
            {
                var to_remove =
                    (from sm in SelectionMarkers
                     where !sm.IsDragging && object.Equals(sm.Item, item)
                     select sm).ToArray();

                foreach (var td in to_remove)
                    SelectionMarkers.Remove(td);
            }

            foreach (var item in e.AddedItems)
            {
                var existing_marker =
                    (from sm in SelectionMarkers
                     where object.Equals(sm.Item, item)
                     select sm).FirstOrDefault();

                if (existing_marker != null)
                    continue;

                var new_marker = new SelectionMarker() { Item = item };
                SelectionMarkers.Add(new_marker);


                var group = (object) SelectorLogic.GetItemGroup(this, SelectorIdentifier, item);

                if (group != null)
                {
                    // disable others within same group
                    var other_with_same_group =
                        (from si in this.SelectedItems.Cast<object>()
                         let si_group = SelectorLogic.GetItemGroup(this, SelectorIdentifier, si)
                             // same group, different item
                         where object.Equals(si_group, @group) && !ItemEqualityComparer.Equals(si, item)
                         select si).ToList();


                    foreach (var rem in other_with_same_group)
                    {
                        SelectedItems.Remove(rem);
                    }
                }
            }

            // make sure only one item from single-selection groups is selected at the time
        }
Ejemplo n.º 2
0
        void RefreshMarker(SelectionMarker marker)
        {
            var offset = GetOffset(marker.Item);

            marker.Left = offset;

            var width = GetThumbWidth(marker.Item);

            marker.Width = width;
        }