/// <summary> /// BAN通知受信時に実行されるイベントです。 /// </summary> /// <param name="message"></param> private void OnBanUser(Lib.Message message) { if (this.commentClient.JoinedRoomSummary == null) { return; } var newMessage = new Message(this.commentClient.JoinedRoomSummary, message); newMessage.OnBanUser += this.BanUser; newMessage.OnUnBanUser += this.UnBanUser; newMessage.OnMarkListener += this.MarkListener; newMessage.OnShowId += this.ShowId; newMessage.OnHideId += this.HideId; var index = this.MessageList.IndexOf(newMessage); if (index < 0) { return; } this.MessageList[index] = newMessage; this.MessageList.Refresh(); }
/// <summary> /// コメント受信時に実行されるイベントです。 /// </summary> /// <param name="summary"></param> /// <param name="message"></param> private void OnReceiveMessage(Lib.Message message) { if (this.commentClient.JoinedRoomSummary == null) { return; } // コメントを追加 var newMessage = new Message(this.commentClient.JoinedRoomSummary, message); newMessage.OnBanUser += this.BanUser; newMessage.OnUnBanUser += this.UnBanUser; newMessage.OnMarkListener += this.MarkListener; newMessage.OnShowId += this.ShowId; newMessage.OnHideId += this.HideId; this.MessageList.Insert(0, newMessage); // コメントの読み上げ var isConnect = this.speechClient != null || this.speechClient.IsConnect == false; if (this.SpeakApplicationStatus && isConnect) { var speechResult = this.speechClient.Speak(message); if (speechResult == false) { base.OnPropertyChanged("SpeakApplicationStatus"); MessageBox.Show("読み上げに失敗しました。"); } } // コードビハインドのイベントを実行 if (this.OnMessage != null) { uiDispatcher.BeginInvoke(new Action(() => { this.OnMessage(message, this.config); })); } }
public Message(Lib.Summary summary, Lib.Message message) { this.summary = summary; this.message = message; this.CopyCommentCommand = new RelayCommand(p => { if (String.IsNullOrEmpty(this.Comment)) { return; } for (var i = 0; i < 3; i++) { try { Clipboard.SetText(this.Comment); } catch (ExternalException) { System.Threading.Thread.Sleep(0); } } }); this.BanUserCommand = new RelayCommand(p => { if (this.OnBanUser != null) { this.OnBanUser(this); } }); this.UnBanUserCommand = new RelayCommand(p => { if (this.OnUnBanUser != null) { this.OnUnBanUser(this); } }); this.ShowIdCommand = new RelayCommand(p => { if (this.OnShowId != null) { this.OnShowId(this); } }); this.HideIdCommand = new RelayCommand(p => { if (this.OnHideId != null) { this.OnHideId(this); } }); this.MarkCommand = new RelayCommand(p => { if (this.IsAuth == false && String.IsNullOrWhiteSpace(this.ListenerId)) { return; } var solidBrush = this.Color as SolidColorBrush; if (solidBrush.Color != Colors.White) { this.Color = Brushes.White; } else { var random = new Random(); // 暗い色だと文字が見えなくなるので、96以上とします。 var red = (byte)random.Next(96, 255); var green = (byte)random.Next(96, 255); var blue = (byte)random.Next(96, 255); this.Color = new SolidColorBrush(System.Windows.Media.Color.FromRgb(red, green, blue)); } if (this.OnMarkListener != null) { this.OnMarkListener(this); } }); }
public Message(Lib.Summary summary, Lib.Message message) { var uiDispatcher = Dispatcher.CurrentDispatcher; ; this.summary = summary; this.message = message; this.CopyCommentCommand = new RelayCommand(p => { if (String.IsNullOrEmpty(this.Comment)) { return; } uiDispatcher.BeginInvoke(new Action(() => { Clipboard.SetText(this.Comment, TextDataFormat.UnicodeText); })); }); this.BanUserCommand = new RelayCommand(p => { if (this.OnBanUser != null) { this.OnBanUser(this); } }); this.UnBanUserCommand = new RelayCommand(p => { if (this.OnUnBanUser != null) { this.OnUnBanUser(this); } }); this.ShowIdCommand = new RelayCommand(p => { if (this.OnShowId != null) { this.OnShowId(this); } }); this.HideIdCommand = new RelayCommand(p => { if (this.OnHideId != null) { this.OnHideId(this); } }); this.ShowCommentCommand = new RelayCommand(p => { if (this.OnShowComment != null) { this.OnShowComment(this); } }); this.HideCommentCommand = new RelayCommand(p => { if (this.OnHideComment != null) { this.OnHideComment(this); } }); this.AllowInstantMessageCommand = new RelayCommand(p => { if (this.OnAllowInstantMessage != null) { this.OnAllowInstantMessage(this); } }); this.MarkCommand = new RelayCommand(p => { if (this.IsAuth == false && String.IsNullOrWhiteSpace(this.ListenerId)) { return; } var solidBrush = this.Color as SolidColorBrush; if (solidBrush.Color != Colors.White) { this.Color = Brushes.White; } else { var random = new Random(); // 暗い色だと文字が見えなくなるので、96以上とします。 var red = (byte)random.Next(96, 255); var green = (byte)random.Next(96, 255); var blue = (byte)random.Next(96, 255); this.Color = new SolidColorBrush(System.Windows.Media.Color.FromRgb(red, green, blue)); } if (this.OnMarkListener != null) { this.OnMarkListener(this); } }); }