Exemple #1
0
 /// <summary>
 /// 选中当前选择的节点
 /// </summary>
 public void CheckedSelectedItem()
 {
     if (tv.SelectedItem != null)
     {
         UnCheckedAllItem();
         SLTreeView2Data item = (SLTreeView2Data)tv.SelectedItem;
         //if (item.IsUnitNode) return;
         item.Checked = true;
     }
 }
Exemple #2
0
 /// <summary>
 /// 选中改变事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void SLTreeView2Data_CheckedItemChanged(SLTreeView2Data item, SLCar car, bool isAdd)
 {
     if (isAdd)
     {
         if (!_checkedCars.ContainsKey(car))
         {
             _checkedCars.Add(car, item);
         }
     }
     else
     {
         if (_checkedCars.ContainsKey(car))
         {
             _checkedCars.Remove(car);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 选择改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void tv_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            SLTreeView2Data item = e.NewValue as SLTreeView2Data;

            if (item != null)
            {
                if (SelectedCar == item.Car)
                {
                    return;
                }

                SelectedCar   = item.Car;
                lastClickTime = DateTime.MinValue;
                if (SelectedCarChanged != null)
                {
                    SelectedCarChanged(SelectedCar);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 展开车辆
        /// </summary>
        /// <param name="car"></param>
        public void ExpandCar(SLCar car)
        {
            if (_tvScrollViewer == null)
            {
                _tvScrollViewer = tv.GetScrollHost();
            }
            SLTreeView2Data data = _rootUnitData.GetTreeViewDataByCar(car);

            if (data != null)
            {
                var datas = data.GetTreeViewDataParents(false);
                if (datas.Any())
                {
                    tv.ExpandPath(datas);
                }

                tv.SelectItem(data);
                if (tv.SelectedItem == null || tv.SelectedItem != data)
                {
                    DispatcherTimer timer = new DispatcherTimer();
                    timer.Tick += (sender, args) =>
                    {
                        if (tv.SelectedItem != null && tv.SelectedItem == data)
                        {
                            _tvScrollViewer.ScrollIntoView(tv.GetSelectedContainer());
                            timer.Stop();
                            timer = null;
                        }
                        else
                        {
                            tv.SelectItem(data);
                        }
                    };
                    timer.Interval = new TimeSpan(0, 0, 0, 0, 300);
                    timer.Start();
                }
                else
                {
                    _tvScrollViewer.ScrollIntoView(tv.GetSelectedContainer());
                }
            }
        }
Exemple #5
0
 public SLTreeView2()
 {
     InitializeComponent();
     _rootUnitData = SLTreeView2Data.CreateRootTreeViewItem();
     InitEvent();
 }