Example #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Panel panel = PanelCell.Get("", "", hashtableCMD);

            flowLayoutPanel1.Controls.Add(panel);
            foreach (Control item in panel.Controls)
            {
                item.Select();
                break;
            }
            panel.BackColor = Color.LightSeaGreen;
            flowLayoutPanel1.ScrollControlIntoView(panel);
        }
Example #2
0
        private void ReadFile(Hashtable hashtableCMD)
        {
            string file_name = path + "CommandLines.txt";

            if (!File.Exists(file_name))
            {
                hashtableCMD.Add("opencurrentfolder", Application.StartupPath);
                flowLayoutPanel1.Controls.Add(PanelCell.Get("opencurrentfolder", Application.StartupPath, hashtableCMD));

                hashtableCMD.Add("history", Environment.GetFolderPath(Environment.SpecialFolder.History));
                flowLayoutPanel1.Controls.Add(PanelCell.Get("history", Environment.GetFolderPath(Environment.SpecialFolder.History), hashtableCMD));

                hashtableCMD.Add("documents", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
                flowLayoutPanel1.Controls.Add(PanelCell.Get("documents", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), hashtableCMD));

                hashtableCMD.Add("facebook", @"https://www.facebook.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("facebook", @"https://www.facebook.com/", hashtableCMD));

                hashtableCMD.Add("youtube", @"https://www.youtube.com/results?search_query=");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("youtube", @"https://www.youtube.com/results?search_query=", hashtableCMD));

                hashtableCMD.Add("translate", @"https://translate.google.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("translate", @"https://translate.google.com/", hashtableCMD));

                hashtableCMD.Add("maps", @"https://www.google.com/maps/search/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("maps", @"https://www.google.com/maps/search/", hashtableCMD));

                hashtableCMD.Add("drive", @"https://drive.google.com/drive/u/0/my-drive");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("drive", @"https://drive.google.com/drive/u/0/my-drive", hashtableCMD));

                hashtableCMD.Add("mediafire", @"https://www.mediafire.com/login/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("mediafire", @"https://www.mediafire.com/login/", hashtableCMD));

                hashtableCMD.Add("email", @"https://login.yahoo.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("yahoo", @"https://login.yahoo.com/", hashtableCMD));

                hashtableCMD.Add("gmail", @"https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("gmail", @"https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin", hashtableCMD));

                hashtableCMD.Add("dropbox", @"https://www.dropbox.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("dropbox", @"https://www.dropbox.com/", hashtableCMD));

                hashtableCMD.Add("github", @"https://github.com/login");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("github", @"https://github.com/login", hashtableCMD));

                hashtableCMD.Add("flaticon", @"https://www.flaticon.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("flaticon", @"https://www.flaticon.com/", hashtableCMD));

                hashtableCMD.Add("cisco", @"https://www.netacad.com/login/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("cisco", @"https://www.netacad.com/login/", hashtableCMD));

                hashtableCMD.Add("ted", @"https://www.ted.com/talks");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("ted", @"https://www.ted.com/talks", hashtableCMD));

                hashtableCMD.Add("bbc", @"https://www.bbc.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("bbc", @"https://www.bbc.com/", hashtableCMD));

                hashtableCMD.Add("imagesearch", @"https://www.google.com.vn/search?authuser=0&q=");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("imagesearch", @"https://www.google.com.vn/search?authuser=0&q=", hashtableCMD));

                hashtableCMD.Add("duolingo", @"https://www.duolingo.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("duolingo", @"https://www.duolingo.com/", hashtableCMD));

                hashtableCMD.Add("stackoverflow", @"https://stackoverflow.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("stackoverflow", @"https://stackoverflow.com/", hashtableCMD));

                hashtableCMD.Add("tophonetics", @"https://tophonetics.com/");
                flowLayoutPanel1.Controls.Add(PanelCell.Get("tophonetics", @"https://tophonetics.com/", hashtableCMD));

                string savingData = "";
                foreach (DictionaryEntry item in hashtableCMD)
                {
                    savingData += item.Key + "\r\n" + item.Value + "\r\n\r\n\r\n";
                }
                try
                {
                    File.WriteAllText(file_name, savingData);
                }
                catch (Exception e)
                {
                    MessageBox.Show("File name: " + file_name + "\n\n" + e.ToString(), "Error writing form file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                return;
            }
            string[] data = null;
ReadAgain:
            try
            {
                data = File.ReadAllLines(file_name);
            }
            catch (Exception e)
            {
                if (MessageBox.Show(e.ToString(), "Error reading form file", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                {
                    goto ReadAgain;
                }
                return;
            }
            if (data == null || data.Length == 0)
            {
                return;
            }
            try
            {
                for (int i = 0; i < data.Length; i += 4)
                {
                    hashtableCMD.Add(data[i], data[i + 1]);
                    flowLayoutPanel1.Controls.Add(PanelCell.Get(data[i], data[i + 1], hashtableCMD));
                }
            }
            catch
            {
                if (MessageBox.Show(file_name, "Error reading form file", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                {
                    goto ReadAgain;
                }
                hashtableCMD.Clear();
                flowLayoutPanel1.Controls.Clear();
            }
        }