Exemplo n.º 1
0
        private void openFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Rectangles doc file (*.rct)|*.rct";
            openFileDialog.Title  = "Open rectangles doc file";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog.FileName;
                try
                {
                    using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
                    {
                        IFormatter formatter = new BinaryFormatter();
                        doc = (RectanglesDoc)formatter.Deserialize(fileStream);
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file: " + FileName);
                    FileName = null;
                    return;
                }
                Invalidate(true);
            }
        }
Exemplo n.º 2
0
 private void newDoc()
 {
     doc           = new RectanglesDoc();
     previousPoint = Point.Empty;
     currentPoint  = Point.Empty;
     FileName      = "Untitled";
 }
Exemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            start = Point.Empty;
            end   = Point.Empty;
            this.DoubleBuffered = true;
            rectanglesDoc       = new RectanglesDoc();
            rectanglesDrawing   = new RectanglesDoc();
        }