public void Get_Bytes(
            VerticalHorizontalScrollType scrollType,
            PageAddress startPageAddress,
            FrameFrequencyType frameFrequencyType,
            PageAddress endPageAddress,
            byte verticalScrollingOffset,
            byte[] expectedBytes)
        {
            ContinuousVerticalAndHorizontalScrollSetup continuousVerticalAndHorizontalScrollSetup = new ContinuousVerticalAndHorizontalScrollSetup(
                scrollType,
                startPageAddress,
                frameFrequencyType,
                endPageAddress,
                verticalScrollingOffset);

            byte[] actualBytes = continuousVerticalAndHorizontalScrollSetup.GetBytes();
            Assert.Equal(expectedBytes, actualBytes);
        }
        /// <summary>
        /// This command consists of 6 consecutive bytes to set up the continuous vertical
        /// scroll parameters and determines the scrolling start page, end page, scrolling
        /// speed and vertical scrolling offset.
        /// </summary>
        /// <param name="scrollType">Vertical/Horizontal scroll type.</param>
        /// <param name="startPageAddress">Start page address with a range of 0-7.</param>
        /// <param name="frameFrequencyType">Frame frequency type with a range of 0-7.</param>
        /// <param name="endPageAddress">End page address with a range of 0-7.</param>
        /// <param name="verticalScrollingOffset">Vertical scrolling offset with a range of 0-63.</param>
        public ContinuousVerticalAndHorizontalScrollSetup(
            VerticalHorizontalScrollType scrollType,
            PageAddress startPageAddress,
            FrameFrequencyType frameFrequencyType,
            PageAddress endPageAddress,
            byte verticalScrollingOffset)
        {
            if (verticalScrollingOffset > 0x3F)
            {
                throw new ArgumentException("The vertical scrolling offset is invalid.", nameof(verticalScrollingOffset));
            }

            ScrollType              = scrollType;
            StartPageAddress        = startPageAddress;
            FrameFrequencyType      = frameFrequencyType;
            EndPageAddress          = endPageAddress;
            VerticalScrollingOffset = verticalScrollingOffset;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AllocationPage"/> class.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <param name="address">The page address.</param>
        public AllocationPage(Database database, PageAddress address)
            : base(database, address)
        {
            PageAddress = address;

            switch (Header.PageType)
            {
            case PageType.Bcm:
            case PageType.Dcm:
            case PageType.Iam:
            case PageType.Sgam:
            case PageType.Gam:
                LoadAllocationMap();
                break;

            default:
                throw new InvalidOperationException(Header.PageType + " is not an allocation page");
            }
        }
Beispiel #4
0
        public void RemovePage(PageAddress pageAddress)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                Page page = GetPage(pageAddress);

                if (page != null)
                {
                    if (repository.Remove(page.ID))
                    {
                        invalidateCachedPageForRemove(page);

                        transaction.Complete();

                        //pluginEngine.ExecuteAll("PageRemoved", new { context, page = new PageReadOnly(page) });

                        return;
                    }
                }
            }
        }
        /// <summary>
        /// Loads a page from a page address
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="pageAddress">The page address.</param>
        public void LoadPage(string connectionString, PageAddress pageAddress)
        {
            pageAddressToolStripStatusLabel.Text = string.Empty;
            offsetToolStripStatusLabel.Text      = string.Empty;

            if (pageAddress.FileId > 0)
            {
                var builder = new SqlConnectionStringBuilder(connectionString);

                ConnectionString = connectionString;

                Page = new Page(ConnectionString, builder.InitialCatalog, pageAddress);

                RefreshAllocationStatus(Page.PageAddress);

                pageToolStripTextBox.DatabaseId = Page.DatabaseId;

                serverToolStripStatusLabel.Text  = builder.DataSource;
                dataaseToolStripStatusLabel.Text = builder.InitialCatalog;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Loads the allocation map.
        /// </summary>
        private void LoadAllocationMap()
        {
            var allocationData = new byte[8000];
            int allocationArrayOffset;

            switch (Header.PageType)
            {
            case PageType.Gam:
            case PageType.Sgam:
            case PageType.Dcm:
            case PageType.Bcm:

                StartPage             = new PageAddress(Header.PageAddress.FileId, 0);
                allocationArrayOffset = AllocationArrayOffset;
                break;

            case PageType.Iam:

                allocationArrayOffset = AllocationArrayOffset;

                LoadIamHeader();
                LoadSinglePageSlots();

                break;

            default:
                return;
            }

            Array.Copy(PageData,
                       allocationArrayOffset,
                       allocationData,
                       0,
                       allocationData.Length - (Header.SlotCount * 2));

            var bitArray = new BitArray(allocationData);

            bitArray.CopyTo(AllocationMap, 0);
        }
        /// <summary>
        /// Writes the allocation bytes directly to the bitmap data
        /// </summary>
        /// <param name="bitmap">The bitmap.</param>
        /// <param name="allocation">The allocation structure.</param>
        /// <param name="startPage">The start page.</param>
        /// <param name="fileSize">Size of the file.</param>
        /// <param name="colour">The layer colour.</param>
        private static void AddAllocationToBitmap(Bitmap bitmap, bool[] allocation, PageAddress startPage, int fileSize, Color colour)
        {
            var startExtent = startPage.PageId / 8;

            var bytesPerExtent = 3; // R, G, B bytes

            var bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                                             ImageLockMode.ReadWrite,
                                             bitmap.PixelFormat);

            var ptr = bitmapData.Scan0;

            var values = new byte[fileSize * bytesPerExtent];

            // Copy the bitmap data into a managed array
            Marshal.Copy(ptr, values, 0, fileSize * bytesPerExtent);

            var extent = startExtent;

            for (var i = startExtent * bytesPerExtent;
                 i < Math.Min(values.Length, (startExtent + allocation.Length) * bytesPerExtent);
                 i += bytesPerExtent)
            {
                // If it's allocated set the B G R values to the colour (else leave them as is)
                if (allocation[extent - startExtent])
                {
                    values[i]     = colour.B;
                    values[i + 1] = colour.G;
                    values[i + 2] = colour.R;
                }

                extent++;
            }

            // Copy the managed array back into the bitmap data
            Marshal.Copy(values, 0, ptr, fileSize * bytesPerExtent);

            bitmap.UnlockBits(bitmapData);
        }
        /// <summary>
        /// Sets the PFS page to be displayed
        /// </summary>
        /// <param name="pageAddress">The page address.</param>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="connectionString">The connection string.</param>
        public void SetPfsPage(PageAddress pageAddress, string databaseName, string connectionString)
        {
            topPanel.Visible = false;

            var pfsPage = new PfsPage(connectionString, databaseName, pageAddress);

            allocationMap.Mode = MapMode.Pfs;

            allocationMap.Pfs         = new Pfs(pfsPage);
            allocationMap.ExtentCount = 1011;
            allocationMap.ExtentSize  = AllocationMap.Large;

            if (pfsPage.PageAddress.PageId > 1)
            {
                allocationMap.StartPage = pfsPage.PageAddress;
            }
            else
            {
                allocationMap.StartPage = new PageAddress(pfsPage.PageAddress.FileId, 0);
            }

            allocationMap.Invalidate();
        }
        /// <summary>
        /// Refreshes the allocation status from the various allocation pages
        /// </summary>
        /// <param name="pageAddress">The page address.</param>
        private void RefreshAllocationStatus(PageAddress pageAddress)
        {
            Image unallocated   = ExtentColour.KeyImage(Color.Gainsboro);
            Image gamAllocated  = ExtentColour.KeyImage(Color.FromArgb(172, 186, 214));
            Image sGamAllocated = ExtentColour.KeyImage(Color.FromArgb(168, 204, 162));
            Image dcmAllocated  = ExtentColour.KeyImage(Color.FromArgb(120, 150, 150));
            Image bcmAllocated  = ExtentColour.KeyImage(Color.FromArgb(150, 120, 150));

            gamPictureBox.Image  = Page.AllocationStatus(PageType.Gam) ? unallocated : gamAllocated;
            sGamPictureBox.Image = Page.AllocationStatus(PageType.Sgam) ? sGamAllocated : unallocated;
            dcmPictureBox.Image  = Page.AllocationStatus(PageType.Dcm) ? dcmAllocated : unallocated;
            bcmPictureBox.Image  = Page.AllocationStatus(PageType.Bcm) ? bcmAllocated : unallocated;

            gamTextBox.Text  = Allocation.AllocationPageAddress(pageAddress, PageType.Gam).ToString();
            sgamTextBox.Text = Allocation.AllocationPageAddress(pageAddress, PageType.Sgam).ToString();
            dcmTextBox.Text  = Allocation.AllocationPageAddress(pageAddress, PageType.Dcm).ToString();
            bcmTextBox.Text  = Allocation.AllocationPageAddress(pageAddress, PageType.Bcm).ToString();
            pfsTextBox.Text  = Allocation.AllocationPageAddress(pageAddress, PageType.Pfs).ToString();

            pfsByte = Page.PfsStatus();

            pfsPanel.Invalidate();
        }
Beispiel #10
0
        /// <summary>
        /// Returns the entry points for a HOBT
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="database">The database.</param>
        /// <param name="objectName">Name of the object.</param>
        /// <param name="indexName">Name of the index.</param>
        /// <returns></returns>
        public static List <HobtEntryPoint> EntryPoints(string connectionString, string database, string objectName, string indexName)
        {
            var entryPoints = new List <HobtEntryPoint>();

            var entryPointDataTable = DataAccess.GetDataTable(connectionString,
                                                              Properties.Resources.SQL_EntryPoints,
                                                              database,
                                                              string.Empty,
                                                              CommandType.Text,
                                                              new[] { new SqlParameter("ObjectName", objectName),
                                                                      new SqlParameter("IndexName", indexName) });

            foreach (DataRow row in entryPointDataTable.Rows)
            {
                var firstIam        = new PageAddress((byte[])row["first_iam_page"]);
                var rootPage        = new PageAddress((byte[])row["root_page"]);
                var firstPage       = new PageAddress((byte[])row["first_page"]);
                var partitionNumber = Convert.ToInt32(row["partition_number"]);

                entryPoints.Add(new HobtEntryPoint(firstIam, rootPage, firstPage, partitionNumber));
            }

            return(entryPoints);
        }
Beispiel #11
0
 /// <summary>
 /// This triple byte command specifies page start address and end address of the display data RAM.
 /// This command also sets the page address pointer to page start address. This pointer is used to
 /// define the current read/write page address in graphic display data RAM. If vertical address
 /// increment mode is enabled by command 20h, after finishing read/write one page data, it is
 /// incremented automatically to the next page address. Whenever the page address pointer finishes
 /// accessing the end page address, it is reset back to start page address.
 /// This command is only for horizontal or vertical addressing modes.
 /// </summary>
 /// <param name="startAddress">Page start address with a range of 0-7.</param>
 /// <param name="endAddress">Page end address with a range of 0-7.</param>
 public SetPageAddress(PageAddress startAddress = PageAddress.Page0, PageAddress endAddress = PageAddress.Page7)
 {
     StartAddress = startAddress;
     EndAddress   = endAddress;
 }
Beispiel #12
0
        private const int           BH_PAGE_ADDRESS            = 1; // 1-4 PageAddress 6 byte

        public BlockHeader(PageAddress pageAddress, bool isFollowingBlock)
        {
            NextBlockAddress = pageAddress;
            IsFollowingBlock = isFollowingBlock;
        }
Beispiel #13
0
 public void Write(PageAddress value)
 {
     this.Write(value.PageID);
     this.Write(value.Index);
 }
        /// <summary>
        /// Handles the Click event of various text boxes with page addresses
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void PageAddressTextBox_Click(object sender, EventArgs e)
        {
            var pageAddress = PageAddress.Parse((sender as TextBox).Text);

            OnPageClicked(sender, new PageEventArgs(new RowIdentifier(pageAddress, 0), false));
        }
Beispiel #15
0
 void CopyCommandToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.SetText(PageAddress.Parse(Text).ToString());
 }
