예제 #1
0
        /// <summary>
        /// Handler for the Channel Removed event
        /// </summary>
        private void TeamspeakService_ChannelRemoved(object sender, TS3.Data.ChannelEventArgs e)
        {
            Threading.BeginInvokeOnUI(() =>
            {
                var removedChannel = new ChannelViewModel(e.Channel, this.TeamspeakService);

                if (removedChannel.ParentID != 0)
                {
                    // This has a parent channel - find it
                    var parentChannel = this.FindParentChannel(this.Channels, removedChannel);

                    if (parentChannel != null)
                    {
                        var toRemove = parentChannel.Subchannels.FirstOrDefault(channel => channel.ID == removedChannel.ID);
                        parentChannel.Subchannels.Remove(toRemove);
                    }
                }
                else
                {
                    // No parent
                    var toRemove = this.Channels.FirstOrDefault(channel => channel.ID == removedChannel.ID);
                    this.Channels.Remove(toRemove);
                }

                this.OnPropertyChanged(() => this.AreChannelsLoaded);
            });
        }
예제 #2
0
 /// <summary>
 /// Handles the New Channel Info event of the Teamspeak Service
 /// </summary>
 private void TeamspeakService_ClientChannelChanged(object sender, TS3.Data.ChannelEventArgs e)
 {
     Threading.InvokeOnUI(() =>
     {
         this.ClientChannelName        = e.Channel.Name;
         this.ClientChannelDescription = e.Channel.Description;
     });
 }
예제 #3
0
        /// <summary>
        /// Handler for the Channel Updated event
        /// </summary>
        private void TeamspeakService_ChannelUpdated(object sender, TS3.Data.ChannelEventArgs e)
        {
            Threading.BeginInvokeOnUI(() =>
            {
                // Find the matching existing channel
                ChannelViewModel existingChannel = this.FindChannel(this.Channels, e.Channel.ID);

                if (existingChannel == null)
                {
                    // This shouldn't happen, but if it does, don't crash, just treat it as a "channel added"
                    this.TeamspeakService_ChannelAdded(sender, e);
                    return;
                }

                existingChannel.Name         = e.Channel.Name;
                existingChannel.OrderIndex   = e.Channel.Order;
                existingChannel.ClientsCount = e.Channel.ClientsCount;

                // Check to see if the parent ID has changed. If so, update it and move the channel
                if (existingChannel.ParentID != e.Channel.ParentID)
                {
                    // Find the existing parent
                    ChannelViewModel existingParent = this.FindParentChannel(this.Channels, existingChannel);

                    if (existingParent != null)
                    {
                        // Remove it from the parent
                        existingParent.Subchannels.Remove(existingChannel);
                    }

                    // Update the parent ID
                    existingChannel.ParentID = e.Channel.ParentID;

                    // Find the new parent
                    ChannelViewModel newParent = this.FindParentChannel(this.Channels, existingChannel);

                    if (newParent != null)
                    {
                        // Add it to the parent
                        newParent.Subchannels.Add(existingChannel);
                    }
                    else
                    {
                        // Orphan...
                        this.orphanChannels.Add(existingChannel);
                    }
                }

                this.OnPropertyChanged(() => this.AreChannelsLoaded);
            });
        }
예제 #4
0
        /// <summary>
        /// Handler for the Channel Added event
        /// </summary>
        private void TeamspeakService_ChannelAdded(object sender, TS3.Data.ChannelEventArgs e)
        {
            Threading.BeginInvokeOnUI(() =>
            {
                if (e.Channel.IsSpacer)
                {
                    return;     // Totally ignore spacers
                }
                var newChannel = new ChannelViewModel(e.Channel, this.TeamspeakService);

                // Check if we have any orphans that are a subchannel of this new channel
                var matchingOrphans = this.orphanChannels.Where(c => c.ParentID == newChannel.ID);
                foreach (var orphan in matchingOrphans)
                {
                    newChannel.Subchannels.Add(orphan);
                }
                this.orphanChannels.RemoveAll(c => c.ParentID == newChannel.ID);

                if (newChannel.ParentID != 0)
                {
                    // This has a parent channel - find it
                    var parentChannel = this.FindParentChannel(this.Channels, newChannel);

                    if (parentChannel != null)
                    {
                        parentChannel.Subchannels.Add(newChannel);
                    }
                    else
                    {
                        // This is an orphan channel... add it to our orphan list for now
                        this.orphanChannels.Add(newChannel);
                    }
                }
                else
                {
                    // No parent
                    this.Channels.Insert(0, newChannel);
                }

                this.OnPropertyChanged(() => this.AreChannelsLoaded);
            });
        }
예제 #5
0
 /// <summary>
 /// Handles the New Channel Info event of the Teamspeak Service
 /// </summary>
 private void TeamspeakService_ClientChannelChanged(object sender, TS3.Data.ChannelEventArgs e)
 {
     this.ClientChannelName        = e.Channel.Name;
     this.ClientChannelDescription = e.Channel.Description;
 }