override protected void OnStart() { appViewModel = new PeerCastAppViewModel(Application); versionChecker = new PeerCastStation.UI.Updater(); notifyIconThread = new Thread(() => { notifyIconManager = new NotifyIconManager(appViewModel, this); versionChecker.NewVersionFound += (sender, e) => { notifyIconManager.NotifyNewVersions(e.VersionDescriptions); }; notifyIconManager.Run(); }); notifyIconThread.SetApartmentState(ApartmentState.STA); notifyIconThread.Start(); versionCheckTimer = new Timer(OnVersionCheckTimer, null, 1000, 1000*7200); mainThread = new Thread(() => { var app = new Application(); var settings = Application.Settings.Get<WPFSettings>(); mainWindow = new MainWindow(appViewModel); if (settings.ShowWindowOnStartup) mainWindow.Show(); app.Run(); }); mainThread.Name = "WPF UI Thread"; mainThread.SetApartmentState(ApartmentState.STA); mainThread.Start(); }
override protected void OnStart() { appViewModel = new PeerCastAppViewModel(Application); versionChecker = new PeerCastStation.UI.Updater(); notifyIconThread = new Thread(() => { notifyIconManager = new NotifyIconManager(appViewModel, this); versionChecker.NewVersionFound += (sender, e) => { notifyIconManager.NotifyNewVersions(e.VersionDescriptions); }; notifyIconManager.Run(); }); notifyIconThread.SetApartmentState(ApartmentState.STA); notifyIconThread.Start(); versionCheckTimer = new Timer(OnVersionCheckTimer, null, 1000, 1000 * 3600 * 24); mainThread = new Thread(() => { var app = new Application(); var settings = Application.Settings.Get <WPFSettings>(); mainWindow = new MainWindow(appViewModel); if (settings.ShowWindowOnStartup) { mainWindow.Show(); } app.Run(); }); mainThread.Name = "WPF UI Thread"; mainThread.SetApartmentState(ApartmentState.STA); mainThread.Start(); Application.MessageNotified += OnMessageNotified; }
public NotifyIconManager(PeerCastAppViewModel app_viewmodel, UserInterface owner) { this.appViewModel = app_viewmodel; this.owner = owner; notifyIcon = new NotifyIcon(); notifyIcon.Icon = Resources.peercaststation_small; notifyIcon.ContextMenuStrip = CreateNotifyIconMenu(); notifyIcon.Text = appViewModel.Version; notifyIcon.Visible = true; notifyIcon.DoubleClick += (sender, args) => this.owner.ShowWindow(); notifyIcon.BalloonTipClicked += (sender, e) => { if (newVersionInfo==null) return; new UpdaterWindow() { DataContext=new UpdaterViewModel(newVersionInfo) }.Show(); }; }
public MainWindow(PeerCastAppViewModel viewmodel) { InitializeComponent(); this.Loaded += MainWindow_Loaded; this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenSettings, OnOpenSettings)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.ShowLogs, OnShowLogs)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.About, OnAbout)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenBrowserUI, OnOpenBrowserUI)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenHelp, OnOpenHelp)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.Quit, OnQuit)); timer = new DispatcherTimer( TimeSpan.FromSeconds(1), DispatcherPriority.Normal, (sender, e) => viewmodel.UpdateStatus(), Application.Current.Dispatcher); this.DataContext = viewmodel; }
public NotifyIconManager(PeerCastAppViewModel app_viewmodel, UserInterface owner) { this.appViewModel = app_viewmodel; this.owner = owner; notifyIcon = new NotifyIcon(); notifyIcon.Icon = Resources.peercaststation_small; notifyIcon.ContextMenuStrip = CreateNotifyIconMenu(); notifyIcon.Text = appViewModel.Version; notifyIcon.Visible = true; notifyIcon.DoubleClick += (sender, args) => this.owner.ShowWindow(); notifyIcon.BalloonTipClicked += (sender, e) => { if (newVersionInfo == null) { return; } new UpdaterWindow().Show(); }; }
public MainWindow(PeerCastAppViewModel viewmodel) { InitializeComponent(); var settings = PeerCastStation.Core.PeerCastApplication.Current.Settings.Get<WPFSettings>(); if (IsFinite(settings.WindowLeft)) this.Left = settings.WindowLeft; if (IsFinite(settings.WindowTop)) this.Top = settings.WindowTop; if (IsFinite(settings.WindowWidth)) this.Width = settings.WindowWidth; if (IsFinite(settings.WindowHeight)) this.Height = settings.WindowHeight; if (IsFinite(this.Left) && IsFinite(this.Width)) { if (this.Width>SystemParameters.VirtualScreenWidth) { this.Width = SystemParameters.VirtualScreenWidth; } if (this.Left+this.Width/2<SystemParameters.VirtualScreenLeft) { this.Left = SystemParameters.VirtualScreenLeft; } if (this.Left+this.Width/2>SystemParameters.VirtualScreenWidth+SystemParameters.VirtualScreenLeft) { this.Left = SystemParameters.VirtualScreenWidth+SystemParameters.VirtualScreenLeft - this.Width; } } if (IsFinite(this.Top) && IsFinite(this.Height)) { if (this.Height>SystemParameters.VirtualScreenHeight) { this.Height = SystemParameters.VirtualScreenHeight; } if (this.Top<SystemParameters.VirtualScreenTop) { this.Top = SystemParameters.VirtualScreenTop; } if (this.Top+this.Height/2>SystemParameters.VirtualScreenHeight+SystemParameters.VirtualScreenTop) { this.Top = SystemParameters.VirtualScreenHeight+SystemParameters.VirtualScreenTop - this.Height; } } this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenSettings, OnOpenSettings)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.ShowLogs, OnShowLogs)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.About, OnAbout)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenBrowserUI, OnOpenBrowserUI)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenHelp, OnOpenHelp)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.Quit, OnQuit)); timer = new DispatcherTimer( TimeSpan.FromSeconds(1), DispatcherPriority.Normal, (sender, e) => viewmodel.UpdateStatus(), Application.Current.Dispatcher); this.DataContext = viewmodel; }
public MainWindow(PeerCastAppViewModel viewmodel) { InitializeComponent(); var settings = PeerCastStation.Core.PeerCastApplication.Current.Settings.Get <WPFSettings>(); if (IsFinite(settings.WindowLeft)) { this.Left = settings.WindowLeft; } if (IsFinite(settings.WindowTop)) { this.Top = settings.WindowTop; } if (IsFinite(settings.WindowWidth)) { this.Width = settings.WindowWidth; } if (IsFinite(settings.WindowHeight)) { this.Height = settings.WindowHeight; } if (IsFinite(this.Left) && IsFinite(this.Width)) { if (this.Width > SystemParameters.VirtualScreenWidth) { this.Width = SystemParameters.VirtualScreenWidth; } if (this.Left + this.Width / 2 < SystemParameters.VirtualScreenLeft) { this.Left = SystemParameters.VirtualScreenLeft; } if (this.Left + this.Width / 2 > SystemParameters.VirtualScreenWidth + SystemParameters.VirtualScreenLeft) { this.Left = SystemParameters.VirtualScreenWidth + SystemParameters.VirtualScreenLeft - this.Width; } } if (IsFinite(this.Top) && IsFinite(this.Height)) { if (this.Height > SystemParameters.VirtualScreenHeight) { this.Height = SystemParameters.VirtualScreenHeight; } if (this.Top < SystemParameters.VirtualScreenTop) { this.Top = SystemParameters.VirtualScreenTop; } if (this.Top + this.Height / 2 > SystemParameters.VirtualScreenHeight + SystemParameters.VirtualScreenTop) { this.Top = SystemParameters.VirtualScreenHeight + SystemParameters.VirtualScreenTop - this.Height; } } this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenSettings, OnOpenSettings)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.ShowLogs, OnShowLogs)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.About, OnAbout)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenBrowserUI, OnOpenBrowserUI)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.OpenHelp, OnOpenHelp)); this.CommandBindings.Add(new System.Windows.Input.CommandBinding(PeerCastCommands.Quit, OnQuit)); timer = new DispatcherTimer( TimeSpan.FromSeconds(1), DispatcherPriority.Normal, (sender, e) => viewmodel.UpdateStatus(), Application.Current.Dispatcher); this.DataContext = viewmodel; }