mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Remove redundant code
1. remove this 2. auto property should be only 1 line 3. misc 4. part of refactoring for PR #494
This commit is contained in:
@@ -52,42 +52,42 @@ namespace Wox
|
||||
WindowIntelopHelper.DisableControlBox(this);
|
||||
CheckUpdate();
|
||||
|
||||
var vm = this.DataContext as MainViewModel;
|
||||
var vm = DataContext as MainViewModel;
|
||||
vm.PropertyChanged += (o, eve) =>
|
||||
{
|
||||
if(eve.PropertyName == "SelectAllText")
|
||||
{
|
||||
if (vm.SelectAllText)
|
||||
{
|
||||
this.tbQuery.SelectAll();
|
||||
tbQuery.SelectAll();
|
||||
}
|
||||
}
|
||||
else if(eve.PropertyName == "CaretIndex")
|
||||
{
|
||||
this.tbQuery.CaretIndex = vm.CaretIndex;
|
||||
tbQuery.CaretIndex = vm.CaretIndex;
|
||||
}
|
||||
else if(eve.PropertyName == "Left")
|
||||
{
|
||||
this.Left = vm.Left;
|
||||
Left = vm.Left;
|
||||
}
|
||||
else if(eve.PropertyName == "Top")
|
||||
{
|
||||
this.Top = vm.Top;
|
||||
Top = vm.Top;
|
||||
}
|
||||
else if(eve.PropertyName == "IsVisible")
|
||||
{
|
||||
if (vm.IsVisible)
|
||||
{
|
||||
this.tbQuery.Focus();
|
||||
tbQuery.Focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
vm.Left = GetWindowsLeft();
|
||||
vm.Top = GetWindowsTop();
|
||||
this.Activate();
|
||||
this.Focus();
|
||||
this.tbQuery.Focus();
|
||||
Activate();
|
||||
Focus();
|
||||
tbQuery.Focus();
|
||||
}
|
||||
|
||||
private double GetWindowsLeft()
|
||||
@@ -159,7 +159,7 @@ namespace Wox
|
||||
|
||||
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var vm = this.DataContext as MainViewModel;
|
||||
var vm = DataContext as MainViewModel;
|
||||
|
||||
if (null == vm) return;
|
||||
//when alt is pressed, the real key should be e.SystemKey
|
||||
|
||||
Reference in New Issue
Block a user