Remove redundant OnPropertyChagned

This commit is contained in:
bao-qian 2016-05-23 22:17:38 +01:00
parent 82d4b866c0
commit d15611fd44
3 changed files with 23 additions and 91 deletions

View File

@ -74,20 +74,23 @@ namespace Wox
QueryTextBox.Focus();
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
};
vm.MainWindowVisibilityChanged += (o, e) =>
vm.PropertyChanged += (o, e) =>
{
if (vm.MainWindowVisibility.IsVisible())
if (e.PropertyName == nameof(vm.MainWindowVisibility))
{
Activate();
QueryTextBox.Focus();
Left = GetWindowsLeft();
Top = GetWindowsTop();
_settings.ActivateTimes++;
}
else
{
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
if (vm.MainWindowVisibility.IsVisible())
{
Activate();
QueryTextBox.Focus();
Left = GetWindowsLeft();
Top = GetWindowsTop();
_settings.ActivateTimes++;
}
else
{
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
}
}
};
}

View File

@ -24,13 +24,7 @@ namespace Wox.ViewModel
{
#region Private Fields
private double _left;
private double _top;
private Visibility _contextMenuVisibility;
private Visibility _progressBarVisibility;
private Visibility _resultListBoxVisibility;
private Visibility _mainWindowVisibility;
private bool _queryHasReturn;
private Query _lastQuery;
@ -285,8 +279,6 @@ namespace Wox.ViewModel
set
{
_queryText = value;
OnPropertyChanged();
if (_ignoreTextChange)
{
_ignoreTextChange = false;
@ -298,25 +290,9 @@ namespace Wox.ViewModel
}
}
public double Left
{
get { return _left; }
set
{
_left = value;
OnPropertyChanged();
}
}
public double Left { get; set; }
public double Top
{
get { return _top; }
set
{
_top = value;
OnPropertyChanged();
}
}
public double Top { get; set; }
public Visibility ContextMenuVisibility
@ -325,7 +301,6 @@ namespace Wox.ViewModel
set
{
_contextMenuVisibility = value;
OnPropertyChanged();
_ignoreTextChange = true;
if (!value.IsVisible())
@ -343,40 +318,16 @@ namespace Wox.ViewModel
}
}
public Visibility ProgressBarVisibility
{
get { return _progressBarVisibility; }
set
{
_progressBarVisibility = value;
OnPropertyChanged();
}
}
public Visibility ProgressBarVisibility { get; set; }
public Visibility ResultListBoxVisibility
{
get { return _resultListBoxVisibility; }
set
{
_resultListBoxVisibility = value;
OnPropertyChanged();
}
}
public Visibility ResultListBoxVisibility { get; set; }
public Visibility MainWindowVisibility
{
get { return _mainWindowVisibility; }
set
{
_mainWindowVisibility = value;
OnPropertyChanged();
MainWindowVisibilityChanged?.Invoke(this, new EventArgs());
}
}
public Visibility MainWindowVisibility { get; set; }
public ICommand EscCommand { get; set; }
public ICommand SelectNextItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; }
//todo happlebao restore history command
public ICommand DisplayNextQueryCommand { get; set; }
public ICommand DisplayPrevQueryCommand { get; set; }
public ICommand SelectNextPageCommand { get; set; }
@ -701,7 +652,6 @@ namespace Wox.ViewModel
#endregion
public event EventHandler MainWindowVisibilityChanged;
public event EventHandler CursorMovedToEnd;
public void OnCursorMovedToEnd()

View File

@ -13,9 +13,7 @@ namespace Wox.ViewModel
{
#region Private Fields
private int _selectedIndex;
public ResultCollection Results { get; }
private Thickness _margin;
private readonly object _addResultsLock = new object();
private readonly object _collectionLock = new object();
@ -45,29 +43,10 @@ namespace Wox.ViewModel
public int MaxHeight => MaxResults * 50;
public int SelectedIndex
{
get { return _selectedIndex; }
set
{
_selectedIndex = value;
OnPropertyChanged();
}
}
public int SelectedIndex { get; set; }
public ResultViewModel SelectedItem { get; set; }
public Thickness Margin
{
get
{
return _margin;
}
set
{
_margin = value;
OnPropertyChanged();
}
}
public Thickness Margin { get; set; }
#endregion