public FriendRequestsPage() { InitializeComponent(); _photosToLoad = new Dictionary<FriendViewModel, AvatarLoadItem>(); _imageCache = new ImageCache(); _CreateBar(); FriendRequestsPanel.ItemsSource = App.Current.EntityService.FriendsRequests; App.Current.EntityService.FriendsRequests.CollectionChanged += FriendsRequests_CollectionChanged; PossibleFriendsPanel.ItemsSource = App.Current.EntityService.FriendsMutual; if (App.Current.EntityService.FriendsRequests.Count == 0 || App.Current.EntityService.FriendsRequests.Count != App.Current.EntityService.StateCounter.CountOfRequests) { GlobalIndicator.Instance.Text = AppResources.SearchFriendRequests; GlobalIndicator.Instance.IsLoading = true; TitlePanel.Text = string.Format(AppResources.FriendRequests, 0); App.Current.EntityService.GetFriendRequests(_LoadingFriendsInfoFinished); } else { TitlePanel.Text = string.Format(AppResources.FriendRequests, App.Current.EntityService.FriendsRequests.Count); if (App.Current.EntityService.FriendsMutual.Any()) PeopleMayKnowLabel.Visibility = System.Windows.Visibility.Visible; else PeopleMayKnowLabel.Visibility = System.Windows.Visibility.Collapsed; } }
public GlobalSearchPage() { InitializeComponent(); _results = new ObservableCollection<FriendViewModel>(); _photosToLoad = new Dictionary<FriendViewModel, AvatarLoadItem>(); _imageCache = new ImageCache(); FriendsPanel.ItemsSource = _results; }
public ChatViewModel(int id, string name, bool isConference, IList<Message> messagesHistory, ImageCache imageCache) { _id = id; _isConference = isConference; _name = string.Empty; if (!string.IsNullOrEmpty(name)) _name = name.ToUpper(); _imageCache = imageCache; Messages = new ObservableCollection<MessageViewModel>(); _defaultAvatar = ResourceHelper.GetBitmap(@"/SlXnaApp1;component/Images/Photo_Placeholder.png"); UpdateAllMessages(messagesHistory); }
public EntityService() { _dialogsCache = new DialogsCache(); _friendsCache = new FriendsCache(); _usersCache = new UsersCache(); _imageCache = new ImageCache(); _messagesCache = new MessagesCache(); Dialogs = new ObservableCollection<Dialog>(); Contacts = new ObservableCollection<PhoneContact>(); Friends = new ObservableCollection<FriendViewModel>(); FriendsRequests = new ObservableCollection<FriendViewModel>(); FriendsMutual = new ObservableCollection<FriendViewModel>(); AttachmentPhotos = new Dictionary<string, Stream>(); OtherUsers = new ObservableCollection<UserInfo>(); IsLoadingMessagesHistory = false; _settings = new Settings(new ProtectDataAdapter()); _stateCounter = new StateCounter(0, new List<int>()); DefaultAvatar = ResourceHelper.GetBitmap(@"/SlXnaApp1;component/Images/Photo_Placeholder.png"); CurrentUser = new CurrentUserInfo(null, DefaultAvatar); App.Current.UpdatesService.UserBecomeOffline += UpdatesService_UserBecomeOffline; App.Current.UpdatesService.UserBecomeOnline += UpdatesService_UserBecomeOnline; App.Current.UpdatesService.MessageAdded += UpdatesService_MessageAdded; App.Current.UpdatesService.MessageDeleted += UpdatesService_MessageDeleted; App.Current.UpdatesService.MessageFlagsChanged += UpdatesService_MessageFlagsChanged; App.Current.UpdatesService.MessageRemovedFlags += UpdatesService_MessageRemovedFlags; App.Current.UpdatesService.MessageSetFlags += UpdatesService_MessageSetFlags; App.Current.UpdatesService.ChatChanged += UpdatesService_ChatChanged; App.Current.UpdatesService.TypingInChatStarted += UpdatesService_TypingInChatStarted; App.Current.UpdatesService.TypingInGroupChatStarted += UpdatesService_TypingInGroupChatStarted; try { var info = App.GetResourceStream(new Uri("Resources/Untitled.wav", UriKind.Relative)); _soundEffect = SoundEffect.FromStream(info.Stream); } catch (Exception ex) { Debug.WriteLine("Loading SoundEffect failed: " + ex.Message); } }
private bool _AddLocationAttachment() { if (!string.IsNullOrEmpty(App.Current.EntityService.AttachedLatitude) && !string.IsNullOrEmpty(App.Current.EntityService.AttachedLongitude)) { try { string uri = String.Format(AppResources.GeolocationMapUriFormatMessage, App.Current.EntityService.AttachedLatitude.Replace(",", "."), App.Current.EntityService.AttachedLongitude.Replace(",", ".")); var avm = new AttachmentViewModel(-1, -1, -1, AttachmentType.Location, uri, null, null, null, null); _model.Add(avm); string filename = CommonHelper.DoDigest(uri); var photosToLoad = new List<AvatarLoadItem>(); photosToLoad.Add(new AvatarLoadItem(1, uri, filename)); var service = new AsyncAvatarsLoader(); if (photosToLoad.Any()) service.LoadAvatars(photosToLoad.ToList(), id => { Deployment.Current.Dispatcher.BeginInvoke(() => { try { ImageCache cache = new ImageCache(); BitmapImage image = cache.GetItem(filename); if (image != null && image.PixelHeight > 0 && image.PixelWidth > 0) { avm.AttachPhoto = image; } } catch (Exception ex) { Debug.WriteLine("_AddLocationAttachment failed in AttachmentsPage: " + ex.Message); } }); }, null); } catch (Exception ex) { Debug.WriteLine("Load attached location photo failed " + ex.Message); } return true; } return false; }