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

            openFileDialog.Filter = "Rectangles file (*.rct)|*.rct";
            openFileDialog.Title  = "Rectangles Rectangles";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog.FileName;
                try
                {
                    using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
                    {
                        IFormatter formater = new BinaryFormatter();
                        Rectangles = (Rectangles)formater.Deserialize(fileStream);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file: " + FileName);
                    FileName = null;
                    return;
                }
                Invalidate(true);
            }
        }
예제 #2
0
 public Form1()
 {
     InitializeComponent();
     DoubleBuffered = true;
     timer          = new Timer();
     timer.Interval = 500;
     timer.Tick    += new EventHandler(timer_Tick);
     Rectangles     = new Rectangles();
     timer.Start();
     color = Color.Red;
 }
예제 #3
0
 private void newToolStripButton_Click(object sender, EventArgs e)
 {
     Rectangles = new Rectangles();
 }