ScreenToGif/Util/ListBoxSelector.cs

(开头部分) 24KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;

namespace ScreenToGif.Util
{
    //TODO: Still not working...
    //Code from http://www.codeproject.com/Articles/209560/ListBox-drag-selection

    /// <summary>
    /// Enables the selection of items inside a ListBox by using a selection rectangle.
    /// </summary>
    public class ListBoxSelector
    {
        #region Properties and Variables

        ///<summary>
        ///Identifies the IsEnabled attached property.
        ///</summary>
        public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool),
            typeof(ListBoxSelector), new UIPropertyMetadata(false, IsEnabledChangedCallback));

        // This stores the ListBoxSelector for each ListBox so we can unregister it.
        private static readonly Dictionary<ListBox, ListBoxSelector> AttachedControls = new Dictionary<ListBox, ListBoxSelector>();

        private readonly ListBox _listBox;
        private ScrollContentPresenter _scrollContent;

        private SelectionAdorner _selectionRect;
        private AutoScroller _autoScroller;
        private ItemsControlSelector _selector;

        private bool _mouseCaptured;
        private Point _start;
        private Point _end;

        #endregion

        public ListBoxSelector(ListBox listBox)
        {
            _listBox = listBox;

            if (_listBox.IsLoaded)
            {
                Register();
            }
            else
            {
                //We need to wait for it to be loaded so we can find the child controls.
                _listBox.Loaded += OnListBoxLoaded;
            }
        }

后面还有 615 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。