public Settings() { InitializeComponent(); checkBoxInternational.Checked = (bool)XMLFunctions.ReadSetting("UseInternational", typeof(bool), false); checkBoxAutoUpdates.Checked = (bool)XMLFunctions.ReadSetting("AutoCheckForUpdates", typeof(bool), true); checkBoxAboutOnStartup.Checked = (bool)XMLFunctions.ReadSetting("ShowAboutOnStartup", typeof(bool), true); checkBoxSendLog.Checked = (bool)XMLFunctions.ReadSetting("SendLogToDeveloper", typeof(bool), true); checkBoxSendStats.Checked = (bool)XMLFunctions.ReadSetting("SendStatisticsToDeveloper", typeof(bool), true); textBoxOffSMRBody.Text = (string)XMLFunctions.ReadSetting("OffSMRBody", typeof(string)); textBoxOffSMRSubject.Text = (string)XMLFunctions.ReadSetting("OffSMRSubject", typeof(string), "SigmaNEST Subscription Membership Renewal"); textBoxGracePeriodBody.Text = (string)XMLFunctions.ReadSetting("GracePeriodBody", typeof(string)); textBoxGracePeriodSubject.Text = (string)XMLFunctions.ReadSetting("GracePeriodSubject", typeof(string), "SigmaNEST Subscription Membership Expiring Soon"); richTextBoxSignature.Text = (string)XMLFunctions.ReadSetting("OffSMRSignature", typeof(string), Properties.Settings.Default.OffSMRSignatureDefault); checkBoxUseOutlookWeb.Checked = (bool)XMLFunctions.ReadSetting("UseOutlookWeb", typeof(bool), false); //If the user's Off SMR Signature is the same as the default, show them where to set up a new one if (Common.RemoveSpecial((string)XMLFunctions.ReadSetting("OffSMRSignature", typeof(bool), Properties.Settings.Default.OffSMRSignatureDefault)) == Common.RemoveSpecial(Properties.Settings.Default.OffSMRSignatureDefault)) { tabControlOffSMREmail.SelectTab(2); richTextBoxSignature.BackColor = Color.LightCoral; } else { richTextBoxSignature.BackColor = Color.White; } }
public static void Stat(string message = "", [System.Runtime.CompilerServices.CallerMemberName] string memberName = "") { if (!(bool)XMLFunctions.ReadSetting("SendStatisticsToDeveloper", typeof(bool), true)) { return; } string statisticsPath = Path.Combine(UserSettingsPath, "stats.txt"); string copyPath = @"\\sigmatek.net\Documents\Employees\Derek_Antrican\SalesMap\Statistics\" + Environment.UserName + ".txt"; if (!File.Exists(statisticsPath)) { var statisticsFile = File.Create(statisticsPath); statisticsFile.Close(); } File.AppendAllText(statisticsPath, "<" + memberName + ">" + message + Environment.NewLine); }
private void Settings_Load(object sender, EventArgs e) { Point startupPoint = (Point)XMLFunctions.ReadSetting("MainWindowLocation", typeof(Point), new Point(0, 0)); if (!startupPoint.IsEmpty) { foreach (Screen s in Screen.AllScreens) { if (s.Bounds.Contains(startupPoint)) { this.Top = startupPoint.Y; this.Left = startupPoint.X; return; } } } Screen screen = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y)); this.Top = screen.Bounds.Y + (screen.Bounds.Height / 10); this.Left = screen.Bounds.X + (screen.Bounds.Width / 10); }
private void buttonSave_Click(object sender, EventArgs e) { Common.Stat(); Common.Log("Saving settings"); XMLFunctions.SaveSetting("AutoCheckForUpdates", checkBoxAutoUpdates.Checked); XMLFunctions.SaveSetting("ShowAboutOnStartup", checkBoxAboutOnStartup.Checked); XMLFunctions.SaveSetting("SendLogToDeveloper", checkBoxSendLog.Checked); XMLFunctions.SaveSetting("SendStatisticsToDeveloper", checkBoxSendLog.Checked); XMLFunctions.SaveSetting("OffSMRSubject", textBoxOffSMRSubject.Text); XMLFunctions.SaveSetting("OffSMRBody", textBoxOffSMRBody.Text); XMLFunctions.SaveSetting("OffSMRSignature", richTextBoxSignature.Text); XMLFunctions.SaveSetting("GracePeriodBody", textBoxGracePeriodBody.Text); XMLFunctions.SaveSetting("GracePeriodSubject", textBoxGracePeriodSubject.Text); XMLFunctions.SaveSetting("UseOutlookWeb", checkBoxUseOutlookWeb.Checked); if (checkBoxInternational.Checked != (bool)XMLFunctions.ReadSetting("UseInternational", typeof(bool), false)) { if (checkBoxInternational.Checked) { XMLFunctions.ParseRegions(true); XMLFunctions.ParseReps(true); } else { XMLFunctions.ParseRegions(false); XMLFunctions.ParseReps(false); } XMLFunctions.SaveSetting("UseInternational", checkBoxInternational.Checked); } if (ModifierKeys == Keys.Control) { MessageBox messageBox = new MessageBox("Factory Reset", "This will factory reset this program! \n\nAre you sure?", "No", Common.MessageBoxResult.No, true, "Yes", Common.MessageBoxResult.Yes); messageBox.ShowDialog(); if (Common.DialogResult == Common.MessageBoxResult.Yes) { Common.Log("Factory reset!"); try { RegistryKey key = Registry.CurrentUser.OpenSubKey("SalesMap", true); if (key != null) { key.DeleteSubKey("SalesMap");//Reset the key value } string settingsPath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\SalesMap"; DirectoryInfo di = new DirectoryInfo(settingsPath); foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } } catch (Exception ex) { Common.Log("Problems encountered during a factory reset: " + ex.Message); MessageBox messageBox2 = new MessageBox("Error during factory reset", "Could not factory reset. Please contact the developer", "OK", Common.MessageBoxResult.OK); messageBox2.ShowDialog(); return; } ProcessStartInfo info = new ProcessStartInfo(); info.Arguments = "/C ping 127.0.0.1 -n 2 && \"" + Application.ExecutablePath + "\""; info.WindowStyle = ProcessWindowStyle.Hidden; info.CreateNoWindow = true; info.FileName = "cmd.exe"; Process.Start(info); Application.Exit(); } } this.Close(); }