-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrected untracked MainWindowViewModel file.
- Loading branch information
1 parent
35886f5
commit 8885512
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Windows; | ||
|
||
namespace ManVan | ||
{ | ||
public class MainWindowViewModel : INotifyPropertyChanged | ||
{ | ||
public MainWindowViewModel() | ||
{ | ||
OpenDetailsCommand = new OpenDetailsCommand(this); | ||
NewEntryCommand = new NewEntryCommand(this); | ||
ImportCommand = new ImportCommand(this); | ||
ExportCommand = new ExportCommand(this); | ||
ExportLabelsCommand = new ExportLabelsCommand(this); | ||
ClearCommand = new ClearCommand(this); | ||
Entries = LocalDataService.Load(); | ||
|
||
_exportVisibility = LeitzAddressBookService.IsLeitzIconInstalled | ||
? Visibility.Visible | ||
: Visibility.Collapsed; | ||
} | ||
|
||
public ClearCommand ClearCommand { get; set; } | ||
|
||
public ExportLabelsCommand ExportLabelsCommand { get; set; } | ||
|
||
public ExportCommand ExportCommand { get; set; } | ||
|
||
public ImportCommand ImportCommand { get; set; } | ||
|
||
public NewEntryCommand NewEntryCommand { get; } | ||
|
||
public OpenDetailsCommand OpenDetailsCommand { get; } | ||
|
||
private Visibility _exportVisibility; | ||
|
||
public Visibility ExportVisibility | ||
{ | ||
get { return _exportVisibility; } | ||
set | ||
{ | ||
_exportVisibility = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public ObservableCollection<EntryViewModel> Entries { get; set; } | ||
|
||
public bool EntriesContainsId(Guid id) | ||
{ | ||
return Entries.Any(entryViewModel => entryViewModel.Id == id); | ||
} | ||
|
||
public EntryViewModel SelectedEntry { get; set; } | ||
|
||
public void Refresh() | ||
{ | ||
OnPropertyChangedExplicit("Entries"); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged( | ||
[CallerMemberName] string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke( | ||
this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
protected virtual void OnPropertyChangedExplicit( | ||
string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke( | ||
this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
} |