Exemple #1
0
        public CacheForm(DirectoryInfo cacheDirectory)
        {
            InitializeComponent();

            if (cacheDirectory.GetFiles("*.dat").Length == 0) // gen3
            {
                var smf = new SelectMapForm(cacheDirectory);

                if (smf.ShowDialog() != DialogResult.OK)
                {
                    Close();
                }

                Text  = smf.SelectedFile.FullName;
                Cache = GameCache.Open(smf.SelectedFile);
            }

            else // HO
            {
                Text  = cacheDirectory.FullName + "\\tags.dat";
                Cache = GameCache.Open(new FileInfo(Text));
            }

            var docFile = new FileInfo(Path.Combine(Application.StartupPath, "BlamCore.xml"));

            if (Documentation.ChildNodes.Count == 0 && docFile.Exists)
            {
                Documentation.Load(docFile.FullName);
            }
        }
Exemple #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var fbd = new FolderBrowserDialog())
            {
                fbd.Description = "Select the cache directory:";

                if (fbd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var found = false;

                foreach (ToolStripMenuItem item in recentToolStripMenuItem.DropDownItems)
                {
                    if (item.Text == fbd.SelectedPath)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    var folderItem = new ToolStripMenuItem(fbd.SelectedPath);
                    folderItem.Click += folderItem_Click;
                    recentToolStripMenuItem.DropDownItems.Add(folderItem);

                    var recentFile = new FileInfo(Path.Combine(Application.StartupPath, "RecentFolders.xml"));

                    if (!recentFile.Exists)
                    {
                        recentFile.Create().Close();
                    }

                    using (var writer = new StreamWriter(recentFile.FullName))
                    {
                        writer.WriteLine("<folders>");

                        foreach (ToolStripMenuItem item in recentToolStripMenuItem.DropDownItems)
                        {
                            writer.WriteLine($"\t<folder>{item.Text}</folder>");
                        }

                        writer.WriteLine("</folders>");
                    }
                }

                recentToolStripMenuItem.Enabled = (recentToolStripMenuItem.DropDownItems.Count != 0);

                var directory = new DirectoryInfo(fbd.SelectedPath);

                if (directory.GetFiles("*.dat").Length == 0)
                {
                    var smf = new SelectMapForm(directory);

                    if (smf.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }
                else
                {
                    var cacheForm = new CacheForm(directory)
                    {
                        MdiParent = this
                    };

                    cacheForm.Show();
                }
            }
        }