private static async Task OnContactPanelActivated(ContactPanelActivatedEventArgs task) { Analytics.TrackEvent("Unicord_LaunchForMyPeople"); if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); try { var id = await ContactListManager.TryGetChannelIdAsync(task.Contact); if (id != 0) { rootFrame.Navigate(typeof(MainPage), new MainPageArgs() { UserId = id, FullFrame = true, IsUriActivation = false }); } } catch { Analytics.TrackEvent("Unicord_MyPeopleFailedToFindPerson"); var dialog = new MessageDialog("Something went wrong trying to find this person, sorry!", "Whoops!"); await dialog.ShowAsync(); } // Place the frame in the current Window Window.Current.Content = rootFrame; } Window.Current.Activate(); }
public async void OnActivated(ContactPanelActivatedEventArgs args) { // Register the handler for a full app launch from the My People flyout args.ContactPanel.LaunchFullAppRequested += AppContactPanel_LaunchFullAppRequested; // Apply some customization. args.ContactPanel.HeaderColor = Windows.UI.Colors.LightBlue; // The Contact object that is passed in with ContactPanelActivatedEventArgs is not very usable, // we need to obtain a full contact from the ContactStore in order to do anything interesting. lightContact = args.Contact; await InitializePageAsync(); }
public async void NavigateToPage(ContactPanelActivatedEventArgs args) { args.ContactPanel.LaunchFullAppRequested += ContactPanel_LaunchFullAppRequested; var lightContact = args.Contact; _appContactId = await MyContactStoreService.Current.GetRemoteIdForContactIdAsync(lightContact.Id); AppContact appContact = null; if (_appContactId != null) { appContact = (from a in App.AppContacts where a.ContactId == _appContactId select a).FirstOrDefault(); } AppFrame.Navigate(typeof(ChatPage), appContact); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var contactManager = new ContactManager(); ContactPanelActivatedEventArgs panelArgs = (ContactPanelActivatedEventArgs)e.Parameter; string userID = await contactManager.ContactIdToRemoteId(panelArgs.Contact.Id); string DmChannelID = LocalState.DMs ?.FirstOrDefault(dm => dm.Value?.Type == 1 && dm.Value.Users.FirstOrDefault()?.Id == userID).Value?.Id ?? (await RESTCalls.CreateDM(new CreateDM { Recipients = new List <string> { userID }.AsEnumerable() })).Id; MessageBody.MyPeopleChannelId = DmChannelID; }
async void ActivateForContactPanel(ContactPanelActivatedEventArgs e) { string remoteId = await DataSource.GetRemoteIdForContactIdAsync(e.Contact); if (string.IsNullOrEmpty(remoteId)) { return; } { Frame rootFrame = Window.Current.Content as Frame; // Ne répétez pas l'initialisation de l'application lorsque la fenêtre comporte déjà du contenu, // assurez-vous juste que la fenêtre est active if (rootFrame == null) { rootFrame = InitFrameLoginAndUserAgentAndBack(e); } if (!DataSource.IsLogedIn) { rootFrame.Navigate(typeof(MainPage)); } else { var header = new ChatHeader() { Href = remoteId, Name = e.Contact.Name, UnreadCount = 2 }; rootFrame.Navigate(typeof(ChatPage), new ChatViewModel(header)); } // Ensure the current window is active Window.Current.Activate(); } }
public virtual Task HandleActivation(ContactPanelActivatedEventArgs args) { return(Task.CompletedTask); }