Beispiel #1
0
        private void OpenFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Figures> tmp;

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    tmp = new List <Figures>();
                    switch (Path.GetExtension(openFile.FileName))
                    {
                    case ".xml":

                        tmp.AddRange((List <Figures>)ds.XML_To(openFile.FileName));
                        LoadElementsInTreeView(tmp);
                        break;

                    case ".bin":

                        tmp.AddRange((List <Figures>)ds.Binary_To(openFile.FileName));
                        LoadElementsInTreeView(tmp);
                        break;

                    case ".json":

                        tmp.AddRange((List <Figures>)ds.JSON_To(openFile.FileName));
                        LoadElementsInTreeView(tmp);
                        break;

                    default:
                        throw new DeserializeException();
                    }
                }

                catch (System.ArgumentNullException)
                {
                    MessageBox.Show("Invalid file extension." + '\n' + "File should be .bin, .json or .xml. Check it!");
                    log.Error("Something wrong with input data: System.ArgumentNullException");
                }

                catch (DeserializeException)
                {
                    MessageBox.Show("Invalid file extension." + '\n' + "File should be .bin, .json or .xml. Check it!");
                    log.Error("Invalid file extension.");
                }
            }
        }