Ejemplo n.º 1
0
        /// <summary>
        /// Creates a channel object and manages everything required for the notifications.
        /// </summary>
        public void CreateChannel(string name)
        {
            Channel channel = new Channel(Resources.icon);
            channel.Loaded += ChannelLoaded;
            channel.GameChanged += ChannelLoaded;
            channel.Initialise(name);

            _channels.Add(channel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs the tray icon and intialises the agent.
        /// </summary>
        public TrayAgent()
        {
            _trayMenu = new ContextMenu();
            _trayMenu.MenuItems.Add("Re-Show Notifications", ReShowNotifications);
            _trayMenu.MenuItems.Add("-");
            _trayMenu.MenuItems.Add("Exit", ExitClicked);

            _trayIcon = new NotifyIcon();
            _trayIcon.Text = "TwitchAgent";
            _trayIcon.Icon = Resources.icon;
            _trayIcon.ContextMenu = _trayMenu;
            _trayIcon.Visible = true;

            ChannelManager.Instance.TrayAgent = this;

            _myChannel = new Channel(Resources.icon);
            _myChannel.FollowingPopulated += FollowingPopulated;
            _myChannel.Initialise("cybutek");
            _myChannel.PopulateFollowing();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Runs when a channel is loaded.  Occures when the online state is changed.
        /// </summary>
        private void ChannelLoaded(Channel sender)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate
                {
                    if (this.Icon != sender.Icon)
                    {
                        this.Icon = sender.Icon;
                    }
                });
            }
            else
            {
                if (this.Icon != sender.Icon)
                {
                    this.Icon = sender.Icon;
                }
            }

            TitleProcessor();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new notification using a specified channel for the details.
        /// </summary>
        public Notification(Channel channel)
        {
            _indexPosition = AddForm(this);

            InitializeComponent();

            this.MouseUp += FormMouseUp;
            this.name.MouseUp += FormMouseUp;
            this.status.MouseClick += FormMouseUp;

            _channelName = channel.Name;
            if (channel.Icon != null)
            {
                channelIcon.BackgroundImage = channel.Icon.ToBitmap();
                channelIcon.Click += IconClick;
            }

            name.Text = channel.DisplayName;
            status.Text = channel.Game;

            ThreadManager.StartThread(TimerThread);
        }
Ejemplo n.º 5
0
 // Runs when the status of the channel changes.
 private void ChannelLoaded(Channel sender)
 {
     if (_notificationsEnabled && _trayAgent != null && sender.IsOnline)
     {
         if (_trayAgent.InvokeRequired)
         {
             _trayAgent.Invoke((MethodInvoker)delegate
             {
                 new Notification(sender).Show();
             });
         }
         else
         {
             new Notification(sender).Show();
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Changes the channel to the selected channel given.
        /// </summary>
        private void ChannelSelected(string name)
        {
            _currentChannel = name;
            TitleProcessor();

            this.flashPanel.Controls.Remove(flashPlayer);
            flashPlayer.Dispose();
            flashPlayer = new AxShockwaveFlashObjects.AxShockwaveFlash();
            flashPlayer.BeginInit();
            flashPlayer.Name = "flashPlayer";
            flashPlayer.EndInit();
            this.flashPanel.Controls.Add(flashPlayer);

            flashPlayer.WMode = "Direct";
            flashPlayer.EmbedMovie = false;
            flashPlayer.AllowNetworking = "all";
            flashPlayer.AllowScriptAccess = "always";
            flashPlayer.FlashVars = "hostname=www.twitch.tv&channel=" + name + "&auto_play=true&start_volume=100";
            flashPlayer.LoadMovie(0, "http://www.twitch.tv/widgets/live_embed_player.swf");

            FlashPanelResize(null,null);

            this.chatPanel.DocumentText = "<html><head></head><body style=\"margin: 0px; padding 0px; width: 350px; \"><iframe frameborder=\"0\" scrolling=\"no\" id=\"chat_embed\" src=\"http://twitch.tv/chat/embed?channel=" + name + "&amp;popout_chat=true\" height=\"100%\" width=\"350\"></iframe></body></html>";

            // Create a channel object to do all of the Twitch API stuff.
            if (_channel != null)
            {
                _channel.Dispose();
            }
            _channel = new Channel(Properties.Resources.icon);
            _channel.Loaded += ChannelLoaded;
            _channel.GameChanged += GameChanged;
            _channel.Initialise(name);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Runs when the channel game changes.
 /// </summary>
 private void GameChanged(Channel sender)
 {
     TitleProcessor();
 }
Ejemplo n.º 8
0
        // Runs when the list of followers has been populated.
        private void FollowingPopulated(Channel sender)
        {
            ChannelManager.Instance.NotificationsEnabled = false;

            foreach (string channel in sender.Following)
            {
                ChannelManager.Instance.CreateChannel(channel);
            }

            ChannelManager.Instance.NotificationsEnabled = true;
        }