Example #1
0
        /// <summary>
        /// Draws the extents for each allocation layer
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        private void DrawExtents(PaintEventArgs e)
        {
            pageExtentRenderer.ResizeExtentBrush(ExtentSize);

            for (var extent = windowPosition;
                 extent < ExtentCount && extent < (VisibleExtents + windowPosition);
                 extent++)
            {
                foreach (var layer in MapLayers)
                {
                    if (layer.Visible && !layer.SingleSlotsOnly)
                    {
                        foreach (var chain in layer.Allocations)
                        {
                            var targetExtent = extent + (StartPage.PageId / 8);

                            if (Allocation.CheckAllocationStatus(targetExtent, FileId, layer.Invert, chain))
                            {
                                pageExtentRenderer.SetExtentBrushColour(layer.Colour,
                                                                        ExtentColour.BackgroundColour(layer.Colour));

                                pageExtentRenderer.DrawExtent(e.Graphics, ExtentPosition(extent - WindowPosition));
                            }
                        }
                    }
                }
            }
        }
Example #2
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #3
0
 protected override object GetFormattedValue(object value,
                                             int rowIndex,
                                             ref DataGridViewCellStyle cellStyle,
                                             TypeConverter valueTypeConverter,
                                             TypeConverter formattedValueTypeConverter,
                                             DataGridViewDataErrorContexts context)
 {
     if (value != DBNull.Value)
     {
         return(ExtentColour.KeyImage((Color)value));
     }
     else
     {
         return(null);
     }
 }
Example #4
0
        internal static Bitmap KeyImage(Color color)
        {
            var key         = new Bitmap(16, 16);
            var keyRectange = new Rectangle(0, 0, key.Width - 1, key.Height - 1);
            var g           = Graphics.FromImage(key);

            var brush = new LinearGradientBrush(keyRectange,
                                                color,
                                                ExtentColour.BackgroundColour(color),
                                                LinearGradientMode.Horizontal);

            g.FillRectangle(brush, keyRectange);
            g.DrawRectangle(SystemPens.ControlDark, keyRectange);

            return(key);
        }
Example #5
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);
        }
Example #6
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);
        }