Beispiel #1
0
        private void FindFiles()
        {
            listView1.Items.Clear();

            var          dir   = new DirectoryInfo(".");
            var          files = dir.GetFiles("spells_us*.txt*");
            ListViewItem item  = null;

            foreach (var f in files)
            {
                // ignore the spell_us_str file since it also matches
                if (f.Name.StartsWith("spells_us_str"))
                {
                    continue;
                }
                item = new ListViewItem(f.Name);
                item.SubItems.Add(f.Length.ToString("#,#"));
                item.SubItems.Add(SpellParser.CountFields(f.Name).ToString());
                listView1.Items.Add(item);
            }

            if (listView1.Items.Count > 0)
            {
                listView1.Items[0].Selected = true;
            }
            else
            {
                Status.Text = "spells_us.txt was not found. Use the download button or copy a file into " + Directory.GetCurrentDirectory();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Download an updated spell file from the patch server. File names will include date (from server timestamp) and patch server type.
        /// </summary>
        private void Download(string server)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                var path = LaunchpadPatcher.DownloadSpellFilesWithVersioning(server);
                Status.Text = String.Format("Downloaded {0}", path);

                var item = listView1.FindItemWithText(path);
                if (item == null)
                {
                    var info = new FileInfo(path);
                    item = new ListViewItem(path);
                    item.SubItems.Add(info.Length.ToString("#,#"));
                    item.SubItems.Add(SpellParser.CountFields(path).ToString());
                    listView1.Items.Add(item);
                }
                listView1.MultiSelect = false;
                item.EnsureVisible();
                item.Selected         = true;
                listView1.MultiSelect = true;
            }
            catch (Exception ex)
            {
                Status.Text = "ERROR: " + ex.Message;
            }
            Cursor.Current = Cursors.Default;
        }