public TrayHandler(ObservationScheduler scheduler, ApplicationConfiguration configuration) { this.icon = new System.Windows.Forms.NotifyIcon(); this.icon.Icon = new Icon(Properties.Resources.Whatson, new Size(16, 16)); this.icon.Visible = true; this.scheduler = scheduler; this.configuration = configuration; this.contextMenu = new ContextMenu(); this.icon.ContextMenu = this.contextMenu; this.contextMenu.Popup += this.OnContextMenuPopup; this.icon.DoubleClick += (s, e) => this.ShowOrHideWindow(); this.icon.BalloonTipClicked += (s, e) => this.BringToFront(true); this.icon.Click += (s, e) => this.BringToFront(false); this.model = new NotificationsModel(this.scheduler); this.model.PropertyChanged += this.CurrentStatusPropertyChanged; if (File.Exists(Path.Combine(SerializationHelper.ConfigFolder, VisualSettingsFile))) { this.visualSettings = SerializationHelper.Load <MainWindowSettigns>(Path.Combine(SerializationHelper.ConfigFolder, VisualSettingsFile)); } if (!this.configuration.OpenMinimized) { this.ShowOrHideWindow(); } }
private void MainWindowConfigurationApplied(object sender, ValueEventArgs <ApplicationConfiguration> e) { this.configuration = e.Value; if (this.scheduler.Running) { this.scheduler.Stop(false); } this.scheduler.UnobserveAll(); foreach (var connectorConfiguration in this.configuration.ConnectorsConfiguration) { var connector = PluginsManager.Instance.GetConnector(connectorConfiguration); this.scheduler.Observe(connector); } this.mainWindow?.ApplyConfiguration(this.configuration); this.model.PropertyChanged -= this.CurrentStatusPropertyChanged; this.model = new NotificationsModel(this.scheduler); this.model.PropertyChanged += this.CurrentStatusPropertyChanged; this.scheduler.Start(); }