From d0f2f84a3269300c95e7b79e74ce017b9afb306d Mon Sep 17 00:00:00 2001 From: Xziino Date: Sun, 14 Apr 2019 03:24:13 +0200 Subject: [PATCH] optimizing timer --- STDHelper/MainWindow.xaml.cs | 12 +++++------- STDHelper/STDHelper.csproj | 6 ++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/STDHelper/MainWindow.xaml.cs b/STDHelper/MainWindow.xaml.cs index 43bc09d..c5d2621 100644 --- a/STDHelper/MainWindow.xaml.cs +++ b/STDHelper/MainWindow.xaml.cs @@ -20,9 +20,13 @@ namespace STDHelper { private DispatcherTimer t; private BitmapSource lastImage; + private System.Windows.Controls.Image i1; + private System.Windows.Controls.Image i2; public MainWindow() { InitializeComponent(); + i1 = FindName("image1") as System.Windows.Controls.Image; + i2 = FindName("image2") as System.Windows.Controls.Image; System.Windows.Controls.ComboBox cb = FindName("cb_Screens") as System.Windows.Controls.ComboBox; Screen[] screens = Screen.AllScreens; foreach(Screen s in screens) @@ -34,7 +38,7 @@ namespace STDHelper t = new DispatcherTimer(); // Hook up the Elapsed event for the timer. t.Tick += new EventHandler(OnTimedEvent); - t.Interval = new TimeSpan(0, 0, 1); + t.Interval = new TimeSpan(0,0,0,0,500); } private WriteableBitmap getAreaFromBitmap(BitmapSource src, Int32Rect area) @@ -67,8 +71,6 @@ namespace STDHelper private void Btn_Switch_Click(object sender, RoutedEventArgs e) { - System.Windows.Controls.Image i1 = FindName("image1") as System.Windows.Controls.Image; - System.Windows.Controls.Image i2 = FindName("image2") as System.Windows.Controls.Image; if (t.IsEnabled) { t.Stop(); @@ -88,8 +90,6 @@ namespace STDHelper private void OnTimedEvent(object sender, EventArgs e) { Debug.WriteLine("TICK"); - System.Windows.Controls.Image i1 = FindName("image1") as System.Windows.Controls.Image; - System.Windows.Controls.Image i2 = FindName("image2") as System.Windows.Controls.Image; Debug.WriteLine("i1 " + i1.Visibility); Debug.WriteLine("i2 " + i2.Visibility); if (i1.Visibility == Visibility.Hidden) @@ -105,8 +105,6 @@ namespace STDHelper private void Btn_LoadScreenshot_Click(object sender, RoutedEventArgs e) { - System.Windows.Controls.Image i1 = FindName("image1") as System.Windows.Controls.Image; - System.Windows.Controls.Image i2 = FindName("image2") as System.Windows.Controls.Image; System.Windows.Controls.ComboBox cb = FindName("cb_Screens") as System.Windows.Controls.ComboBox; string scrStr = cb.SelectedItem as string; Screen screen = Screen.AllScreens.Where(elem => elem.DeviceName == scrStr).SingleOrDefault(); diff --git a/STDHelper/STDHelper.csproj b/STDHelper/STDHelper.csproj index 2124f78..3b06973 100644 --- a/STDHelper/STDHelper.csproj +++ b/STDHelper/STDHelper.csproj @@ -60,7 +60,10 @@ true - true + false + + + true @@ -120,7 +123,6 @@ SettingsSingleFileGenerator Settings.Designer.cs -