public void Open()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Polygon doc file (*.pol) | *.pol";
            openFileDialog.Title  = "OpenFile";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog.FileName;
                try
                {
                    using (FileStream filestream = new FileStream(FileName, FileMode.Open))
                    {
                        IFormatter formatter = new BinaryFormatter();
                        doc = (PolygonDoc)formatter.Deserialize(filestream);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Could not read file: " + FileName);
                    FileName = null;
                    return;
                }
                Invalidate(true);
            }
        }
Exemple #2
0
        private void openFile()
        {
            askToSave();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Polygons doc file (*.pgn)|*.pgn";
            openFileDialog.Title  = "Open polygons doc file";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog.FileName;
                try
                {
                    using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
                    {
                        IFormatter formater = new BinaryFormatter();
                        polygonDoc = (PolygonDoc)formater.Deserialize(fileStream);
                    }
                    setTitle();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file: " + FileName);
                    FileName = null;
                    return;
                }
                Invalidate(true);
            }
        }
 private void newToolStripButton_Click(object sender, EventArgs e)
 {
     doc   = new PolygonDoc();
     start = Point.Empty;
     end   = Point.Empty;
     p     = null;
     Invalidate(true);
 }
Exemple #4
0
 void open(string path)
 {
     using (FileStream stream = new FileStream(path, FileMode.Open))
     {
         IFormatter formatter = new BinaryFormatter();
         polygons = (PolygonDoc)formatter.Deserialize(stream);
     }
 }
 public Form1()
 {
     InitializeComponent();
     doc   = new PolygonDoc();
     start = Point.Empty;
     end   = Point.Empty;
     // points = new Point[50];
     this.DoubleBuffered = true;
 }
Exemple #6
0
 private void newDoc()
 {
     askToSave();
     FileName       = "Untitled";
     polygonDoc     = new PolygonDoc();
     currentPolygon = null;
     startPoint     = Point.Empty;
     previousPoint  = Point.Empty;
     setTitle();
 }
Exemple #7
0
 private void openFile()
 {
     askToSave();
     OpenFileDialog openFileDialog = new OpenFileDialog();
     openFileDialog.Filter = "Polygons doc file (*.pgn)|*.pgn";
     openFileDialog.Title = "Open polygons doc file";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         FileName = openFileDialog.FileName;
         try
         {
             using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
             {
                 IFormatter formater = new BinaryFormatter();
                 polygonDoc = (PolygonDoc)formater.Deserialize(fileStream);
             }
             setTitle();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Could not read file: " + FileName);
             FileName = null;
             return;
         }
         Invalidate(true);
     }
 }
Exemple #8
0
 private void newDoc()
 {
     askToSave();
     FileName = "Untitled";
     polygonDoc = new PolygonDoc();
     currentPolygon = null;
     startPoint = Point.Empty;
     previousPoint = Point.Empty;
     setTitle();
 }
Exemple #9
0
 public Form1()
 {
     InitializeComponent();
     DoubleBuffered = true;
     polygons       = new PolygonDoc();
 }
 public void newFile()
 {
     currentPolygon = null;
     polygons       = new PolygonDoc();
     currentColor   = Color.Blue;
 }
Exemple #11
0
 public Form1()
 {
     InitializeComponent();
     DoubleBuffered = true;
     polygons = new PolygonDoc();
 }