public UnreadItemsNotificationsBackgroundTask()
 {
     _localNotificationService = new WindowsNotificationService();
     _gitterApiService = new GitterApiService();
     _passwordStorageService = new PasswordStorageService();
     _applicationStorageService = new ApplicationStorageService();
 }
示例#2
0
 public SessionService(AuthenticationService authenticationService,
     IGitterApiService gitterApiService,
     IPasswordStorageService passwordStorageService)
 {
     _authenticationService = authenticationService;
     _gitterApiService = gitterApiService;
     _passwordStorageService = passwordStorageService;
 }
示例#3
0
        public MainViewModel(IGitterApiService gitterApiService,
            ILocalNotificationService localNotificationService,
            IApplicationStorageService applicationStorageService,
            IProgressIndicatorService progressIndicatorService,
            IPasswordStorageService passwordStorageService,
            IEventService eventService,
            ITelemetryService telemetryService,
            INavigationService navigationService)
        {
            // Services
            _gitterApiService = gitterApiService;
            _localNotificationService = localNotificationService;
            _applicationStorageService = applicationStorageService;
            _progressIndicatorService = progressIndicatorService;
            _passwordStorageService = passwordStorageService;
            _eventService = eventService;
            _navigationService = navigationService;
            _telemetryService = telemetryService;

            // Commands
            SelectRoomCommand = new RelayCommand<IRoomViewModel>(SelectRoom);
            ChatWithUsCommand = new RelayCommand(ChatWithUs, CanChatWithUs);
            GoToAboutPageCommand = new RelayCommand(GoToAboutPage);
            RefreshCommand = new RelayCommand(Refresh, () => !IsRefreshing);
            ToggleSearchCommand = new RelayCommand<bool>(ToggleSearch);

            // Properties
            CurrentDateTime = DateTime.Now;

            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.

                CurrentUser = new User
                {
                    Id = "53307734c3599d1de448e192",
                    Username = "******",
                    DisplayName = "Mauro Pompilio",
                    Url = "/malditogeek",
                    SmallAvatarUrl = "https://avatars.githubusercontent.com/u/14751?",
                    MediumAvatarUrl = "https://avatars.githubusercontent.com/u/14751?"
                };

                var suprememoocow = new User
                {
                    Id = "53307831c3599d1de448e19a",
                    Username = "******",
                    DisplayName = "Andrew Newdigate",
                    Url = "/suprememoocow,",
                    SmallAvatarUrl = "https://avatars.githubusercontent.com/u/594566?",
                    MediumAvatarUrl = "https://avatars.githubusercontent.com/u/594566?"
                };

                Rooms.Add(new RoomViewModel(new Room
                {
                    Id = "53307860c3599d1de448e19d",
                    Name = "Andrew Newdigate",
                    Topic = string.Empty,
                    OneToOne = true,
                    Users = new[] { suprememoocow },
                    UnreadItems = 52,
                    UnreadMentions = 0,
                    DisabledNotifications = false,
                    Type = "ONETOONE"
                }, gitterApiService, localNotificationService, progressIndicatorService, eventService, telemetryService, this));

                Rooms.Add(new RoomViewModel(new Room
                {
                    Id = "5330777dc3599d1de448e194",
                    Name = "gitterHQ",
                    Topic = "Gitter",
                    Url = "gitterHQ",
                    OneToOne = false,
                    UserCount = 2,
                    UnreadItems = 0,
                    UnreadMentions = 0,
                    LastAccessTime = new DateTime(2014, 3, 24, 18, 22, 28),
                    DisabledNotifications = false,
                    Type = "ORG",
                    Version = 1
                }, gitterApiService, localNotificationService, progressIndicatorService, eventService, telemetryService, this));

                Rooms.Add(new RoomViewModel(new Room
                {
                    Id = "5330780dc3599d1de448e198",
                    Name = "gitterHQ/devops",
                    Topic = string.Empty,
                    Url = "gitterHQ/devops",
                    OneToOne = false,
                    UserCount = 2,
                    UnreadItems = 3,
                    UnreadMentions = 0,
                    LastAccessTime = new DateTime(2014, 3, 24, 18, 23, 10),
                    DisabledNotifications = false,
                    Type = "ORG_CHANNEL",
                    Version = 1
                }, gitterApiService, localNotificationService, progressIndicatorService, eventService, telemetryService, this));

                Rooms.Add(new RoomViewModel(new Room
                {
                    Id = "53307793c3599d1de448e196",
                    Name = "malditogeek/vmux",
                    Topic = "VMUX - Plugin-free video calls in your browser using WebRTC",
                    Url = "gitterHQ/devops",
                    OneToOne = false,
                    UserCount = 2,
                    UnreadItems = 42,
                    UnreadMentions = 0,
                    LastAccessTime = new DateTime(2014, 3, 24, 18, 21, 08),
                    DisabledNotifications = false,
                    Type = "REPO",
                    Version = 1
                }, gitterApiService, localNotificationService, progressIndicatorService, eventService, telemetryService, this));

                SelectedRoom = Rooms.FirstOrDefault();

                foreach (var room in Rooms)
                    SearchedRooms.Add(room);
            }
            else
            {
                // Code runs "for real"

                // Events
                _eventService.ReadRoom
                    .Subscribe(room =>
                    {
                        HtmlToXaml.HtmlToXaml.RoomName = room.Room.Name;
                    });

                HtmlToXaml.HtmlToXaml.ImageTapped += (sender, args) =>
                {
                    var image = sender as Image;
                    var bitmapImage = image.Source as BitmapImage;

                    ViewModelLocator.FullImage.Source = bitmapImage.UriSource.OriginalString;
                    _navigationService.NavigateTo("FullImage");
                };

                // Retrieve access token to use in the app
                string token = _passwordStorageService.Retrieve("token");
                _gitterApiService.SetToken(token);

                // Add event that will update READ new messages
                _currentSelectedRoomUnreadMessages = _eventService.NotifyUnreadMessages
                    .Subscribe(async unreadMessages => await NotifyReadMessages(unreadMessages));
            }
        }
 public NotificationsBackgroundTask()
 {
     _gitterApiService = new GitterApiService();
     _passwordStorageService = new PasswordStorageService();
     _applicationStorageService = new ApplicationStorageService();
 }