Beispiel #1
0
        /// <summary>
        /// Draws the pages in the single page slots for the allocations the map displays
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        private void DrawSinglePages(PaintEventArgs e)
        {
            pageExtentRenderer.ResizePageBrush(ExtentSize);

            foreach (var layer in MapLayers)
            {
                if (layer.Visible)
                {
                    Color pageColour;

                    if (layer.UseDefaultSinglePageColour)
                    {
                        pageColour = Color.Salmon;
                    }
                    else
                    {
                        pageColour = layer.Colour;
                    }

                    pageExtentRenderer.SetExtentBrushColour(pageColour, ExtentColour.LightBackgroundColour(pageColour));

                    if (layer.UseBorderColour)
                    {
                        pageExtentRenderer.PageBorderColour = layer.BorderColour;
                    }
                    else
                    {
                        pageExtentRenderer.PageBorderColour = defaultPageBorderColour;
                    }

                    foreach (var allocation in layer.Allocations)
                    {
                        foreach (var address in allocation.SinglePageSlots)
                        {
                            if (address.FileId == FileId && address.PageId != 0 && CheckPageVisible(address.PageId))
                            {
                                pageExtentRenderer.DrawPage(e.Graphics,
                                                            PagePosition(address.PageId - (WindowPosition * 8)),
                                                            layer.LayerType);
                            }
                        }

                        if (IncludeIam)
                        {
                            foreach (var page in allocation.Pages)
                            {
                                if (CheckPageVisible(page.PageAddress.PageId))
                                {
                                    pageExtentRenderer.DrawPage(e.Graphics,
                                                                PagePosition(page.PageAddress.PageId - (WindowPosition * 8)),
                                                                AllocationLayerType.Standard);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void CreateBrushesAndPens()
        {
            pfsIamBrush   = new SolidBrush(IamColour);
            pfsGhostBrush = new SolidBrush(GhostColour);
            pfsMixedBrush = new SolidBrush(MixedColor);

            pfsAllocatedBrush = new LinearGradientBrush(pageRectangle,
                                                        AllocatedColour,
                                                        backColour,
                                                        LinearGradientMode.ForwardDiagonal);
            pfsAllocatedBrush.WrapMode = WrapMode.TileFlipX;

            pfsSpaceBrush = new LinearGradientBrush(pageRectangle,
                                                    ExtentColour.LightBackgroundColour(SpaceColour),
                                                    SpaceColour,
                                                    LinearGradientMode.Vertical);

            pageBorderPen = new Pen(borderColour);
            borderPen     = new Pen(Color.Gainsboro);

            pfsFont = new Font("Sans Serif", 6, FontStyle.Regular);

            displayAllocationText = (TextRenderer.MeasureText("%", pfsFont).Height < pageRectangle.Height);
        }
Beispiel #3
0
        protected override void Paint(Graphics graphics,
                                      Rectangle clipBounds,
                                      Rectangle cellBounds,
                                      int rowIndex,
                                      DataGridViewElementStates elementState,
                                      object value,
                                      object formattedValue,
                                      string errorText,
                                      DataGridViewCellStyle cellStyle,
                                      DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics,
                       clipBounds,
                       cellBounds,
                       rowIndex,
                       elementState,
                       value,
                       formattedValue,
                       errorText,
                       cellStyle,
                       advancedBorderStyle,
                       paintParts);

            string cellText;

            var font = new Font(DataGridView.DefaultCellStyle.Font, FontStyle.Regular);

            if (value != null)
            {
                Color gradientColour;

                var r = (OwningColumn as BarColumn).ColourRanges.Find(delegate(ColourRange range)
                {
                    return(range.From <= Convert.ToInt32(value ?? 0) &&
                           range.To >= Convert.ToInt32(value ?? 0));
                });

                if (r != null)
                {
                    gradientColour = r.Colour;
                }
                else
                {
                    gradientColour = Color.DarkGray;
                }

                using (var brush = new LinearGradientBrush(cellBounds,
                                                           gradientColour,
                                                           ExtentColour.LightBackgroundColour(gradientColour),
                                                           90F,
                                                           false))
                {
                    graphics.FillRectangle(brush,
                                           cellBounds.X + 2,
                                           cellBounds.Y + 3,
                                           (int)((cellBounds.Width - 6) * (Convert.ToDecimal(value) / 100)),
                                           cellBounds.Height - 8);
                }

                graphics.DrawRectangle(Pens.Gray, cellBounds.X + 2, cellBounds.Y + 3, cellBounds.Width - 6, cellBounds.Height - 8);

                cellText = string.Format("{0:0}%", Convert.ToDecimal(value));
            }
            else
            {
                cellText = "Pending...";
            }

            // Centre the text in the middle of the bar
            var textPoint = new Point(cellBounds.X + cellBounds.Width / 2 - (TextRenderer.MeasureText(cellText, font).Width / 2),
                                      cellBounds.Y + 4);

            TextRenderer.DrawText(graphics, cellText, font, textPoint, Color.Black);
        }