Exemplo n.º 1
0
        /// <summary>
        /// Clears the current selection
        /// </summary>
        public void ClearSelected()
        {
            foreach (ItemViewerItem item in _selectedItems)
            {
                item.IsSelected = false;
            }

            _selectedItems.Clear();
            _selected = null;
        }
Exemplo n.º 2
0
        private void SetChildEvents(ItemViewerItem item)
        {
            item.Loaded          -= new RoutedEventHandler(Element_Loaded);
            item.ItemSelected    -= new ItemViewerEventHandler(ItemViewer_ItemSelected);
            item.EditingFinished -= new ItemViewerEventHandler(RaiseEditingFinished);

            item.Loaded          += new RoutedEventHandler(Element_Loaded);
            item.ItemSelected    += new ItemViewerEventHandler(ItemViewer_ItemSelected);
            item.EditingFinished += new ItemViewerEventHandler(RaiseEditingFinished);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This event handler is called when an item is selected
        /// </summary>
        /// <param name="sender">Event source object</param>
        /// <param name="e">Event arguments</param>
        private void ItemViewer_ItemSelected(object sender, ItemViewerEventArgs e)
        {
            ItemViewerItem item = (ItemViewerItem)sender;

            if (IsCtrlDown())
            {
                if (item.IsSelected)
                {
                    item.IsSelected = false;
                    if (_selectedItems.Contains(item))
                    {
                        _selectedItems.Remove(item);
                    }

                    if (_selected == item)
                    {
                        _selected = null;
                        if (_selectedItems.Count > 0)
                        {
                            _selected = _selectedItems[0];
                        }
                    }
                }
                else
                {
                    if (_selectedItems.Count > 0)
                    {
                        _selectedItems.Add(item);
                        item.IsSelected = true;
                    }
                    else
                    {
                        Selected = item;
                    }
                }
            }
            else if (IsShiftDown())
            {
            }
            else
            {
                if (Selected != null && Selected != sender)
                {
                    _ticksSinceLastClick = 0;
                    if (Selected.IsEditable)
                    {
                        Selected.IsEditable = false;
                    }
                }

                Selected = (ItemViewerItem)sender;

                if (_ticksSinceLastClick > 0 && _ticksSinceLastClick < 15 && sender == Selected)
                {       // Double-click
                    RaiseDoubleClick(this, e);
                }
                else if (_ticksSinceLastClick > 0 && _ticksSinceLastClick < 40 && sender == Selected)
                {       // Slow double-click
                    RaiseSlowDoubleClick(this, e);
                }
                else
                {
                    RaiseItemSelected(this, e);
                }
            }

            _ticksSinceLastClick = 0;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a single ItemViewerItem object
        /// </summary>
        /// <param name="item">Item object</param>
        public void Add(ItemViewerItem item)
        {
            SetChildEvents(item);

            ElementChildren.Add(item);
        }