Rect AddActiveWindowBox(TaskActive task, bool isLast)
        {
            Rectangle   taskRect    = new Rectangle();
            StepDiagram stepDiagram = Session.StepDiagram;
            double      left        = ConversionHelper.MillisecondsToPixels(stepDiagram.GetOffset(task.Start).TotalMilliseconds);

            Canvas.SetLeft(taskRect, left);
            double width = ConversionHelper.MillisecondsToPixels(task.Duration.TotalMilliseconds);

            if (isLast && HookEngine.Listening)
            {
                width = cvsWindows.ActualWidth;
            }
            taskRect.Width  = width;
            taskRect.Height = cvsWindows.ActualHeight;
            Canvas.SetTop(taskRect, 0);

            taskRect.Fill = GetTaskFillBrush(task);
            FrameworkElement windowTooltip = GetWindowTooltip();

            windowTooltip.DataContext = task;
            taskRect.ToolTip          = windowTooltip;
            taskRect.ToolTipOpening  += taskRect_ToolTipOpening;
            taskRect.Tag = task;
            cvsWindows.Children.Add(taskRect);
            return(new Rect(left, 0, width, cvsWindows.ActualHeight));
        }
Exemple #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime dateTime = (DateTime)value;
            TimeSpan span     = Session.StepDiagram.GetOffset(dateTime);

            return(ConversionHelper.MillisecondsToPixels(span.TotalMilliseconds));
        }
        void AddTimeTickMark(double seconds)
        {
            if (seconds == 0)
            {
                return;
            }
            double horizontalAxisHeight = GetHorizontalAxisHeight();

            double longTickLength   = horizontalAxisHeight / 5.0;
            double mediumTickLength = horizontalAxisHeight / 7.5;
            double shortTickLength  = horizontalAxisHeight / 10.0;
            double tickLength       = shortTickLength;

            double strokeThickness = 0.5;

            double tickFontSize   = tickMarkFontSize;
            string timeAsStr      = seconds.ToString("0.0");
            int    indexOfDecimal = timeAsStr.IndexOf('.');

            if (indexOfDecimal > 0 && indexOfDecimal < timeAsStr.Length)
            {
                char charAfterDecimal = timeAsStr[indexOfDecimal + 1];
                if (charAfterDecimal == '0')
                {
                    tickLength      = longTickLength;
                    tickFontSize    = tickMarkFontSize * 1.2;
                    strokeThickness = 1.5;
                }
                else if (charAfterDecimal == '5')
                {
                    tickLength      = mediumTickLength;
                    tickFontSize    = tickMarkFontSize * 1.1;
                    strokeThickness = 1;
                }
            }

            double x = ConversionHelper.MillisecondsToPixels(seconds * 1000);

            AddTimeTickMarkLine(x, tickLength, strokeThickness);
            AddTimeTickMarkLabel(x, longTickLength, seconds, tickFontSize);
        }