Advertisement
vytenis555

[vApps] C# - EMS ID Finder

Mar 19th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using System.Net;
  12.  
  13. namespace IDFinder
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void Search(String sCategory, String sKeyword)
  23.         {
  24.             if (sCategory == String.Empty)
  25.             {
  26.                 MessageBox.Show("Please select a category first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  27.                 return;
  28.             }
  29.             else if (String.IsNullOrWhiteSpace(sKeyword))
  30.             {
  31.                 MessageBox.Show("Please enter a keyword first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  32.                 return;
  33.             }
  34.             else
  35.             {
  36.                 this.lvResultViewer.Items.Clear();
  37.  
  38.                 StreamReader srDataFile = new StreamReader("C:\\vApps\\ID Finder\\" + sCategory + ".txt");
  39.                 String sLine;
  40.              
  41.                 while ((sLine = srDataFile.ReadLine()) != null)
  42.                 {
  43.                     String[] sSplit = sLine.Split('|');
  44.  
  45.                     if (sSplit[1].ToUpper().Contains(sKeyword.ToUpper()))
  46.                     {
  47.                         this.lvResultViewer.Items.Add(sSplit[0]);
  48.                         this.lvResultViewer.Items[this.lvResultViewer.Items.Count - 1].SubItems.Add(sSplit[1]);
  49.                     }
  50.                 }
  51.             }
  52.         }
  53.  
  54.         private void GetData()
  55.         {
  56.             WebClient wcDownload = new WebClient();
  57.  
  58.             wcDownload.DownloadFile(new Uri("http://db.tt/lvcIV19U"), "C:\\vApps\\ID Finder\\Cash.txt");
  59.             wcDownload.DownloadFile(new Uri("http://db.tt/hHAAp69Z"), "C:\\vApps\\ID Finder\\Consume.txt");
  60.             wcDownload.DownloadFile(new Uri("http://db.tt/9WrdZIdp"), "C:\\vApps\\ID Finder\\Equipment.txt");
  61.             wcDownload.DownloadFile(new Uri("http://db.tt/7hXCJXfH"), "C:\\vApps\\ID Finder\\Etc.txt");
  62.             wcDownload.DownloadFile(new Uri("http://db.tt/YS8UZ7BL"), "C:\\vApps\\ID Finder\\Maps.txt");
  63.             wcDownload.DownloadFile(new Uri("http://db.tt/tknROFeX"), "C:\\vApps\\ID Finder\\Monsters.txt");
  64.             wcDownload.DownloadFile(new Uri("http://db.tt/IrDsqc3Y"), "C:\\vApps\\ID Finder\\NPCs.txt");
  65.             wcDownload.DownloadFile(new Uri("http://db.tt/YCyHeF7j"), "C:\\vApps\\ID Finder\\Pets.txt");
  66.             wcDownload.DownloadFile(new Uri("http://db.tt/7W3vyeJg"), "C:\\vApps\\ID Finder\\Quests.txt");
  67.             wcDownload.DownloadFile(new Uri("http://db.tt/A6b40jhU"), "C:\\vApps\\ID Finder\\Set-Up.txt");
  68.             wcDownload.DownloadFile(new Uri("http://db.tt/kUmXIJxq"), "C:\\vApps\\ID Finder\\Skills.txt");
  69.         }
  70.  
  71.         private void Form1_Load(object sender, EventArgs e)
  72.         {
  73.             if (!Directory.Exists("C:\\vApps\\ID Finder"))
  74.                 Directory.CreateDirectory("C:\\vApps\\ID Finder");
  75.  
  76.             if (!Directory.EnumerateFileSystemEntries("C:\\vApps\\ID Finder").Any())
  77.                 GetData();
  78.         }
  79.  
  80.         private void tbKeyword_KeyPress(object sender, KeyPressEventArgs e)
  81.         {
  82.             if (e.KeyChar == Convert.ToChar(Keys.Enter))
  83.             {
  84.                 Search(this.cbCategory.Text, this.tbKeyword.Text);
  85.             }
  86.         }
  87.  
  88.         private void bCopyID_Click(object sender, EventArgs e)
  89.         {
  90.             if (this.lvResultViewer.Items.Count != 0)
  91.                 Clipboard.SetDataObject(this.lvResultViewer.SelectedItems[0].Text);
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement