public ServerHandler(objects.Client client1, TextBox output1, TreeView channelTreeView1) { client = client1; output = output1; channelTreeView = channelTreeView1; channelTreeView.Dispatcher.Invoke(() => { welcomeChannelTreeView = new TreeViewItem(); welcomeChannelTreeView.Header = "Welcome_Channel"; welcomeChannelTreeView.Foreground = Brushes.White; channelTreeView.Items.Add(welcomeChannelTreeView); }); }
public void handleInput(string command1, objects.Client client1, TextBox output) { bool isCommand = true; client = client1; string[] command = command1.Split(new string[] { " " }, StringSplitOptions.None); try { var s = command[0]; } catch (Exception ex) { isCommand = false; output.Dispatcher.Invoke(() => { output.AppendText("[Client/Error] type /help for a list of commands" + Environment.NewLine); }); } if (isCommand) { if (command[0].ToLower() == cmdClear.Name) { output.Dispatcher.Invoke(() => { output.Text = ""; }); } else { output.Dispatcher.Invoke(() => { output.AppendText("[Client/Error] Unknown command: " + command[0] + Environment.NewLine); output.AppendText("[Client/Error] type /help for a list of commands" + Environment.NewLine); }); } } }
public void handleRequest(string request, objects.Client client) { string requestId = request.Substring(0, 3); string requestdata = request.Remove(0, 3); if (easyRequestIds.Contains(requestId)) { output.Dispatcher.Invoke(() => { output.AppendText(requestdata + Environment.NewLine); }); } else if (requestId == "611") { if (requestdata.Contains("exists")) { output.Dispatcher.Invoke(() => { output.AppendText(requestdata + Environment.NewLine); }); } else { string[] tempList; tempList = requestdata.Split(new string[] { "," }, StringSplitOptions.None); foreach (string obj in tempList) { string s = obj.Replace("'", "").Replace("[", "").Replace("]", "").Replace(" ", string.Empty); if (s.Contains(client.Username)) { output.Dispatcher.Invoke(() => { TreeViewItem t = new TreeViewItem(); t.Header = s + "(you)"; t.Foreground = Brushes.White; welcomeChannelTreeView.Items.Add(t); }); } else { output.Dispatcher.Invoke(() => { TreeViewItem t = new TreeViewItem(); t.Header = s; t.Foreground = Brushes.White; welcomeChannelTreeView.Items.Add(t); }); } } } } else if (requestId == "811") { string[] test = requestdata.Split(new string[] { " " }, StringSplitOptions.None); if (requestdata.Contains("joined")) { Debug.WriteLine(test[0] + "should be added"); // TreeViewItem t = new TreeViewItem(); // t.Header = test[0]; // t.Foreground = Brushes.White; // welcomeChannelTreeView.Dispatcher.Invoke(() => // { // welcomeChannelTreeView.Items.Add(t); // }); } else { Debug.WriteLine(test[0] + "should be removed"); // welcomeChannelTreeView.Dispatcher.Invoke(() => // { // foreach (TreeViewItem item in welcomeChannelTreeView.Items) /// { // if (item.Header.ToString() == test[0]) // { // welcomeChannelTreeView.Items.Remove(item); // } // } // Debug.WriteLine("left"); // }); } } }