private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // check if there is a selection
     if (listView1.SelectedItems.Count > 0)
     {
         try
         {
             SQLiteDatabase db = new SQLiteDatabase();
             for (int i = 0; i < listView1.SelectedItems.Count; i++)
             {
                 ListViewItem item = listView1.SelectedItems[i];
                 db.Delete("history", String.Format("id = {0}", item.SubItems[3].Text));
             }
             // reload
             loadItems();
         }
         catch (Exception fail)
         {
             String error = "The following error has occurred:\n\n";
             error += fail.Message.ToString() + "\n\n";
             fallyToast.Toaster alertdb = new fallyToast.Toaster();
             alertdb.Show("fallyGrab", error, -1, "Fade", "Up", "", "", "error");
             commonFunctions.writeLog(fail.Message, fail.StackTrace);
         }
     }
 }
 private void clickItem(string link)
 {
     try
     {
         webBrowser1.Navigate(link);
     }
     catch (Exception webex) {
         fallyToast.Toaster alertdb = new fallyToast.Toaster();
         alertdb.Show("fallyGrab", webex.Message, -1, "Fade", "Up", "", "", "error");
         commonFunctions.writeLog(webex.Message, webex.StackTrace);
     }
     toolStripStatusLabel2.Text = link;
 }
Beispiel #3
0
        private void Upload(string ftpServer, string userName, string password, string filename)
        {
            try
            {
                using (System.Net.WebClient client = new System.Net.WebClient())
                {
                    ftpServer = commonFunctions.cleanUri(ftpServer);
                    client.Credentials = new System.Net.NetworkCredential(userName, password);
                    client.UploadFile(commonFunctions.cleanUri(ftpServer) + new FileInfo(filename).Name, "STOR", filename);
                    client.Dispose();
                }
                // Url shortening
                string shorturl = "";
                string normalurl = commonFunctions.cleanPublicUri(fallyGrab.Properties.Settings.Default.ftpPublic) + new FileInfo(filename).Name;
                if (fallyGrab.Properties.Settings.Default.shortenUrls==1)
                    shorturl = ShortUrl.shortenUrl(commonFunctions.cleanPublicUri(fallyGrab.Properties.Settings.Default.ftpPublic) + new FileInfo(filename).Name);

                // copy to clipboard
                if (shorturl != "")
                {
                    System.Windows.Forms.Clipboard.SetText(shorturl);
                    linkreturned = shorturl;
                }
                else
                {
                    System.Windows.Forms.Clipboard.SetText(commonFunctions.cleanPublicUri(fallyGrab.Properties.Settings.Default.ftpPublic) + new FileInfo(filename).Name);
                    linkreturned = commonFunctions.cleanPublicUri(fallyGrab.Properties.Settings.Default.ftpPublic) + new FileInfo(filename).Name;
                }
                // show alert
                fallyToast.Toaster alertformup = new fallyToast.Toaster();
                alertformup.Show("fallyGrab", "File uploaded to FTP server. The link has been copied to your clipboard.", 8, "Fade", "Up",normalurl,fullname);
            }
            catch (Exception e)
            {
                // show alert
                fallyToast.Toaster alertformuperr = new fallyToast.Toaster();
                alertformuperr.Show("fallyGrab", "Error: "+e.Message, 5, "Fade", "Up");
                commonFunctions.writeLog(e.Message, e.StackTrace);
            }
        }
 private void editToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // check if there is a selection
     if (listView1.SelectedItems.Count > 0)
     {
         ListViewItem item = listView1.SelectedItems[0];
         string x = Interaction.InputBox("Type a label for the screenshot", "Label", item.Text);
         if (x.Trim() != "")
         {
             SQLiteDatabase db = new SQLiteDatabase();
             Dictionary<String, String> data = new Dictionary<String, String>();
             data.Add("label", x);
             try
             {
                 db.Update("history", data, String.Format("history.id = {0}", item.SubItems[3].Text));
                 // reload
                 loadItems();
             }
             catch (Exception crap)
             {
                 fallyToast.Toaster alertdb = new fallyToast.Toaster();
                 alertdb.Show("fallyGrab", crap.Message, -1, "Fade", "Up", "", "", "error");
                 commonFunctions.writeLog(crap.Message, crap.StackTrace);
             }
         }
     }
 }
 private void toolStripButton4_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult dialogResult = MessageBox.Show("Are you sure you want to clear your history?", "fallyGrab", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             SQLiteDatabase db = new SQLiteDatabase();
             db.Delete("history", "1=1");
             // reload
             loadItems();
         }
     }
     catch (Exception fail)
     {
         String error = "The following error has occurred:\n\n";
         error += fail.Message.ToString() + "\n\n";
         fallyToast.Toaster alertdb = new fallyToast.Toaster();
         alertdb.Show("fallyGrab", error, -1, "Fade", "Up", "", "", "error");
         commonFunctions.writeLog(fail.Message, fail.StackTrace);
     }
 }
        private void loadItems(string where="")
        {
            listView1.Items.Clear();
            toolStripButton1.Enabled = false;
            toolStripButton2.Enabled = false;
            toolStripStatusLabel2.Text = "";
            webBrowser1.Navigate("");
            try
            {
                SQLiteDatabase db = new SQLiteDatabase();
                String query;
                if (where!="")
                    query = "select * from `history` WHERE "+where+" ORDER BY `date` DESC;";
                else query = "select * from `history` ORDER BY `date` DESC;";
                DataTable history = db.GetDataTable(query);
                foreach (DataRow r in history.Rows)
                {
                    ListViewItem item = new ListViewItem();
                    item.Text = r["label"].ToString();
                    item.SubItems.Add(r["link"].ToString());
                    item.SubItems.Add(r["date"].ToString());
                    item.SubItems.Add(r["id"].ToString());

                    listView1.Items.Add(item);
                }
                toolStripStatusLabel1.Text = history.Rows.Count.ToString() + " item(s) in history";
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                fallyToast.Toaster alertdb = new fallyToast.Toaster();
                alertdb.Show("fallyGrab", error, -1, "Fade", "Up", "", "", "error");
                toolStripStatusLabel1.Text = "0 item(s) in history";
                commonFunctions.writeLog(fail.Message, fail.StackTrace);
            }
        }
 private void listView1_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Control && e.KeyCode == Keys.C && listView1.SelectedItems.Count > 0)
         {
             ListViewItem item = listView1.SelectedItems[0];
             System.Windows.Forms.Clipboard.SetText(item.SubItems[1].Text);
             toolStripStatusLabel1.Text = "The URL has been copied to your clipboard";
             timer1.Enabled = true;
         }
     }
     catch (Exception crap)
     {
         fallyToast.Toaster alertdb = new fallyToast.Toaster();
         alertdb.Show("fallyGrab", crap.Message, -1, "Fade", "Up", "", "", "error");
         commonFunctions.writeLog(crap.Message, crap.StackTrace);
     }
 }
 private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
 {
     if (e.Label == null)
         return;
     ListViewItem item = listView1.Items[e.Item];
     SQLiteDatabase db = new SQLiteDatabase();
     Dictionary<String, String> data = new Dictionary<String, String>();
     data.Add("label", e.Label.ToString());
     try
     {
         db.Update("history", data, String.Format("history.id = {0}", item.SubItems[3].Text));
         // reload
         loadItems();
     }
     catch (Exception crap)
     {
         fallyToast.Toaster alertdb = new fallyToast.Toaster();
         alertdb.Show("fallyGrab", crap.Message, -1, "Fade", "Up", "", "", "error");
         commonFunctions.writeLog(crap.Message, crap.StackTrace);
     }
 }