Beispiel #16
0
 public void SetFollowingBlock(PageAddress pageAddress)
 {
     Header = new BlockHeader(pageAddress, Header.IsFollowingBlock);
     Header.ToBuffer(Page.GetDataByIndex(_entryId));
 }
Beispiel #17
0
 private void Option3ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CopyDbccPageToClipboard(3, PageAddress.Parse(Text));
 }
Beispiel #18
0
        public void CopyDbccPageToClipboard(int option, PageAddress address)
        {
            var text = string.Format(Properties.Resources.SQL_CopyDbccPage, DatabaseId, address.FileId, address.PageId, option);

            Clipboard.SetText(text);
        }
Beispiel #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Allocation"/> class.
 /// </summary>
 /// <param name="database">The database.</param>
 /// <param name="pageAddress">The page address.</param>
 public Allocation(Database database, PageAddress pageAddress)
 {
     FileId    = pageAddress.FileId;
     MultiFile = false;
     BuildChain(database, pageAddress);
 }
Beispiel #20
0
 public DataBlock(DataPage page, byte entryId, PageAddress nextBlock, bool isFollowingBlock) : base(page, entryId, nextBlock, isFollowingBlock)
 {
 }
Beispiel #21
0
        public void LoadPage(string connectionString, PageAddress pageAddress)
        {
            Caption = $"Page {pageAddress.ToString()}";

            PageViewerWindow.LoadPage(connectionString, pageAddress);
        }
