コード例 #1
0
        private NicoCommentViewModel(NicoSitePlugin.INicoMessage message, IMessageMetadata metadata, IMessageMethods methods, IConnectionStatus connectionStatus, IOptions options)
        {
            _message  = message;
            _metadata = metadata;
            _methods  = methods;

            ConnectionName = connectionStatus;
            _options       = options;
            ConnectionName.PropertyChanged += (s, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(ConnectionName.Name):
                    RaisePropertyChanged(nameof(ConnectionName));
                    break;

                case nameof(ConnectionName.BackColor):
                    RaisePropertyChanged(nameof(Background));
                    break;

                case nameof(ConnectionName.ForeColor):
                    RaisePropertyChanged(nameof(Foreground));
                    break;
                }
            };
            options.PropertyChanged += (s, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(options.IsEnabledSiteConnectionColor):
                    RaisePropertyChanged(nameof(Background));
                    RaisePropertyChanged(nameof(Foreground));
                    break;
                }
            };
            _message.ValueChanged += (s, e) =>
            {
                if (_message is INicoComment nicoComment)
                {
                    switch (e.PropertyName)
                    {
                    case nameof(nicoComment.UserName):
                        RaisePropertyChanged(nameof(NameItems));
                        break;
                    }
                }
            };
            _metadata.PropertyChanged += (s, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(_metadata.BackColor):
                    RaisePropertyChanged(nameof(Background));
                    break;

                case nameof(_metadata.ForeColor):
                    RaisePropertyChanged(nameof(Foreground));
                    break;

                case nameof(_metadata.FontFamily):
                    RaisePropertyChanged(nameof(FontFamily));
                    break;

                case nameof(_metadata.FontStyle):
                    RaisePropertyChanged(nameof(FontStyle));
                    break;

                case nameof(_metadata.FontWeight):
                    RaisePropertyChanged(nameof(FontWeight));
                    break;

                case nameof(_metadata.FontSize):
                    RaisePropertyChanged(nameof(FontSize));
                    break;

                case nameof(_metadata.IsNameWrapping):
                    RaisePropertyChanged(nameof(UserNameWrapping));
                    break;

                case nameof(_metadata.IsVisible):
                    RaisePropertyChanged(nameof(IsVisible));
                    break;
                }
            };
            if (_metadata.User != null)
            {
                var user = _metadata.User;
                user.PropertyChanged += (s, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case nameof(user.Nickname):
                        SetNickname(user);
                        RaisePropertyChanged(nameof(NameItems));
                        break;
                    }
                };
                SetNickname(user);
            }
        }
コード例 #2
0
 public NicoCommentViewModel(NicoSitePlugin.INicoDisconnected disconnected, IMessageMetadata metadata, IMessageMethods methods, IConnectionStatus connectionStatus, IOptions options)
     : this(disconnected as NicoSitePlugin.INicoMessage, metadata, methods, connectionStatus, options)
 {
     _message     = disconnected;
     MessageItems = Common.MessagePartFactory.CreateMessageItems(disconnected.Text);
 }