示例#1
0
文件: frmMain.cs 项目: vidarw/RVWorld
        private void DirTree_RvSelected(object sender, MouseEventArgs e)
        {
            RvTreeRow tr = (RvTreeRow)sender;

            Debug.WriteLine(tr.dirFullName);
            updateSelectedTreeRow(tr);
        }
示例#2
0
 public frmMain()
 {
     InitializeComponent();
     addGameGrid();
     DataAccessLayer.UpdateGotTotal();
     DirTree.Setup(RvTreeRow.ReadTreeFromDB());
 }
示例#3
0
        public void Setup(List <RvTreeRow> rows)
        {
            _rows = rows;

            int yPos      = 0;
            int treeCount = _rows.Count;

            for (int i = 0; i < treeCount; i++)
            {
                RvTreeRow pTree     = _rows[i];
                int       nodeDepth = pTree.dirFullName.Count(x => x == '\\') - 1;
                if (pTree.MultiDatDir)
                {
                    nodeDepth += 1;
                }
                pTree.RTree = new Rectangle(0, yPos - 8, nodeDepth * 18, 16);
                if (pTree.DatId == null)
                {
                    pTree.RExpand = new Rectangle(5 + nodeDepth * 18, yPos + 4, 9, 9);
                }
                pTree.RIcon = new Rectangle(20 + nodeDepth * 18, yPos, 16, 16);
                pTree.RText = new Rectangle(36 + nodeDepth * 18, yPos, 500, 16);
                yPos        = yPos + 16;
            }
            AutoScrollMinSize = new Size(500, yPos);


            string lastBranch = "";

            for (int i = treeCount - 1; i >= 0; i--)
            {
                RvTreeRow pTree     = _rows[i];
                int       nodeDepth = pTree.dirFullName.Count(x => x == '\\');
                if (pTree.MultiDatDir)
                {
                    nodeDepth += 1;
                }

                string thisBranch;
                if (nodeDepth - 1 == 0)
                {
                    thisBranch = "";
                }
                else if (nodeDepth - 1 > lastBranch.Length)
                {
                    thisBranch = lastBranch + new string(' ', nodeDepth - 1 - lastBranch.Length);
                }
                else
                {
                    thisBranch = lastBranch.Substring(0, nodeDepth - 1);
                }

                thisBranch  = thisBranch.Replace("└", "│");
                thisBranch += "└";

                pTree.TreeBranches = thisBranch;
                lastBranch         = thisBranch;
            }
            Refresh();
        }
示例#4
0
文件: frmMain.cs 项目: vidarw/RVWorld
        private void updateSelectedTreeRow(RvTreeRow tr)
        {
            lblDITName.Text = tr.datName;
            lblDITPath.Text = tr.dirFullName;

            if (tr.DatId != null)
            {
                RvDat tDat = new RvDat();
                tDat.DbRead((uint)tr.DatId);
                lblDITDescription.Text = tDat.Description;
                lblDITCategory.Text    = tDat.Category;
                lblDITVersion.Text     = tDat.Version;
                lblDITAuthor.Text      = tDat.Author;
                lblDITDate.Text        = tDat.Date;
            }
            else
            {
                lblDITDescription.Text = "";
                lblDITCategory.Text    = "";
                lblDITVersion.Text     = "";
                lblDITAuthor.Text      = "";
                lblDITDate.Text        = "";
            }
            lblDITRomsGot.Text     = tr.RomGot.ToString("#,0");
            lblDITRomsMissing.Text = (tr.RomTotal - tr.RomGot - tr.RomNoDump).ToString("#,0");
            lblDITRomsTotal.Text   = tr.RomTotal.ToString("#,0");
            lblDITRomsNoDump.Text  = tr.RomNoDump.ToString("#,0");

            UpdateGameGrid(tr.DatId);
        }
示例#5
0
文件: frmMain.cs 项目: vidarw/RVWorld
        public frmMain()
        {
            InitializeComponent();
            Text = $@"RomVaultX {Application.StartupPath}";

            string driveLetter = AppSettings.ReadSetting("vDriveLetter");

            if (driveLetter == null)
            {
                AppSettings.AddUpdateAppSettings("vDriveLetter", "V");

                driveLetter = AppSettings.ReadSetting("vDriveLetter");
            }
            vDriveLetter = driveLetter.ToCharArray()[0];

            addGameGrid();
            string res = Program.db.ConnectToDB();

            if (!string.IsNullOrEmpty(res))
            {
                MessageBox.Show("res", "DB Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            DatUpdate.UpdateGotTotal();
            DirTree.Setup(RvTreeRow.ReadTreeFromDB());
        }
示例#6
0
        private void createGameZipToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RvTreeRow selected = DirTree.Selected;
            if (selected == null)
                return;

            if (selected.DatId == null)
            {
                MessageBox.Show("Select a DAT to remake", "RomVaultX", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (GameGrid.SelectedRows.Count == 0)
            {
                MessageBox.Show("Select a Game to remake", "RomVaultX", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            };

             int GameId = (int)GameGrid.SelectedRows[0].Tag;

            if (outputDir == null)
                outputDir = new FolderBrowserDialog();

            DialogResult result = outputDir.ShowDialog();
            if (result != DialogResult.OK)
                return;

            ReMakeZips.SetDatZipInfo(GameId, outputDir.SelectedPath);

            FrmProgressWindow progress = new FrmProgressWindow(this, "Extracting File To Zips", ReMakeZips.MakeDatZips);
            progress.ShowDialog(this);
            progress.Dispose();

        }
示例#7
0
        protected override void OnMouseDown(MouseEventArgs mevent)
        {
            bool mousehit = false;

            int x = mevent.X + HorizontalScroll.Value;
            int y = mevent.Y + VerticalScroll.Value;

            if (_rows != null)
            {
                for (int i = 0; i < _rows.Count; i++)
                {
                    RvTreeRow tDir = _rows[i];
                    if (CheckMouseDown(tDir, x, y, mevent))
                    {
                        mousehit = true;
                        break;
                    }
                }
            }

            if (mousehit)
            {
                return;
            }

            base.OnMouseDown(mevent);
        }
示例#8
0
 private void deepReScanToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FrmProgressWindow progress = new FrmProgressWindow(this, "Scanning RomRoot Files", romRootScanner.ScanFilesDeep);
     progress.ShowDialog(this);
     progress.Dispose();
     DirTree.Setup(RvTreeRow.ReadTreeFromDB());
     DatSetSelected(DirTree.Selected);
 }
示例#9
0
 private void btnUpdateDats_Click(object sender, EventArgs e)
 {
     FrmProgressWindow progress = new FrmProgressWindow(this, "Scanning Dats", DatUpdate.UpdateDat);
     progress.ShowDialog(this);
     progress.Dispose();
     DirTree.Setup(RvTreeRow.ReadTreeFromDB());
     DatSetSelected(DirTree.Selected);
 }
示例#10
0
文件: frmMain.cs 项目: vidarw/RVWorld
        private void DoScan()
        {
            FrmProgressWindow progress = new FrmProgressWindow(this, "Scanning Files", RomScanner.ScanFiles);

            progress.ShowDialog(this);
            progress.Dispose();
            DirTree.Setup(RvTreeRow.ReadTreeFromDB());
            DatSetSelected(DirTree.Selected);
        }
示例#11
0
        private void DatSetSelected(RvTreeRow cf)
        {
            DirTree.Refresh();
            GameGrid.Rows.Clear();
            RomGrid.Rows.Clear();

            if (cf == null)
                return;

            UpdateGameGrid(cf.DatId);
        }
示例#12
0
 private void SetExpanded(UITreeRow pTree, MouseButtons mouseB)
 {
     if (mouseB == MouseButtons.Left)
     {
         RvTreeRow.SetTreeExpanded(pTree.TRow.DirId, !pTree.TRow.Expanded);
         Setup(RvTreeRow.ReadTreeFromDB());
     }
     else
     {
         RvTreeRow.SetTreeExpandedChildren(pTree.TRow.DirId);
         Setup(RvTreeRow.ReadTreeFromDB());
     }
 }
示例#13
0
        private bool CheckMouseDown(RvTreeRow pTree, int x, int y, MouseEventArgs mevent)
        {
            if (pTree.RExpand.Contains(x, y))
            {
                SetExpanded(pTree, mevent.Button);
                return(true);
            }

            if (pTree.RText.Contains(x, y))
            {
                RvSelected?.Invoke(pTree, mevent);

                Selected = pTree;
                Refresh();
                return(true);
            }

            return(false);
        }
示例#14
0
        private void createDATZipsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RvTreeRow selected = DirTree.Selected;
            if (selected == null)
                return;

            if (outputDir == null)
                outputDir = new FolderBrowserDialog();

            DialogResult result = outputDir.ShowDialog();
            if (result != DialogResult.OK)
                return;

            ReMakeZips.SetDatZipInfo(selected, outputDir.SelectedPath);

            FrmProgressWindow progress = new FrmProgressWindow(this, "Extracting File To Zips", ReMakeZips.MakeDatZips);
            progress.ShowDialog(this);
            progress.Dispose();
        }
示例#15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            _hScroll = HorizontalScroll.Value;
            _vScroll = VerticalScroll.Value;

            Rectangle t = new Rectangle(e.ClipRectangle.Left + _hScroll, e.ClipRectangle.Top + _vScroll, e.ClipRectangle.Width, e.ClipRectangle.Height);

            g.FillRectangle(Brushes.White, e.ClipRectangle);


            int treeCount = _rows.Count;

            for (int i = 0; i < treeCount; i++)
            {
                RvTreeRow pTree = _rows[i];
                PaintTree(pTree, g, t);
            }
        }
示例#16
0
        private static void FindDats(RvTreeRow treeRow)
        {
            if (treeRow.DatId != null)
            {
                string localdir = treeRow.dirFullName;
                localdir = localdir.Substring(treeRow.dirFullName.Length);
                Debug.WriteLine(localdir);
                localdir = Path.Combine(_outputdir, localdir);
                ExtractZips((uint)treeRow.DatId, localdir);
                return;
            }


            List <RvTreeRow> rows = RvTreeRow.ReadTreeFromDBZipRebuild(treeRow.dirFullName);

            for (int i = 0; i < rows.Count; i++)
            {
                if (_bgw.CancellationPending)
                {
                    return;
                }

                Debug.WriteLine(rows[i].dirName + " : " + rows[i].dirFullName);
                if (rows[i].DatId == null)
                {
                    continue;
                }

                string localdir = rows[i].dirFullName;
                localdir = localdir.Substring(treeRow.dirFullName.Length);
                if (rows[i].MultiDatDir)
                {
                    localdir = Path.Combine(localdir, rows[i].datName);
                }
                Debug.WriteLine(localdir);
                localdir = Path.Combine(_outputdir, localdir);

                ExtractZips((uint)rows[i].DatId, localdir);
            }
        }
示例#17
0
        public static List <RvTreeRow> ReadTreeFromDB()
        {
            List <RvTreeRow> rows = new List <RvTreeRow>();

            using (SQLiteDataReader dr = CmdReadTree.ExecuteReader())
            {
                bool multiDatDirFound = false;

                string skipUntil = "";

                RvTreeRow lastTree = null;
                while (dr.Read())
                {
                    // a single DAT in a directory is just displayed in the tree at the same level as the directory
                    RvTreeRow pTree = new RvTreeRow
                    {
                        DirId       = Convert.ToUInt32(dr["DirId"]),
                        dirName     = dr["dirname"].ToString(),
                        dirFullName = dr["fullname"].ToString(),
                        Expanded    = Convert.ToBoolean(dr["expanded"]),
                        DatId       = dr["DatId"] == DBNull.Value ? null : (uint?)Convert.ToUInt32(dr["DatId"]),
                        datName     = dr["datname"] == DBNull.Value ? null : dr["datname"].ToString(),
                        description = dr["description"] == DBNull.Value ? null : dr["description"].ToString(),
                        RomTotal    = dr["RomTotal"] == DBNull.Value ? Convert.ToInt32(dr["dirRomTotal"]) : Convert.ToInt32(dr["RomTotal"]),
                        RomGot      = dr["RomGot"] == DBNull.Value ? Convert.ToInt32(dr["dirRomGot"]) : Convert.ToInt32(dr["RomGot"]),
                        RomNoDump   = dr["RomNoDump"] == DBNull.Value ? Convert.ToInt32(dr["dirNoDump"]) : Convert.ToInt32(dr["RomNoDump"]),
                    };

                    if (!string.IsNullOrEmpty(skipUntil))
                    {
                        if (pTree.dirFullName.Length >= skipUntil.Length)
                        {
                            if (pTree.dirFullName.Substring(0, skipUntil.Length) == skipUntil)
                            {
                                continue;
                            }
                        }
                    }
                    if (!pTree.Expanded)
                    {
                        skipUntil         = pTree.dirFullName;
                        pTree.DatId       = null;
                        pTree.datName     = null;
                        pTree.description = null;
                        pTree.RomTotal    = Convert.ToInt32(dr["dirRomTotal"]);
                        pTree.RomGot      = Convert.ToInt32(dr["dirRomGot"]);
                        pTree.RomNoDump   = Convert.ToInt32(dr["dirNoDump"]);
                    }
                    rows.Add(pTree);

                    if (lastTree != null)
                    {
                        // if multiple DAT's are in the same directory then we should add another level in the tree to display the directory
                        bool thisMultiDatDirFound = (lastTree.DirId == pTree.DirId);
                        if (thisMultiDatDirFound && !multiDatDirFound)
                        {
                            // found a new multidat
                            RvTreeRow dirTree = new RvTreeRow
                            {
                                DirId       = lastTree.DirId,
                                dirName     = lastTree.dirName,
                                dirFullName = lastTree.dirFullName,
                                Expanded    = lastTree.Expanded,
                                DatId       = null,
                                datName     = null,
                                RomTotal    = Convert.ToInt32(dr["dirRomTotal"]),
                                RomGot      = Convert.ToInt32(dr["dirRomGot"]),
                                RomNoDump   = Convert.ToInt32(dr["dirNoDump"])
                            };
                            rows.Insert(rows.Count - 2, dirTree);
                            lastTree.MultiDatDir = true;
                        }
                        if (thisMultiDatDirFound)
                        {
                            pTree.MultiDatDir = true;
                        }

                        multiDatDirFound = thisMultiDatDirFound;
                    }


                    lastTree = pTree;
                }
            }

            return(rows);
        }
示例#18
0
 public static void SetDatZipInfo(RvTreeRow treeRow, string outputDir)
 {
     _gameId    = null;
     _treeRow   = treeRow;
     _outputdir = outputDir;
 }
示例#19
0
 public static void SetDatZipInfo(int gameId, string outputDir)
 {
     _gameId    = (uint?)gameId;
     _treeRow   = null;
     _outputdir = outputDir;
 }
示例#20
0
        private void PaintTree(RvTreeRow pTree, Graphics g, Rectangle t)
        {
            int y = pTree.RTree.Top - _vScroll;

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

                string lTree = pTree.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 "└":
                        g.DrawLine(p, x + 9, y, x + 9, y + 16);
                        g.DrawLine(p, x + 9, y + 16, x + 27, y + 16);
                        break;
                    }
                }
            }

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

            if (pTree.RIcon.IntersectsWith(t))
            {
                int icon;

                if (pTree.RomGot == pTree.RomTotal - pTree.RomNoDump)
                {
                    icon = 3;
                }
                else if (pTree.RomGot > 0)
                {
                    icon = 2;
                }
                else
                {
                    icon = 1;
                }


                Bitmap bm;
                //if (pTree.Dat == null && pTree.DirDatCount != 1) // Directory above DAT's in Tree
                bm = string.IsNullOrEmpty(pTree.datName) ?
                     RvImages.GetBitmap("DirectoryTree" + icon) :
                     RvImages.GetBitmap("Tree" + icon);

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


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

            if (recBackGround.IntersectsWith(t))
            {
                string thistxt = pTree.dirName;
                if (!string.IsNullOrEmpty(pTree.datName) || !string.IsNullOrEmpty(pTree.description))
                {
                    if (!string.IsNullOrEmpty(pTree.description))
                    {
                        thistxt += ": " + pTree.description;
                    }
                    else
                    {
                        thistxt += ": " + pTree.datName;
                    }
                }
                if ((pTree.RomTotal > 0) || (pTree.RomGot > 0) || (pTree.RomNoDump > 0))
                {
                    thistxt += " ( Have: " + pTree.RomGot.ToString("#,0") + " / Missing: " + (pTree.RomTotal - pTree.RomGot - pTree.RomNoDump).ToString("#,0") + " )";
                }
                if (Selected == pTree)
                {
                    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.RText.Left - _hScroll, pTree.RText.Top + 1 - _vScroll);
                }
                else
                {
                    g.DrawString(thistxt, new Font("Microsoft Sans Serif", 8), Brushes.Black, pTree.RText.Left - _hScroll, pTree.RText.Top + 1 - _vScroll);
                }
            }
        }
示例#21
0
 public UITreeRow(RvTreeRow treeRow)
 {
     TRow = treeRow;
 }