public static MachineCollection LoadSettings(string path)
        {
            MachineCollection machineCollection;

            if (File.Exists(path))
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(MachineCollection));
                using (TextReader textReader = new StreamReader(path))
                {
                    try
                    {
                        machineCollection = (MachineCollection)deserializer.Deserialize(textReader);
                        machineCollection.Initialize();
                    }
                    catch (System.Exception ex)
                    {
                        machineCollection = new MachineCollection();
                        Log.LogError("", ex);
                    }
                }
            }
            else
            {
                machineCollection = new MachineCollection();
            }
            return machineCollection;
        }
예제 #2
0
 public SettingsForm(MachineCollection machineCollection)
 {
     InitializeComponent();
     m_MachineCollection = machineCollection;
 }
예제 #3
0
 private void LoadSettings()
 {
     m_MachineCollection = MachineCollection.LoadSettings(SettingsPath());
 }
예제 #4
0
 private void loadSettingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == openFileDialog1.ShowDialog())
     {
         m_MachineCollection = MachineCollection.LoadSettings(openFileDialog1.FileName);
         InitializeGrid();
     }
 }