Ejemplo n.º 1
0
        public string FormatName(IEvent @event)
        {
            IEventFormatter formatter = _formatters[@event.EventType];

            if (formatter == null)
            {
                return("<UNKNOWN EVENT>");
            }
            return(formatter.FormatName(@event));
        }
Ejemplo n.º 2
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     //------------------
     _headerPanel = GetTemplateChild(HeaderPanelPartName) as Panel;
     if (_headerPanel != null)
     {
         _headerPanel.MouseLeftButtonDown += ContainerGridOnMouseDown;
         _headerPanel.MouseEnter          += ContainerGridOnMouseEnter;
         _headerPanel.MouseLeave          += ContainerGridOnMouseLeave;
     }
     //------------------
     _childrenIndicatorBorder = GetTemplateChild(ChildrenIndicatorBorderPartName) as Border;
     if (_childrenIndicatorBorder != null)
     {
         _childrenIndicatorBorder.Visibility = _hasChildren ? Visibility.Visible : Visibility.Hidden;
     }
     //------------------
     _percentsColorIndicatorBorder = GetTemplateChild(PercentsColorIndicatorBorderPartName) as Border;
     if (_percentsColorIndicatorBorder != null)
     {
         _percentsColorIndicatorBorder.Background = new SolidColorBrush(PercentsToColorConverter.Convert(_event.Percent));
     }
     //------------------
     _percentTextBlock = GetTemplateChild(PercentTextBlockPartName) as TextBlock;
     if (_percentTextBlock != null)
     {
         _percentTextBlock.Text = string.Format("{0}%", _event.Percent);
     }
     //------------------
     _timeTextBlock = GetTemplateChild(TimeTextBlockPartName) as TextBlock;
     if (_timeTextBlock != null)
     {
         _timeTextBlock.Text = string.Format("{0}ms", _event.Time);
     }
     //------------------
     _hitsTextBlock = GetTemplateChild(HitsTextBlockPartName) as TextBlock;
     if (_hitsTextBlock != null)
     {
         _hitsTextBlock.Text = string.Format("{0}hits", _event.Hits);
     }
     //------------------
     _nameTextBlock = GetTemplateChild(NameTextBlockPartName) as TextBlock;
     if (_nameTextBlock != null)
     {
         _nameTextBlock.Text = _eventFormatter.FormatName(_event);
     }
     //------------------
     _childrenItemsControl = GetTemplateChild(ChildrenItemsControlPartName) as ItemsControl;
     if (_childrenItemsControl != null)
     {
         _childrenItemsControl.Visibility = Visibility.Collapsed;
     }
 }