Ejemplo n.º 1
0
        // This function creates the timescale (or timeline), that accompanies every stackPanel inside the graph area
        public TimeScaleElement CreateTimeScale(int index)
        {
            TimeScaleElement newTSE = new TimeScaleElement();
            int tickBarMarginBottom = -1;

            for (int i = 0; i < totalPipelineTime + 1; i++)
            {
                // Position it horizontally, depending on the 'CPU_Count'
                // The values are absolute, if the PipelineControl is ever to be resized in height, these values need to be made relative
                if (CPU_Count == 1)
                {
                    tickBarMarginBottom = 45;
                }
                else if (CPU_Count == 2)
                {
                    tickBarMarginBottom = 20;
                }
                else if (CPU_Count == 3)
                {
                    tickBarMarginBottom = 3;
                }
                else if (CPU_Count == 4)
                {
                    tickBarMarginBottom = -2;
                }

                newTSE = new TimeScaleElement();
                newTSE.HorizontalAlignment     = HorizontalAlignment.Left;
                newTSE.VerticalAlignment       = VerticalAlignment.Bottom;
                newTSE.textBlockTickValue.Text = i.ToString();
                newTSE.rectangleTick.Uid       = i.ToString();
                newTSE.textBlockTickValue.Uid  = i.ToString();

                if (i == 0)
                {
                    newTSE.Margin = new Thickness(stackPanelTickBarMarginLeft - 16, 0, 0, tickBarMarginBottom);
                }
                else
                {
                    newTSE.Margin = new Thickness(stackPanelTickBarMarginLeft - 16 + (TimeScaleUnitValue * i), 0, 0, tickBarMarginBottom);
                }

                Grid.SetRow(newTSE, index);

                CustomGrid.Children.Add(newTSE);
            }

            return(newTSE);
        }
Ejemplo n.º 2
0
        // This is the main function that fills the graph area
        public void FillPipelines()
        {
            // For each CPU
            for (int i = 0; i < CPU_Count_Prop; i++)
            {
                // Create a new stackPanel, which will hold the visual representations of the processes
                StackPanel sPanel = new StackPanel();
                sPanel = CreateStackPanels(i);

                // Create the timescale
                TimeScaleElement tse = CreateTimeScale(i);

                // For each process in the current pipeline (current CPU)
                for (int j = 0; j < processList[i].Count; j++)
                {
                    // Create a new grid (visual representation of the process)
                    Grid newGrid = new Grid();
                    newGrid.Height = 50;

                    // If the current element in the pipeline is a process, create and style the Grid
                    if (processList[i][j] is Process)
                    {
                        TextBlock tb = CreateProcessTextBlock((processList[i][j] as Process).ID);
                        newGrid.Children.Add(tb);
                        newGrid.Width      = TimeScaleUnitValue * (processList[i][j] as Process).ExecutedTime;
                        newGrid.Background = colorPalette[((processList[i][j] as Process).ID - 1) % colorPalette.Count];
                        newGrid.Uid        = i.ToString() + '-' + j.ToString();
                    }
                    // Else, if the current element in the pipeline is not a process (and is of type DeadTime), insert a grid styled accordingly
                    else
                    {
                        newGrid.Width      = TimeScaleUnitValue * (processList[i][j] as DeadTime).DelayValue;
                        newGrid.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "img/diagonalLines4_GrayGradient.png")));
                        newGrid.Opacity    = 0.7;
                        newGrid.Uid        = "UCelement";
                    }

                    // Position the created grid accordingly
                    Grid.SetRow(newGrid, i);
                    sPanel.Children.Add(newGrid);
                }
            }
        }