linphone-tutorials/uwp/cs/03_OutgoingCall/Views/NavigationRoot.xaml.cs
Thibault Lemaire aca479888a Give the UWP Tutorial a little refresher
In order to write an equivalent tutorial for Xamarin, I am first
following the UWP tutorial.

Fixed many little spelling mistakes and rephrased some sentences.

Fixed a crash when video is requested but the device has no camera.

Fixed a crash when opening an audio recording. (Linphone.Content.FilePath
returns a path with mixed '/' and '\'. I don't know why and I'm not sure
I understand why the file was auto-downloaded either)
2022-02-17 16:10:10 +01:00

107 lines
2.9 KiB
C#

/*
* Copyright (c) 2010-2020 Belledonne Communications SARL.
*
* This file is part of Linphone TutorialCS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using _03_OutgoingCall.Service;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
namespace _03_OutgoingCall.Views
{
/// <summary>
/// Introduced in step 02 IncomingCall
/// </summary>
public sealed partial class NavigationRoot : Page
{
private CoreService CoreService { get; } = CoreService.Instance;
private bool hasLoadedPreviously;
public NavigationRoot()
{
this.InitializeComponent();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (!hasLoadedPreviously)
{
AppNavFrame.Navigate(typeof(CallsPage));
hasLoadedPreviously = true;
}
}
private void AppNavFrame_Navigated(object sender, NavigationEventArgs e)
{
switch (e.SourcePageType)
{
case Type _ when e.SourcePageType == typeof(CallsPage):
((NavigationViewItem)navview.MenuItems[0]).IsSelected = true;
break;
}
}
private async void Navview_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
if (args.IsSettingsInvoked)
{
ContentDialog noSettingsDialog = new ContentDialog
{
Title = "No settings",
Content = "There are no settings in this little app",
CloseButtonText = "OK"
};
_ = await noSettingsDialog.ShowAsync();
return;
}
if (args.InvokedItem is string invokedItemValue && invokedItemValue.Contains("Calls"))
{
_ = AppNavFrame.Navigate(typeof(CallsPage));
}
}
private void SignOut_Tapped(object sender, TappedRoutedEventArgs e)
{
DisplaySignOutDialog();
}
private async void DisplaySignOutDialog()
{
ContentDialog signOutDialog = new ContentDialog
{
Title = "Sign out ?",
Content = "All your current calls and actions will be canceled.",
PrimaryButtonText = "Sign out",
CloseButtonText = "Cancel"
};
ContentDialogResult result = await signOutDialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
CoreService.Core.TerminateAllCalls();
CoreService.LogOut();
this.Frame.Navigate(typeof(LoginPage));
}
}
}
}