private void ApplicationStartup(object sender, StartupEventArgs e) { if (e.Args.Length == 0 || e.Args[0].ToLower().StartsWith("/s")) { for (int i = 0; i < Screen.AllScreens.Length; i++) { var s = Screen.AllScreens[i]; MainWindow window = new MainWindow(); window.Left = s.WorkingArea.Left; window.Top = s.WorkingArea.Top; window.Width = s.WorkingArea.Width; window.Height = s.WorkingArea.Height; window.Show(); windows[i] = window; // System.Windows.MessageBox.Show("Activated at monitor "+i.ToString()); } var initResult = HpaClient.initTask().Result; foreach (var window in windows) { //window.Activate(); window.StartShow(); } } else { Current.Shutdown(); } }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { // System.Diagnostics.Trace.WriteLine("tick..."); if (!IsSwitching) { IsSwitching = true; Task.Run(() => { try { Dispatcher.Invoke(() => { Image = nextImage; }); nextImage = HpaClient.getRandImageTask().Result; } catch (Exception ex) { MessageBox.Show("Exception: " + ex.ToString()); } finally { IsSwitching = false; } }); } }
public void StartShow() { timer = new Timer(); timer.Interval = 10000; timer.AutoReset = true; timer.Elapsed += Timer_Elapsed; timer.Start(); IsSwitching = true; try { Image = HpaClient.getRandImageTask().Result; nextImage = HpaClient.getRandImageTask().Result; } catch (Exception ex) { MessageBox.Show("first init exception: " + ex.ToString()); } finally { IsSwitching = false; } }