Пример #1
0
        public void Import(string dir = @".\Config\Calculators")
        {
            if (!Directory.Exists(dir))
            {
                return;
            }

            var files = Directory.GetFiles(dir);
            foreach (var file in files)
            {
                try
                {
                    var calc = Thermo1GeometryCalculator.Load(file);
                    if (Calculators.Exists(c => c.ProductName == calc.ProductName))
                    {
                        continue;
                    }

                    Calculators.Add(calc);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Load Calculators Error:{ex.Message}");
                }
            }
        }
Пример #2
0
        private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Calculator = new Thermo1GeometryCalculator();

                ReloadCalculator();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"新建文件失败:{ex.Message}");
            }
        }
Пример #3
0
        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog()
            {
                InitialDirectory = Directory.GetCurrentDirectory(),
                Multiselect      = false,
                Filter           = $"(Fprj计算文件)|*.calc|(所有文件)|*.*",
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Calculator = Thermo1GeometryCalculator.Load(ofd.FileName);

                    ReloadCalculator();
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"打开文件失败:{ex.Message}");
                }
            }
        }
Пример #4
0
 public void LoadCalculator(Thermo1GeometryCalculator calculator)
 {
     Calculator = calculator;
     ReloadCalculator();
 }