Пример #1
0
        void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Import_File_Dialog.ShowDialog() == DialogResult.OK)
            {
                this.Controls.OfType <Panel>().ToList().ForEach(panel => this.Controls.Remove(panel));
                counter = 1;
                Panel_List.Clear();
                bool lock_input = false;

                try
                {
                    List <string> All_Lines = File.ReadAllLines(Import_File_Dialog.FileName).ToList();
                    if (All_Lines[0] == "locked")
                    {
                        lock_input = true;
                        All_Lines.RemoveAt(0);
                    }


                    foreach (string line in All_Lines)
                    {
                        New_Panel(line, lock_input);
                    }
                }
                catch (Exception FileImportEx)
                {
                    MessageBox.Show(FileImportEx.Message);
                }
            }
        }
Пример #2
0
        //

        void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Import_File_Dialog.ShowDialog() == DialogResult.OK)
            {
                if (Panel_List.Count > 0)
                {
                    DialogResult Overwrite = MessageBox.Show("Remove existing panels first?", "Remove existing panels?", MessageBoxButtons.YesNoCancel);

                    if (Overwrite == DialogResult.Yes)
                    {
                        this.Controls.OfType<Panel>().ToList().ForEach(panel => this.Controls.Remove(panel));
                        counter = 1;
                        Panel_List.Clear();
                    }
                    else if (Overwrite == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                try
                {
                    List<UrlPanel> temp_PanelList = JsonConvert.DeserializeObject<List<UrlPanel>>(File.ReadAllText(Import_File_Dialog.FileName));

                    foreach (UrlPanel urlPanel in temp_PanelList)
                    {
                        urlPanel.panel = New_Panel(urlPanel.Url, urlPanel.InputLock, urlPanel.Label);
                        Panel_List.Add(urlPanel);
                    }

                }
                catch (Exception FileImportEx)
                {
                    MessageBox.Show(FileImportEx.ToString());
                }
            }
        }