Пример #1
0
 public ChatPage()
 {
     InitializeComponent();
     _vm                    = new ChatPageViewModel();
     DataContext            = _vm;
     MessageFacade.ChatPage = this;
 }
Пример #2
0
 public ChatPage()
 {
     InitializeComponent();
     chatPageViewModel            = new ChatPageViewModel();
     chatPageViewModel.navigation = Navigation;
     this.BindingContext          = chatPageViewModel;
 }
 public ConnectionManager()
 {
     _hubConnection = new HubConnectionBuilder().WithUrl(Uri + "/chatHub").Build();
     _hubConnection.ServerTimeout = TimeSpan.FromMilliseconds(100000);
     _operationFile     = OperationFile.GetInstance();
     _chatPageViewModel = new ChatPageViewModel();
     _newChatMessage    = new ChatMessage();
 }
Пример #4
0
 public ChatPage(string receiverName, string receiverPhone)
 {
     InitializeComponent();
     this.receiverPhone = receiverPhone;
     chatContext        = new ChatPageViewModel(receiverName, receiverPhone, Constants.AppConstants.appUserName);
     Services.ChatClient.AddMessageListener(OnReceiveMessage);
     BindingContext = chatContext;
 }
Пример #5
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter is object[] arr && arr.Length >= 2 && arr[0] is MajaConversation conversation && arr[1] is SpeechRecognitionService service)
     {
         DataContext = _viewModel = new ChatPageViewModel(conversation, service);
     }
 }
Пример #6
0
        public ChatPage(string usernameSender)
        {
            InitializeComponent();

            viewModel = new ChatPageViewModel(usernameSender, Application.Current.Properties["username"].ToString());

            BindingContext = viewModel;
        }
Пример #7
0
 public ChatPage(string userId)
 {
     InitializeComponent();
     _userId             = userId;
     this.BindingContext = viewModel = new ChatPageViewModel(userId);
     labelTitle.Text     = viewModel.user.FullName;
     imageAvatar.Source  = viewModel.user.AvatarFullUrl;
     this.Initialize();
 }
 public ChatPageView()
 {
     InitializeComponent();
     vm                   = new ChatPageViewModel();
     hubBase              = new HubBase();
     vm.ChatHub           = hubBase;
     hubBase.Subscribers += vm.ReceiveMessagew;
     BindingContext       = vm;
 }
Пример #9
0
        private static void NotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            try
            {
                String notificationContent = String.Empty;

                switch (args.NotificationType)
                {
                case PushNotificationType.Badge:
                    notificationContent = args.BadgeNotification.Content.GetXml();
                    break;

                case PushNotificationType.Tile:
                    notificationContent = args.TileNotification.Content.GetXml();
                    break;

                case PushNotificationType.Toast:
                    notificationContent = args.ToastNotification.Content.GetXml();
                    break;

                case PushNotificationType.Raw:
                    notificationContent = args.RawNotification.Content;
                    break;
                }

                ToastMessage message = JsonConvert.DeserializeObject <ToastMessage>(notificationContent);
                if (App.ApplicationApplicationState == Enums.ApplicationStateType.Active)
                {
                    args.Cancel = true;
                    try
                    {
                        if (ChatPageViewModel.SelectedFriend.Id != message.FromId)
                        {
                            ToastHelper.DisplayTextToast(ToastTemplateType.ToastImageAndText01, message.FromId, message.Content, message.FromPicture);
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }
                }
                else
                {
                }
                ChatPageViewModel chatPageViewModel = ServiceLocator.Current.GetInstance <ChatPageViewModel>();
                chatPageViewModel.UpdateMessages(message.FromId, message.Content);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Пример #10
0
        public ChatPage()
        {
            InitializeComponent();

            BindingContext = vm = new ChatPageViewModel();


            vm.ListMessages.CollectionChanged += (sender, e) =>
            {
                var target = vm.ListMessages[vm.ListMessages.Count - 1];
                MessagesListView.ScrollTo(target, ScrollToPosition.End, true);
            };
        }
Пример #11
0
        public ChatPage(IChatController controller)
        {
            InitializeComponent();

            var vm = new ChatPageViewModel(controller);

            BindingContext = vm;

            vm.ScrollToLast += () =>
            {
                MessagesListView.ScrollTo(controller.CurrentConversation?.Messages.Last(), ScrollToPosition.End, true);
            };
        }
        public ChatView()
        {
            InitializeComponent();

            BindingContext = new ChatPageViewModel();

            ScrollListCommand = new Command(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                                               ChatList.ScrollTo((this.BindingContext as ChatPageViewModel).Messages.Last(), ScrollToPosition.End, true)
                                               );
            });
        }
