public FormChat(IClient client, ChatDataModel.Account account, IAudioCall phoneCall)
        {
            InitializeComponent();
            _client = client;
            _user   = account;
            Stream imageMe, imageFriend;
            string myName = "";

            lock (this)
            {
                imageMe = GoogleDriveFilesRepository.DownloadFile(Util.Instance.CurrentUser.AvatarDriveID);
                myName  = Util.Instance.CurrentUser.Name;
            }
            imageFriend                = GoogleDriveFilesRepository.DownloadFile(_user.AvatarDriveID);
            _ptbFriendsAvatar.Image    = Image.FromStream(imageFriend);
            _ptbFriendsAvatar.SizeMode = PictureBoxSizeMode.StretchImage;
            _lbFriendsName.Text        = _user.Name;
            authorMe          = new Author(Image.FromStream(imageMe), myName);
            authorFriend      = new Author(Image.FromStream(imageFriend), _user.Name);
            _rcChatlog.Author = authorMe;
            //gửi yêu cầu lấy lịch sử chat
            _client.RequestGetHistory(Util.Instance.CurrentUser.Email, _user.Email);
            _rcChatlog.ChatElement.ShowToolbarButtonElement.Click += ShowToolbarButtonElement_Click;
            _rcChatlog.ChatElement.SendButtonElement.Click        += SendButtonElement_Click;
            _rcChatlog.CardActionClicked += _rcChatlog_CardActionClicked;
            _rcChatlog.ChatElement.MessagesViewElement.BackColor = Color.White;
            _rcChatlog.AutoScroll = false;

            _phoneCall = phoneCall;
            _phoneCall.CallStateChange += _phoneCall_CallStateChange;
        }
Exemple #2
0
        public FormMain(IClient client, ChatDataModel.Account account)
        {
            InitializeComponent();
            //AddWaitingBar();
            _client  = client;
            _account = account;
            Init();
            _client.OnNewRecieve += _client_OnNewRecieve;

            RegisPhoneLine();
        }
        public void RegisterAccount(ChatDataModel.Account account)
        {
            var tach = account.Email.Split('@');

            sipAccount = new SIPAccount(true, tach[0], tach[0], tach[0], tach[0], "192.168.0.86", 5060);
            try
            {
                phoneLine = softPhone.CreatePhoneLine(sipAccount);
                phoneLine.RegistrationStateChanged += PhoneLine_RegistrationStateChanged;
                softPhone.RegisterPhoneLine(phoneLine);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }