Beispiel #1
0
        void Init()
        {
            _frmChooseCheckDevice = new frmChooseCheckDevice();
            _frmSettings          = new frmSettings();
            _frmMain                                    = new frmMain();
            _frmListBoard                               = new frmListBoard();
            _frmHelpBoard                               = new frmHelpBoard();
            _frmBoardSignals                            = new frmBoardSignals();
            _frmBoardShowPDF                            = new frmBoardShowPDF();
            _frmCurrents                                = new frmCurrents();
            _frmMainWindow                              = _frmChooseCheckDevice._frmMainWindow = _frmSettings._frmMainWindow =
                _frmMain._frmMainWindow                 = _frmListBoard._frmMainWindow = _frmHelpBoard._frmMainWindow =
                    _frmBoardSignals._frmMainWindow     =
                        _frmBoardShowPDF._frmMainWindow =
                            this;

            sets = new SettingsXML();
            xml  = new XMLParser();


            this.Text = sTitleMainForm + sVersion;

            if (Utils.isFileExist(sFileStandSignals))
            {
                standSignals = xml.openStandXML(Application.StartupPath + "//" + sFileStandSignals);
            }
            else
            {
                MessageBox.Show("Файл стендовых сигналов " + sFileStandSignals + " не найден! Приложение не сможет функционировать и будет закрыто.", "Ошибка загрузки файла", MessageBoxButtons.OK, MessageBoxIcon.Error);

                //Application.Exit();
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        private void LoadSettings()
        {
            try
            {
                sets = LoadList(Application.StartupPath + "\\" + sFileSettings);

                _frmSettings.txtIPAddress1.Text = sets.IpAddressTo;
                _frmSettings.txtIPPort1.Text    = sets.IpPortTo1;
                _frmSettings.txtIPPort2.Text    = sets.IpPortTo2;
                _frmSettings.txtIPPort3.Text    = sets.IpPortTo3;

                /*frmSetts.txtIPPortBAD.Text = sets.IpPortFrom;
                 * frmSetts.chkIPFrom.Checked = sets.BIPAddrFromAny;
                 * if (frmSetts.chkIPFrom.Checked) { frmSetts.txtIPAddress2.Text = "IPAddress.Any"; }
                 * else frmSetts.txtIPAddress2.Text = sets.IpAddressFrom;*/
            }
            catch
            {
                MessageBox.Show("Файл настроек XML не может быть загружен. Использованы параметры по умолчанию.", "Ошибка открытия файла", MessageBoxButtons.OK, MessageBoxIcon.Information);
                sets = new SettingsXML();
                _frmSettings.txtIPAddress1.Text = "192.168.0.1";
                _frmSettings.txtIPPort1.Text    = "50000";
                _frmSettings.txtIPPort2.Text    = "50001";
                _frmSettings.txtIPPort3.Text    = "50002";

                /*frmSetts.txtIPAddress2.Text = "192.168.0.2";
                 * frmSetts.txtIPPortBAD.Text = "50000";
                 * frmSetts.chkIPFrom.Checked = false;*/
            }
        }
Beispiel #3
0
 private void SaveList(string fileName, SettingsXML obj)
 {
     try
     {
         XmlSerializer writer = new XmlSerializer(typeof(SettingsXML));
         using (TextWriter tw = new StreamWriter(fileName))
         {
             writer.Serialize(tw, obj);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error occured while saving XML-file");
     }
 }