Esempio n. 1
0
        // Входящий звонок
        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);
        }
Esempio n. 2
0
        // Звонок завершился
        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);
        }