AdvancedSettings.xaml.cs 3.23 KB
Newer Older
1 2 3 4
using Linphone.Model;
using Linphone.Resources;
using Microsoft.Phone.Shell;
using System;
5 6 7 8 9
using System.Collections.Generic;
using System.Windows.Navigation;

namespace Linphone.Views
{
10 11 12
    /// <summary>
    ///  Page displaying advanced settings (such as Tunnel, DTMFs, ...)
    /// </summary>
13
    public partial class AdvancedSettings : BasePage
14
    {
15 16
        private CallSettingsManager _callSettings = new CallSettingsManager();
        private NetworkSettingsManager _networkSettings = new NetworkSettingsManager();
17

18 19 20
        /// <summary>
        /// Public constructor.
        /// </summary>
21 22 23 24 25
        public AdvancedSettings()
        {
            InitializeComponent();
            BuildLocalizedApplicationBar();

26 27 28
            _callSettings.Load();
            _networkSettings.Load();
            rfc2833.IsChecked = _callSettings.SendDTFMsRFC2833;
Ghislain MARY's avatar
Ghislain MARY committed
29
            sipInfo.IsChecked = _callSettings.SendDTFMsSIPInfo;
30 31 32 33 34 35 36 37 38

            List<string> tunnelModes = new List<string>
            {
                AppResources.TunnelModeDisabled,
                AppResources.TunnelMode3GOnly,
                AppResources.TunnelModeAlways,
                AppResources.TunnelModeAuto
            };
            tunnelMode.ItemsSource = tunnelModes;
39 40 41
            tunnelMode.SelectedItem = _networkSettings.TunnelMode;
            tunnelPort.Text = _networkSettings.TunnelPort;
            tunnelServer.Text = _networkSettings.TunnelServer;
42 43 44 45

            List<string> transports = new List<string>
            {
                AppResources.TransportUDP,
46 47
                AppResources.TransportTCP,
                AppResources.TransportTLS
48 49
            };
            Transport.ItemsSource = transports;
50
            Transport.SelectedItem = _networkSettings.Transport;
51 52 53 54 55 56 57 58 59
        }

        private void cancel_Click_1(object sender, EventArgs e)
        {
            NavigationService.GoBack();
        }

        private void save_Click_1(object sender, EventArgs e)
        {
60
            _callSettings.SendDTFMsRFC2833 = rfc2833.IsChecked;
Ghislain MARY's avatar
Ghislain MARY committed
61 62
            _callSettings.SendDTFMsSIPInfo = sipInfo.IsChecked;
            _callSettings.Save();
63 64 65 66 67
            _networkSettings.TunnelMode = tunnelMode.SelectedItem.ToString();
            _networkSettings.TunnelServer = tunnelServer.Text;
            _networkSettings.TunnelPort = tunnelPort.Text;
            _networkSettings.Transport = Transport.SelectedItem.ToString();
            _networkSettings.Save();
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

            NavigationService.GoBack();
        }

        private void BuildLocalizedApplicationBar()
        {
            ApplicationBar = new ApplicationBar();

            ApplicationBarIconButton appBarSave = new ApplicationBarIconButton(new Uri("/Assets/AppBar/save.png", UriKind.Relative));
            appBarSave.Text = AppResources.SaveSettings;
            ApplicationBar.Buttons.Add(appBarSave);
            appBarSave.Click += save_Click_1;

            ApplicationBarIconButton appBarCancel = new ApplicationBarIconButton(new Uri("/Assets/AppBar/cancel.png", UriKind.Relative));
            appBarCancel.Text = AppResources.CancelChanges;
            ApplicationBar.Buttons.Add(appBarCancel);
            appBarCancel.Click += cancel_Click_1;
        }
    }
}