/// <summary>
        /// Finds a page.
        /// </summary>
        /// <param name="pageAddress">The page address.</param>
        /// <param name="findInverted">if set to <c>true</c> [find inverted].</param>
        /// <returns></returns>
        public AllocationLayer FindPage(PageAddress pageAddress, bool findInverted)
        {
            int extentAddress;

            extentAddress = pageAddress.PageId / 8;

            foreach (var alloc in allocations)
            {
                // Check if it's the actual IAM
                if (alloc.Pages.Exists(delegate(AllocationPage p) { return(p.PageAddress == pageAddress); }))
                {
                    return(this);
                }

                if (Allocation.CheckAllocationStatus(extentAddress, pageAddress.FileId, findInverted, alloc))
                {
                    return(this);
                }

                if (alloc.SinglePageSlots.Contains(pageAddress))
                {
                    return(this);
                }
            }

            return(null);
        }
Beispiel #2
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));
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Finds an allocated extent in the layer.
        /// </summary>
        /// <param name="extent">The extent.</param>
        /// <param name="fileId">The file id.</param>
        /// <param name="findInverted">if set to <c>true</c> [find inverted].</param>
        /// <returns></returns>
        public AllocationLayer FindExtent(int extent, int fileId, bool findInverted)
        {
            foreach (var alloc in allocations)
            {
                if (Allocation.CheckAllocationStatus(extent, fileId, findInverted, alloc))
                {
                    return(this);
                }
            }

            return(null);
        }