Esempio n. 1
0
        private void select(int value)
        {
            if (value == -1)   // Unselect
            {
                _selectedIndex = value;
            }
            else if (value < _panel.Children.Count)
            {
                _selectedIndex = value;
            }
            else     // Selecting index beyond the scope
            {
                _selectedIndex = -1;
            }

            if (CurrentlySelected != null)
            {
                CurrentlySelected.__unselect();
            }

            if (_selectedIndex == -1)
            {
                CurrentlySelected = null;
                return;
            }

            UIElement            sel = _panel.Children[value];
            MySelectableListItem newlySelectedItem = backMapping[sel];

            CurrentlySelected = newlySelectedItem;
            CurrentlySelected.__select();
        }
Esempio n. 2
0
 private void handleSelectionDispatch(MySelectableListItem lastSelected, MySelectableListItem newSelected)
 {
     if (lastSelected != newSelected)
     {
         _currentlySelected = newSelected;
         SelectionChange(lastSelected, newSelected);
     }
 }
Esempio n. 3
0
 public void MoveItemBeforeItem(MySelectableListItem what, MySelectableListItem beforeWhat)
 {
     _panel.Children.Remove(what.Element);
     _panel.Children.Insert(_panel.Children.IndexOf(beforeWhat.Element), what.Element);
     if (_selectedIndex != -1)
     {
         _selectedIndex = _panel.Children.IndexOf(CurrentlySelected.Element);
     }
     SelectionChange(CurrentlySelected, CurrentlySelected);
 }
Esempio n. 4
0
 public void Remove(MySelectableListItem element)
 {
     _panel.Children.Remove(element.Element);
     element.__setList(null);
     backMapping.Remove(element.Element);
     if (CurrentlySelected == element)
     {
         CurrentlySelected = null;
         SelectedIndex     = -1;
     }
 }
Esempio n. 5
0
        public void SelectMe(MySelectableListItem item)
        {
            int indexss = _panel.Children.IndexOf(item.Element);

            if (item != CurrentlySelected)
            {
                int index = _panel.Children.IndexOf(item.Element);
                if (index >= 0)
                {
                    SelectedIndex = index;
                }
            }
        }
Esempio n. 6
0
        public void MoveItemDown(MySelectableListItem item)
        {
            int index = _panel.Children.IndexOf(item.Element);

            if (index >= 0 && index < _panel.Children.Count - 1)// Can move down
            {
                UIElement there = _panel.Children[index];
                _panel.Children.RemoveAt(index);
                _panel.Children.Insert(index + 1, there);
                if (item == CurrentlySelected)
                {
                    _selectedIndex++;
                }
                SelectionChange(CurrentlySelected, CurrentlySelected);
            }
        }
Esempio n. 7
0
        public void MoveItemUp(MySelectableListItem item)
        {
            int index = _panel.Children.IndexOf(item.Element);

            if (index > 0)   // Can move up
            {
                UIElement there = _panel.Children[index];
                _panel.Children.RemoveAt(index);
                _panel.Children.Insert(index - 1, there);
                if (item == CurrentlySelected)
                {
                    _selectedIndex--;
                }
                SelectionChange(CurrentlySelected, CurrentlySelected);
            }
        }
Esempio n. 8
0
        public void SelectNextItem(MySelectableListItem item)
        {
            int index = _panel.Children.IndexOf(item.Element);
            int count = _panel.Children.Count;

            if (index == count - 1) // Keep selection
            {
                return;
            }
            if (index < 0 || index >= count)
            {
                SelectedIndex = -1;
            }
            else
            {
                SelectedIndex = index + 1;
            }
        }
Esempio n. 9
0
        public void SelectPreviousItem(MySelectableListItem item)
        {
            int index = _panel.Children.IndexOf(item.Element);
            int count = _panel.Children.Count;

            if (index == 0)
            {
                return;
            }
            if (index < 0 || index >= count)
            {
                SelectedIndex = -1;
            }
            else
            {
                SelectedIndex = index - 1;
            }
        }
Esempio n. 10
0
 public void Add(MySelectableListItem element)
 {
     _panel.Children.Add(element.Element);
     element.__setList(this);
     backMapping.Add(element.Element, element);
 }
Esempio n. 11
0
 public void DoubleClickMe(MySelectableListItem item)
 {
     SelectMe(item);
     DoubleClick(item);
 }