Exemple #1
0
        public TeamspeakViewModel(ITeamspeakService teamspeakService, TeamspeakUserData userData)
        {
            this.isShuttingDown        = false;
            this.UserData              = userData;
            this.ChatMessages          = new ObservableCollection <ChatMsgViewModel>();
            this.Notifications         = new ObservableCollection <TSNotificationViewModel>();
            this.Channels              = new ObservableCollection <ChannelViewModel>();
            this.CurrentChannelClients = new ObservableCollection <ClientViewModel>();

            var channelsSource = new AutoRefreshCollectionViewSource();

            channelsSource.Source = this.Channels;
            this.ChannelsSource   = channelsSource;
            this.ChannelsSource.SortDescriptions.Add(new SortDescription("OrderIndex", ListSortDirection.Ascending));

            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.None, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemple #2
0
        public TeamspeakViewModel(ITeamspeakService teamspeakService, TeamspeakUserData userData)
        {
            this.isShuttingDown = false;
            this.UserData = userData;
            this.ChatMessages = new ObservableCollection<ChatMsgViewModel>();
            this.Notifications = new ObservableCollection<TSNotificationViewModel>();
            this.Channels = new ObservableCollection<ChannelViewModel>();
            this.CurrentChannelClients = new ObservableCollection<ClientViewModel>();

            var channelsSource = new AutoRefreshCollectionViewSource();
            channelsSource.Source = this.Channels;
            this.ChannelsSource = channelsSource;
            this.ChannelsSource.SortDescriptions.Add(new SortDescription("OrderIndex", ListSortDirection.Ascending));

            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.None, TaskScheduler.FromCurrentSynchronizationContext() );
        }