コード例 #1
0
ファイル: TimeLine.cs プロジェクト: tony-jang/Delight
        private void TimeLine_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement element = null;

            try
            {
                element = ((FrameworkElement)e.OriginalSource).TemplatedParent as FrameworkElement;
            }
            catch (InvalidCastException)
            {
                return;
            }

            AllItems.ForEach(i => i.IsSelected = false);
            SelectedItem = null;
            if (element is TrackItem trackItem)
            {
                trackItem.IsSelected = true;
                SelectedItem         = trackItem;
                ItemSelected?.Invoke(trackItem, new EventArgs());
            }
            else
            {
                ItemDeselected?.Invoke(null, new EventArgs());
            }
        }
コード例 #2
0
        protected virtual void OnDeselected()
        {
            if (ExpandOnSelect)
            {
                Collapse();
            }

            ItemDeselected?.Invoke(this);
        }
コード例 #3
0
        private void UserControl_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (IsSelected && ItemDeselected != null)
            {
                ItemDeselected?.Invoke(sender, null);
            }

            if (!IsSelected && ItemSelected != null)
            {
                ItemSelected?.Invoke(sender, null);
            }

            IsSelected = !IsSelected;
        }
コード例 #4
0
        private void ToggleItemIsSelected(SelectedAndTextAndTag clickedItem)
        {
            // toggle selection
            if (clickedItem == null)
            {
                return;
            }

            if (!clickedItem.IsSelected)
            {
                clickedItem.IsSelected = true;
                ItemSelected?.Invoke(this, clickedItem.TextAndTag);
            }
            else if (IsMultiSelectCheckBoxEnabled)
            {
                clickedItem.IsSelected = false;
                ItemDeselected?.Invoke(this, clickedItem.TextAndTag);
            }
        }