Пример #13
0
        public ChatPage(SteamID friendSteamID)
        {
            InitializeComponent();
            Title          = sc.bot.SteamFriends.GetFriendPersonaName(friendSteamID);
            BindingContext = vm = new ChatPageViewModel(friendSteamID);


            vm.ListMessages.CollectionChanged += (sender, e) =>
            {
                var target = vm.ListMessages[vm.ListMessages.Count - 1];
                MessagesListView.ScrollTo(target, ScrollToPosition.End, true);
            };
        }
Пример #14
0
        private static void ToastTapped(ToastNotification sender, object args)
        {
            try
            {
                if (args is Dictionary <String, String> )
                {
                    Dictionary <String, String> values            = args as Dictionary <String, String>;
                    ChatPageViewModel           chatPageViewModel = ServiceLocator.Current.GetInstance <ChatPageViewModel>();

                    chatPageViewModel.SetSelectedUser(values["fromId"]);
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Пример #15
0
        public ChatPage(ChatRoomLoader _chatRoomLoader)
        {
            InitializeComponent();
            titleLabel.Text = $"{_chatRoomLoader.Title} Room";
            current_context = new ChatPageViewModel()
            {
                Room_ID = _chatRoomLoader.Id
            };
            this.BindingContext = current_context;
            chatRoomLoader      = _chatRoomLoader;
            Settings_Label.Text = Constants.FontAwe.Cog;

            ScrollListCommand = new Command(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if ((this.BindingContext as ChatPageViewModel).Messages.Count > 0)
                    {
                        ChatList.ScrollTo((this.BindingContext as ChatPageViewModel).Messages.LastOrDefault(), ScrollToPosition.End, false);
                    }
                });
            });

            FocusCommand = new Command(() =>
            {
                chatInput.FocusEntry();
            });

            GetPhotoCommand = new Command(async() =>
            {
                await Navigation.PushModalAsync(new CameraPage(chatRoomLoader));
                chatInput.UnFocusEntry();
            });
            MessagingCenter.Subscribe <object>(this, Constants.go_back, (sender) =>
            {
                Navigation.PopModalAsync();
            });

            MessagingCenter.Subscribe <object>(this, Constants.scroll_chat, (sender) =>
            {
                ScrollListCommand.Execute(null);
            });
        }
Пример #16
0
        private async static void RetrieveFriends()
        {
            try
            {
                Dictionary <String, String> query = new Dictionary <string, string>();
                query.Add("userId", CurrentUser.ProviderIdLong);
                List <Friend> friends = await App.MobileService.InvokeApiAsync <List <Friend> >(ApplicationConstants.GET_USERS_METHOD, HttpMethod.Get, query);

                if (friends != null)
                {
                    ChatPageViewModel chatPageViewModel = ServiceLocator.Current.GetInstance <ChatPageViewModel>();
                    chatPageViewModel.FriendsViewModel = new ObservableCollection <Friend>(friends);
                    chatPageViewModel.SelectedFriend   = friends[0];
                }
            }
            catch (Exception ex)
            {
                HandleInsertChannelException(ex);
            }
        }
Пример #17
0
        public ChatPage()
        {
            try
            {
                InitializeComponent();

                Webview.Source = "https://web-chat.global.assistant.watson.cloud.ibm.com/preview.html?region=eu-gb&integrationID=b097d5fb-d034-40c0-be3b-a61f82f598de&serviceInstanceID=5e250dbe-ef07-4823-96df-3126941ea2a2";

                //BindingContext = vm = new ChatBotViewModel();
                ChatPageViewModel vm = (ViewModels.ChatPageViewModel) this.BindingContext;

                vm.Messages.CollectionChanged += (sender, e) =>
                {
                    var target = vm.Messages[vm.Messages.Count - 1];
                    //MessagesList.ScrollTo(target, ScrollToPosition.End, true);
                };
            }
            catch (Exception ex)
            {
            }
        }
Пример #18
0
        public void ScrollTap(object sender, System.EventArgs e)
        {
            lock (new object())
            {
                if (BindingContext != null)
                {
                    ChatPageViewModel vm = BindingContext as ChatPageViewModel;

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        while (vm.DelayedMessages.Count > 0)
                        {
                            vm.Messages.Insert(0, vm.DelayedMessages.Dequeue());
                        }
                        vm.ShowScrollTap       = false;
                        vm.LastMessageVisible  = true;
                        vm.PendingMessageCount = 0;
                        ChatList?.ScrollToFirst();
                    });
                }
            }
        }
