Ejemplo n.º 1
0
 void LoadSelected()
 {
     if (treeView1.SelectedNode.ImageIndex == 1)
     {
         Image           img = FTPHandle.DownloadImage("ScreenShot/" + treeView1.SelectedNode.Parent.Text + "/" + treeView1.SelectedNode.Text);
         ZoomImageWindow ziw = new ZoomImageWindow(img);
         ziw.ShowDialog();
     }
 }
        public MainWindow()
        {
            InitializeComponent();
            form1 = this;

            PasswordDialog pd = new PasswordDialog();

            pd.ShowDialog();
            FTPHandle.CreateDir("ScreenShot/");
        }
Ejemplo n.º 3
0
        public FTPDelete()
        {
            InitializeComponent();
            FTPExplorer ex = new FTPExplorer();

            items = ex.GetItems();
            for (int i = 0; i < items.Count; i++)
            {
                comboBox1.Items.Add(items[i].Name + "    ||    Count : " + FTPHandle.GetItemsList(items[i].FullName).Count);
            }
        }
Ejemplo n.º 4
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Do you want to delete? " + Environment.NewLine + items[comboBox1.SelectedIndex].Name, "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             FTPHandle.FTPDelete(items[comboBox1.SelectedIndex].FullName);
         }
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
Ejemplo n.º 5
0
 public void RefreshTree()
 {
     try
     {
         ftpDownload.ftpImage1.Visible = true;
         List <FtpListItem> itemsinmain = FTPHandle.GetItemsList("/ScreenShot");
         par    = new List <TreeNode>();
         parall = new List <TreeNode>();
         for (int i = 0; i < itemsinmain.Count; i++)
         {
             try
             {
                 List <TreeNode>    nodes        = new List <TreeNode>();
                 List <FtpListItem> itemsinunder = FTPHandle.GetItemsList(itemsinmain[i].FullName);
                 for (int i2 = 0; i2 < itemsinunder.Count; i2++)
                 {
                     nodes.Add(new TreeNode(itemsinunder[i2].Name));
                 }
                 for (int i2 = 0; i2 < nodes.Count; i2++)
                 {
                     nodes[i2].ImageIndex         = 1;
                     nodes[i2].SelectedImageIndex = 2;
                 }
                 TreeNode node = new TreeNode(itemsinmain[i].Name, nodes.ToArray());
                 if (node.Nodes.Count > 0)
                 {
                     par.Add(node);
                 }
                 parall.Add(node);
             }
             catch { }
         }
         if (Hide_ShowEmptyToolStripMenuItem1.Text.Contains("Hide"))
         {
             treeView1.Nodes.Clear();
             TreeNode mainnode = new TreeNode("Main Folder", parall.ToArray());
             treeView1.Nodes.Add(mainnode);
         }
         else
         {
             treeView1.Nodes.Clear();
             TreeNode mainnode = new TreeNode("Main Folder", par.ToArray());
             treeView1.Nodes.Add(mainnode);
         }
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
 }
Ejemplo n.º 6
0
        private void GetFiles(List <FtpListItem> dirs)
        {
            imagesindir = FTPHandle.GetItemsList(dirs[index].FullName);
            int max = imagesindir.Count;

            images.Clear();
            int index2 = 0;

            for (int i = 0; i < max; i++)
            {
                try
                {
                    images.Add(FTPHandle.DownloadImage(dirs[index].FullName + "/" + index2 + ".jpg"));
                    index2++;
                }
                catch (Exception ex) { i = 100000; ResultsList.FromException(ex); }
            }
        }
Ejemplo n.º 7
0
 private void Button2_Click(object sender, EventArgs e)
 {
     try
     {
         for (int i = 0; i < openFileDialog1.FileNames.Length; i++)
         {
             char     u   = @"\".ToCharArray()[0];
             string[] tmp = openFileDialog1.FileNames[i].Split(u);
             ///MessageBox.Show(tmp[tmp.Length - 1]);
             FTPHandle.UploadFile(openFileDialog1.FileNames[i], textBox2.Text, tmp[tmp.Length - 1]);
         }
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
Ejemplo n.º 8
0
 private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode.Level != 0)
     {
         string name = "";
         if (treeView1.SelectedNode.Level == 1)
         {
             name = treeView1.SelectedNode.Text;
         }
         if (treeView1.SelectedNode.Level == 2)
         {
             name = treeView1.SelectedNode.Parent.Text + "/" + treeView1.SelectedNode.Text;
         }
         if (MessageBox.Show("Do You Want To DELETE Selected File/Directory?" + Environment.NewLine + "Main Folder/" + name, "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             FTPHandle.FTPDelete("ScreenShot/" + name.TrimEnd(' '));
             RefreshTree();
         }
     }
 }
Ejemplo n.º 9
0
        public List <FtpListItem> GetItems(bool changecombobox = false)
        {
            if (comboBox1.SelectedIndex >= 0)
            {
                index = comboBox1.SelectedIndex;
            }
            if (changecombobox)
            {
                comboBox1.Items.Clear();
            }
            //if (changecombobox) comboBox1.Items.Add("Select Dir");
            List <FtpListItem> dirs = FTPHandle.GetItemsList("/ScreenShot");

            for (int i = 0; i < dirs.Count; i++)
            {
                if (changecombobox)
                {
                    comboBox1.Items.Add(dirs[i].Name + "   ||    Count : " + FTPHandle.GetItemsList(dirs[i].FullName).Count);
                }
            }
            //if (changecombobox) comboBox1.SelectedIndex = 0;
            return(dirs);
        }
Ejemplo n.º 10
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         button1.Enabled = false;
         this.Visible    = false;
         Canvas c = new Canvas();
         if (c.ShowDialog() == DialogResult.OK)
         {
             if (!folder_created)
             {
                 FTPHandle.CreateDir("ScreenShot/" + DateTime.Now.ToShortTimeString(), true);
             }
             folder_created = true;
             FTPHandle.FTPSend(c.image);
         }
         this.Visible    = true;
         button1.Enabled = true;
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
Ejemplo n.º 11
0
        public void SendCmd(string arg, bool user = false)
        {
            if (user)
            {
                log.Add(arg);
            }

            List <string> args    = arg.Split(' ').ToList();
            string        command = args[0];

            string GetArgs(int index, int to = -1)
            {
                string data = "";

                if (to == -1)
                {
                    to = 999999999;
                }
                for (int i = 0; i < args.Count; i++)
                {
                    if (i >= index && i <= to)
                    {
                        data += args[i] + " ";
                    }
                }
                return(data.TrimEnd());
            }

            if (arg.Split(' ')[0] == "echocl")
            {
                string color = arg.Split(' ')[1];
                Add(GetArgs(2), Color.FromName(color));
                return;
            }
            if (arg.Split(' ')[0] == "echoclcode")
            {
                try
                {
                    int R = Convert.ToInt32(arg.Split(' ')[1]);
                    int G = Convert.ToInt32(arg.Split(' ')[2]);
                    int B = Convert.ToInt32(arg.Split(' ')[3]);
                    Add(GetArgs(4), Color.FromArgb(R, G, B));
                }
                catch (Exception ex) { ResultsList.FromException(ex); }
                return;
            }
            if (arg.Split(' ')[0] == "echo")
            {
                Add(GetArgs(1));
                return;
            }
            if (arg.Split(' ')[0] == "ln")
            {
                if (GetArgs(1) == password)
                {
                    Add("Logged In!", Color.Lime);
                    login = true;
                    return;
                }
                if (GetArgs(1) == "logout")
                {
                    Add("Logged Out!", Color.Red);
                    login = false;
                    return;
                }
                Add("Bad Password!", Color.Red);
                return;
            }

            Add(" - " + arg, Color.Yellow);

            if (arg.Split(' ')[0] == "cd")
            {
                bool inoe = false;
                try
                {
                    var tmp = arg.Split(' ')[1];
                    if (tmp == " ")
                    {
                        inoe = true;
                    }
                }
                catch { inoe = true; }
                if (inoe)
                {
                    List <FluentFTP.FtpListItem> items = FTPHandle.GetItemsList("/ScreenShot");
                    Add("Items In Dir : Main : ");
                    for (int i = 0; i < items.Count; i++)
                    {
                        Add(items[i].Name, Color.Violet);
                    }
                }
                else
                {
                    List <FluentFTP.FtpListItem> items = FTPHandle.GetItemsList("/ScreenShot/" + arg.Split(' ')[1]);
                    Add("Items In Dir : " + arg.Split(' ')[1] + " : ");
                    for (int i = 0; i < items.Count; i++)
                    {
                        Add(items[i].Name, Color.Violet);
                    }
                }
                return;
            }
            if (arg.Split(' ')[0] == "wshmax")
            {
                if (login)
                {
                    try
                    {
                        wikipediamax = Convert.ToInt32(arg.Split(' ')[1]);
                        Add("Limit set to " + wikipediamax.ToString(), Color.Lime);
                    }
                    catch
                    {
                        return;
                    }

                    return;
                }
            }
            if (arg.Split(' ')[0] == "color")
            {
                try
                {
                    if (arg.Split(' ')[1] == "1" || arg.Split(' ')[1] == "0")
                    {
                        if (arg.Split(' ')[1] == "1")
                        {
                            color = true;
                        }
                        if (arg.Split(' ')[1] == "0")
                        {
                            color = false;
                        }
                        Add("Color is " + color.ToString(), Color.Lime);
                    }
                    richTextBox1.Visible = color;
                    richTextBox2.Visible = !color;
                    richTextBox2.Text    = richTextBox1.Text;
                    richTextBox2.SelectAll();
                    richTextBox2.SelectionColor = Color.Gray;
                    richTextBox2.DeselectAll();
                }
                catch
                {
                    return;
                }

                return;
            }
            if (arg.Split(' ')[0] == "wsearch" || arg.Split(' ')[0] == "wsh")
            {
                if (login)
                {
                    string querry = GetArgs(1);
                    try
                    {
                        Add("Searching : " + querry, Color.Aqua);
                        List <Search> searches  = new List <Search>();
                        Wikipedia     wikipedia = new Wikipedia(WikipediaNet.Enums.Language.Polish);
                        wikipedia.Limit = wikipediamax;
                        QueryResult   result  = wikipedia.Search(querry);
                        List <string> results = new List <string>();
                        foreach (Search s in result.Search)
                        {
                            searches.Add(s);
                            results.Add(s.Snippet);
                        }

                        for (int i = 0; i < results.Count; i++)
                        {
                            results[i] = results[i].Replace("<span class=\"searchmatch\">", "");
                            results[i] = results[i].Replace("</span>", "");
                        }
                        for (int i = 0; i < results.Count; i++)
                        {
                            Add(results[i], Color.Violet);
                        }
                    }
                    catch (Exception ex) { Add(ex.ToString()); }
                    return;
                }
            }
            if (arg.Split(' ')[0] == "clear" || arg.Split(' ')[0] == "cs")
            {
                richTextBox1.Text = "";
                log.Clear();
                return;
            }
            if (arg.Split(' ')[0] == "credentials")
            {
                if (args.Count > 1)
                {
                    if (args[1] == "reset")
                    {
                        FTPHandle.credential.Password = FTPHandle.haslo;
                        FTPHandle.credential.UserName = FTPHandle.login;
                        FTPHandle.adres = FTPHandle.adresfactory;
                        Add("Credentials changed to factory", Color.Violet);
                    }
                    if (args[1] == "ping")
                    {
                        try
                        {
                            FluentFTP.FtpClient f = new FluentFTP.FtpClient(FTPHandle.adres, FTPHandle.credential);
                            f.Connect();
                            f.Disconnect();
                            Add("Credentials ping succes", Color.Lime);
                        }
                        catch (Exception ex) { ResultsList.FromException(ex); Add("To reset write : credentials reset", Color.Violet); }
                        return;
                    }
                    if (args[1] == "changepass")
                    {
                        FTPHandle.credential.Password = GetArgs(2);
                        Add("Password changed to : " + GetArgs(2), Color.Violet);
                    }
                    if (args[1] == "changelogin")
                    {
                        FTPHandle.credential.UserName = GetArgs(2);
                        Add("Login changed to        : " + GetArgs(2), Color.Violet);
                    }
                    if (args[1] == "changehost")
                    {
                        FTPHandle.adres = GetArgs(2);
                        Add("Host changed to         : " + GetArgs(2), Color.Violet);
                    }
                }
                Add("Login Credentials", Color.Yellow);
                Add("Host         : " + FTPHandle.adres, Color.Violet);
                Add("Login        : "******"Password : "******"";
                for (int i = 0; i < FTPHandle.credential.Password.Length; i++)
                {
                    passhide += "*";
                }
                if (!login)
                {
                    Add("Password : "******"Null Command", Color.Red);
        }