Example #1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public TeamspeakViewModel(ITeamspeakService teamspeakService, TeamspeakSettings userSettings)
        {
            this.isShuttingDown = false;
            this.UserSettings   = userSettings;
            this.Notifications  = new ObservableCollection <TSNotificationViewModel>();
            this.Channels       = new ObservableCollection <ChannelViewModel>();

            this.TeamspeakService = teamspeakService;
            this.TeamspeakService.NewServerInfo        += TeamspeakService_NewServerInfo;
            this.TeamspeakService.ClientChannelChanged += TeamspeakService_ClientChannelChanged;
            this.TeamspeakService.ConnectionRefused    += TeamspeakService_ConnectionRefused;
            this.TeamspeakService.TalkStatusChanged    += TeamspeakService_TalkStatusChanged;
            this.TeamspeakService.TextMessageReceived  += TeamspeakService_TextMessageReceived;
            this.TeamspeakService.ClientEnteredChannel += TeamspeakService_ClientEnteredChannel;
            this.TeamspeakService.ClientExitedChannel  += TeamspeakService_ClientExitedChannel;
            this.TeamspeakService.ChannelAdded         += TeamspeakService_ChannelAdded;
            this.TeamspeakService.ChannelRemoved       += TeamspeakService_ChannelRemoved;
            this.TeamspeakService.ChannelUpdated       += TeamspeakService_ChannelUpdated;

            Task.Factory.StartNew((state) =>
            {
                // Start this on another thread so that we don't hold up anything creating us
                this.TeamspeakService.Connect();
            }, null, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.FromCurrentSynchronizationContext());
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public ApplicationController()
        {
            // Create services
            logger.Debug("Creating services");
            this.EventsService    = new EventsService();
            this.PlayerService    = new PlayerService();
            this.SystemService    = new SystemService();
            this.ZoneService      = new ZoneService();
            this.DungeonsService  = new DungeonsService();
            this.WvWService       = new WvWService();
            this.GuildService     = new GuildService();
            this.TeamspeakService = new TeamspeakService();
            this.CommerceService  = new CommerceService();

            // Create ZoneName view model for the Zone Completion Assistant
            this.ZoneName = new ZoneNameViewModel();

            // Create WvWMap view model for the WvW Tracker
            this.WvWMap = new WvWMapViewModel();

            // Load user settings
            logger.Debug("Loading event user settings");
            this.EventSettings = EventSettings.LoadSettings(EventSettings.Filename);
            if (this.EventSettings == null)
            {
                this.EventSettings = new EventSettings();
            }

            logger.Debug("Loading zone completion assistant user settings");
            this.ZoneCompletionSettings = ZoneCompletionSettings.LoadSettings(ZoneCompletionSettings.Filename);
            if (this.ZoneCompletionSettings == null)
            {
                this.ZoneCompletionSettings = new ZoneCompletionSettings();
            }

            logger.Debug("Loading dungeon user settings");
            this.DungeonSettings = DungeonSettings.LoadSettings(DungeonSettings.Filename);
            if (this.DungeonSettings == null)
            {
                this.DungeonSettings = new DungeonSettings();
            }

            logger.Debug("Loading wvw user settings");
            this.WvWSettings = WvWSettings.LoadSettings(WvWSettings.Filename);
            if (this.WvWSettings == null)
            {
                this.WvWSettings = new WvWSettings();
            }

            logger.Debug("Loading teamspeak settings");
            this.TeamspeakSettings = TeamspeakSettings.LoadSettings(TeamspeakSettings.Filename);
            if (this.TeamspeakSettings == null)
            {
                this.TeamspeakSettings = new TeamspeakSettings();
            }

            logger.Debug("Loading commerce settings");
            this.CommerceSettings = CommerceSettings.LoadSettings(CommerceSettings.Filename);
            if (this.CommerceSettings == null)
            {
                this.CommerceSettings = new CommerceSettings();
            }

            // Enable autosave on the user settings
            logger.Debug("Enabling autosave of user settings");
            this.EventSettings.EnableAutoSave();
            this.ZoneCompletionSettings.EnableAutoSave();
            this.DungeonSettings.EnableAutoSave();
            this.WvWSettings.EnableAutoSave();
            this.TeamspeakSettings.EnableAutoSave();
            this.CommerceSettings.EnableAutoSave();

            // Create the controllers
            logger.Debug("Creating browser controller");
            this.BrowserController = new BrowserController();

            logger.Debug("Creating events controller");
            this.EventsController = new EventsController(this.EventsService, this.EventSettings);
            this.EventsController.Start(); // Get it started for event notifications

            logger.Debug("Creating zone completion assistant controller");
            this.ZoneCompletionController = new ZoneCompletionController(this.ZoneService, this.PlayerService, this.SystemService, this.ZoneName, this.ZoneCompletionSettings);

            logger.Debug("Creating dungeons controller");
            this.DungeonsController = new DungeonsController(this.DungeonsService, this.BrowserController, this.DungeonSettings);

            logger.Debug("Creating wvw controller");
            this.WvWController = new WvWController(this.WvWService, this.PlayerService, this.GuildService, this.WvWMap, this.WvWSettings);
            this.WvWController.Start(); // Get it started for wvw notifications

            logger.Debug("Creating commerce controller");
            this.CommerceController = new CommerceController(this.CommerceService, this.CommerceSettings);
            this.CommerceController.Start(); // Get it started for price-watch notifications

            // Create the event notifications view
            logger.Debug("Initializing event notifications");
            this.eventNotificationsView = new EventNotificationWindow(this.EventsController);
            this.eventNotificationsView.Show(); // Transparent window, just go ahead and show it

            // Create the wvw notifications view
            logger.Debug("Initializing WvW notifications");
            this.wvwNotificationsView = new WvWNotificationWindow(this.WvWController);
            this.wvwNotificationsView.Show(); // Transparent window, just go ahead and show it

            logger.Debug("Initializing price notifications");
            this.priceNotificationsView = new PriceNotificationWindow(this.CommerceController);
            this.priceNotificationsView.Show(); // Transparent window, just go ahead and show it

            // Initialize the menu items
            logger.Debug("Initializing application menu items");
            this.BuildMenuItems();

            logger.Info("Application controller initialized");
        }