Exemplo n.º 1
0
        public FriendViewModel(IDataService dataService, int friendNumber)
        {
            _toxModel      = dataService.ToxModel;
            _avatarManager = dataService.AvatarManager;

            FriendNumber = friendNumber;

            Conversation  = new ConversationViewModel(dataService, this);
            FileTransfers = new FileTransfersViewModel(dataService, friendNumber);
            Call          = new CallViewModel(friendNumber);

            Name = _toxModel.GetFriendName(friendNumber);
            if (Name == string.Empty)
            {
                Name = _toxModel.GetFriendPublicKey(friendNumber).ToString();
            }

            StatusMessage = _toxModel.GetFriendStatusMessage(friendNumber);
            if (StatusMessage == string.Empty)
            {
                StatusMessage = "Friend request sent.";
            }

            SetFriendStatus(_toxModel.GetFriendStatus(friendNumber));
            IsConnected = _toxModel.IsFriendOnline(friendNumber);

            _avatarManager.FriendAvatarChanged += FriendAvatarChangedHandler;

            _toxModel.FriendNameChanged             += FriendNameChangedHandler;
            _toxModel.FriendStatusMessageChanged    += FriendStatusMessageChangedHandler;
            _toxModel.FriendStatusChanged           += FriendStatusChangedHandler;
            _toxModel.FriendConnectionStatusChanged += FriendConnectionStatusChangedHandler;
        }
Exemplo n.º 2
0
        private ProfileViewModel(IDataService dataService, ToxData toxData, ToxDataInfo toxDataInfo)
        {
            _toxModel      = dataService.ToxModel;
            _avatarManager = dataService.AvatarManager;

            _toxData     = toxData;
            _toxDataInfo = toxDataInfo;
        }
Exemplo n.º 3
0
        public UserViewModel(IDataService dataService)
        {
            _toxModel      = dataService.ToxModel;
            _avatarManager = dataService.AvatarManager;

            _toxModel.PropertyChanged        += ToxModelPropertyChangedHandler;
            _avatarManager.UserAvatarChanged += UserAvatarChangedHandler;
        }
        public ProfileManagementViewModel(IDataService dataService)
        {
            _dataService   = dataService;
            _toxModel      = dataService.ToxModel;
            _avatarManager = dataService.AvatarManager;

            Profiles = new ObservableCollection <ProfileViewModel>();
        }
Exemplo n.º 5
0
        public AvatarManager(IToxModel toxModel)
        {
            _toxModel = toxModel;
            _avatarTransferManager = new AvatarTransferManager(toxModel, this);

            ResetUserAvatar();
            FriendAvatars = new Dictionary <int, BitmapImage>();
            _toxModel.FriendConnectionStatusChanged += FriendConnectionStatusChangedHandler;
        }
Exemplo n.º 6
0
        public OneFriendRequestViewModel(IToxModel toxModel, FriendRequestsViewModel friendRequestsViewModel,
                                         ToxKey publicKey,
                                         string message)
        {
            _toxModel = toxModel;

            _friendRequestsViewModel = friendRequestsViewModel;
            _publicKey = publicKey;
            Message    = message;
        }
Exemplo n.º 7
0
        public ProfileSettingsViewModel(IDataService dataService)
        {
            _toxModel      = dataService.ToxModel;
            _avatarManager = dataService.AvatarManager;

            _toxModel.PropertyChanged             += ToxModelPropertyChangedHandler;
            _avatarManager.UserAvatarChanged      += UserAvatarChangedHandler;
            _avatarManager.IsUserAvatarSetChanged += IsUserAvatarSetChangedHandler;
            RefreshQrCodeId();
        }
Exemplo n.º 8
0
        public FileTransfersModel(IDataService dataService, int friendNumber)
        {
            _dataService         = dataService;
            _toxModel            = dataService.ToxModel;
            _fileTransferResumer = dataService.FileTransferResumer;

            _friendNumber = friendNumber;
            _toxModel.FileSendRequestReceived       += FileSendRequestReceivedHandler;
            _toxModel.FriendConnectionStatusChanged += FriendConnectionStatusChangedHandler;
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Invoked when the application is launched normally by the end user.  Other entry points
        ///     will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            DispatcherHelper.Initialize();

            // We cheat a little bit here... TODO: Fix it! Until then: Please, don't use ServiceLocator anywhere else in the code than ViewModelLocator!
            var dataService = ServiceLocator.Current.GetInstance <IDataService>();

            _toxModel      = dataService.ToxModel;
            _avatarManager = dataService.AvatarManager;

            var rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
                // Set the default language
                rootFrame.Language = ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                await HandlePreviousExecutionState(e.PreviousExecutionState);

                await InitializeSingletons();

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (Window.Current.Bounds.Width < 930)
                {
                    rootFrame.Navigate(typeof(FriendListPage));
                }
                else
                {
                    rootFrame.Navigate(typeof(MainPage));
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size {
                Width = 500, Height = 500
            });
        }