Пример #19
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables MobileServicesUser idle detection will continue to run
                // and consume battery power when the MobileServicesUser is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            ChatPageViewModel = ServiceLocator.Current.GetInstance <ChatPageViewModel>();
        }
Пример #20
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            ViewModel = new ChatPageViewModel(PoorManDependencyResolver.SpellCheckerApi, PoorManDependencyResolver.VisionApi, PoorManDependencyResolver.DialogManager);

            base.OnNavigatedTo(e);
        }
Пример #21
0
 public ChatPage(string RoomID)
 {
     InitializeComponent();
     BindingContext = new ChatPageViewModel(Navigation, RoomID);
 }
Пример #22
0
        private void Client_OnMessageReceived(SignalrUser user)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                if (!user.message.Contains("Connected!") && !user.message.Contains("Reconnected!") && !user.message.Contains("undefined") && !user.message.Contains("Disconnected!"))
                {
                    if (user.username == currentUser.Email) // EĞER GELEN MESAJ BENİM İSE
                    {
                        if (LastMessageOwnerId == currentUser.Id)
                        {
                            ChatPageViewModel chatPageViewModel = new ChatPageViewModel()
                            {
                                isMyMessage         = true,
                                Message             = user.message,
                                SendingTime         = DateTime.Now,
                                isUserChangingPoint = false,
                                SenderUser          = currentUser
                            };
                            //ChatPageViewModels.Add(new ChatPageViewModel()
                            //{
                            //    isMyMessage = true,
                            //    Message = user.message,
                            //    SendingTime = DateTime.Now,
                            //    isUserChangingPoint = false,
                            //    SenderUser = currentUser
                            //});
                            ChatPageViewModels.Add(chatPageViewModel);
                        }
                        else
                        {
                            ChatPageViewModel chatPageViewModel = new ChatPageViewModel()
                            {
                                isMyMessage         = true,
                                Message             = user.message,
                                SendingTime         = DateTime.Now,
                                isUserChangingPoint = true,
                                SenderUser          = currentUser
                            };
                            //ChatPageViewModels.Add(new ChatPageViewModel()
                            //{
                            //    isMyMessage = true,
                            //    Message = user.message,
                            //    SendingTime = DateTime.Now,
                            //    isUserChangingPoint = true,
                            //    SenderUser = currentUser
                            //});
                            ChatPageViewModels.Add(chatPageViewModel);
                        }
                        LastMessageOwnerId = currentUser.Id;
                    }
                    else // EĞER GELEN MESAJ BENİM DEĞİL İSE
                    {
                        if (user.username == messagesPageViewModel.otherUserEmail)
                        {
                            if (LastMessageOwnerId == messagesPageViewModel.OtherUser.Id)
                            {
                                ChatPageViewModel chatPageViewModel = new ChatPageViewModel()
                                {
                                    isMyMessage         = false,
                                    Message             = user.message,
                                    SendingTime         = DateTime.Now,
                                    isUserChangingPoint = false,
                                    SenderUser          = messagesPageViewModel.OtherUser
                                };

                                ChatPageViewModels.Add(chatPageViewModel);
                            }
                            else
                            {
                                ChatPageViewModel chatPageViewModel = new ChatPageViewModel()
                                {
                                    isMyMessage         = false,
                                    Message             = user.message,
                                    SendingTime         = DateTime.Now,
                                    isUserChangingPoint = true,
                                    SenderUser          = messagesPageViewModel.OtherUser
                                };

                                ChatPageViewModels.Add(chatPageViewModel);
                            }
                            LastMessageOwnerId = messagesPageViewModel.OtherUser.Id;
                        }
                    }
                    colMessages.ItemsSource = null;
                    colMessages.ItemsSource = ChatPageViewModels;
                    colMessages.ScrollTo(ChatPageViewModels.Last(), -1, ScrollToPosition.End, true);
                }
            });
        }
Пример #23
0
 public SendMessageCommand(ChatPageViewModel parentModel)
 {
     ParentModel = parentModel;
     parentModel.PropertyChanged += delegate { CanExecuteChanged?.Invoke(this, EventArgs.Empty); };
 }
