protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); _components = new Container(); _notifyIcon = new NotifyIcon(_components) { ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(), Icon = Wpf.Properties.Resources.tray, Text = "PWM frequency manager", Visible = true }; AddMenuItems(_notifyIcon.ContextMenuStrip.Items); _notifyIcon.ContextMenuStrip.Opening += ContextMenuStrip_Opening; // ToDo fix position // _notifyIcon.Click += (a, b) => _notifyIcon.ContextMenuStrip.Show(); _pwm = new PwmManager(); _pwm.OnFrequencySet += (f, s) => _notifyIcon.ShowBalloonTip( 1000, "PWM Tool", $"PWM frequency set to {f}", System.Windows.Forms.ToolTipIcon.Info); _pwm.OnError += (f, s) => _notifyIcon.ShowBalloonTip( 1000, "PWM Tool", s, System.Windows.Forms.ToolTipIcon.Error); // by some reason _pwm.SetFrequency doesn't work if called from a background thread // _pwm.LookAfterFreq(); CheckLastFrequency(); var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(5) }; timer.Tick += OnTimedEvent; timer.Start(); _pwm.FreqWatch = true; }
public RestoreFreqWindow(PwmManager pwm) { _pwm = pwm; InitializeComponent(); }
public MainWindow(PwmManager pwm) { InitializeComponent(); _pwm = pwm; }