private void SaveAs() { if (SaveFD.ShowDialog() == DialogResult.OK) { _filename = SaveFD.FileName; var prev_filename = _filename; try { if (_filename.EndsWith(".rtf")) { rtb.SaveFile(_filename, RichTextBoxStreamType.RichText); } else { rtb.SaveFile(_filename, RichTextBoxStreamType.PlainText); } _filename = SaveFD.FileName; } catch (Exception) { _filename = prev_filename; return; } /* Сохранение прошло успешно */ // UI Text = _filename + CAPTURE_RIGHT_SIDE; isFileSaved = true; isFileOpen = true; } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (SaveFD.ShowDialog() == DialogResult.OK) { string[] info = Graph.GraphToFile(TheGraph); File.WriteAllLines(SaveFD.FileName, info); } }
private void SalvarBT_Click(object sender, EventArgs e) { imgfinal = new Bitmap(templete.Width, templete.Height); Graphics tImg = Graphics.FromImage(imgfinal); Rectangle marcador = EditorPn.RectangleToScreen(EditorPn.ClientRectangle); tImg.CopyFromScreen(marcador.Location, Point.Empty, templete.Size); tImg.Dispose(); SaveFD.ShowDialog(this); }
private void ButSave_Click(object sender, EventArgs e) { if (lvVehicles.SelectedItems.Count == 0) { return; } object[] vehicle = new object[lvVehicles.SelectedItems.Count]; ListView.SelectedIndexCollection indexs = lvVehicles.SelectedIndices; int i = 0; foreach (int index in indexs) { vehicle[i] = Vehicles[index]; i++; } ISer ser = (ISer)Activator.CreateInstance(Sers[ComboBSers.SelectedIndex]); SaveFD.Filter = ser.FileExtension; if (SaveFD.ShowDialog() == DialogResult.Cancel) { return; } string filePath = SaveFD.FileName; ser.Serialize(vehicle, filePath); DialogResult choice = MessageBox.Show("Заархивировать файл?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (choice == DialogResult.Yes) { if (ComboBArchiving.SelectedIndex == -1) { MessageBox.Show("Не загружены файлы для архивации."); return; } Assembly assembly = Assembly.LoadFile(Plugins[ComboBArchiving.SelectedIndex]); object obj = assembly.CreateInstance("Compressions"); Type type = obj.GetType(); MethodInfo method = type.GetMethod("Compress"); method.Invoke(obj, new object[] { filePath }); File.Delete(filePath); } }