Exemplo n.º 1
0
 /// <summary>
 /// Сериализация
 /// </summary>
 /// <param name="elementsProject"></param>
 public void Serilization(ElementsProject elementsProject)
 {
     using (var fs = new FileStream(elementsProject.FileName, FileMode.OpenOrCreate))
     {
         formatter.Serialize(fs, elementsProject);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Главная форма
        /// </summary>
        public ElementListForm(string[] args)
        {
            InitializeComponent();

            if (args.Length > 0)
            {
                using (var fs = new FileStream(args[0], FileMode.OpenOrCreate))
                {
                    var elementsProject = (ElementsProject)formatter.Deserialize(fs);

                    ElementsProject = elementsProject;

                    textBoxAngularFrequency.Text = ElementsProject.AngularFrequency.ToString();
                    _fileName = ElementsProject.FileName;
                    Text      = _fileName.Substring(_fileName.LastIndexOf("\\") + 1) + @" - SPO Laboratory Works";

                    for (int i = 0; i < ElementsProject.Elements.Count; i++)
                    {
                        elementDataGridView.Rows.Add(ElementsProject.Elements[i].Name, ElementsProject.Elements[i].Value,
                                                     ElementsProject.Elements[i].GetImpedance(Convert.ToDouble(textBoxAngularFrequency.Text)));
                    }
                }
            }


            Text      = _fileName;
            _elements = new List <IElement>();
#if !DEBUG
            buttonRandom.Visible = false;
#endif
            Text                             = FileNameGenerate.GenerateFileName(_fileName);
            ElementsProject                  = new ElementsProject();
            ElementsProject.Elements         = _elements;
            ElementsProject.AngularFrequency = Convert.ToDouble(textBoxAngularFrequency.Text);
            ElementsProject.FileName         = _fileName;
        }