using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace URLShrinkPlatinum
{
public partial class Form1 : Form
{
string convert = "Status: Conversion Complete!";
string save = "Status: Save Complete!";
string apploaded = "Status: App Loaded!";
string copyrights = " - Developed by Vick@Dexozoft.com";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Declare, and set WebClient Vars, txtStatus.text
txtStatus.Enabled = false;
txtStatus.Text = apploaded + copyrights;
// AutoLoad raw urls..
this.lbRaw.Items.Clear();
try
{
StreamReader LoadURL = new StreamReader(Convert.ToString("rawURL.txt"));
while (LoadURL.Peek() >= 0)
lbRaw.Items.Add(Convert.ToString(LoadURL.ReadLine()));
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex.Message));
return;
}
}
private void btnExit_Click(object sender, EventArgs e)
{
// easy said, easy done..
this.Close();
}
private void btnConvert_Click(object sender, EventArgs e)
{
// Disable this.button, so users know its converting..if there smart..
this.btnConvert.Enabled = false;
// Loop for each item in listbox and convert..
for (int i = 0; i < this.lbRaw.Items.Count; i++)
{
// get count of items
this.lbRaw.SetSelected(i, false);
// webclient declaration
System.Net.WebClient newClient = new System.Net.WebClient();
// string to hold url retreieved.. <wrong spellin lawl..
string apikey = "901f3bb31fd2638fd14ee0a6d216263a"; // replace with your api key found in adf.ly api docs
string uid = "511563"; //replace with your user id found in adf.ly api docs
string newURL = newClient.DownloadString("http://api.adf.ly/api.php?key=" + apikey + "&uid=" + uid + "&advert_type=int&domain=adf.ly&url=" + this.lbRaw.Items[i]);
// add new urls to 2nd listbox..
this.lbNew.Items.Add(newURL.ToString());
}
// re-enable button, convert
this.btnConvert.Enabled = true;
// set status update..
txtStatus.Text = "Status: Converted! " + copyrights;
}
private void btnSave_Click(object sender, EventArgs e)
{
// save to file..
StreamWriter Write;
try
{
Write = new StreamWriter("newURL.txt");
for (int a = 0; a < this.lbNew.Items.Count; a++)
{
Write.WriteLine(Convert.ToString(lbNew.Items[a]));
}
Write.Close();
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex.Message));
return;
}
txtStatus.Text = "Status: Saved! " + copyrights;
}
}
}