Exemple #1
0
        /// <summary>
        /// Copy the screen data to the clipboard
        /// </summary>
        public override string GetClipboardText()
        {
            StringBuilder builder = new StringBuilder(1000);

            for (int row = rows; row >= 0; row--)
            {
                for (int column = 0; column < columns + 1; column++)
                {
                    if (column == 0)
                    {
                        float yValue = SawMillUtility.GetHeader(row, rows, yMin, yMax);
                        builder.Append(yValue.ToString("0.00"));
                    }
                    else if (row == 0)
                    {
                        float xValue = SawMillUtility.GetHeader(column, columns, 0f, xMax);
                        builder.Append(xValue.ToString("0"));
                    }
                    else
                    {
                        int    xIndex   = column - 1;
                        int    yIndex   = row - 1;
                        Cell   cell     = this.dataPoints[xIndex][yIndex];
                        string cellText = this.GetCellText(cell);
                        builder.Append(cellText);
                    }

                    if (column == columns)
                    {
                        builder.AppendLine();
                    }
                    else
                    {
                        builder.Append('\t');
                    }
                }
            }
            return(builder.ToString());
        }
Exemple #2
0
 private float GetColumnHeader(int x)
 {
     return(SawMillUtility.GetHeader(x, 2, 0f, 10f));
 }
Exemple #3
0
 private float GetRowHeader(int y)
 {
     return(SawMillUtility.GetHeader(y, 2, 0f, 10f));
 }
Exemple #4
0
 private float GetColumnHeader(int x)
 {
     return(SawMillUtility.GetHeader(x, columns, 0f, this.xMax));
 }
Exemple #5
0
 private float GetRowHeader(int y)
 {
     return(SawMillUtility.GetHeader(y, rows, this.yMin, this.yMax));
 }
Exemple #6
0
        private void DrawDataPoints(Graphics graphics, float width, float height)
        {
            double cellWidth  = width / (columns + 1);
            double cellHeight = height / (rows + 1);

            using (Font largeFont = new Font(
                       FontFamily.GenericSansSerif,
                       (float)cellHeight * this.cellFontScale,
                       FontStyle.Regular,
                       GraphicsUnit.Pixel))
                using (Font smallFont = new Font(
                           FontFamily.GenericSansSerif,
                           (float)cellHeight * 0.4f,
                           FontStyle.Regular,
                           GraphicsUnit.Pixel))
                {
                    for (int column = 0; column < columns + 1; column++)
                    {
                        for (int row = 0; row < rows + 1; row++)
                        {
                            double x = column * cellWidth;
                            double y = height - ((row + 1d) * cellHeight);

                            int xIndex = column - 1;
                            int yIndex = row - 1;

                            RectangleF rectangle = new RectangleF(
                                (float)x,
                                (float)y,
                                (float)cellWidth,
                                (float)cellHeight);

                            //if ((column == 0) && (row == 0))
                            //{
                            //}
                            //else
                            if (column == 0)
                            {
                                float        yValue = SawMillUtility.GetHeader(row, rows, yMin, yMax);
                                StringFormat format = new StringFormat();
                                format.Alignment     = StringAlignment.Far;
                                format.LineAlignment = StringAlignment.Center;
                                graphics.DrawString(yValue.ToString("0.00"), smallFont, axisTextBrush, rectangle, format);
                            }
                            else if (row == 0)
                            {
                                float        xValue = SawMillUtility.GetHeader(column, columns, 0f, xMax);
                                StringFormat format = new StringFormat();
                                format.Alignment     = StringAlignment.Center;
                                format.LineAlignment = StringAlignment.Center;

                                if (column % 2 == 1)
                                {
                                    graphics.FillRectangle(axisHighlightBrush, rectangle);
                                }

                                graphics.DrawString(xValue.ToString("0"), smallFont, axisTextBrush, rectangle, format);
                            }
                            else
                            {
                                Cell   thisCell      = this.dataPoints[xIndex][yIndex];
                                double thisCellValue = thisCell.Average;

                                this.maxCellValue = Math.Max(thisCellValue, this.maxCellValue);
                                this.minCellValue = Math.Min(thisCellValue, this.minCellValue);
                                double range = this.maxCellValue - this.minCellValue;
                                double ratio = range == 0 ?
                                               0 :
                                               (thisCellValue - this.minCellValue) / range;

                                Brush brush;

                                if (thisCell.Hits == 0)
                                {
                                    brush = backgroundBrush;
                                }
                                else if ((xIndex == this.lastX) && (yIndex == this.lastY))
                                {
                                    brush = highlightBrush;
                                }
                                else
                                {
                                    brush = new SolidBrush(Color.FromArgb(
                                                               (int)Utility.Interpolate(backgroundColor.R, foregroundColor.R, ratio),
                                                               (int)Utility.Interpolate(backgroundColor.G, foregroundColor.G, ratio),
                                                               (int)Utility.Interpolate(backgroundColor.B, foregroundColor.B, ratio)));
                                }

                                graphics.FillRectangle(
                                    brush,
                                    rectangle);

                                if (thisCell.Hits > 0)
                                {
                                    StringFormat format = new StringFormat();
                                    format.Alignment     = StringAlignment.Far;
                                    format.LineAlignment = StringAlignment.Center;
                                    string cellText = this.GetCellText(thisCell);
                                    graphics.DrawString(cellText, largeFont, cellTextBrush, rectangle, format);
                                }

                                if ((brush != highlightBrush) && (brush != backgroundBrush))
                                {
                                    brush.Dispose();
                                }
                            }
                        }
                    }
                }

            if (this.lastTrace == null)
            {
                return;
            }

            using (Font font = new Font(
                       FontFamily.GenericSansSerif,
                       (float)30,
                       GraphicsUnit.Pixel))
            {
                switch (this.displayValue)
                {
                case DisplayValue.Undefined:
                    break;

                case DisplayValue.Average:
                    this.lastTrace += Environment.NewLine + "Average";
                    break;

                case DisplayValue.Maximum:
                    this.lastTrace += Environment.NewLine + "Maximum";
                    break;

                case DisplayValue.Minimum:
                    this.lastTrace += Environment.NewLine + "Minimum";
                    break;

                case DisplayValue.Hits:
                    this.lastTrace += Environment.NewLine + "Hits";
                    break;
                }

                graphics.DrawString(this.lastTrace, font, overlayBrush, width / 10, 15);
            }
        }