2121
2222namespace OneDrive_Cloud_Player . Main
2323{
24- class MainWindowViewModel : MetroWindow , INotifyPropertyChanged , IValueConverter
24+ class MainWindowViewModel : MetroWindow , INotifyPropertyChanged , IValueConverter
2525 {
2626 public ICommand GetDrivesCommand { get ; set ; }
2727 public ICommand GetSharedFolderChildrenCommand { get ; set ; }
@@ -40,11 +40,9 @@ class MainWindowViewModel : MetroWindow, INotifyPropertyChanged, IValueConverte
4040 // The list of the different drives
4141 private List < CachedDrive > driveList ;
4242
43- public List < CachedDrive > DriveList
44- {
43+ public List < CachedDrive > DriveList {
4544 get { return driveList ; }
46- set
47- {
45+ set {
4846 driveList = value ;
4947 NotifyPropertyChanged ( ) ;
5048 }
@@ -53,11 +51,9 @@ public List<CachedDrive> DriveList
5351 // The list of children that is given back when you click on a parent
5452 private List < CachedDriveItem > explorerItemsList ;
5553
56- public List < CachedDriveItem > ExplorerItemsList
57- {
54+ public List < CachedDriveItem > ExplorerItemsList {
5855 get { return explorerItemsList ; }
59- set
60- {
56+ set {
6157 explorerItemsList = value ;
6258 NotifyPropertyChanged ( ) ;
6359 }
@@ -66,11 +62,9 @@ public List<CachedDriveItem> ExplorerItemsList
6662 // The folder that gets selected when you click on a onedrive
6763 private CachedDrive selectedDriveFolder ;
6864
69- public CachedDrive SelectedDriveFolder
70- {
65+ public CachedDrive SelectedDriveFolder {
7166 get { return selectedDriveFolder ; }
72- set
73- {
67+ set {
7468 selectedDriveFolder = value ;
7569 NotifyPropertyChanged ( ) ;
7670 }
@@ -79,47 +73,39 @@ public CachedDrive SelectedDriveFolder
7973 // The folder that gets selected when you click on a onedrive
8074 private CachedDriveItem selectedExplorerItem ;
8175
82- public CachedDriveItem SelectedExplorerItem
83- {
76+ public CachedDriveItem SelectedExplorerItem {
8477 get { return selectedExplorerItem ; }
85- set
86- {
78+ set {
8779 selectedExplorerItem = value ;
8880 NotifyPropertyChanged ( ) ;
8981 }
9082 }
9183
9284 private string visibilityReloadButton = "Visible" ;
9385
94- public string VisibilityReloadButton
95- {
86+ public string VisibilityReloadButton {
9687 get { return visibilityReloadButton ; }
97- set
98- {
88+ set {
9989 visibilityReloadButton = value ;
10090 NotifyPropertyChanged ( ) ;
10191 }
10292 }
10393
10494 private string currentUsername ;
10595
106- public string CurrentUsername
107- {
96+ public string CurrentUsername {
10897 get { return currentUsername ; }
109- set
110- {
98+ set {
11199 currentUsername = value ;
112100 NotifyPropertyChanged ( ) ;
113101 }
114102 }
115103 // The users profile picture
116104 private System . IO . Stream profileImage ;
117105
118- public System . IO . Stream ProfileImage
119- {
106+ public System . IO . Stream ProfileImage {
120107 get { return profileImage ; }
121- set
122- {
108+ set {
123109 profileImage = value ;
124110 NotifyPropertyChanged ( ) ;
125111 }
@@ -129,11 +115,9 @@ public System.IO.Stream ProfileImage
129115
130116 private CachedDriveItem parentItem ;
131117
132- public CachedDriveItem ParentItem
133- {
118+ public CachedDriveItem ParentItem {
134119 get { return parentItem ; }
135- set
136- {
120+ set {
137121 parentItem = value ;
138122 NotifyPropertyChanged ( ) ;
139123 }
@@ -158,7 +142,14 @@ public MainWindowViewModel()
158142 public async void GetUserInformation ( )
159143 {
160144 CurrentUsername = "Hi, " + ( await graph . GetOneDriveUserInformationAsync ( ) ) . GivenName ;
161- ProfileImage = await graph . GetOneDriveOwnerPhotoAsync ( ) ;
145+ try
146+ {
147+ ProfileImage = await graph . GetOneDriveOwnerPhotoAsync ( ) ;
148+ }
149+ catch ( ServiceException )
150+ {
151+ // A user may not have a picture.
152+ }
162153 }
163154
164155 /// <param name="obj"></param>
0 commit comments