/// <summary> /// Converts the file to binary and saves it in .XML format. /// </summary> /// <param name="net">The network that will be saved.</param> /// <param name="path">The location where the network will be saved.</param> public static void SaveToFile(Network net, String path) { using (FileStream fl = new FileStream(path, FileMode.OpenOrCreate)) { BinaryFormatter binFormatter = new BinaryFormatter(); binFormatter.Serialize(fl, net); } }
public NetworkForm() { //intialization of the fields. InitializeComponent(); myNetwork = new Network(); panel1.Paint += panel1_Paint; splitterTrackBar.Visible = false; AdjSplitLb.Visible = false; AdjSplitLb1.Visible = false; inbetweenPts = new List<Point>(); font = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold); saved = false; }
private void btnLoad_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Do you want to save your changes?", "Save?", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { btnSaveAs.PerformClick(); OpenFileDialog load = new OpenFileDialog(); if (load.ShowDialog() == DialogResult.OK) { load.Title = "Load from file"; FILE_PATH = load.FileName; myNetwork = Network.LoadFromFile(load.FileName); panel1.Invalidate(); } } else if (dialog == DialogResult.No) { OpenFileDialog load = new OpenFileDialog(); if (load.ShowDialog() == DialogResult.OK) { FILE_PATH = load.FileName; load.Title = "Load from file"; myNetwork = Network.LoadFromFile(load.FileName); panel1.Invalidate(); } } }