예제 #1
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         FileStream      fs = null;
         BinaryFormatter bf = null;
         try
         {
             fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
             bf = new BinaryFormatter();
             lbInfo.Items.Clear();
             mc = (ManufacturingCompany)(bf.Deserialize(fs));
             btnShowInfo.PerformClick();
         }
         catch (IOException) { MessageBox.Show("I/O Error"); }
         catch (SerializationException) { MessageBox.Show("serialization Error Maybe wrong file"); }
         finally
         {
             if (fs != null)
             {
                 fs.Close(); MessageBox.Show("loading Done");
             }
         }
     }
 }
예제 #2
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            //todo
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    FileStream fs = null;
                    try
                    {
                        fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read);
                        BinaryFormatter bf = new BinaryFormatter();

                        mc = (ManufacturingCompany)bf.Deserialize(fs);
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show("Error reading file: " + ex.Message);
                    }
                    catch (SerializationException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }
                    }
                }
            }
        }
예제 #3
0
 public Form1()
 {
     InitializeComponent();
     mc = new ManufacturingCompany("VOL");
     saveFileDialog1.Filter       = "Text Files (*.txt)|*.txt";
     saveFileDialog1.DefaultExt   = "txt";
     saveFileDialog1.AddExtension = true;
 }
예제 #4
0
파일: Form1.cs 프로젝트: fabestine1/MyThing
        public Form1()
        {
            InitializeComponent();
            mc = new ManufacturingCompany("VDL assembling Mini Cooper");
            Machine machine = new Machine("machine", 12, 12);

            mc.AddMachine(machine);
            machine.CriticalState += new Machine.CriticalStateHandler(ShowInListBox);
        }
예제 #5
0
파일: Form1.cs 프로젝트: aimethierry/pc4
 private void btnLoad_Click(object sender, EventArgs e)
 {
     try
     {
         using (FileStream fs = new FileStream("saveFile.bin", FileMode.Open, FileAccess.Read))
         {
             BinaryFormatter bf = new BinaryFormatter();
             mc = (ManufacturingCompany)bf.Deserialize(fs);
             MessageBox.Show("loaded from file");
         }
     }
     catch (SerializationException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (IOException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #6
0
파일: Form1.cs 프로젝트: aimethierry/pc4
        private void btnLoad_Click(object sender, EventArgs e)
        {
            //todo
            string          fileName = "C:/Users/Ov/Documents/votesFromEindhoven.txt";
            FileStream      fs       = null;
            BinaryFormatter bf       = null;

            try
            {
                fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                bf = new BinaryFormatter();
                lbInfo.Items.Clear();
                mc = (ManufacturingCompany)(bf.Deserialize(fs));
            }
            catch (IOException) { MessageBox.Show("I/O Error"); }
            catch (SerializationException) { MessageBox.Show("serialization Error"); }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
예제 #7
0
파일: Form1.cs 프로젝트: aimethierry/pc4
 public Form1()
 {
     InitializeComponent();
     mc = new ManufacturingCompany("VDL assembling Mini Cooper");
 }