Beispiel #1
0
        public ServerCommandService(IChatState chatState,
                                    IAutomateThings automation,
                                    IManageNotes notes,
                                    IManageChannels channels,
                                    IFriendRequestService friendRequestService)
            : base(chatState)
        {
            this.channels             = channels;
            this.automation           = automation;
            this.notes                = notes;
            this.friendRequestService = friendRequestService;

            Events.GetEvent <CharacterSelectedLoginEvent>()
            .Subscribe(GetCharacter, ThreadOption.BackgroundThread, true);
            Events.GetEvent <ChatCommandEvent>().Subscribe(EnqueueAction, ThreadOption.BackgroundThread, true);
            Events.GetEvent <ConnectionClosedEvent>().Subscribe(WipeState, ThreadOption.PublisherThread, true);

            ChatModel.CurrentAccount = ChatConnection.Account;

            noisyTypes = new[]
            {
                UserJoin,
                UserLeave,
                UserStatus,
                PublicChannelList,
                PrivateChannelList,
                UserList,
                ChannelAd,
                ChannelMessage
            };

            LoggingSection = "cmnd serv";
        }
        public ServerCommandService(IChatState chatState,
            IAutomateThings automation,
            IManageNotes notes,
            IManageChannels channels,
            IFriendRequestService friendRequestService)
            : base(chatState)
        {
            this.channels = channels;
            this.automation = automation;
            this.notes = notes;
            this.friendRequestService = friendRequestService;

            Events.GetEvent<CharacterSelectedLoginEvent>()
                .Subscribe(GetCharacter, ThreadOption.BackgroundThread, true);
            Events.GetEvent<ChatCommandEvent>().Subscribe(EnqueueAction, ThreadOption.BackgroundThread, true);
            Events.GetEvent<ConnectionClosedEvent>().Subscribe(WipeState, ThreadOption.PublisherThread, true);

            ChatModel.CurrentAccount = ChatConnection.Account;

            noisyTypes = new[]
            {
                UserJoin,
                UserLeave,
                UserStatus,
                PublicChannelList,
                PrivateChannelList,
                UserList,
                ChannelAd,
                ChannelMessage
            };

            LoggingSection = "cmnd serv";
        }