Пример #24
0
        public static List <Conversation> GenerateFakeConversations()
        {
            var result = new List <Conversation>()
            {
                new Conversation()
                {
                    Title         = "Normal Conversation",
                    LatestMessage = new Message()
                    {
                        User = "******", Text = "Some Latest Message", SubmittedDate = DateTime.Now
                    },
                    HTMLTable = @"<table style=""width:100 % "">
  <tr>
    <th> Firstname </th>
    <th> Lastname </th>
    <th> Age </th>
  </tr>
  <tr>
    <td> Jill </td>
    <td> Smith </td>
    <td> 50 </td>
  </tr>
  <tr>
    <td> Eve </td>
    <td> Jackson </td>
    <td> 94 </td>
  </tr>
</table> "
                },
                new Conversation()
                {
                    Title = "aisdjiasdji"
                }
            };


            var Messages = result[0].Messages;

            for (int i = 0, j = 0; i < 70; i++)
            {
                var msg = ChatPageViewModel.GenRandomMessage();
                msg.SubmittedDate = DateTime.Now.Add(new TimeSpan((24 * j * -1), -i, 0));
                string txt = "A";
                msg.Text = "A";
                for (int k = 0; k < i; k++)
                {
                    msg.Text += txt;
                    msg.Text += txt;
                    msg.Text += txt;
                }

                msg.IsMasked = false;
                if (i % 3 == 0)
                {
                    msg.IsMasked = true;
                }
                Messages.Add(msg);
            }
            for (int i = 0; i < 10; i++)
            {
                result.Add(new Conversation()
                {
                    Title = $"Conversation {i}"
                });
            }


            return(result);
        }
Пример #25
0
        /// <summary>
        /// Invoked when the application is launched normally by the end MobileServicesUser.  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)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            timer.Interval = new TimeSpan(0, 0, 0, 1);
            //timer.Tick += CheckIfAppIsSuspended();
            Frame rootFrame = Window.Current.Content as Frame;
            ApplicationApplicationState = Enums.ApplicationStateType.Active;
            // 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();
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            ChatPageViewModel = ServiceLocator.Current.GetInstance <ChatPageViewModel>();

            Window.Current.VisibilityChanged += CheckIfAppIsSuspended;

            //MainPage.RegisterWithMobileServices();

            // Ensure the current window is active
            Window.Current.Activate();

            RegisterBackgroundTask();

            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

                Object userEntry = ApplicationDataManager.GetValue(ApplicationConstants.UserKey);
                if (userEntry != null)
                {
                    try
                    {
                        App.CurrentUser = JsonConvert.DeserializeObject <UserEntity>((String)userEntry);
                        if (App.CurrentUser != null)
                        {
                            try
                            {
                                if (CurrentUser.IdentityProvider == Enums.IdentityProvider.MicrosoftAccount)
                                {
                                    App.MobileServicesUser = await App.MobileService.LoginWithMicrosoftAccountAsync(CurrentUser.AccessToken);
                                }

                                else
                                {
                                    dynamic jToken = new JObject();
                                    IdentityProviderParser.RetrieveTokenObjectSpecificToIdentityProvider(CurrentUser.IdentityProvider, CurrentUser.AccessToken, CurrentUser.AccessTokenSecret, out jToken);
                                    App.MobileServicesUser = await App.MobileService.LoginAsync(CurrentUser.IdentityProvider.ToString(), jToken);
                                }
                                RegisterWithMobileServices(CurrentUser.IdentityProvider.ToString());
                                rootFrame.Navigate(typeof(ChatPage), e.Arguments);
                                return;
                            }
                            catch (Exception ex)
                            {
                                ex.ToString();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }
                }

                rootFrame.Navigate(typeof(LoginPage), e.Arguments);
            }
        }
Пример #26
0
 public ChatPage()
 {
     InitializeComponent();
     vm = BindingContext as ChatPageViewModel;
 }
Пример #27
0
 public ChatPage()
 {
     BindingContext = new ChatPageViewModel(new PageService());
     InitializeComponent();
 }
Пример #28
0
 public ChatPage(ChatPageViewModel vm)
 {
     this.BindingContext = vm;
     InitializeComponent();
 }
Пример #29
0
 public ChatPage()
 {
     InitializeComponent();
     Storage.IsChatNow = true;
     BindingContext    = new ChatPageViewModel();
 }
Пример #30
0
        public ChatPage(SavedChats savedChats, UsersInfoModel usersInfoModel)
        {
            InitializeComponent();

            DataContext = new ChatPageViewModel(savedChats, usersInfoModel);
        }