protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

                SoftphoneEngine model = new SoftphoneEngine();

                MainWindow_1 window = new MainWindow_1(model);
                window.Show();
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Could not initialize softphone: \r\n");
                sb.Append(ex.Message);
                sb.Append("\r\n");
                sb.Append(ex.InnerException);
                sb.Append(ex.StackTrace);
                MessageBox.Show(sb.ToString());
                Application.Current.Shutdown();
            }

            base.OnStartup(e);
        }
        public MainWindow_1(SoftphoneEngine model)
        {
            Model = model;

            KeepAliveValues = new List<KeepAliveMode>();
            var keelAliveValues = Enum.GetValues(typeof(KeepAliveMode));
            foreach (KeepAliveMode mode in keelAliveValues)
                KeepAliveValues.Add(mode);

            VideoQualities = new List<VideoQuality>();
            var qualities = Enum.GetValues(typeof(VideoQuality));
            foreach (VideoQuality quality in qualities)
                VideoQualities.Add(quality);
            //VideoEncoderQuality = VideoQuality.High;

            InitializeComponent();

            Model.PhoneLineStateChanged += (Model_PhoneLineStateChanged);
            Model.PhoneCallStateChanged += (Model_PhoneCallStateChanged);
            Model.MessageSummaryReceived += (Model_MessageSummaryReceived);
            Model.NatDiscoveryFinished += (Model_NatDiscoveryFinished);
            Model.CallInstantMessageReceived += (Model_CallInstantMessageReceived);
            Model.MediaHandlers.MicrophoneStopped += MediaHandlers_MicrophoneStopped;
            Model.MediaHandlers.SpeakerStopped += MediaHandlers_SpeakerStopped;
        }