/// <summary> /// Podwójne kliknięcie na danym kontakcie otwiera z nim rozmowę, numer telefonu zostaje zapisany jako bieżący /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListViewAddressBook_DoubleClick(object sender, MouseButtonEventArgs e) { znaleziony = false; //messageForm.ConnectionsListView.Items.Add(new ConnectionItem { UserName = "******", UserNumber = "test" }); if (trafficController.GetState() == State.LoggedIn || trafficController.GetState() == State.OpenedGate) { MyItem selectedItem = (MyItem)ListViewAddressBook.SelectedItems[0]; currentNumber = trafficController.FindNumber(selectedItem.UserName); trafficController.SetState(State.OpenedGate); if (!trafficController.protection_unavailable(selectedItem.UserName)) { trafficController.SetState(State.OpenedGate); messageForm.Show(); ConnectionItem connectionItem = new ConnectionItem { UserName = selectedItem.UserName, UserNumber = currentNumber, IsConv = false }; if (messageForm.ConnectionsListView.HasItems == true) //Sprawdz czy lista posiada itemy jesli nie to dodaj { foreach (ConnectionItem item in messageForm.ConnectionsListView.Items) { if (item.UserName == selectedItem.UserName) { znaleziony = true; } } if (znaleziony == true) //Jesli lista posiada juz ten item { Console.WriteLine("Połączenie juz istnieje"); } else { messageForm.ConnectionsListView.Items.Add(connectionItem); messageForm.Initialize(openedConnections, Int32.Parse(currentNumber), myNumber); } } else { messageForm.ConnectionsListView.Items.Add(connectionItem); messageForm.Initialize(openedConnections, Int32.Parse(currentNumber), myNumber); } } } else { MessageBox.Show("Najpierw musisz ustanowić połączenie!", "Warning"); } }
private int[] numeryPolaczen() { foreach (MyItem items in myItems) { numbers.Add(trafficController.FindNumber(items.UserName)); } number = new int[numbers.Count + 1]; number[0] = myNumber; for (int i = 1; i < number.Length; i++) { number[i] = Int32.Parse(numbers[i - 1]); Console.WriteLine(number[i] + " Połączenie"); } return(number); }
private void SetHyperlink(string text) { if (Chat.Dispatcher.Thread == Thread.CurrentThread) { Border borderOkienka = new Border(); if (text.Substring(0, 2) == "Ja") { borderOkienka.Background = new SolidColorBrush(Color.FromRgb(3, 145, 253)); borderOkienka.HorizontalAlignment = HorizontalAlignment.Right; } else { borderOkienka.Background = new SolidColorBrush(Color.FromRgb(68, 68, 68)); borderOkienka.HorizontalAlignment = HorizontalAlignment.Left; } borderOkienka.CornerRadius = new CornerRadius(4); borderOkienka.BorderThickness = new Thickness(1); string[] lines = text.Split(new Char[] { '?', '!' }); //int index = text.IndexOf("?"); //int lastindex = text.- 1; //Console.WriteLine(index); //string text1 = text.Substring(0, index); //string hiperlink = text.Substring(index + 1, lastindex); string folderName = trafficController.FindNumber(o) + "_" + mynumber.ToString(); var h = new Hyperlink(); h.Inlines.Add(lines[1]); h.Click += (s, a) => { download(lines[1], folderName); }; TextBlock textBlock = new TextBlock(); textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Inlines.Add(lines[0]); textBlock.Inlines.Add(h); textBlock.Foreground = new SolidColorBrush(Colors.White); borderOkienka.Child = textBlock; stackPanelBorder.Children.Add(borderOkienka); } else { Console.WriteLine("SetTextHTML"); SetTextCallBack f = new SetTextCallBack(SetHyperlink); Dispatcher.Invoke(f, new object[] { text }); } }