コード例 #1
0
        private void tsButton_save_Click(object sender, EventArgs e)
        {
            StreamWriter log = null;
            ErrorForm    error;
            FileDialog   saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "Save file";
            saveFileDialog.Filter = "Text file (*.txt)|*.txt";
            bool flag = saveFileDialog.ShowDialog() == DialogResult.OK;

            if (flag)
            {
                try
                {
                    log = new StreamWriter(saveFileDialog.FileName);
                    log.Write(this.txtDebug.Text);
                }
                catch (Exception ex)
                {
                    error = new ErrorForm();
                    error.txtError.Text = "Exception while trying to save file!" + Environment.NewLine;
                    error.txtError.Text = ex.Message;
                    error.Show();
                }
                log.Close();
            }
        }
コード例 #2
0
        private void LoadConfigToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.openFile.Title            = "Load settings";
            this.openFile.InitialDirectory = this.currentDir;
            this.openFile.FileName         = "config.xml";
            this.openFile.Filter           = "Config (*.xml)|*.xml";
            bool flag = this.openFile.ShowDialog() == DialogResult.OK;

            if (flag)
            {
                try
                {
                    XmlSerializer s = new XmlSerializer(typeof(Data));
                    TextReader    r = new StreamReader(this.openFile.FileName);
                    this.data = (Data)s.Deserialize(r);
                    this.LoadSettings();
                    this.Text = this.Text + " - " + this.openFile.FileName;
                }
                catch (Exception ex)
                {
                    ErrorForm error = new ErrorForm();
                    error.txtError.Text = "Error Ocourred while loading settings! Exception Information:";
                    TextBox txtError = error.txtError;
                    txtError.Text += ex.Message;
                    TextBox txtError2 = error.txtError;
                    txtError2.Text = txtError2.Text + Environment.NewLine + "Your settings file may be corrupt.";
                    error.Show();
                }
            }
        }
コード例 #3
0
        private void PipeErrorHandler(object sender, PipeErrorEventArgs args)
        {
            ErrorForm err      = new ErrorForm();
            TextBox   txtError = err.txtError;

            txtError.Text = txtError.Text + "PipeErrorHandler:" + Environment.NewLine;
            TextBox txtError2 = err.txtError;

            txtError2.Text += args.ErrorDesc;
            err.Show();
        }