private async void Btn_Accept_Click(object sender, RoutedEventArgs e) { try { timer.Stop(); var data = await WoWonderClient.Requests.RequestsAsync.Send_Video_Call_Answer_Web("answer", Main_callID); if (data.Item1 == 200) { string AvatarSplit = Main_avatar.Split('/').Last(); Classes.Call_Video CV = new Classes.Call_Video(); CV.Call_Video_user_id = Main_IDuser; CV.Call_Video_Avatar = Functions.Get_image(Main_IDuser, AvatarSplit, Main_avatar); CV.Call_Video_User_Name = Main_Name; CV.Call_Video_Call_id = Main_callID; CV.Call_Video_Tupe_icon = "CallReceived"; CV.Call_Video_Color_icon = "green"; CV.Call_Video_User_DataTime = Functions.Get_datatime(); if (MainWindow.ModeDarkstlye) { CV.S_Color_Background = "#232323"; CV.S_Color_Foreground = "#efefef"; } else { CV.S_Color_Background = "#ffff"; CV.S_Color_Foreground = "#444"; } MainWindow.ListCall.Insert(0, CV); _MainWindow.Calls_list.ItemsSource = MainWindow.ListCall; SQLiteCommandSender.Insert_To_CallVideoTable(CV); if (_MainWindow.No_call.Visibility == Visibility.Visible) { _MainWindow.No_call.Visibility = Visibility.Collapsed; } Video_Call_Window VideoCallFrm = new Video_Call_Window(data.Item2["url"], _MainWindow, CV); //maybe bug check VideoCallFrm.Show(); this.Close(); } } catch (Exception exception) { Console.WriteLine(exception); } }
public async Task Checke_Video_Call_Answer(string Call_ID) //begovsky maybe change { try { var response = await WoWonderClient.Requests.RequestsAsync.API_Check_For_Video_Answer(UserDetails.User_id, Send_Video_Call.Call_ID); if (response.Item1 == 200) { timer2.Stop(); timer.Stop(); App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { mediaPlayer.Stop(); Classes.Call_Video CV = new Classes.Call_Video(); CV.Call_Video_user_id = recipt_ID; CV.Call_Video_User_Name = User_Name; CV.Call_Video_Avatar = main_avatar; CV.Call_Video_Call_id = Call_ID; CV.Call_Video_Tupe_icon = "CallMade"; CV.Call_Video_Color_icon = "green"; CV.Call_Video_User_DataTime = Functions.Get_datatime(); if (MainWindow.ModeDarkstlye) { CV.S_Color_Background = "#232323"; CV.S_Color_Foreground = "#efefef"; } else { CV.S_Color_Background = "#ffff"; CV.S_Color_Foreground = "#444"; } MainWindow.ListCall.Insert(0, CV); Main_Window.Calls_list.ItemsSource = MainWindow.ListCall; SQLiteCommandSender.Insert_To_CallVideoTable(CV); Video_Call_Window Video_CallFrm = new Video_Call_Window(Url, Main_Window, CV); Video_CallFrm.Show(); this.Close(); }); } else { App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { mediaPlayer.Stop(); TextOfcall.Text = User_Name + LocalResources.label_Declined_your_call; Task.Run(() => { Thread.Sleep(4500); App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { mediaPlayer.Close(); this.Close(); }); }); }); } } catch (Exception ex) { var ff = ex.ToString(); this.Close(); } }