Exemple #1
0
        /// <summary>
        /// Enters a group conversation
        /// </summary>
        /// <param name="sender">A reference to the ListView (i think)</param>
        /// <param name="e">A reference to the GroupsContent</param>
        public void groupClicked(object sender, ItemClickEventArgs e)
        {
            GroupsContent           group = (GroupsContent)e.ClickedItem;
            MessageHistoryViewModel view  = group.messageHistoryViewModel;

            RightFrameNavigator.Navigate(typeof(MessageHistoryView), view);
        }
Exemple #2
0
        /// <summary>
        /// Updates the frames to display the newly created group
        /// <param>groupContent: The newly created GroupsContent</param>
        public void displayNewGroup(GroupsContent groupContent)
        {
            bool frameVisible = LeftFrameNavigator.isSubFrameVisible();

            // determine whether to add the group to the group list or journal list
            // switch to that list
            if (groupContent.group.GroupMembers.Count == 1)
            {
                journalList.Add(groupContent);
                switchToJournal();
            }
            else
            {
                convoList.Add(groupContent);
                switchToGroups();
            }

            //display the new conversation in the proper frame
            if (frameVisible)
            {
                LeftFrameNavigator.NavigateSubFrame(typeof(MessageHistoryView), groupContent.messageHistoryViewModel);
                RightFrameNavigator.Navigate(typeof(MessageHistoryView), groupContent.messageHistoryViewModel);
                RightFrameNavigator.Navigate(typeof(CanvasPage), groupContent);
            }
            else
            {
                RightFrameNavigator.Navigate(typeof(MessageHistoryView), groupContent.messageHistoryViewModel);
            }
        }
Exemple #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            sideBar.Navigate(typeof(GroupsSideBar));

            ProfileNavigator.ClearFrame();
            LeftFrameNavigator.Navigate(typeof(GroupsView), "");
            LeftFrameNavigator.ClearSubFrame();
            RightFrameNavigator.Navigate(typeof(MessageHistoryView));
        }
Exemple #4
0
 private void toggleCanvasView()
 {
     if (LeftFrameNavigator.isSubFrameVisible())
     {
         // change the view
         LeftFrameNavigator.ClearSubFrame();
         RightFrameNavigator.Navigate(typeof(MessageHistoryView), this);
     }
     else
     {
         // change the view
         LeftFrameNavigator.NavigateSubFrame(typeof(MessageHistoryView), this);
         RightFrameNavigator.Navigate(typeof(CanvasPage), group);
     }
 }
Exemple #5
0
        public MainPage()
        {
            this.InitializeComponent();

            // set the sidebar to GroupsSideBar
            sideBar.Navigate(typeof(GroupsSideBar));

            // set the Frame Navigator instances for navigating through the frames
            ProfileNavigator.SetFrame(profileFrame);
            LeftFrameNavigator.SetFrame(leftFrame);
            RightFrameNavigator.SetFrame(rightFrame);

            viewModel                = new MainPageViewModel();
            this.DataContext         = viewModel;
            this.NavigationCacheMode = NavigationCacheMode.Required;
        }
Exemple #6
0
        /// <summary>
        /// Creates a popup box to allow the user to change the group name and then sends the
        /// updated groupname to the server
        /// </summary>
        public async Task changeGroupNameAsync(GroupsContent groupContent)
        {
            if (App.User != null)
            {
                string currentGroupName     = groupContent.group.Name;
                Tuple <Boolean, String> tup = await createGroupNameInputDialog();

                // User inputs
                Boolean cancelled    = tup.Item1;
                string  newGroupName = tup.Item2;
                if (!cancelled && newGroupName != "")
                {
                    GroupChat updatedGroup = await renameGroupChat(groupContent.group, newGroupName);

                    // Display message to user if the name change failed (no server)
                    if (updatedGroup == null)
                    {
                        ContentDialog noServerDialog = new ContentDialog()
                        {
                            Title             = "Cannot change groupname",
                            Content           = "Is your wifi down?",
                            PrimaryButtonText = "Ok"
                        };
                        await ContentDialogHelper.CreateContentDialogAsync(noServerDialog, true);
                    }
                    else
                    {
                        string members = await getGroupMemberNames(updatedGroup);

                        GroupsContent updatedContent = new GroupsContent(updatedGroup, members);
                        updatedContent.updateCanvasFrom(groupContent);

                        // Preserve ordering
                        int originalIndex = getGroupsContentIndex(groupContent.group.id);
                        GroupsList.Remove(groupContent);
                        GroupsList.Insert(originalIndex, updatedContent);

                        // if the user is currently looking at the group, update the group content message history
                        if (RightFrameNavigator.GetLastContext() != null &&
                            RightFrameNavigator.GetLastContext().Equals(groupContent.messageHistoryViewModel))
                        {
                            RightFrameNavigator.Navigate(typeof(MessageHistoryView), updatedContent.messageHistoryViewModel);
                        }
                    }
                }
            }
        }
        private void GroupsButton_Click(object sender, RoutedEventArgs e)
        {
            LeftFrameNavigator.Navigate(typeof(GroupsView), "groups");

            if (LeftFrameNavigator.isSubFrameVisible())
            {
                LeftFrameNavigator.ClearSubFrame();
                RightFrameNavigator.NavigateToLastMessageHistory();
            }

            if (ProfileNavigator.isFrameVisible())
            {
                ProfileNavigator.ClearFrame();
                ProfileButton.Visibility = Visibility.Visible;
                BackButton.Visibility    = Visibility.Collapsed;
            }
        }
Exemple #8
0
        public async void messageClicked(ItemClickEventArgs e)
        {
            MessageContent clickedMessage = (MessageContent)e.ClickedItem;
            Uri            path           = clickedMessage.imageSource;

            if (path != null)
            {
                group.backgroundPath = path.ToString();

                if (!LeftFrameNavigator.isSubFrameVisible())
                {
                    LeftFrameNavigator.NavigateSubFrame(typeof(MessageHistoryView), this);
                }

                RightFrameNavigator.Navigate(typeof(CanvasPage), group);
            }
        }
Exemple #9
0
        public async void deleteGroup(GroupsContent groupContent)
        {
            int     numMembers         = groupContent.group.GroupMembers.Count;
            Boolean leaveOrDeleteGroup = false;

            // If there are more than 1 members in this group, we leave the chat
            if (numMembers > 1)
            {
                leaveOrDeleteGroup = await createLeaveGroupWarningDialog();
            }
            // If you are the last member in the group, we delete the group
            else
            {
                leaveOrDeleteGroup = await createDeleteGroupWarningDialog();
            }
            // Make rest call and refresh gui
            if (leaveOrDeleteGroup)
            {
                var res = await deleteGroupChat(groupContent.group);

                GroupsList.Remove(groupContent);

                // clear the right frame if the user is currently looking at the deleted group
                if (RightFrameNavigator.GetLastContext() != null &&
                    RightFrameNavigator.GetLastContext().Equals(groupContent.messageHistoryViewModel))
                {
                    RightFrameNavigator.Navigate(typeof(MessageHistoryView));
                }
            }
            // refresh gui
            else
            {
                // Preserve ordering
                int originalIndex = getGroupsContentIndex(groupContent.group.id);
                GroupsList.Remove(groupContent);
                GroupsList.Insert(originalIndex, groupContent);
                //retrieveGroupsFromServer();
            }
        }
 /// <summary>
 /// Resets the screen, returns to the Home Screen of the app
 /// Left Frame: List of groups
 /// Right Frame: Empty screen
 /// </summary>
 public void resetScreen()
 {
     LeftFrameNavigator.Navigate(typeof(GroupsView), "groups");
     LeftFrameNavigator.ClearSubFrame();
     RightFrameNavigator.Navigate(typeof(MessageHistoryView));
 }