Пример #1
0
        public void Navigate(IEvent targetEvent)
        {
            IList <IEvent> sequence = new List <IEvent>();

            while (targetEvent.Parent != null)
            {
                sequence.Insert(0, targetEvent);
                targetEvent = targetEvent.Parent;
            }
            EventsTreeItem item = FindItem(targetEvent);

            if (item == null)
            {
                System.Diagnostics.Debugger.Break();
                return;
            }
            item.Expand();
            for (int i = 0; i < sequence.Count; i++)
            {
                IEvent coreEvent = sequence[i];
                item = item.FindItem(coreEvent);
                if (item == null)
                {
                    break;
                }
                item.Expand();
            }
            if (item != null && _scrollViewer != null)
            {
                Point point = item.GetMiddlePosition(_scrollViewer);
                _scrollViewer.ScrollToVerticalOffset(point.Y);
            }
        }
Пример #2
0
        private static void OnIsHoveredPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            EventsTreeItem item     = (EventsTreeItem)sender;
            bool           newValue = (bool)e.NewValue;
            bool           oldValue = (bool)e.OldValue;

            if (newValue == oldValue)
            {
                return;
            }
            if (newValue)
            {
                item._treeView.HoveredEvent = item.Event;
            }
            else if (item._treeView.HoveredEvent == item.Event)
            {
                item._treeView.HoveredEvent = null;
            }
        }
Пример #3
0
 protected override void InitializeItems()
 {
     EventsTable.Clear();
     if (_itemsControl != null && Source != null)
     {
         List <EventsTreeItem> items = new List <EventsTreeItem>();
         foreach (IEventsTree tree in Source)
         {
             if (!tree.HasChildren)
             {
                 continue;
             }
             EventsTreeItem item = new EventsTreeItem(tree, EventFormatter, this);
             EventsTable.Add(tree, item);
             items.Add(item);
         }
         _itemsControl.ItemsSource = items;
     }
 }
Пример #4
0
 public EventsTreeItem Navigate(IEvent targetEvent)
 {
     Expand();
     if (_event == targetEvent)
     {
         return(this);
     }
     if (_childrenItemsControl == null)
     {
         Collapse();
         return(null);
     }
     foreach (EventsTreeItem item in _childrenItemsControl.Items)
     {
         EventsTreeItem result = item.Navigate(targetEvent);
         if (result != null)
         {
             return(result);
         }
     }
     Collapse();
     return(null);
 }
Пример #5
0
 private void InitializeChildren()
 {
     if (_areChildrenInitialized)
     {
         return;
     }
     if (_childrenItemsControl != null)
     {
         if (_event.HasChildren)
         {
             List <EventsTreeItem> items = new List <EventsTreeItem>();
             foreach (IEvent @event in _event.Children)
             {
                 EventsTreeItem item = new EventsTreeItem(@event, _eventFormatter, _treeView);
                 items.Add(item);
                 _treeView.EventsTable.Add(@event, item);
             }
             _childrenItemsControl.ItemsSource = items;
             DispatcherExtensions.DoEvents();
         }
         _areChildrenInitialized = true;
     }
 }
Пример #6
0
        private static void OnIsSelectedPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            EventsTreeItem item = (EventsTreeItem)sender;

            if (!item._notifySelection)
            {
                return;
            }
            bool newValue = (bool)e.NewValue;
            bool oldValue = (bool)e.OldValue;

            if (newValue == oldValue)
            {
                return;
            }
            if (newValue)
            {
                item._treeView.SetSelectedEventInternal(item.Event);
            }
            else if (item._treeView.SelectedEvent == item.Event)
            {
                item._treeView.SetSelectedEventInternal(null);
            }
        }