コード例 #1
0
        /// <summary>
        /// データ送信
        /// </summary>
        public void SendData(CommentDataEx data, DataType type = DataType.Json)
        {
            lock (syncObject)
            {
                foreach (var socket in Sockets)
                {
                    if (socket.State == WebSocketState.Open)
                    {
                        var converted = XSSConvert(data.Clone());
                        var response  = string.Empty;

                        if (type == DataType.Json)
                        {
                            response = System.Text.Json.JsonSerializer.Serialize <CommentDataEx>(converted as CommentDataEx);
                        }
                        else if (type == DataType.Xml)
                        {
                            response = XmlSerializer.Serialize <CommentDataEx>(converted);
                        }

                        var buffer  = Encoding.UTF8.GetBytes(response);
                        var segment = new ArraySegment <byte>(buffer);

                        socket.SendAsync(segment, WebSocketMessageType.Text, true, CancellationToken.None);
                    }
                }
            }
        }
コード例 #2
0
        public static void ShowUserSettingWindow(CommentDataEx commentData)
        {
            if (commentData is not null)
            {
                var usersData = UserDataManager.Instance.FirstOrDefault(x => x.LiveName.Equals(commentData.LiveName) && x.UserID.Equals(commentData.UserID));

                // ウィンドウ表示
                ShowUserSettingWindow(usersData ?? new(commentData));
            }
        }
コード例 #3
0
        public static void ShowUserDataWindow(CommentDataEx user)
        {
            if (user is null || WindowHelper.SearchUserDataWindow(user.LiveName, user.UserID))
            {
                return;
            }

            var userData = new UserDataWindow();

            userData.DataContext = new UserDataWindowViewModel(user);
            userData.Owner       = Application.Current.MainWindow;
            userData.Show();
            userData.Activate();
        }
コード例 #4
0
        public UserDataWindowViewModel(CommentDataEx user)
        {
            this.LiveName = user.LiveName;
            this.UserId   = user.UserID;

            Title     = new ReactiveProperty <string>().AddTo(Disposable);
            BackColor = new ReactiveProperty <SolidColorBrush>(new SolidColorBrush(Color.FromArgb(255, 0, 0, 0))).AddTo(Disposable);
            ShowUserSettingCommand = new ReactiveCommand().WithSubscribe(() => WindowManager.ShowUserSettingWindow(user)).AddTo(Disposable);
            MenuItemOpenedCommand  = new ReactiveCommand <MenuItem>().WithSubscribe(MenuItemCopyOpened).AddTo(Disposable);

            CommentFilter         = new() { Source = CommentManager.Instance };
            CommentFilter.Filter += CommentFilter_Filter;

            user.ObserveProperty(o => o.UserName).Subscribe(value => Title.Value            = $"{user.LiveName} - " + (string.IsNullOrEmpty(user.UserName) ? user.UserID : user.UserName)).AddTo(Disposable);
            user.ObserveProperty(o => o.BackColor).Subscribe(value => BackColor.Value.Color = value.ToArgb()).AddTo(Disposable);
        }
コード例 #5
0
 public static UserData Find(this UserDataManager manager, CommentDataEx commentDataEx)
 => manager.Find(commentDataEx.LiveName, commentDataEx.UserID);