Beispiel #22
0
        public static void Create(Canvas p, Thickness m)
        {
            if (sv != null)
            {
                sv.Show();
                ReSize(m);
                return;
            }
            task1 = load1 = false;
            WebClass.TaskGet("http://m.v.qq.com/index.html", (o) => {
                data1 = o;
                if (task1)
                {
                    ParseData.AnalyzeData(o.ToCharArray(), ref sv.area);
                    sv.Refresh();
                }
                else
                {
                    load1 = true;
                }
            });
            margin = m;
            sv     = new Scroll_ex();
#if desktop
            sv.maxcolumn = 5;
#else
            sv.maxcolumn = 4;
            sv.Lock      = MainEx.LockPivot;
            sv.UnLock    = MainEx.UnLockPivot;
#endif
            sv.UsingCustomTitle = true;
            sv.ForceUpdateOnce  = true;
            sv.area             = new Area_m[nav_all.Length];
            sv.ItemClick        = (o) => {
                if (o != null)
                {
                    VideoPage.SetAdress(o as string);
                    PageManageEx.CreateNewPage(PageTag.videopage);
                }
            };
            sv.PageClick = (o) => {
                PageAddress t = (PageAddress)o;
                if (t != PageAddress.None)
                {
                    PartialNav.LoadPage(t);
                    PageManageEx.CreateNewPage(PageTag.partial);
                }
            };
            for (int i = 0; i < nav_all.Length; i++)
            {
                int c = nav_all[i].count;
                sv.area[i].page  = nav_all[i].page;
                sv.area[i].title = nav_all[i].title;
                sv.area[i].count = c;
                sv.area[i].data  = new ItemData_m[c];
            }
            sv.ReSize(m);
            sv.SetParent(p);
            task1 = true;
            if (load1)
            {
                ParseData.AnalyzeData(data1.ToCharArray(), ref sv.area);
                sv.Refresh();
                load1 = false;
            }
        }
Beispiel #23
0
        /// <summary>
        /// Generates map layers by loading object's allocation structures
        /// </summary>
        /// <param name="database">The database.</param>
        /// <param name="worker">The backgroundWorker object.</param>
        /// <returns></returns>
        public static List <AllocationLayer> GenerateLayers(Database database, BackgroundWorker worker, bool separateIndexes, bool separateSystemObjects)
        {
            var             layers             = new List <AllocationLayer>();
            AllocationLayer layer              = null;
            var             colourIndex        = 0;
            var             count              = 0;
            var             systemColourIndex  = 0;
            var             previousObjectName = string.Empty;

            var allocationUnits = database.AllocationUnits();

            string filter;

            if (separateIndexes)
            {
                filter = "allocation_unit_type=1 AND index_id < 2";
            }
            else
            {
                filter = string.Empty;
            }

            var userObjectCount = (int)allocationUnits.Compute("COUNT(table_name)", filter + " AND system=0");   // "allocation_unit_type=1 AND system=0 AND index_id < 2");

            var systemObjectCount = (int)allocationUnits.Compute("COUNT(table_name)", filter + " AND system=1"); //, "allocation_unit_type=1 AND system=1 AND index_id < 2");

            foreach (DataRow row in allocationUnits.Rows)
            {
                if (worker.CancellationPending)
                {
                    return(null);
                }

                count++;

                string currentObjectName;

                if ((bool)row["system"] && !separateSystemObjects)
                {
                    currentObjectName = "(System object)";
                }
                else
                {
                    if (separateIndexes && !string.IsNullOrEmpty(row["index_name"].ToString()))
                    {
                        currentObjectName = row["schema_name"] + "." + row["table_name"] + "." + row["index_name"];
                    }
                    else
                    {
                        currentObjectName = row["schema_name"] + "." + row["table_name"];
                    }
                }

                if (currentObjectName != previousObjectName)
                {
                    layer = new AllocationLayer();

                    layer.Name       = currentObjectName;
                    layer.ObjectName = row["schema_name"] + "." + row["table_name"];

                    if (!Convert.ToBoolean(row["system"]))
                    {
                        layer.IndexName  = row["index_name"].ToString();
                        layer.UsedPages  = Convert.ToInt32(row["used_pages"]);
                        layer.TotalPages = Convert.ToInt32(row["total_pages"]);
                        layer.IndexType  = (IndexTypes)Convert.ToInt32(row["index_type"]);
                    }

                    layer.UseDefaultSinglePageColour = false;

                    if ((bool)row["system"])
                    {
                        if (layer.Name != previousObjectName)
                        {
                            systemColourIndex += (int)Math.Floor(ColourCount / (double)systemObjectCount);

                            if (colourIndex >= ColourCount)
                            {
                                colourIndex = 1;
                            }
                        }

                        layer.Colour = Color.FromArgb(255, 190, 190, 205);
                    }
                    else
                    {
                        if (layer.Name != previousObjectName)
                        {
                            if (userObjectCount > ColourCount)
                            {
                                colourIndex += 1;
                            }
                            else
                            {
                                colourIndex += (int)Math.Floor(ColourCount / (double)userObjectCount);
                            }
                        }

                        layer.Colour = HsvColour.HsvToColor(colourIndex, UserSaturation, UserValue);
                    }

                    layers.Add(layer);
                }

                var address = new PageAddress((byte[])row["first_iam_page"]);

                if (address.PageId > 0)
                {
                    if (layer != null)
                    {
                        layer.Allocations.Add(new IamAllocation(database, address));
                    }
                }

                if (layer != null)
                {
                    previousObjectName = layer.Name;
                }

                worker.ReportProgress((int)(count / (float)allocationUnits.Rows.Count * 100), layer.Name);
            }

            return(layers);
        }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PageReader"/> class.
 /// </summary>
 /// <param name="pageAddress">The page address.</param>
 /// <param name="databaseId">The database id.</param>
 protected PageReader(PageAddress pageAddress, int databaseId)
 {
     PageAddress = pageAddress;
     DatabaseId  = databaseId;
 }
