/// <summary>
        /// Disposes the softphone engine. Hangs up calls, unregisters phone lines and disposes the media handlers.
        /// </summary>
        public void Dispose()
        {
            lock (_sync)
            {
                PhoneCalls.Clear();

                // unregister phone lines
                foreach (IPhoneLine line in PhoneLines)
                {
                    if (line.RegState == RegState.RegistrationSucceeded)
                    {
                        softPhone.UnregisterPhoneLine(line);
                    }

                    UnsubscribeFromLineEvents(line);
                    line.Dispose();
                }
                PhoneLines.Clear();

                // dispose media
                MediaHandlers.Dispose();

                // close softphone
                softPhone.Close();
            }
        }
Example #2
0
        /// <summary>
        /// Updates the line picker view with information from the calling info singleton.
        /// </summary>
        public void UpdateLinePickerInfo()
        {
            //Color Values to be used during update
            Color NoColor            = Color.FromArgb(0, 0, 0, 0);
            Color DisplayAccentColor = (Color)Application.Current.Resources["SystemAccentColor"];

            //Show and setup multiSIM components
            if (CallingInfo.CallingInfoInstance.NoOfLines >= 2)
            {
                //Show Multi line controls
                VisibilityState = "Visible";

                //Set Phone Lines
                if (CallingInfo.CallingInfoInstance.AllPhoneLines != null)
                {
                    PhoneLines.Clear();

                    //Sortphonelines by slot index to ensure cosistent line picker order
                    var phoneLinesQuery = from phoneLine in CallingInfo.CallingInfoInstance.AllPhoneLines.Values
                                          orderby((PhoneLine)phoneLine).CellularDetails.SimSlotIndex
                                          select phoneLine;

                    foreach (var line in phoneLinesQuery)
                    {
                        Color ActualLineColor = line.DisplayColor;
                        if (ActualLineColor == NoColor)
                        {
                            ActualLineColor = DisplayAccentColor;
                        }
                        SolidColorBrush ActualLineColorBrush = new SolidColorBrush(ActualLineColor);
                        PhoneLines.Add(new PhoneLinePickerItem(line.DisplayName, line.Id, ActualLineColorBrush));
                    }
                }
            }

            //Set branding info
            DisplayName = CallingInfo.CallingInfoInstance.CurrentDisplayName;
            Color DisplayColorObject = CallingInfo.CallingInfoInstance.CurrentDisplayColor;

            //Set Accent highlight based on display
            if (DisplayColorObject == NoColor)
            {
                DisplayColorObject = DisplayAccentColor;
            }
            DisplayAccentBrush = new SolidColorBrush(DisplayColorObject);
        }