private void MyBottonWrite_Click(object sender, EventArgs e) { for (int i = 1; i < int.Parse(MyTextBoxStripes.Text) + 1; i++) { if (color) { bw = HexConverter(MyColorDialogFill.Color); } else { bw = HexConverter(MyColorDialogFill2.Color); } MySVGcontent = MySVGcontent + "<rect x=\"" + (i * (double.Parse(MyTextBoxWidth.Text) / int.Parse(MyTextBoxStripes.Text))).ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "mm\" y=\"10mm\" height=\"100mm\" width=\"" + ((double.Parse(MyTextBoxWidth.Text) / int.Parse(MyTextBoxStripes.Text))).ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "mm\" style=\"stroke:" + bw + "; stroke-width:0.1mm; fill: " + bw + " \"/> \n\r"; color = !color; } MySVGcontent = MySVGcontent + "<rect x=\"" + (1 * (double.Parse(MyTextBoxWidth.Text) / int.Parse(MyTextBoxStripes.Text))).ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "mm\" y=\"10mm\" height=\"100mm\" width=\"" + ((double.Parse(MyTextBoxWidth.Text))).ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "mm\" style=\"stroke:#000000; stroke-width:0.1mm; fill: none \"/> \n\r"; MySVG = MySVGstart + MySVGcontent + MySVGend; MySaveFileDialog.ShowDialog(); if (MySaveFileDialog.FileName != "") { path = Path.GetFullPath(MySaveFileDialog.FileName); File.WriteAllText(path, MySVG); } }
private void SaveCheckedMenuItem_Click(object sender, System.EventArgs e) { FileServer fs; string filename; try { //Get file name. if (MySaveFileDialog.ShowDialog() == DialogResult.Cancel) { return; } filename = MySaveFileDialog.FileName; //Save file. base.FindForm().Cursor = Cursors.WaitCursor; fs = new FileServer(); fs.SaveFile(GetListAsString(false), filename); base.FindForm().Cursor = Cursors.Default; } catch (Exception ex) { MessageManager.ShowError(ex, "Unable to save checked items.", base.FindForm()); } }
private void SaveSelectionMenuItem_Click(object sender, System.EventArgs e) { FileServer fs; string filename; try { //Get file name. if (MySaveFileDialog.ShowDialog() == DialogResult.Cancel) { return; } filename = MySaveFileDialog.FileName; if (MyParentForm != null) { MyParentForm.Cursor = Cursors.WaitCursor; } //Save file. fs = new FileServer(); fs.SaveFile(GetListAsString(false, true), filename); if (MyParentForm != null) { MyParentForm.Cursor = Cursors.Default; } } catch (Exception ex) { MessageManager.ShowError(ex, "Unable to save selected items.", MyParentForm); } }
private void SaveButton_Click(object sender, EventArgs e) { string filename; FileServer fs; try { if (MySaveFileDialog.ShowDialog(this) != DialogResult.OK) { return; } filename = MySaveFileDialog.FileName; fs = new FileServer(); this.Cursor = Cursors.WaitCursor; fs.SaveFile(MainTextBox.Text, filename); this.Cursor = Cursors.Default; } catch (Exception ex) { MessageManager.ShowError(ex, "Error when saving file.", this); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// 保存结果报告 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveReportToolStripMenuItem_Click(object sender, EventArgs e) { MySaveFileDialog.InitialDirectory = Application.StartupPath; MySaveFileDialog.Filter = "txt file(*.txt)|*.txt"; // 文件类型过滤器设置为txt文件 if (MySaveFileDialog.ShowDialog() == DialogResult.OK) { File.WriteAllText(MySaveFileDialog.FileName, ReportTextBox.Text); } }
private void exportToolStripMenuItem_Click(object sender, EventArgs e) { MySaveFileDialog.ShowDialog(); if (MySaveFileDialog.FileName == "") { return; } var filePath = MySaveFileDialog.FileName; ExportToFile(filePath); }
//2:保存文件 private void SaveLabel_Click(object sender, System.EventArgs e) { MySaveFileDialog.Filter = this.MyOenFileDialog.Filter; MySaveFileDialog.CreatePrompt = true; MySaveFileDialog.OverwritePrompt = true; MySaveFileDialog.RestoreDirectory = true; if (MySaveFileDialog.ShowDialog() == DialogResult.OK) { ResultLabel.Text = "你要保存的文件为\n" + MySaveFileDialog.FileName; } }
private void MyButtonOpenFolder_Click(object sender, EventArgs e) { if (MySaveFileDialog.FileName.Length == 0) { MySaveFileDialog.FileName = "default.txt"; } if (MySaveFileDialog.ShowDialog() == DialogResult.OK) { MyTextBoxSelectedPath.Text = MySaveFileDialog.FileName; } }
private void SaveTableToolStripMenuItem_Click(object sender, EventArgs e) { if (DataTableGridView.Rows.Count == 0) { MessageBox.Show("没有可以导出的数据", "无数据", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); return; } MySaveFileDialog.InitialDirectory = Application.StartupPath; MySaveFileDialog.Filter = "txt file(*.txt)|*.txt"; MySaveFileDialog.RestoreDirectory = true; if (MySaveFileDialog.ShowDialog() == DialogResult.OK) { String datatable = FileHelperUtil.DataToTxt(DataTableGridView); File.WriteAllText(MySaveFileDialog.FileName, datatable); MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } }