Exemplo n.º 1
0
        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);
                }
            });
        }
Exemplo n.º 2
0
        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);
                }
            });
        }
Exemplo n.º 3
0
		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);
				}
			});
		}