예제 #1
0
파일: FormNetwork.cs 프로젝트: xAlexV/OOD2
 public FormNetwork()
 {
     InitializeComponent();
     nw = new Network();
     tbcapacity.Enabled = false;
     tbflow.Enabled = false;
     selectedSplitter.Items.Add("Normal Splitter");
     selectedSplitter.Items.Add("Adjustable Splitter");
 }
예제 #2
0
파일: Network.cs 프로젝트: xAlexV/OOD2
 public static void Save(Network network, String path)
 {
     //include save as as a condition
     using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
     {
         
         BinaryFormatter binForm = new BinaryFormatter();
         binForm.Serialize(fs, network); 
     }
 }
예제 #3
0
파일: FormNetwork.cs 프로젝트: xAlexV/OOD2
        private void btload_Click(object sender, EventArgs e)
        {
            if (panel2.Controls.Count > 0)
            {
                DialogResult dialog = MessageBox.Show("Do you want to save your network before loading?", "Save?", MessageBoxButtons.YesNo);

                if (dialog == DialogResult.Yes)
                {
                    btsaveas.PerformClick();
                    OpenFileDialog loadDialog = new OpenFileDialog();
                    if (loadDialog.ShowDialog() == DialogResult.OK)
                    {
                        loadDialog.Title = "Load Network from a file";
                        path = loadDialog.FileName;
                        nw = Network.Load(loadDialog.FileName);
                        btsave.Enabled = true;
                        


                    }
                }
                else if (dialog == DialogResult.No)
                {
                    OpenFileDialog loadDialog = new OpenFileDialog();
                    if (loadDialog.ShowDialog() == DialogResult.OK)
                    {
                        loadDialog.Title = "Load Network from a file";
                        path = loadDialog.FileName;
                        nw = Network.Load(loadDialog.FileName);
                        btsave.Enabled = true;

                    }
                }

            }
            else
            {
                OpenFileDialog loadDialog = new OpenFileDialog();
                if (loadDialog.ShowDialog() == DialogResult.OK)
                {
                    loadDialog.Title = "Load Network from a file";
                    path = loadDialog.FileName;
                    nw = Network.Load(loadDialog.FileName);
                    btsave.Enabled = true;
                    

                }
            }
            DrawAllPipes();
            DrawAllPictureBoxes();
        }