コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: ping203/SipClient
        private void buttonKeyPadButton_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (call == null && btn.Content.Equals('#'))
            {
                return;
            }

            //Вводим номер для перевода
            bool transferFlag = (isTransferNumber(txtPhoneNumber.Text) || btn.Content.Equals("#"));

            if (transferFlag)
            //if (txtPhoneNumber.Text.Contains("#"))
            {
                InvokeGUIThread(() =>
                {
                    txtStatus.Text = "Трансфер на..";
                    PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer");
                    this.btnConnectOrReject.Background = Brushes.Green;
                });
            }

            if (call != null && !transferFlag)
            {
                return;
            }

            // Добавим символ с кнокпки
            PutNumberWithDTMF(btn.Content.ToString());
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: ping203/SipClient
        // Входящий звонок
        private void softphone_IncomingCallEvent(Call incomingCall)
        {
            // Reject incoming call, if we have active
            if (this.call != null)
            {
                Softphone.TerminateCall(incomingCall);

                // write rejected call to base
                RecordToLocalDataBase.Phone      = GetPhone(incomingCall.From);
                RecordToLocalDataBase.TimeStart  = DateTime.Now;
                RecordToLocalDataBase.isRejected = true;

                return;
            }
            ;

            // set flag
            isIncoming = true;
            // Recieve incoming call
            this.call = incomingCall;

            //Echo cancellation
            Softphone.EchoCancellation(this.call, Settings.isEchoOff);

            string phone  = GetPhone(this.call.From);
            string callId = GetCallId(this.call.From);

            InvokeGUIThread(() =>
            {
                dialog = new IncomingDialog();
                // show incoming call dialog
                dialog.Call      = this.call;
                dialog.SoftPhone = Softphone;
                dialog.UpdateTextPanel(phone, callId);

                dialog.Show();

                // change icon to incoming call
                this.txtStatus.Text  = "Занят";
                lblStatusRecord.Text = "Входящий";
                PhoneIcon.SetResourceReference(Image.SourceProperty, "decline");
                StatusIcon.SetResourceReference(Image.SourceProperty, "presence_not_available");
                this.btnConnectOrReject.Background = Brushes.Red;
            });

            // Play Sound
#pragma warning disable CS0103 // The name 'Properties' does not exist in the current context
#pragma warning disable CS0103 // The name 'Properties' does not exist in the current context
            Classes.LocalAudioPlayer.PlaySound(Properties.Resources.signal, true);
#pragma warning restore CS0103 // The name 'Properties' does not exist in the current context
#pragma warning restore CS0103 // The name 'Properties' does not exist in the current context

            // record call info
            RecordToLocalDataBase.Phone     = phone;
            RecordToLocalDataBase.TimeStart = DateTime.Now;

            // Get information about caller
            GetInfoAboutCaller(call.From);
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: ping203/SipClient
        // Звонок завершился
        private void softphone_CallCompletedEvent(Call call)
        {
            if (isIncoming)
            {
                // drop down Incoming call form
                InvokeGUIThread(() =>
                {
                    // Close borderCallNotification
                    CloseCallNotification();

                    // hide incoming call dialog
                    if (dialog != null)
                    {
                        dialog.Close();
                        dialog = null;
                    }

                    // add badge value to history button
                    int value            = string.IsNullOrEmpty(viewModel.BadgeValue) ? 0 : Convert.ToInt32(viewModel.BadgeValue);
                    viewModel.BadgeValue = (++value).ToString();
                });
            }

            // write to database
            RecordToLocalDataBase.isOutcoming = isOutcoming;
            RecordToLocalDataBase.isIncoming  = isIncoming;
            RecordToLocalDataBase.TimeEnd     = DateTime.Now;
            Classes.SQLiteBase.AddRecordToDataBase(RecordToLocalDataBase);

            // clear flags
            isIncoming  = false;
            isOutcoming = false;

            this.call = null;

            InvokeGUIThread(() =>
            {
                txtStatus.Text = "Свободно";
                PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer");
                StatusIcon.SetResourceReference(Image.SourceProperty, "presenceAvailable");
                btnConnectOrReject.Background = Brushes.Green;

                CloseCallNotification();

                // discard blur effect to infoPanel
                if (borderCallNotification.BitmapEffect != null)
                {
                    borderCallNotification.BitmapEffect = null;
                    borderCallNotification.Background   = null;
                }
            });

            Classes.LocalAudioPlayer.PlaySound(Properties.Resources.notification_call_ended);
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: ping203/SipClient
 private void softphone_PhoneConnectedEvent()
 {
     InvokeGUIThread(() =>
     {
         //set available icon and text message
         PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer");
         this.btnConnectOrReject.Background = Brushes.Green;
         StatusIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "presenceAvailable");
         txtStatus.Text = "Подключен!";
     });
 }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: ping203/SipClient
        // Звонок принят или исходящий
        private void softphone_CallActiveEvent(Call call)
        {
            if (isIncoming)
            {
                // sound notification off
                Classes.LocalAudioPlayer.StopSound();

                if (dialog != null)
                {
                    dialog.Close();
                }

                // write incoming call to base
                RecordToLocalDataBase.Phone      = GetPhone(call.From);
                RecordToLocalDataBase.TimeStart  = DateTime.Now;
                RecordToLocalDataBase.isRejected = false;
            }
            else
            {
                this.call = call;
                // set outcoming call flag
                isOutcoming = true;

                // Disable echo
                Softphone.EchoCancellation(this.call, Settings.isEchoOff);
                string phone = GetPhone(call.To);

                //show caller info
                GetInfoAboutCaller(call.To);

                InvokeGUIThread(() =>
                {
                    txtStatus.Text       = "Занят";
                    lblStatusRecord.Text = "Исходящий";
                    PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "decline");
                    StatusIcon.SetResourceReference(Image.SourceProperty, "presence_not_available");
                    btnConnectOrReject.Background = Brushes.Red;
                });

                // set volume
                Softphone.SetSpeakerValue(this.call, (float)volumeSliderValue);

                // db record
                RecordToLocalDataBase.Phone       = phone;
                RecordToLocalDataBase.isOutcoming = true;
                RecordToLocalDataBase.TimeStart   = DateTime.Now;
                //Classes.SQLiteBase.AddRecordToDataBase(RecordToLocalDataBase);
            }
        }