Browse Source

optimizing timer

master
Xziino 6 years ago
parent
commit
d0f2f84a32
  1. 12
      STDHelper/MainWindow.xaml.cs
  2. 6
      STDHelper/STDHelper.csproj

12
STDHelper/MainWindow.xaml.cs

@ -20,9 +20,13 @@ namespace STDHelper
{ {
private DispatcherTimer t; private DispatcherTimer t;
private BitmapSource lastImage; private BitmapSource lastImage;
private System.Windows.Controls.Image i1;
private System.Windows.Controls.Image i2;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); 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; System.Windows.Controls.ComboBox cb = FindName("cb_Screens") as System.Windows.Controls.ComboBox;
Screen[] screens = Screen.AllScreens; Screen[] screens = Screen.AllScreens;
foreach(Screen s in screens) foreach(Screen s in screens)
@ -34,7 +38,7 @@ namespace STDHelper
t = new DispatcherTimer(); t = new DispatcherTimer();
// Hook up the Elapsed event for the timer. // Hook up the Elapsed event for the timer.
t.Tick += new EventHandler(OnTimedEvent); 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) private WriteableBitmap getAreaFromBitmap(BitmapSource src, Int32Rect area)
@ -67,8 +71,6 @@ namespace STDHelper
private void Btn_Switch_Click(object sender, RoutedEventArgs e) 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) if (t.IsEnabled)
{ {
t.Stop(); t.Stop();
@ -88,8 +90,6 @@ namespace STDHelper
private void OnTimedEvent(object sender, EventArgs e) private void OnTimedEvent(object sender, EventArgs e)
{ {
Debug.WriteLine("TICK"); 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("i1 " + i1.Visibility);
Debug.WriteLine("i2 " + i2.Visibility); Debug.WriteLine("i2 " + i2.Visibility);
if (i1.Visibility == Visibility.Hidden) if (i1.Visibility == Visibility.Hidden)
@ -105,8 +105,6 @@ namespace STDHelper
private void Btn_LoadScreenshot_Click(object sender, RoutedEventArgs e) 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; System.Windows.Controls.ComboBox cb = FindName("cb_Screens") as System.Windows.Controls.ComboBox;
string scrStr = cb.SelectedItem as string; string scrStr = cb.SelectedItem as string;
Screen screen = Screen.AllScreens.Where(elem => elem.DeviceName == scrStr).SingleOrDefault(); Screen screen = Screen.AllScreens.Where(elem => elem.DeviceName == scrStr).SingleOrDefault();

6
STDHelper/STDHelper.csproj

@ -60,7 +60,10 @@
<GenerateManifests>true</GenerateManifests> <GenerateManifests>true</GenerateManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignManifests>true</SignManifests> <SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@ -120,7 +123,6 @@
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<None Include="STDHelper_TemporaryKey.pfx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />

Loading…
Cancel
Save