private void SystrayForm_Load(object sender, EventArgs e) { string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + "\\AutoProxySwitcher\\"; System.IO.Directory.CreateDirectory(folder); string rulesFile = folder + Environment.ExpandEnvironmentVariables(System.Configuration.ConfigurationManager.AppSettings["RulesFile"]); log.Info("rules file expected location is " + rulesFile); // Create default rules files if it doesn't exists if (!System.IO.File.Exists(rulesFile)) { log.Info("rules file doesn't exists, creating one from example"); try { System.IO.File.Copy("Examples/rules.xml", rulesFile); } catch (Exception ex) { log.Error("Failed to create rules file", ex); throw; } } // Build status form m_statusForm = new StatusForm(m_networkChangeDetector); m_statusForm.FormClosing += new FormClosingEventHandler(m_statusForm_FormClosing); // Charger les règles try { m_networkChangeDetector.LoadConfigurations(rulesFile); } catch (Exception ex) { m_statusForm.Status = ex.Message + ":\n\n" + ex.InnerException.Message; m_notifyIcon.BalloonTipText = m_statusForm.Status; m_notifyIcon.ShowBalloonTip(3000); } // Build configuration list m_statusForm.comboProxy.Items.Add("auto"); foreach (NetworkConfiguration configuration in m_networkChangeDetector.Configurations) { m_statusForm.comboProxy.Items.Add(configuration.Name); } m_statusForm.comboProxy.SelectedIndex = 0; }