Ejemplo n.º 1
0
        public HomeChannelViewModel(string name, IChatState chatState, IAutomateThings automation, IBrowseThings browser,
                                    HomeSettingsViewModel settingsVm, HomeHelpViewModel helpVm, IUpdateMyself updateService)
            : base(chatState)
        {
            try
            {
                Model         = Container.Resolve <GeneralChannelModel>(name);
                ConnectTime   = 0;
                flavorText    = new StringBuilder("Connecting");
                connectDotDot = new StringBuilder();

                this.updateService = updateService;
                HelpVm             = helpVm;

                Container.RegisterType <object, HomeChannelView>(Model.Id, new InjectionConstructor(this));
                minuteOnlineCount = new CacheCount(OnlineCountPrime, 15, 1000 * 15);

                updateTimer.Enabled  = true;
                updateTimer.Elapsed += (s, e) =>
                {
                    OnPropertyChanged("RoughServerUpTime");
                    OnPropertyChanged("RoughClientUpTime");
                    OnPropertyChanged("LastMessageReceived");
                };

                updateTimer.Elapsed += UpdateConnectText;
                SettingsVm           = settingsVm;

                Events.GetEvent <NewUpdateEvent>().Subscribe(param =>
                {
                    var temp = param as CharacterUpdateModel;
                    if (!(temp?.Arguments is LoginStateChangedEventArgs))
                    {
                        return;
                    }

                    OnPropertyChanged("OnlineCount");
                    OnPropertyChanged("OnlineFriendsCount");
                    OnPropertyChanged("OnlineBookmarksCount");
                    OnPropertyChanged("OnlineCountChange");
                });

                Events.GetEvent <LoginAuthenticatedEvent>().Subscribe(LoggedInEvent);
                Events.GetEvent <LoginFailedEvent>().Subscribe(LoginFailedEvent);
                Events.GetEvent <ReconnectingEvent>().Subscribe(LoginReconnectingEvent);

                this.automation = automation;
                this.browser    = browser;

                LoggingSection = "utility channel vm";

                Themes = new ObservableCollection <ThemeModel>();
            }
            catch (Exception ex)
            {
                ex.Source = "Utility Channel ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 2
0
        public HomeChannelViewModel(string name, IChatState chatState, IAutomateThings automation, IBrowseThings browser,
            HomeSettingsViewModel settingsVm, HomeHelpViewModel helpVm, IUpdateMyself updateService)
            : base(chatState)
        {
            try
            {
                Model = Container.Resolve<GeneralChannelModel>(name);
                ConnectTime = 0;
                flavorText = new StringBuilder("Connecting");
                connectDotDot = new StringBuilder();

                this.updateService = updateService;
                HelpVm = helpVm;

                Container.RegisterType<object, HomeChannelView>(Model.Id, new InjectionConstructor(this));
                minuteOnlineCount = new CacheCount(OnlineCountPrime, 15, 1000*15);

                updateTimer.Enabled = true;
                updateTimer.Elapsed += (s, e) =>
                {
                    OnPropertyChanged("RoughServerUpTime");
                    OnPropertyChanged("RoughClientUpTime");
                    OnPropertyChanged("LastMessageReceived");
                };

                updateTimer.Elapsed += UpdateConnectText;
                SettingsVm = settingsVm;

                Events.GetEvent<NewUpdateEvent>().Subscribe(param =>
                {
                    var temp = param as CharacterUpdateModel;
                    if (!(temp?.Arguments is LoginStateChangedEventArgs))
                        return;

                    OnPropertyChanged("OnlineCount");
                    OnPropertyChanged("OnlineFriendsCount");
                    OnPropertyChanged("OnlineBookmarksCount");
                    OnPropertyChanged("OnlineCountChange");
                });

                Events.GetEvent<LoginAuthenticatedEvent>().Subscribe(LoggedInEvent);
                Events.GetEvent<LoginFailedEvent>().Subscribe(LoginFailedEvent);
                Events.GetEvent<ReconnectingEvent>().Subscribe(LoginReconnectingEvent);

                this.automation = automation;
                this.browser = browser;

                LoggingSection = "utility channel vm";

                Themes = new ObservableCollection<ThemeModel>();
            }
            catch (Exception ex)
            {
                ex.Source = "Utility Channel ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }