Пример #1
0
        private void UpdateGameGrid(RvDir tDir)
        {


            lblDITName.Text = tDir.Name;
            if (tDir.Dat != null)
            {
                RvDat tDat = tDir.Dat;
                lblDITDescription.Text = tDat.GetData(RvDat.DatData.Description);
                lblDITCategory.Text = tDat.GetData(RvDat.DatData.Category);
                lblDITVersion.Text = tDat.GetData(RvDat.DatData.Version);
                lblDITAuthor.Text = tDat.GetData(RvDat.DatData.Author);
                lblDITDate.Text = tDat.GetData(RvDat.DatData.Date);
            }
            else if (tDir.DirDatCount == 1)
            {
                RvDat tDat = tDir.DirDat(0);
                lblDITDescription.Text = tDat.GetData(RvDat.DatData.Description);
                lblDITCategory.Text = tDat.GetData(RvDat.DatData.Category);
                lblDITVersion.Text = tDat.GetData(RvDat.DatData.Version);
                lblDITAuthor.Text = tDat.GetData(RvDat.DatData.Author);
                lblDITDate.Text = tDat.GetData(RvDat.DatData.Date);
            }
            else
            {
                lblDITDescription.Text = "";
                lblDITCategory.Text = "";
                lblDITVersion.Text = "";
                lblDITAuthor.Text = "";
                lblDITDate.Text = "";
            }



            lblDITPath.Text = tDir.FullName;


            lblDITRomsGot.Text = tDir.DirStatus.CountCorrect().ToString(CultureInfo.InvariantCulture);
            lblDITRomsMissing.Text = tDir.DirStatus.CountMissing().ToString(CultureInfo.InvariantCulture);
            lblDITRomsFixable.Text = tDir.DirStatus.CountFixesNeeded().ToString(CultureInfo.InvariantCulture);
            lblDITRomsUnknown.Text = (tDir.DirStatus.CountUnknown() + tDir.DirStatus.CountInToSort()).ToString(CultureInfo.InvariantCulture);

            _updatingGameGrid = true;

            if (Settings.IsMono)
            {
                if (GameGrid.RowCount > 0)
                    GameGrid.CurrentCell = GameGrid[0,0];
                if (RomGrid.RowCount > 0)
                    RomGrid.CurrentCell = RomGrid[0,0];
            }

            GameGrid.Rows.Clear();
            RomGrid.Rows.Clear();

            // clear sorting
            GameGrid.Columns[_gameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None;
            _gameGridSortColumnIndex = 0;
            _gameGridSortOrder = SortOrder.Descending;


            ReportStatus tDirStat;

            _gameGridColumnXPositions = new int[(int)RepStatus.EndValue];

            int rowCount = 0;
            for (int j = 0; j < tDir.ChildCount; j++)
            {

                RvDir tChildDir = tDir.Child(j) as RvDir;
                if (tChildDir == null) continue;

                tDirStat = tChildDir.DirStatus;

                bool gCorrect = tDirStat.HasCorrect();
                bool gMissing = tDirStat.HasMissing();
                bool gUnknown = tDirStat.HasUnknown();
                bool gInToSort = tDirStat.HasInToSort();
                bool gFixes = tDirStat.HasFixesNeeded();

                bool show = (chkBoxShowCorrect.Checked && gCorrect && !gMissing && !gFixes);
                show = show || (chkBoxShowMissing.Checked && gMissing);
                show = show || (chkBoxShowFixed.Checked && gFixes);
                show = show || (gUnknown);
                show = show || (gInToSort);
                show = show || (tChildDir.GotStatus == GotStatus.Corrupt);
                show = show || !(gCorrect || gMissing || gUnknown || gInToSort || gFixes);

                if (!show) continue;

                rowCount++;

                int columnIndex = 0;
                for (int l = 0; l < RepairStatus.DisplayOrder.Length; l++)
                {
                    if (l >= 13) columnIndex = l;

                    if (tDirStat.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;

                    int len = DigitLength(tDirStat.Get(RepairStatus.DisplayOrder[l])) * 7 + 26;
                    if (len > _gameGridColumnXPositions[columnIndex])
                        _gameGridColumnXPositions[columnIndex] = len;
                    columnIndex++;
                }
            }
            GameGrid.RowCount = rowCount;

            int t = 0;
            for (int l = 0; l < (int)RepStatus.EndValue; l++)
            {
                int colWidth = _gameGridColumnXPositions[l];
                _gameGridColumnXPositions[l] = t;
                t += colWidth;
            }

            int row = 0;
            for (int j = 0; j < tDir.ChildCount; j++)
            {
                RvDir tChildDir = tDir.Child(j) as RvDir;
                if (tChildDir == null) continue;

                tDirStat = tChildDir.DirStatus;

                bool gCorrect = tDirStat.HasCorrect();
                bool gMissing = tDirStat.HasMissing();
                bool gUnknown = tDirStat.HasUnknown();
                bool gFixes = tDirStat.HasFixesNeeded();
                bool gInToSort = tDirStat.HasInToSort();

                bool show = (chkBoxShowCorrect.Checked && gCorrect && !gMissing && !gFixes);
                show = show || (chkBoxShowMissing.Checked && gMissing);
                show = show || (chkBoxShowFixed.Checked && gFixes);
                show = show || (gUnknown);
                show = show || (gInToSort);
                show = show || (tChildDir.GotStatus == GotStatus.Corrupt);
                show = show || !(gCorrect || gMissing || gUnknown || gInToSort || gFixes);

                if (!show) continue;
               
                GameGrid.Rows[row].Selected = false;
                GameGrid.Rows[row].Tag = tChildDir;
                row++;
            }

            _updatingGameGrid = false;

            UpdateRomGrid(tDir);
        }
Пример #2
0
        private static void RemoveOldDats(RvBase dbDir, RvDir tmpDir)
        {
            // now compare the old and new dats removing any old dats
            // in the current directory

            RvDir lDir = dbDir as RvDir;
            if (lDir == null) return;

            int dbIndex = 0;
            int scanIndex = 0;

            while (dbIndex < lDir.DirDatCount || scanIndex < tmpDir.DirDatCount)
            {
                RvDat dbDat = null;
                RvDat fileDat = null;
                int res = 0;

                if (dbIndex < lDir.DirDatCount && scanIndex < tmpDir.DirDatCount)
                {
                    dbDat = lDir.DirDat(dbIndex);
                    fileDat = tmpDir.DirDat(scanIndex);
                    res = DBHelper.DatCompare(dbDat, fileDat);
                }
                else if (scanIndex < tmpDir.DirDatCount)
                {
                    //this is a new dat that we have now found at the end of the list
                    //fileDat = tmpDir.DirDat(scanIndex);
                    res = 1;
                }
                else if (dbIndex < lDir.DirDatCount)
                {
                    dbDat = lDir.DirDat(dbIndex);
                    res = -1;
                }

                switch (res)
                {
                    case 0:
                        dbDat.Status = DatUpdateStatus.Correct;
                        dbIndex++;
                        scanIndex++;
                        break;

                    case 1:
                        // this is a new dat that we will add next time around
                        scanIndex++;
                        break;
                    case -1:
                        dbDat.Status = DatUpdateStatus.Delete;
                        lDir.DirDatRemove(dbIndex);
                        break;
                }

            }

            // now scan the child directory structure of this directory
            dbIndex = 0;
            scanIndex = 0;

            while (dbIndex < lDir.ChildCount || scanIndex < tmpDir.ChildCount)
            {
                RvBase dbChild = null;
                RvBase fileChild = null;
                int res = 0;

                if (dbIndex < lDir.ChildCount && scanIndex < tmpDir.ChildCount)
                {
                    dbChild = lDir.Child(dbIndex);
                    fileChild = tmpDir.Child(scanIndex);
                    res = DBHelper.CompareName(dbChild, fileChild);
                }
                else if (scanIndex < tmpDir.ChildCount)
                {
                    //found a new directory on the end of the list
                    //fileChild = tmpDir.Child(scanIndex);
                    res = 1;
                }
                else if (dbIndex < lDir.ChildCount)
                {
                    dbChild = lDir.Child(dbIndex);
                    res = -1;
                }
                switch (res)
                {
                    case 0:
                        // found a matching directory in DATRoot So recurse back into it
                        RemoveOldDats(dbChild, (RvDir)fileChild);
                        dbIndex++;
                        scanIndex++;
                        break;

                    case 1:
                        // found a new directory will be added later
                        scanIndex++;
                        break;
                    case -1:
                        if (dbChild.FileType == FileType.Dir && dbChild.Dat == null)
                            RemoveOldDats(dbChild, new RvDir(FileType.Dir));
                        dbIndex++;
                        break;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Add the new DAT's into the DAT list
        /// And merge in the new DAT data into the database
        /// </summary>
        /// <param name="dbDir">The Current database dir</param>
        /// <param name="tmpDir">A temp directory containing the DAT found in this directory in DATRoot</param>
        private static void AddNewDats(RvDir dbDir, RvDir tmpDir)
        {
            bool autoAddDirectory = (tmpDir.DirDatCount) > 1;

            int dbIndex = 0;
            int scanIndex = 0;

            Debug.WriteLine("");
            Debug.WriteLine("Scanning for Adding new DATS");
            while (dbIndex < dbDir.DirDatCount || scanIndex < tmpDir.DirDatCount)
            {
                RvDat dbDat = null;
                RvDat fileDat = null;
                int res = 0;

                if (dbIndex < dbDir.DirDatCount && scanIndex < tmpDir.DirDatCount)
                {
                    dbDat = dbDir.DirDat(dbIndex);
                    fileDat = tmpDir.DirDat(scanIndex);
                    res = DBHelper.DatCompare(dbDat, fileDat);
                    Debug.WriteLine("Checking " + dbDat.GetData(RvDat.DatData.DatFullName) + " : and " + fileDat.GetData(RvDat.DatData.DatFullName) + " : " + res);
                }
                else if (scanIndex < tmpDir.DirDatCount)
                {
                    fileDat = tmpDir.DirDat(scanIndex);
                    res = 1;
                    Debug.WriteLine("Checking : and " + fileDat.GetData(RvDat.DatData.DatFullName) + " : " + res);
                }
                else if (dbIndex < dbDir.DirDatCount)
                {
                    dbDat = dbDir.DirDat(dbIndex);
                    res = -1;
                    Debug.WriteLine("Checking " + dbDat.GetData(RvDat.DatData.DatFullName) + " : and : " + res);
                }

                switch (res)
                {
                    case 0:
                        _datsProcessed++;
                        _bgw.ReportProgress(_datsProcessed);
                        _bgw.ReportProgress(0, new bgwText("Dat : " + Path.GetFileNameWithoutExtension(fileDat.GetData(RvDat.DatData.DatFullName))));

                        Debug.WriteLine("Correct");
                        // Should already be set as correct above
                        dbDat.Status = DatUpdateStatus.Correct;
                        dbIndex++;
                        scanIndex++;
                        break;

                    case 1:
                        _datsProcessed++;
                        _bgw.ReportProgress(_datsProcessed);
                        _bgw.ReportProgress(0, new bgwText("Scanning New Dat : " + Path.GetFileNameWithoutExtension(fileDat.GetData(RvDat.DatData.DatFullName))));

                        Debug.WriteLine("Adding new DAT");
                        if (UpdateDatFile(fileDat, autoAddDirectory, dbDir))
                            dbIndex++;
                        scanIndex++;
                        break;

                    case -1:
                        // This should not happen as deleted dat have been removed above
                        //dbIndex++;
                        ReportError.SendAndShow(Resources.DatUpdate_UpdateDatList_ERROR_Deleting_a_DAT_that_should_already_be_deleted);
                        break;
                }

            }
        }
Пример #4
0
        private static bool RecursiveDatTree(RvDir tDir, out int datCount)
        {
            datCount = 0;
            string strPath = tDir.DatFullName;

            if (!Directory.Exists(strPath))
            {
                ReportError.Show(Resources.DatUpdate_UpdateDatList_Path + strPath + Resources.DatUpdate_UpdateDatList_Not_Found);
                return false;
            }

            DirectoryInfo oDir = new DirectoryInfo(strPath);

            FileInfo[] oFilesIn = oDir.GetFiles("*.dat", false);
            datCount += oFilesIn.Length;
            foreach (FileInfo file in oFilesIn)
            {
                RvDat tDat = new RvDat();
                tDat.AddData(RvDat.DatData.DatFullName, file.FullName);
                tDat.TimeStamp = file.LastWriteTime;
                tDir.DirDatAdd(tDat);
            }

            oFilesIn = oDir.GetFiles("*.xml", false);
            datCount += oFilesIn.Length;
            foreach (FileInfo file in oFilesIn)
            {
                RvDat tDat = new RvDat();
                tDat.AddData(RvDat.DatData.DatFullName, file.FullName);
                tDat.TimeStamp = file.LastWriteTime;
                tDir.DirDatAdd(tDat);
            }

            if (tDir.DirDatCount > 1)
                for (int i = 0; i < tDir.DirDatCount; i++)
                    tDir.DirDat(i).AutoAddDirectory = true;

            DirectoryInfo[] oSubDir = oDir.GetDirectories(false);

            foreach (DirectoryInfo t in oSubDir)
            {
                RvDir cDir = new RvDir(FileType.Dir) { Name = t.Name, DatStatus = DatStatus.InDatCollect };
                int index = tDir.ChildAdd(cDir);

                int retDatCount;

                RecursiveDatTree(cDir, out retDatCount);
                datCount += retDatCount;

                if (retDatCount == 0)
                    tDir.ChildRemove(index);
            }

            return true;
        }
Пример #5
0
        private void PaintTree(RvDir pTree, Graphics g, Rectangle t)
        {
            int y = pTree.Tree.RTree.Top - _vScroll;

            if (pTree.Tree.RTree.IntersectsWith(t))
            {
                Pen p = new Pen(Brushes.Gray, 1) { DashStyle = DashStyle.Dot };

                string lTree = pTree.Tree.TreeBranches;
                for (int j = 0; j < lTree.Length; j++)
                {
                    int x = j * 18 - _hScroll;
                    string cTree = lTree.Substring(j, 1);
                    switch (cTree)
                    {
                        case "│":
                            g.DrawLine(p, x + 9, y, x + 9, y + 16);
                            break;

                        case "├":
                        case "└":
                            g.DrawLine(p, x + 9, y, x + 9, y + 16);
                            g.DrawLine(p, x + 9, y + 16, x + 27, y + 16);
                            break;
                    }
                }
            }

            if (!pTree.Tree.RExpand.IsEmpty)
                if (pTree.Tree.RExpand.IntersectsWith(t))
                {
                    g.DrawImage(pTree.Tree.TreeExpanded ? rvImages.ExpandBoxMinus : rvImages.ExpandBoxPlus, RSub(pTree.Tree.RExpand, _hScroll, _vScroll));
                }

            if (pTree.Tree.RChecked.IntersectsWith(t))
            {
                switch (pTree.Tree.Checked)
                {
                    case RvTreeRow.TreeSelect.Disabled:
                        g.DrawImage(rvImages.TickBoxDisabled, RSub(pTree.Tree.RChecked, _hScroll, _vScroll));
                        break;
                    case RvTreeRow.TreeSelect.UnSelected:
                        g.DrawImage(rvImages.TickBoxUnTicked, RSub(pTree.Tree.RChecked, _hScroll, _vScroll));
                        break;
                    case RvTreeRow.TreeSelect.Selected:
                        g.DrawImage(rvImages.TickBoxTicked, RSub(pTree.Tree.RChecked, _hScroll, _vScroll));
                        break;
                }
            }

            if (pTree.Tree.RIcon.IntersectsWith(t))
            {
                int icon = 2;
                if (pTree.DirStatus.HasInUnsorted())
                {
                    icon = 4;
                }
                else if (!pTree.DirStatus.HasCorrect())
                {
                    icon = 1;
                }
                else if (!pTree.DirStatus.HasMissing())
                {
                    icon = 3;
                }

                Bitmap bm;
                if (pTree.Dat == null && pTree.DirDatCount != 1) // Directory above DAT's in Tree
                    bm = rvImages.GetBitmap("DirectoryTree" + icon);
                else if (pTree.Dat == null && pTree.DirDatCount == 1) // Directory that contains DAT's
                    bm = rvImages.GetBitmap("Tree" + icon);
                else if (pTree.Dat != null && pTree.DirDatCount == 0) // Directories made by a DAT
                    bm = rvImages.GetBitmap("Tree" + icon);
                else
                {
                    ReportError.SendAndShow("Unknown Tree settings in DisplayTree.");
                    bm = null;
                }

                if (bm != null)
                {
                    g.DrawImage(bm, RSub(pTree.Tree.RIcon, _hScroll, _vScroll));
                }
            }

            Rectangle recBackGround = new Rectangle(pTree.Tree.RText.X, pTree.Tree.RText.Y, Width - pTree.Tree.RText.X + _hScroll, pTree.Tree.RText.Height);

            if (recBackGround.IntersectsWith(t))
            {
                string thistxt;

                if (pTree.Dat == null && pTree.DirDatCount != 1) // Directory above DAT's in Tree
                    thistxt = pTree.Name;
                else if (pTree.Dat == null && pTree.DirDatCount == 1) // Directory that contains DAT's
                    thistxt = pTree.Name + ": " + pTree.DirDat(0).GetData(RvDat.DatData.Description) + " ( Have:" + pTree.DirStatus.CountCorrect() + " \\ Missing: " + pTree.DirStatus.CountMissing() + " )";

                // pTree.Parent.DirDatCount>1: This should probably be a test like parent contains Dat
                else if (pTree.Dat != null && pTree.Dat.AutoAddDirectory && pTree.Parent.DirDatCount > 1)
                    thistxt = pTree.Name + ": " + pTree.Dat.GetData(RvDat.DatData.Description) + " ( Have:" + pTree.DirStatus.CountCorrect() + " \\ Missing: " + pTree.DirStatus.CountMissing() + " )";
                else if (pTree.Dat != null && pTree.DirDatCount == 0) // Directories made by a DAT
                    thistxt = pTree.Name + " ( Have:" + pTree.DirStatus.CountCorrect() + " \\ Missing: " + pTree.DirStatus.CountMissing() + " )";
                else
                {
                    ReportError.SendAndShow("Unknown Tree settings in DisplayTree.");
                    thistxt = "";
                }

                if (_lSelected != null && pTree.TreeFullName == _lSelected.TreeFullName)
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(51, 153, 255)), RSub(recBackGround, _hScroll, _vScroll));
                    g.DrawString(thistxt, new Font("Microsoft Sans Serif", 8), Brushes.White, pTree.Tree.RText.Left - _hScroll, pTree.Tree.RText.Top + 1 - _vScroll);
                }
                else
                {
                    g.DrawString(thistxt, new Font("Microsoft Sans Serif", 8), Brushes.Black, pTree.Tree.RText.Left - _hScroll, pTree.Tree.RText.Top + 1 - _vScroll);
                }
            }

            if (pTree.Tree.TreeExpanded)
                for (int i = 0; i < pTree.ChildCount; i++)
                {
                    RvBase tBase = pTree.Child(i);
                    if (tBase is RvDir)
                    {
                        RvDir tDir = (RvDir)tBase;
                        if (tDir.Tree != null)
                            PaintTree(tDir, g, t);
                    }
                }
        }