private BnetChattingRGB getListColor(BnetChattingColor bnetChattingColor = BnetChattingColor.Plain) { BnetChattingRGB colorSet = new BnetChattingRGB(); switch (bnetChattingColor) { case BnetChattingColor.Error: colorSet.r = 255; colorSet.g = 200; colorSet.b = 200; break; case BnetChattingColor.Info: colorSet.r = 230; colorSet.g = 242; colorSet.b = 255; break; case BnetChattingColor.Tip: colorSet.r = 224; colorSet.g = 240; colorSet.b = 255; break; case BnetChattingColor.Whisper: colorSet.r = 224; colorSet.g = 255; colorSet.b = 224; break; case BnetChattingColor.Me: colorSet.r = 255; colorSet.g = 240; colorSet.b = 224; break; default: colorSet.r = 250; colorSet.g = 250; colorSet.b = 255; break; } return colorSet; }
private void AddListItem(BnetUsername data, BnetChattingColor bnetChattingColor = BnetChattingColor.Plain, BnetChattingStatus bnetChattingStatus = BnetChattingStatus.Default) { String message = ""; if (bnetChattingColor == BnetChattingColor.Info || bnetChattingColor == BnetChattingColor.Error) { if(bnetChattingStatus == BnetChattingStatus.Join) { String currentChannel = bClient.getCurrentChannel(); if (currentChannel != "") { message = "님이 채널 [" + currentChannel + "]에 입장하셨습니다."; } else { message = "님이 입장하셨습니다."; } } else if(bnetChattingStatus == BnetChattingStatus.Leave) { String currentChannel = bClient.getCurrentChannel(); if (currentChannel != "") { message = "님이 채널 [" + currentChannel + "]에서 나가셨습니다."; } else { message = "님이 나가셨습니다."; } } } this.AddListItem(data, message, bnetChattingColor); }
private void AddListFriend(BnetUsername name, String clan, BnetChattingColor bnetChattingColor = BnetChattingColor.Plain) { ListBoxItem lb = new ListBoxItem(); TextBlock tb = new TextBlock(); tb.TextWrapping = TextWrapping.Wrap; tb.Text = name.name + ((clan != "") ? " [" + clan + "]" : ""); lb.Content = tb; FriendsList.Items.Add(lb); FriendsList.SelectedIndex = FriendsList.Items.Count - 1; FriendsList.ScrollIntoView(FriendsList.Items[FriendsList.Items.Count - 1]); if (name.color != null) { tb.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#" + name.color)); } BnetChattingRGB colorSet = this.getListColor(bnetChattingColor); BnetChattingRGB borderSet = new BnetChattingRGB(); borderSet.r = (byte)Math.Max(0, colorSet.r - 32); borderSet.g = (byte)Math.Max(0, colorSet.g - 32); borderSet.b = (byte)Math.Max(0, colorSet.b - 32); lb.Background = new SolidColorBrush(Color.FromRgb(colorSet.r, colorSet.g, colorSet.b)); lb.BorderBrush = new SolidColorBrush(Color.FromRgb(borderSet.r, borderSet.g, borderSet.b)); lb.BorderThickness = new Thickness(1, 1, 1, 1); }
private void OnChatFriendsUpdateHandler(BnetFriends[] bnetFriends) { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { FriendsList.Items.Clear(); BnetChattingColor bnetChattingColor = new BnetChattingColor(); for (int i=0; i<bnetFriends.Length; i++) { if(bnetFriends[i].name.name == bnetUsername.name) { bnetChattingColor = BnetChattingColor.Me; } else { bnetChattingColor = BnetChattingColor.Plain; } this.AddListFriend(bnetFriends[i].name, bnetFriends[i].locationName, bnetChattingColor); } })); }
private void AddListItem(String message, BnetChattingColor bnetChattingColor = BnetChattingColor.Plain) { ListBoxItem lb = new ListBoxItem(); DockPanel dp = new DockPanel(); TextBlock tb = new TextBlock(); tb.TextWrapping = TextWrapping.Wrap; tb.Text = message; if (bnetChattingColor == BnetChattingColor.Error || bnetChattingColor == BnetChattingColor.Info || bnetChattingColor == BnetChattingColor.Whisper) { TextBlock status = new TextBlock(); Thickness statusMargin = status.Margin; statusMargin.Right = 6; status.Margin = statusMargin; if (bnetChattingColor == BnetChattingColor.Error) { status.Text = "[에러]"; } else if (bnetChattingColor == BnetChattingColor.Info) { status.Text = "[정보]"; } else if (bnetChattingColor == BnetChattingColor.Whisper) { status.Text = "[귓속말]"; } dp.Children.Add(status); } dp.Children.Add(tb); lb.Content = dp; MainChatList.Items.Add(lb); MainChatList.SelectedIndex = MainChatList.Items.Count - 1; MainChatList.ScrollIntoView(MainChatList.Items[MainChatList.Items.Count - 1]); BnetChattingRGB colorSet = this.getListColor(bnetChattingColor); BnetChattingRGB borderSet = new BnetChattingRGB(); borderSet.r = (byte)Math.Max(0, colorSet.r - 32); borderSet.g = (byte)Math.Max(0, colorSet.g - 32); borderSet.b = (byte)Math.Max(0, colorSet.b - 32); lb.Background = new SolidColorBrush(Color.FromRgb(colorSet.r, colorSet.g, colorSet.b)); lb.BorderBrush = new SolidColorBrush(Color.FromRgb(borderSet.r, borderSet.g, borderSet.b)); lb.BorderThickness = new Thickness(1, 1, 1, 1); }