protected void OnDeleteEvent(object sender, DeleteEventArgs a) { var settings = new ProgramSettings.JSONSettings(cbEnable.Active, cbPlayNotificationSound.Active, GenerateListOfEnabledCategories(), cbOnlyNewTopics.Active, cbTitleContains.Active, cbBodyContains.Active, textviewContains.Buffer.Text, cbIgnoreUsers.Active, tvIgnoreUsers.Buffer.Text, comboboxInterval.Active); try { ProgramSettings.Save(settings, jsonSettingsFileName); } catch { } Application.Quit(); a.RetVal = true; }
public MainWindow() : base(WindowType.Toplevel) { Build(); this.WindowStateEvent += MainWindow_WindowStateEvent; treeStore = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(string)); categoryRenderer = new CellRendererText(); titleRenderer = new CellRendererText(); bodyRenderer = new CellRendererText(); columnCategory = new TreeViewColumn("Category", categoryRenderer) { Resizable = true, Sizing = TreeViewColumnSizing.Fixed, FixedWidth = 200 }; columnTitle = new TreeViewColumn("Title", titleRenderer) { Resizable = true, Sizing = TreeViewColumnSizing.Fixed, FixedWidth = 200 }; columnBody = new TreeViewColumn("Body", bodyRenderer) { Resizable = true }; columnLink = new TreeViewColumn() { Title = "Link", Resizable = true, Visible = false }; columnCategory.PackStart(categoryRenderer, true); columnTitle.PackStart(titleRenderer, true); columnBody.PackStart(bodyRenderer, true); columnCategory.AddAttribute(categoryRenderer, "text", 0); columnTitle.AddAttribute(titleRenderer, "text", 1); columnBody.AddAttribute(bodyRenderer, "text", 2); tvNotifications.AppendColumn(columnCategory); tvNotifications.AppendColumn(columnTitle); tvNotifications.AppendColumn(columnBody); tvNotifications.AppendColumn(columnLink); tvNotifications.Model = treeStore; int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 6 || platform == 128) //unix/mac { cbRunOnStartup.Sensitive = false; //disable running on startup } else //windows { runSubkey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); object regVal = runSubkey.GetValue(REGISTRY_KEY_NAME); //just in case the program is moved to another location if (regVal != null && (regVal as string) != Assembly.GetExecutingAssembly().Location + " -startup") { runSubkey.DeleteValue(REGISTRY_KEY_NAME, false); regVal = null; } cbRunOnStartup.Active = regVal != null; //add event handler after change checked value, so that we don't trigger setting the registry value cbRunOnStartup.Toggled += cbRunOnStartup_Toggled; } jsonSettingsFileName = System.IO.Path.ChangeExtension(Assembly.GetExecutingAssembly().Location, ".json"); if (File.Exists(jsonSettingsFileName)) { try { ProgramSettings.JSONSettings settings = null; if (ProgramSettings.Load(jsonSettingsFileName, out settings)) { cbPlayNotificationSound.Active = settings.PlaySound; SetCheckedCategoryCheckboxesFromList(settings.EnabledCategories); cbOnlyNewTopics.Active = settings.OnlyNewTopics; cbTitleContains.Active = settings.OnlyTitleContains; cbBodyContains.Active = settings.OnlyBodyContains; textviewContains.Buffer.Text = settings.Contains; cbIgnoreUsers.Active = settings.IgnoreUsers; tvIgnoreUsers.Buffer.Text = settings.Users; comboboxInterval.Active = settings.IntervalIndex; if (settings.Enabled) { cbEnable.Active = settings.Enabled; } } } catch { } } statusIcon = new StatusIcon(); statusIcon.Pixbuf = Gdk.Pixbuf.LoadFromResource("GTA5MFNotifier.Resources.icon.png"); statusIcon.Tooltip = "GTA5-Mods Forums Notifier"; statusIcon.Visible = false; statusIcon.Activate += statusIcon_Activate; //GTA5MFNotifier.Notification.Initialize(); }