Beispiel #3
0
        public PmChannelViewModel(string name, IChatState chatState, IManageNotes notes, IGetProfiles profile)
            : base(chatState)
        {
            try
            {
                model = Container.Resolve <PmChannelModel>(name);
                Model = model;

                noteService = notes;
                notes.GetNotesAsync(name);

                profileService = profile;
                profile.GetProfileDataAsync(name);

                Model.PropertyChanged += OnModelPropertyChanged;

                Container.RegisterType <object, PmChannelView>(
                    StringExtensions.EscapeSpaces(Model.Id), new InjectionConstructor(this));
                Events.GetEvent <NewUpdateEvent>()
                .Subscribe(OnNewUpdateEvent, ThreadOption.PublisherThread, true, UpdateIsOurCharacter);

                cooldownTimer.Elapsed += (s, e) =>
                {
                    isInCoolDown          = false;
                    cooldownTimer.Enabled = false;
                    OnPropertyChanged("CanPost");
                };

                noteCooldownTimer.Elapsed += (s, e) =>
                {
                    isInNoteCoolDown               = false;
                    noteCooldownTimer.Enabled      = false;
                    noteCooldownUpdateTick.Enabled = false;
                    OnPropertyChanged("CanPost");
                    OnPropertyChanged("CanShowNoteTimeLeft");
                };

                if (AllKinks == null)
                {
                    AllKinks = new ListCollectionView(new ProfileKink[0]);
                }

                noteCooldownUpdateTick.Elapsed += (s, e) => OnPropertyChanged("NoteTimeLeft");

                checkTick.Elapsed += (s, e) =>
                {
                    if (!IsTyping)
                    {
                        checkTick.Enabled = false;
                    }

                    if (!string.IsNullOrEmpty(Message) && typingLengthCache == Message.Length)
                    {
                        IsTyping = false;
                        SendTypingNotification(TypingStatus.Paused);
                        checkTick.Enabled = false;
                    }

                    if (IsTyping)
                    {
                        typingLengthCache = Message?.Length ?? 0;
                    }
                };

                Model.Settings = SettingsService.GetChannelSettings(
                    ChatModel.CurrentCharacter.Name, Model.Title, Model.Id, Model.Type);

                ChannelSettings.Updated += (s, e) =>
                {
                    OnPropertyChanged("ChannelSettings");
                    if (!ChannelSettings.IsChangingSettings)
                    {
                        SettingsService.UpdateSettingsFile(
                            ChannelSettings, ChatModel.CurrentCharacter.Name, Model.Title, Model.Id);
                    }
                };

                messageManager = new FilteredCollection <IMessage, IViewableObject>(
                    Model.Messages, message => true);

                ChatModel.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == "CurrentCharacterData")
                    {
                        UpdateProfileProperties();
                    }
                };

                isCharacterStatusExpanded = false;

                if (!string.IsNullOrWhiteSpace(ChannelSettings.LastMessage))
                {
                    return;
                }

                Message = ChannelSettings.LastMessage;
                ChannelSettings.LastMessage = null;

                LoggingSection = "pm channel vm";
            }
            catch (Exception ex)
            {
                ex.Source = "PM Channel ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Beispiel #4
0
        public PmChannelViewModel(string name, IChatState chatState, IManageNotes notes, IGetProfiles profile)
            : base(chatState)
        {
            try
            {
                model = Container.Resolve<PmChannelModel>(name);
                Model = model;

                noteService = notes;
                notes.GetNotesAsync(name);

                profileService = profile;
                profile.GetProfileDataAsync(name);

                Model.PropertyChanged += OnModelPropertyChanged;

                Container.RegisterType<object, PmChannelView>(
                    StringExtensions.EscapeSpaces(Model.Id), new InjectionConstructor(this));
                Events.GetEvent<NewUpdateEvent>()
                    .Subscribe(OnNewUpdateEvent, ThreadOption.PublisherThread, true, UpdateIsOurCharacter);

                cooldownTimer.Elapsed += (s, e) =>
                {
                    isInCoolDown = false;
                    cooldownTimer.Enabled = false;
                    OnPropertyChanged("CanPost");
                };

                noteCooldownTimer.Elapsed += (s, e) =>
                {
                    isInNoteCoolDown = false;
                    noteCooldownTimer.Enabled = false;
                    noteCooldownUpdateTick.Enabled = false;
                    OnPropertyChanged("CanPost");
                    OnPropertyChanged("CanShowNoteTimeLeft");
                };

                if (AllKinks == null)
                    AllKinks = new ListCollectionView(new ProfileKink[0]);

                noteCooldownUpdateTick.Elapsed += (s, e) => OnPropertyChanged("NoteTimeLeft");

                checkTick.Elapsed += (s, e) =>
                {
                    if (!IsTyping)
                        checkTick.Enabled = false;

                    if (!string.IsNullOrEmpty(Message) && typingLengthCache == Message.Length)
                    {
                        IsTyping = false;
                        SendTypingNotification(TypingStatus.Paused);
                        checkTick.Enabled = false;
                    }

                    if (IsTyping)
                        typingLengthCache = Message?.Length ?? 0;
                };

                Model.Settings = SettingsService.GetChannelSettings(
                    ChatModel.CurrentCharacter.Name, Model.Title, Model.Id, Model.Type);

                ChannelSettings.Updated += (s, e) =>
                {
                    OnPropertyChanged("ChannelSettings");
                    if (!ChannelSettings.IsChangingSettings)
                    {
                        SettingsService.UpdateSettingsFile(
                            ChannelSettings, ChatModel.CurrentCharacter.Name, Model.Title, Model.Id);
                    }
                };

                messageManager = new FilteredCollection<IMessage, IViewableObject>(
                    Model.Messages, message => true);

                ChatModel.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == "CurrentCharacterData")
                        UpdateProfileProperties();
                };

                isCharacterStatusExpanded = false;

                if (!string.IsNullOrWhiteSpace(ChannelSettings.LastMessage)) return;

                Message = ChannelSettings.LastMessage;
                ChannelSettings.LastMessage = null;

                LoggingSection = "pm channel vm";
            }
            catch (Exception ex)
            {
                ex.Source = "PM Channel ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }