private void autoSyncToggle_Click(object sender, EventArgs e) { String menuItemText = (sender as ToolStripMenuItem).Text; Forms.Main.Instance.Console.Update("Automatic sync "+ menuItemText.ToLower() +"d."); if (menuItemText == "Enable") { if (Settings.Instance.SyncInterval == 0) { log.Debug("Switching on automatic syncing - hourly."); Forms.Main.Instance.cbIntervalUnit.SelectedItem = "Hours"; Forms.Main.Instance.tbInterval.Value = 1; XMLManager.ExportElement("SyncInterval", 1, Settings.ConfigFile); XMLManager.ExportElement("SyncIntervalUnit", "Hours", Settings.ConfigFile); } if (Sync.Engine.Instance.OgcsTimer == null) Sync.Engine.Instance.OgcsTimer = new Sync.SyncTimer(); Sync.Engine.Instance.OgcsTimer.Switch(true); Forms.Main.Instance.StrikeOutNextSyncVal(false); if (Settings.Instance.OutlookPush) Sync.Engine.Instance.RegisterForPushSync(); UpdateAutoSyncItems(); } else { if (Sync.Engine.Instance.OgcsTimer == null) { log.Warn("Auto sync timer not initialised."); return; } Sync.Engine.Instance.OgcsTimer.Switch(false); Forms.Main.Instance.StrikeOutNextSyncVal(true); if (Settings.Instance.OutlookPush) Sync.Engine.Instance.DeregisterForPushSync(); UpdateAutoSyncItems(); } }
public static void InitialiseConfigFile(String filename, String directory = null) { if (!string.IsNullOrEmpty(filename)) { configFilename = filename; } Program.WorkingFilesDirectory = directory; if (string.IsNullOrEmpty(Program.WorkingFilesDirectory)) { if (Program.IsInstalled || File.Exists(Path.Combine(Program.RoamingProfileOGCS, ConfigFilename))) { Program.WorkingFilesDirectory = Program.RoamingProfileOGCS; } else { Program.WorkingFilesDirectory = System.Windows.Forms.Application.StartupPath; } } if (!File.Exists(ConfigFile)) { log.Info("No settings.xml file found in " + Program.WorkingFilesDirectory); Settings.Instance.Save(ConfigFile); log.Info("New blank template created."); if (!Program.IsInstalled) { XMLManager.ExportElement("Portable", true, ConfigFile); } } log.Info("Running OGCS from " + System.Windows.Forms.Application.ExecutablePath); }
private void notifyIcon_BubbleClick(object sender, EventArgs e) { NotifyIcon notifyIcon = (sender as NotifyIcon); if (notifyIcon.Tag != null && notifyIcon.Tag.ToString() == "ShowBubbleWhenMinimising") { Settings.Instance.ShowBubbleWhenMinimising = false; XMLManager.ExportElement("ShowBubbleWhenMinimising", false, Program.SettingsFile); notifyIcon.Tag = ""; } else { MainForm.Instance.MainFormShow(); MainForm.Instance.tabApp.SelectedTab = MainForm.Instance.tabPage_Sync; } }
private void notifyIcon_BubbleClick(object sender, EventArgs e) { NotifyIcon notifyIcon = (sender as NotifyIcon); if (notifyIcon.Tag != null && notifyIcon.Tag.ToString() == "ShowBubbleWhenMinimising") { Settings.Instance.ShowBubbleWhenMinimising = false; XMLManager.ExportElement("ShowBubbleWhenMinimising", false, Settings.ConfigFile); notifyIcon.Tag = ""; } else if (notifyIcon.Tag != null && notifyIcon.Tag.ToString() == "OOMsecurity") { System.Diagnostics.Process.Start("https://github.com/phw198/OutlookGoogleCalendarSync/wiki/FAQs---Outlook-Security"); notifyIcon.Tag = ""; } else { Forms.Main.Instance.TopMost = true; Forms.Main.Instance.MainFormShow(); Forms.Main.Instance.TopMost = false; Forms.Main.Instance.tabApp.SelectedTab = Forms.Main.Instance.tabPage_Sync; } }
private void autoSyncToggle_Click(object sender, EventArgs e) { String menuItemText = (sender as ToolStripMenuItem).Text; MainForm.Instance.Logboxout("Automatic sync " + menuItemText.ToLower() + "d."); if (menuItemText == "Enable") { if (Settings.Instance.SyncInterval == 0) { log.Debug("Switching on automatic syncing - hourly."); MainForm.Instance.cbIntervalUnit.SelectedItem = "Hours"; MainForm.Instance.tbInterval.Value = 1; XMLManager.ExportElement("SyncInterval", 1, Program.SettingsFile); XMLManager.ExportElement("SyncIntervalUnit", "Hours", Program.SettingsFile); } if (MainForm.Instance.OgcsTimer == null) { MainForm.Instance.OgcsTimer = new SyncTimer(); } MainForm.Instance.OgcsTimer.Switch(true); MainForm.Instance.lNextSyncVal.Font = new System.Drawing.Font(MainForm.Instance.lNextSyncVal.Font, System.Drawing.FontStyle.Regular); if (Settings.Instance.OutlookPush) { OutlookCalendar.Instance.RegisterForPushSync(); } UpdateAutoSyncItems(); } else { if (MainForm.Instance.OgcsTimer == null) { log.Warn("Auto sync timer not initialised."); return; } MainForm.Instance.OgcsTimer.Switch(false); MainForm.Instance.lNextSyncVal.Font = new System.Drawing.Font(MainForm.Instance.lNextSyncVal.Font, System.Drawing.FontStyle.Strikeout); if (Settings.Instance.OutlookPush) { OutlookCalendar.Instance.DeregisterForPushSync(); } UpdateAutoSyncItems(); } }
/// <summary> /// When an error is logged, check if user has chosen to upload logs or not /// </summary> protected override void Append(LoggingEvent loggingEvent) { if (!GoogleOgcs.ErrorReporting.Initialised || errorOccurred) { return; } errorOccurred = true; String configSetting = null; if (Settings.IsLoaded) { configSetting = Settings.Instance.CloudLogging.ToString(); } else { configSetting = XMLManager.ImportElement("CloudLogging", Settings.ConfigFile); } if (!string.IsNullOrEmpty(configSetting)) { if (configSetting == "true" && GoogleOgcs.ErrorReporting.GetThreshold().ToString().ToUpper() != "ALL") { GoogleOgcs.ErrorReporting.SetThreshold(true); replayLogs(); } else if (configSetting == "false" && GoogleOgcs.ErrorReporting.GetThreshold().ToString().ToUpper() != "OFF") { GoogleOgcs.ErrorReporting.SetThreshold(false); } return; } //Cloud logging value not set yet - let's ask the user Forms.ErrorReporting frm = new Forms.ErrorReporting(); DialogResult dr = frm.ShowDialog(); if (dr == DialogResult.Cancel) { errorOccurred = false; return; } Boolean confirmative = dr == DialogResult.Yes; if (Settings.IsLoaded) { Settings.Instance.CloudLogging = confirmative; } else { XMLManager.ExportElement("CloudLogging", confirmative, Settings.ConfigFile); } Telemetry.Send(Analytics.Category.ogcs, Analytics.Action.setting, "CloudLogging=" + confirmative.ToString()); try { Forms.Main.Instance.SetControlPropertyThreadSafe(Forms.Main.Instance.cbCloudLogging, "CheckState", confirmative ? CheckState.Checked : CheckState.Unchecked); } catch { } if (confirmative) { replayLogs(); } }
private static void initialiseFiles() { string appFilePath = System.Windows.Forms.Application.StartupPath; string roamingAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); roamingOGCS = Path.Combine(roamingAppData, Application.ProductName); //Don't know where to write log file to yet. If settings.xml exists in Roaming profile, //then log should go there too. if (File.Exists(Path.Combine(roamingOGCS, settingsFilename))) { UserFilePath = roamingOGCS; initialiseLogger(UserFilePath, true); log.Info("Storing user files in roaming directory: " + UserFilePath); } else { UserFilePath = appFilePath; initialiseLogger(UserFilePath, true); log.Info("Storing user files in application directory: " + appFilePath); if (!File.Exists(Path.Combine(appFilePath, settingsFilename))) { log.Info("No settings.xml file found in " + appFilePath); Settings.Instance.Save(Path.Combine(appFilePath, settingsFilename)); log.Info("New blank template created."); if (!Program.IsInstalled) { XMLManager.ExportElement("Portable", true, Path.Combine(appFilePath, settingsFilename)); } startingTab = "Help"; } } log.Info("Running from " + System.Windows.Forms.Application.ExecutablePath); //Now let's confirm the actual setting settingsFile = Path.Combine(UserFilePath, settingsFilename); Boolean keepPortable = (XMLManager.ImportElement("Portable", settingsFile) ?? "false").Equals("true"); if (keepPortable) { if (UserFilePath != appFilePath) { log.Info("File storage location is incorrect according to " + settingsFilename); MakePortable(true); } } else { if (UserFilePath != roamingOGCS) { log.Info("File storage location is incorrect according to " + settingsFilename); MakePortable(false); } } string logLevel = XMLManager.ImportElement("LoggingLevel", settingsFile); Settings.configureLoggingLevel(logLevel ?? "FINE"); purgeLogFiles(30); }