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 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; }