Пример #1
0
        //Open button clicked
        private void button4_Click(object sender, EventArgs e)
        {
            DialogResult result1 = MessageBox.Show(@"Are you sure you want to open a file? Your current document will be gone",
                                                   @"Important Question",
                                                   MessageBoxButtons.OKCancel);

            switch (result1)
            {
            case DialogResult.Cancel:

                break;

            case DialogResult.OK:

                ClearAll();

                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    StreamReader file =
                        new StreamReader(openFileDialog1.FileName);
                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        //try
                        //{
                        string[] data = line.Split(' ');
                        if (((data[0])[0]).ToString() == "E")
                        {
                            Draw shape = new DrawEllipse((Int16.Parse(data[1])), (Int16.Parse(data[2])), (Int16.Parse(data[3])), (Int16.Parse(data[4])));
                            _compositeList.Add(shape);

                            //shapeList.Add(composite);
                        }
                        else if (((data[0])[0]).ToString() == "R")
                        {
                            Draw shape = new DrawRectangle((Int16.Parse(data[1])), (Int16.Parse(data[2])), (Int16.Parse(data[3])), (Int16.Parse(data[4])));
                            _shapeList.Add(shape);
                        }
                        UpdateControls();
                        _selected = null;
                        //}
                        //catch
                        //{
                        //    MessageBox.Show(@"shit went terribly wrong");
                        //    ClearAll();
                        //    UpdateControls();
                        //    Invalidate();
                        //    break;
                        //}
                    }
                    Composite composite = new Composite(_compositeList, _shapeList);
                    composite.AddToList();
                }
                break;
            }
        }
Пример #2
0
        //Open button clicked
        private void button4_Click(object sender, EventArgs e)
        {
            DialogResult result1 = MessageBox.Show(@"Are you sure you want to open a file? Your current document will be gone",
            @"Important Question",
            MessageBoxButtons.OKCancel);
            switch (result1)
            {
                case DialogResult.Cancel:

                    break;
                case DialogResult.OK:

                    ClearAll();

                    OpenFileDialog openFileDialog1 = new OpenFileDialog();
                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        StreamReader file =
                            new StreamReader(openFileDialog1.FileName);
                        string line;
                        while ((line = file.ReadLine()) != null)
                        {
                            //try
                            //{
                                string[] data = line.Split(' ');
                                if (((data[0])[0]).ToString() == "E")
                                {
                                    Draw shape = new DrawEllipse((Int16.Parse(data[1])), (Int16.Parse(data[2])), (Int16.Parse(data[3])), (Int16.Parse(data[4])));
                                    _compositeList.Add(shape);

                                    //shapeList.Add(composite);
                                }
                                else if (((data[0])[0]).ToString() == "R")
                                {
                                    Draw shape = new DrawRectangle((Int16.Parse(data[1])), (Int16.Parse(data[2])), (Int16.Parse(data[3])), (Int16.Parse(data[4])));
                                    _shapeList.Add(shape);
                                }
                                UpdateControls();
                                _selected = null;
                            //}
                            //catch
                            //{
                            //    MessageBox.Show(@"shit went terribly wrong");
                            //    ClearAll();
                            //    UpdateControls();
                            //    Invalidate();
                            //    break;
                            //}
                        }
                        Composite composite = new Composite(_compositeList, _shapeList);
                        composite.AddToList();
                    }
                    break;
            }
        }