Beispiel #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IamAllocation"/> class.
 /// </summary>
 /// <param name="database">The database.</param>
 /// <param name="pageAddress">The page address.</param>
 public IamAllocation(Database database, PageAddress pageAddress)
     : base(database, pageAddress)
 {
     MultiFile = true;
 }
Beispiel #26
0
 public AllocationPage(string connectionString, string database, PageAddress pageAddress)
     : base(connectionString, database, pageAddress)
 {
     LoadAllocationMap();
 }
Beispiel #27
0
 /// <summary>
 /// This command positions the page start address from 0 to 7 in GDDRAM under Page Addressing Mode.
 /// </summary>
 /// <param name="startAddress">Page start address with a range of 0-7.</param>
 public SetPageStartAddressForPageAddressingMode(PageAddress startAddress = PageAddress.Page0)
 {
     StartAddress = startAddress;
 }
Beispiel #28
0
 public Page GetPage(PageAddress pageAddress)
 {
     return(repository.GetPage(context.Site.ID, pageAddress.Slug));
 }
Beispiel #29
0
        public void Get_Bytes(HorizontalScrollType scrollType, PageAddress startPageAddress, FrameFrequencyType frameFrequencyType, PageAddress endPageAddress, byte[] expectedBytes)
        {
            HorizontalScrollSetup horizontalScrollSetup = new HorizontalScrollSetup(
                scrollType,
                startPageAddress,
                frameFrequencyType,
                endPageAddress);

            byte[] actualBytes = horizontalScrollSetup.GetBytes();
            Assert.Equal(expectedBytes, actualBytes);
        }
Beispiel #30
0
        /// <summary>
        /// Returns a page address for the allocation page that corresponds to a page address and allocation page type
        /// </summary>
        /// <param name="pageAddress">The page address.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns></returns>
        public static PageAddress AllocationPageAddress(PageAddress pageAddress, PageType pageType)
        {
            int pageId;

            switch (pageType)
            {
            case PageType.Pfs:

                if (pageAddress.PageId < Database.PfsInterval)
                {
                    return(new PageAddress(pageAddress.FileId, 1));
                }
                else
                {
                    pageId = (pageAddress.PageId / Database.PfsInterval) * Database.PfsInterval;

                    return(new PageAddress(pageAddress.FileId, pageId));
                }

            default:

                if (pageAddress.PageId < Database.AllocationInterval)
                {
                    pageId = 2;

                    switch (pageType)
                    {
                    case PageType.Sgam:

                        pageId += 1;
                        break;

                    case PageType.Dcm:

                        pageId += 4;
                        break;

                    case PageType.Bcm:

                        pageId += 5;
                        break;
                    }
                }
                else
                {
                    pageId = (pageAddress.PageId / Database.AllocationInterval) * Database.AllocationInterval;

                    switch (pageType)
                    {
                    case PageType.Sgam:

                        pageId += 1;
                        break;

                    case PageType.Dcm:

                        pageId += 6;
                        break;

                    case PageType.Bcm:

                        pageId += 7;
                        break;
                    }
                }

                return(new PageAddress(pageAddress.FileId, pageId));
            }
        }