Пример #1
0
        /// <summary>
        /// Transfer list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listViewTransfer_SelectedIndexChanged(object sender, EventArgs e)
        {
            // if items selected.
            if (listViewTransfer.SelectedItems.Count > 0)
            {
                // Clear the number list.
                listViewNumber.Items.Clear();

                // Add all the numbers.
                string name = listViewTransfer.SelectedItems[0].Name;
                Data.contactsContact contact = _contacts.contact.First(u => u.sipAccount == name);

                // Add the sip account.
                listViewNumber.Items.Add(name, name, 0);

                // For each number.
                foreach (string number in contact.numbers)
                {
                    try
                    {
                        // Split the name an number.
                        string[] data = number.Split(new char[] { '|' });

                        // Add the contacts.
                        listViewNumber.Items.Add(data[1], data[0] + " " + data[1], 0);
                    }
                    catch { }
                }
            }
            else
            {
                buttonOK.Enabled = false;
            }
        }
Пример #2
0
        /// <summary>
        /// OK.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            // If updating.
            if (!_adding)
            {
                if (_contacts != null)
                {
                    // Get the contact.
                    Data.contactsContact contact = _contacts.contact.First(u => u.sipAccount == _contactKey);
                    contact.name          = textBoxName.Text;
                    contact.presenceState = checkBoxPresenceState.Checked;
                    contact.group         = comboBoxGroup.Text;
                    contact.numbers       = _numbers.ToArray();
                    contact.picture       = textBoxPicture.Text;
                    _name          = contact.name;
                    _group         = contact.group;
                    _presenecState = contact.presenceState;
                    _picture       = contact.picture;
                }
            }
            else
            {
                if (_contacts != null)
                {
                    // Load the current list.
                    List <Data.contactsContact> contacts = new List <Data.contactsContact>(_contacts.contact);
                    Data.contactsContact        contact  = new Data.contactsContact()
                    {
                        name          = textBoxName.Text,
                        sipAccount    = textBoxSipAccount.Text,
                        presenceState = checkBoxPresenceState.Checked,
                        numbers       = _numbers.ToArray(),
                        group         = comboBoxGroup.Text,
                        picture       = textBoxPicture.Text,
                    };

                    // Add the new contact.
                    contacts.Add(contact);
                    _contacts.contact = contacts.ToArray();

                    // New contact.
                    _newContact    = true;
                    _presenecState = contact.presenceState;
                    _sipAccount    = contact.sipAccount;
                    _name          = contact.name;
                    _group         = contact.group;
                    _picture       = contact.picture;
                }
            }
            Close();
        }
Пример #3
0
        /// <summary>
        /// Load.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContactInfo_Load(object sender, EventArgs e)
        {
            // Numbers list.
            _numbers = new List <string>();

            // Load the group list.
            if (_contactsView != null)
            {
                // For each group.
                foreach (ListViewGroup group in _contactsView.Groups)
                {
                    // Add the group.
                    comboBoxGroup.Items.Add(group.Header);
                }
            }

            // If updating.
            if (!_adding)
            {
                if (_contacts != null)
                {
                    // Get the contact.
                    Data.contactsContact contact = _contacts.contact.First(u => u.sipAccount == _contactKey);
                    textBoxName.Text              = contact.name;
                    textBoxSipAccount.Text        = contact.sipAccount;
                    checkBoxPresenceState.Checked = contact.presenceState;
                    comboBoxGroup.SelectedIndex   = comboBoxGroup.Items.IndexOf(contact.group);
                    textBoxPicture.Text           = contact.picture;
                    textBoxSipAccount.ReadOnly    = true;

                    // For each number.
                    foreach (string number in contact.numbers)
                    {
                        // Split the name an number.
                        string[] data = number.Split(new char[] { '|' });
                        _numbers.Add(number);

                        try
                        {
                            // Add the contacts.
                            listViewNumbers.Items.Add(number, data[0] + " " + data[1], 0);
                        }
                        catch { }
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Add to conference call.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAddToConferenceCall_Click(object sender, EventArgs e)
        {
            _isConferenceCall = true;

            // Answer the call.
            AnswerIncomingCall();

            // Add to the conference list.
            Param.ConferenceCallContainer conference = new Param.ConferenceCallContainer()
            {
                Call = _inComingCall.Call, Video = null
            };
            _voipCall.AddConferenceCallContact(conference);

            int imageIndex = 0;

            Data.contactsContact contact = null;

            try
            {
                // Get the contact.
                contact = _contacts.contact.First(u => u.name.ToLower() == _contactName.ToLower());
                if (contact != null)
                {
                    // Find in the contact list view.
                    ListViewItem listViewItem = _contactsView.Items[contact.sipAccount];
                    imageIndex = listViewItem.ImageIndex;
                }
            }
            catch { imageIndex = 0; }

            // Add the conference call.
            ListViewItem item = new ListViewItem(_contactName, imageIndex);

            item.Name = _inComingCall.Call.CallID + "|" + _inComingCall.Call.ID;

            // Add the item.
            _conferenceView.Items.Add(item);

            // Close the window.
            Close();
        }
Пример #5
0
        /// <summary>
        /// Delete number.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            string contactName = "";
            string contactKey  = "";

            // Add each contact.
            foreach (ListViewItem item in listViewNumbers.SelectedItems)
            {
                // Get the name.
                contactName = item.Text;
                contactKey  = item.Name;
                break;
            }

            // If a key has been selected.
            if (!String.IsNullOrEmpty(contactKey))
            {
                // Ask the used to answer incomming call.
                DialogResult result = MessageBox.Show(this, "Are you sure you wish to delete number " + contactName + ".",
                                                      "Delete Number", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                // If delete.
                if (result == DialogResult.Yes)
                {
                    // Remove the item.
                    listViewNumbers.Items.RemoveByKey(contactKey);

                    try
                    {
                        // Remove from contact file.
                        Data.contactsContact contact = _contacts.contact.First(u => u.sipAccount == _contactKey);
                        string number = contact.numbers.First(u => u == contactKey);
                        contact.numbers = contact.numbers.Remove(u => u.Equals(number));
                        _numbers.Remove(number);
                    }
                    catch { }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Load.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InComingCall_Load(object sender, EventArgs e)
        {
            _callEnded = () => CallEnded();
            this.Text  = "Incoming Call - From : " + _contactName + " - Source : " + (String.IsNullOrEmpty(_inComingCall.SrcAddress) ? "Unknown" : _inComingCall.SrcAddress.Trim());

            UISync.Init(this);
            if (_inComingCall != null)
            {
                // If player.
                if (_player != null)
                {
                    try
                    {
                        // If a file exists.
                        if (!String.IsNullOrEmpty(_ringFilePath))
                        {
                            // Open the file.
                            _player.Open(_ringFilePath);

                            // Start the wave file.
                            _player.Play();
                            _playerStarted = true;
                        }
                    }
                    catch { }
                }

                // If auto answer is on.
                if (_autoAnswer && !String.IsNullOrEmpty(_autoAnswerFilePath))
                {
                    // If there is a wait time.
                    if (_autoAnswerWait > 0)
                    {
                        // Auto answer indication.
                        toolStripStatusLabelAuto.Text = "Auto answer in '" + _autoAnswerWait.ToString() + "' seconds.";

                        // Create the auto answer timer.
                        _autoAnswerTimer = new System.Threading.Timer(AutoAnswerTimeout, null,
                                                                      new TimeSpan(0, 0, _autoAnswerWait),
                                                                      new TimeSpan(0, 0, _autoAnswerWait));

                        // Suspended.
                        _suspended = true;
                    }
                }
                else if (_redirectEnabled && !String.IsNullOrEmpty(_redirectCallNumber))
                {
                    // Auto redirect call.
                    // If there is a wait time.
                    if (_redirectCallAfter > 0)
                    {
                        // Auto answer indication.
                        toolStripStatusLabelAuto.Text = "Redirecting to '" + _redirectCallNumber + "' in '" + _redirectCallAfter.ToString() + "' seconds.";

                        // Create the redirect call timer.
                        _redirectCallTimer = new System.Threading.Timer(RedirectCallTimeout, null,
                                                                        new TimeSpan(0, 0, _redirectCallAfter),
                                                                        new TimeSpan(0, 0, _redirectCallAfter));

                        // Suspended.
                        _suspended = true;
                    }
                }
                else
                {
                    // If message bank is enabled.
                    if (_messageBankWaitTime > 0 && !String.IsNullOrEmpty(_autoAnswerFilePath) && !String.IsNullOrEmpty(_autoAnswerRecordingPath))
                    {
                        buttonSendToMessageBank.Enabled = true;

                        // Suspended.
                        _suspended = true;
                    }
                }

                _inComingCall.Call.OnCallMediaState     += Call_OnCallMediaState;
                _inComingCall.Call.OnCallState          += Call_OnCallState;
                _inComingCall.Call.OnPlayerEndOfFile    += Call_OnPlayerEndOfFile;
                _inComingCall.Call.OnDtmfDigit          += Call_OnDtmfDigit;
                _inComingCall.Call.OnCallTransferStatus += Call_OnCallTransferStatus;

                // Ask the used to answer incomming call.
                textBoxDetails.Text =
                    "Source : \t" + (String.IsNullOrEmpty(_inComingCall.SrcAddress) ? "Unknown" : _inComingCall.SrcAddress.Trim()) + "\r\n" +
                    (String.IsNullOrEmpty(_inComingCall.From.Trim()) ? "" : "From : \t" + _inComingCall.From.Trim() + "\r\n") +
                    (String.IsNullOrEmpty(_inComingCall.FromContact.Trim()) ? "" : "Contact : \t" + _inComingCall.FromContact.Trim() + "\r\n\r\n") +
                    (String.IsNullOrEmpty(_contactName) ? "" : "Contact : \t" + _contactName + "\r\n\r\n");

                try
                {
                    // Get the contact.
                    Data.contactsContact contact = null;
                    try
                    {
                        // Get the contact.
                        contact = _contacts.contact.First(u => u.name.ToLower() == _contactName.ToLower());
                    }
                    catch { }

                    // If contact.
                    if (contact != null)
                    {
                        // Find in the contact list view.
                        ListViewItem listViewItem = _contactsView.Items[contact.sipAccount];
                        int          imageIndex   = listViewItem.ImageIndex;

                        // Get the image.
                        Image picture = _imageListLarge.Images[imageIndex];
                        panelCallerImage.BackgroundImage = picture;
                    }
                    else
                    {
                        // Not a contact.
                        // Get the default image.
                        Image picture = _imageListLarge.Images[0];
                        panelCallerImage.BackgroundImage = picture;
                    }
                }
                catch { }
            }
        }