예제 #1
0
        private void openFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Stars doc file (*.str)|*.str";
            openFileDialog.Title  = "Open stars doc file";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog.FileName;
                try
                {
                    using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
                    {
                        IFormatter formater = new BinaryFormatter();
                        starsDoc = (StarsDoc)formater.Deserialize(fileStream);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Could not read file: " + FileName);
                    FileName = null;
                    return;
                }
                Invalidate(true);
            }
        }
예제 #2
0
 public Form1()
 {
     InitializeComponent();
     starsDoc       = new StarsDoc();
     generateStar   = 0;
     random         = new Random();
     timer          = new Timer();
     timer.Interval = 70;
     timer.Tick    += new EventHandler(timer_Tick);
     timer.Start();
     DoubleBuffered = true;
 }