Exemplo n.º 10
0
        public AvatarTransferManager(IToxModel toxModel, AvatarManager avatarManager)
        {
            _toxModel      = toxModel;
            _avatarManager = avatarManager;

            _transfers = new Dictionary <TransferId, TransferData>();

            _toxModel.FileControlReceived     += FileControlReceivedHandler;
            _toxModel.FileChunkRequested      += FileChunkRequestedHandler;
            _toxModel.FileSendRequestReceived += FileSendRequestReceivedHandler;
            _toxModel.FileChunkReceived       += FileChunkReceivedHandler;
        }
Exemplo n.º 11
0
        public ConversationViewModel(IDataService dataService, FriendViewModel friendViewModel)
        {
            _dataService = dataService;
            _toxModel    = dataService.ToxModel;

            _friendViewModel = friendViewModel;
            MessageGroups    = new ObservableCollection <MessageGroupViewModel>();
            _toxModel.FriendMessageReceived += FriendMessageReceivedHandler;
            _toxModel.FriendTypingChanged   += FriendTypingChangedHandler;

            RestoreMessageHistory(dataService.MessageHistoryManager);
        }
Exemplo n.º 12
0
        public FriendRequestsViewModel(IDataService dataService)
        {
            _toxModel = dataService.ToxModel;

            Requests = new ObservableCollection <OneFriendRequestViewModel>();
            Requests.CollectionChanged      += FriendRequestsCollectionChangedHandler;
            _toxModel.FriendRequestReceived += FriendRequestReceivedHandler;

            RestoreData();

            DecideFriendRequestsListVisibility();
        }
Exemplo n.º 13
0
        public SentMessageViewModel(IDataService dataService, string text, DateTime timestamp,
                                    ToxMessageType messageType, int id, FriendViewModel target, MessageDeliveryState state)
        {
            _toxModel = dataService.ToxModel;

            Text        = text;
            Timestamp   = timestamp;
            MessageType = messageType;
            Sender      = new UserViewModel(dataService);
            Id          = id;
            _target     = target;
            State       = state;

            if (state == MessageDeliveryState.Pending)
            {
                _toxModel.ReadReceiptReceived           += ReadReceiptReceivedHandler;
                _toxModel.FriendConnectionStatusChanged += FriendConnectionStatusChangedHandler;

                SetupAndStartResendTimer();
            }
        }
Exemplo n.º 14
0
        public FriendListViewModel(IDataService dataService)
        {
            _dataService = dataService;
            _toxModel    = dataService.ToxModel;

            Friends = new ObservableCollection <FriendViewModel>();

            foreach (var friendNumber in _toxModel.Friends)
            {
                // TODO: Remember which friend we talked last and set the selection to that one by default!
                if (Friends.Count == 0)
                {
                    SelectedFriend = new FriendViewModel(_dataService, friendNumber);
                    Friends.Add(SelectedFriend);
                    continue;
                }
                //

                Friends.Add(new FriendViewModel(dataService, friendNumber));
            }

            _toxModel.FriendListChanged += FriendListChangedHandler;
        }
Exemplo n.º 15
0
 public AvatarResizer(IToxModel toxModel, StorageFolder avatarsFolder, StorageFile avatarFile)
 {
     _toxModel      = toxModel;
     _avatarsFolder = avatarsFolder;
     _avatarFile    = avatarFile;
 }
Exemplo n.º 16
0
 public AddFriendViewModel(IDataService dataService)
 {
     _toxModel = dataService.ToxModel;
 }
Exemplo n.º 17
0
        public FileTransferResumer(IToxModel toxModel)
        {
            _toxModel = toxModel;

            _toxModel.FriendListChanged += FriendListChangedHandler;
        }