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));
        }
Beispiel #2
0
        public void AddTaskActive(string windowName, IntPtr handle)
        {
            if (lastTaskActive != null)
            {
                lastTaskActive.Stop = DateTime.Now;
            }

            TaskActive newTaskActive = new TaskActive(windowName, handle);

            //newTaskActive.CaptureActiveWindow(handle);
            lastTaskActive = newTaskActive;
            tasks.Add(newTaskActive);
        }
        void AddActiveWindowLabel(TaskActive task, Rect rect)
        {
            TextBlock label = new TextBlock()
            {
                Text = task.WindowName, Foreground = taskForegroundBrush, FontSize = activeWindowFontSize
            };

            label.IsHitTestVisible = false;
            label.Width            = rect.Width;
            label.Height           = rect.Height;
            label.TextAlignment    = TextAlignment.Center;
            cvsWindows.Children.Add(label);
            Canvas.SetLeft(label, rect.Left);
            Canvas.SetTop(label, 0);
        }
        void AddWindowActivations()
        {
            StepDiagram stepDiagram = Session.StepDiagram;

            if (stepDiagram == null)
            {
                return;
            }
            IList <TaskActive> tasks = stepDiagram.Tasks;

            for (int i = nextTaskIndexToAdd; i < tasks.Count; i++)
            {
                TaskActive task   = tasks[i];
                bool       isLast = i == tasks.Count - 1;
                Rect       rect   = AddActiveWindowBox(task, isLast);
                AddActiveWindowLabel(task, rect);
            }
            nextTaskIndexToAdd = tasks.Count;
        }
        public void Stop()
        {
            StepDiagram stepDiagram = Session.StepDiagram;

            if (stepDiagram != null)
            {
                stepDiagram.TightFit();
                IList <TaskActive> tasks = stepDiagram.Tasks;
                if (tasks != null)
                {
                    TaskActive lastTask = tasks.Last <TaskActive>();
                    if (lastTask != null)
                    {
                        lastTask.Stop = stepDiagram.StopTime;
                    }
                }
            }
            RefreshDataView();
        }
        Brush GetTaskFillBrush(TaskActive taskActive)
        {
            IntPtr handle = taskActive.Handle;

            if (taskBrushIdCache.ContainsKey(handle))
            {
                return(taskBackgroundBrushes[taskBrushIdCache[handle]]);
            }

            taskBrushIdCache.Add(handle, brushIndex);

            Brush brush = taskBackgroundBrushes[brushIndex];

            brushIndex++;
            if (brushIndex >= taskBackgroundBrushes.Count)
            {
                brushIndex = 0;
            }

            return(brush);
        }
Beispiel #7
0
 void CropTasksToSpan()
 {
     for (int i = tasks.Count - 1; i >= 0; i--)
     {
         TaskActive task = tasks[i];
         if (task.Start >= stopTime)
         {
             tasks.RemoveAt(i);
         }
         else if (task.Stop >= stopTime)
         {
             task.Stop = stopTime;
         }
         else if (task.Stop < startTime)
         {
             tasks.RemoveAt(i);
         }
         else if (task.Start < startTime)
         {
             task.Start = startTime;
         }
     }
 }