コード例 #1
0
        void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Panel_List.Count != 0)
            {
                DialogResult ExportResult = MessageBox.Show("Lock this configuration?", "Lock?", MessageBoxButtons.YesNoCancel);
                if (ExportResult != DialogResult.Cancel)
                {
                    if (Export_Config_Dialog.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            using (StreamWriter writer = new StreamWriter(Export_Config_Dialog.OpenFile()))
                            {
                                if (ExportResult == DialogResult.Yes)
                                {
                                    foreach (UrlPanel urlPanel in Panel_List)
                                    {
                                        urlPanel.InputLock = true;
                                    }
                                }

                                foreach (UrlPanel urlPanel in Panel_List)
                                {
                                    urlPanel.Url = urlPanel.panel.Controls.OfType<TextBox>().ToList()[0].Text;
                                    urlPanel.Label = urlPanel.panel.Controls.OfType<TextBox>().ToList()[1].Text;
                                }

                                writer.WriteLine(JsonConvert.SerializeObject(Panel_List, Formatting.Indented));

                            }
                        }
                        catch (Exception FileExportEx)
                        {
                            MessageBox.Show(FileExportEx.Message);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("What's the point of exporting nothing?");
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: conamatic/Dispatcher-Tool
        void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Panel_List.Count != 0)
            {
                DialogResult ExportResult = MessageBox.Show("Lock this configuration?", "Error", MessageBoxButtons.YesNoCancel);
                if (ExportResult != DialogResult.Cancel)
                {
                    if (Export_Config_Dialog.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            using (StreamWriter writer = new StreamWriter(Export_Config_Dialog.OpenFile()))
                            {
                                if (ExportResult == DialogResult.Yes)
                                {
                                    writer.WriteLine("locked");
                                    foreach (TextBox text in Panel_List.SelectMany(t => t.Controls.OfType <TextBox>()))
                                    {
                                        text.ReadOnly = true;
                                    }
                                }

                                foreach (TextBox text in Panel_List.SelectMany(t => t.Controls.OfType <TextBox>()))
                                {
                                    writer.WriteLine(text.Text);
                                }
                            }
                        }
                        catch (Exception FileExportEx)
                        {
                            MessageBox.Show(FileExportEx.Message);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("What's the point of exporting nothing?");
            }
        }