Пример #1
0
 public Form1()
 {
     InitializeComponent();
     _tubeData = new TubeData
     {
         Name     = "No Name",
         TubeWall = 1,
         TubeOD   = 1
     };
     tubeDataBindingSource.DataSource = _tubeData;
 }
Пример #2
0
        private void BtnImportFromText_Click(object sender, EventArgs e)
        {
            const string title    = "Import Tube Data from Text File";
            string       fileName = GetFileNameFromOpenDialog(textFilePattern, title);

            if (!string.IsNullOrWhiteSpace(fileName))
            {
                string text = File.ReadAllText(fileName);
                _tubeData = JsonConvert.DeserializeObject <TubeData>(text);
                tubeDataBindingSource.DataSource = _tubeData;
            }
        }
Пример #3
0
        private void BtnImportFromXml_Click(object sender, EventArgs e)
        {
            const string title    = "Import Tube Data from Xml File";
            string       fileName = GetFileNameFromOpenDialog(xmlFilePattern, title);

            if (!string.IsNullOrWhiteSpace(fileName))
            {
                string      fileContent = File.ReadAllText(fileName);
                XmlDocument doc         = new XmlDocument();
                doc.LoadXml(fileContent);

                fileContent = JsonConvert.SerializeXmlNode(doc);
                JObject json = JObject.Parse(fileContent);
                _tubeData = JsonConvert.DeserializeObject <TubeData>(json.First.First.ToString());
                tubeDataBindingSource.DataSource = _tubeData;
            }
        }