Exemplo n.º 1
0
 public FormNetwork()
 {
     InitializeComponent();
     nw = new Network();
     tbcapacity.Enabled = false;
     tbflow.Enabled = false;
     selectedSplitter.Items.Add("Normal Splitter");
     selectedSplitter.Items.Add("Adjustable Splitter");
 }
Exemplo n.º 2
0
 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); 
     }
 }
Exemplo n.º 3
0
        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();
        }