예제 #1
0
        private void ViewChatFromHistory(object match)
        {
            Console.WriteLine("STATUS: Getting chat from history");
            ChatData chatData = ChatHistoryList.Single(chat => chat.SearchString == (string)match);

            OnlineViewModel.LoadChatAsHistory(chatData);
        }
예제 #2
0
 /// <summary>
 /// Switches app state to the online view
 /// </summary>
 /// <param name="user">User object containing information chosen by the user</param>
 public void ChangeToOnlineView(User user)
 {
     Console.WriteLine("STATUS: Going online");
     OnlineViewModel        = new OnlineViewModel(this, user);
     MainWindow.Closing    += OnlineViewModel.MenuViewModel.ClosingApp;
     MainWindow.Closing    += OnlineViewModel.ChatViewModel.ClosingApp;
     MainWindow.Closing    += OnlineViewModel.ClosingApp;
     MainWindow.DataContext = OnlineViewModel;
 }
        private void SaveToChatHistory()
        {
            Console.WriteLine("STATUS: Saving chat to history");
            ChatData chatData = new ChatData(Connection.LocalUser, Connection.RemoteUser,
                                             HistoryConverter.ChatToHistory(UserMessages),
                                             HistoryConverter.ChatToHistory(RemoteMessages),
                                             DateTime.Now.ToString());

            OnlineViewModel.AddToHistory(chatData);
        }
예제 #4
0
        private async void HandleExit()
        {
            Console.WriteLine("STATUS: Handling exit");
            await Connection.SendNetworkData(new NetworkData(User, NetworkDataType.Response, "", ResponseType.Exit));

            if (Connection.State == ConnectionState.Chatting)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    OnlineViewModel.ExitChat();
                });
            }
            Connection.State = ConnectionState.Listening;
        }
        public ChatViewModel(OnlineViewModel onlineViewModel, User user, Connection connection)
        {
            User       = user;
            Connection = connection;
            Connection.AddRemoteMessage = AddReceivedMessage;
            Connection.PrepareChat      = CloseHistoryMode;
            OnlineViewModel             = onlineViewModel;

            UserMessages   = new ObservableCollection <ChatMessage>();
            RemoteMessages = new ObservableCollection <ChatMessage>();

            SendTextCommand        = new DelegateCommand(SendTextMessage, CanUseChatButtons);
            SendImageButtonCommand = new DelegateCommand(SendImageMessage, CanUseChatButtons);
            BuzzButtonCommand      = new DelegateCommand(SendBuzz, CanUseChatButtons);
        }
예제 #6
0
        /// <summary>
        /// MenuViewModel constructor
        /// </summary>
        /// <param name="onlineViewModel">Parent viewmodel</param>
        /// <param name="user">User information</param>
        public MenuViewModel(OnlineViewModel onlineViewModel, User user, Connection connection)
        {
            User       = user;
            Connection = connection;
            Connection.UpdateMenuButtons = UpdateButtons;
            OnlineViewModel = onlineViewModel;

            ChatHistoryList     = new ObservableCollection <ChatData>();
            FilteredHistoryList = new ObservableCollection <ChatData>();
            Task.Run(() => LoadHistory());

            // Create new command objects
            SendRequestCommand   = new DelegateCommand(SendRequest, IsDisconnected);
            ExitButtonCommand    = new DelegateCommand(HandleExit);
            AcceptButtonCommand  = new DelegateCommand(AcceptRequest);
            DeclineButtonCommand = new DelegateCommand(DeclineRequest);
            ViewChatCommand      = new ParameterCommand(ViewChatFromHistory, IsDisconnected);
        }