Esempio n. 1
0
        // Notification Methods
        public List<NotificationForm> NewActiveNotification(NotificationForm Notification)
        {
            ActiveNotifications.Add(Notification);

            //MessageBox.Show("New Active Notification");

            return ActiveNotifications;
        }
Esempio n. 2
0
 public void RemoveActiveNotification(NotificationForm Notification)
 {
     ActiveNotifications.Remove(Notification);
 }
Esempio n. 3
0
        // Send form to System Tray
        private void formToTray(bool ShowBalloonTip = false)
        {
            NotificationForm Notification = new NotificationForm(ui);

            Notification.Title = "WhyNs Stream Watcher";
            Notification.Message = "The Application has been minimized to System Tray.\n\n(Right click icon to restore)";
            notifyIconMain.Visible = true;

            if (ShowBalloonTip) {

                Notification.Show();

            }

            this.ShowInTaskbar = false;
            this.WindowState = FormWindowState.Minimized;
            this.Hide();
        }
Esempio n. 4
0
        private List<Control> UpdateStreams()
        {
            // Creating new TwitchAPI based on username
            twitchAPI = new TwitchAPI(Properties.Settings.Default.TwitchUsername);

            Label lblErrorStatus = new Label();
            lblErrorStatus.AutoSize = true;
            lblErrorStatus.Margin = new Padding(30);
            lblErrorStatus.Font = new Font(lblErrorStatus.Font, FontStyle.Bold);

            if (Properties.Settings.Default.TwitchUsername.Length != 0)
            {

                // List for Channel Controls
                List<Control> listStreamControls = new List<Control>();

                List<Channel> NewChannels;

                // Getting Twitch channels
                List<Channel> TwitchChannels = this.twitchAPI.GetChannelsUserIsFollowing();

                // Merging Channels from Stream Clients
                try
                {
                    NewChannels = new List<Channel>(TwitchChannels);
                }
                catch {

                    NewChannels = null;
                }

                // New List for Channels
                List<Channel> NewChangedChannels = new List<Channel>();

                // New Channel Object for Channel
                Channel ChangedChannel = new Channel();

                if (NewChannels != null)
                {

                    string OfflineStreamsText = string.Empty;
                    int i = 0;
                    foreach(Channel NewChannel in NewChannels)
                    {

                        ChangedChannel = NewChannel;

                        if (OldChannels != null)
                        {
                            foreach (Channel OldChannel in OldChannels)
                            {

                                if (NewChannel.id == OldChannel.id)
                                {
                                    // Checking for Changes and returning changed channel
                                    ChangedChannel = CheckForStreamChanges(NewChannel, OldChannel);

                                    break;
                                }

                            }
                        }
                        else
                        {
                            // If no OldChannels

                            // First time Notifications at Application Start
                            if (NewChannel.live)
                            {
                                // Channel Is Live!
                                ChangedChannel.IsLive = true;

                            }

                        }

                        // Adding Changed Channel to List
                        NewChangedChannels.Add(ChangedChannel);

                        // Showing Notification if Any
                        ShowNotification(ChangedChannel);

                        // Creating control for Channel
                        Control ChannelControl = new ChannelLayout(ChangedChannel);

                        if (ChangedChannel.live)
                        {

                            listStreamControls.Add(ChannelControl);

                        }
                        else if (Properties.Settings.Default.ShowOfflineStreams)
                        {

                            listStreamControls.Add(ChannelControl);
                            OfflineStreamsText = "";
                        }
                        else
                        {
                            i++;

                            OfflineStreamsText = "(" + i + " streams offline)";

                        }

                    }

                    this.lblStreamsOffline.Invoke(new UpdateOfflineStreamsLabelCallback(this.UpdateOfflineStreamsLabel), new object[] { OfflineStreamsText });

                    OldChannels = NewChangedChannels; // Or Should it be NewChannels? Testing will show!

                    return listStreamControls;

                }

                // No data from Stream Clients
                lblErrorStatus.Text = "Something went worng when getting data from Twitch.tv!\n\nMake sure the entered username is valid!\nIf it is, Try again later...";

            }
            else
            {
                // No Username
                lblErrorStatus.Text = "No Username Entered!";
            }

            // Creating Error Notification and Status
            NotificationForm nf = new NotificationForm(ui);
            nf.Title = "WhyNs Stream Watcher";
            nf.Message = lblErrorStatus.Text;

            Thread.Sleep(1000);

            this.panelStreams.Invoke(new ShowNotificationCallback(this.ShowNotification), new object[] { nf });

            return new List<Control>(new Control[] { lblErrorStatus });
        }
Esempio n. 5
0
        private void ShowNotification(Channel channel)
        {
            ChannelLayout ChannelControl = new ChannelLayout(channel);
            //ChannelControl.Location = new Point(0, 0);

            NotificationForm ChannelNotification = new NotificationForm(ui);
            ChannelNotification.FormBorderStyle = FormBorderStyle.None;
            ChannelNotification.Size = new Size(ChannelControl.Size.Width, ChannelControl.Size.Height);
            ChannelNotification.CustomControl = ChannelControl;

            if (channel.IsLive && Properties.Settings.Default.ChannelNotificationIsLive)
            {

                this.panelStreams.Invoke(new ShowNotificationCallback(this.ShowNotification), new object[] { ChannelNotification });

            }
            else if (channel.IsLiveNow && Properties.Settings.Default.ChannelNotificationIsLiveNow)
            {

                this.panelStreams.Invoke(new ShowNotificationCallback(this.ShowNotification), new object[] { ChannelNotification });

            }
            else if (channel.IsOfflineNow && Properties.Settings.Default.ChannelNotificationIsOfflineNow)
            {

                this.panelStreams.Invoke(new ShowNotificationCallback(this.ShowNotification), new object[] { ChannelNotification });

            }
        }
Esempio n. 6
0
 private void ShowNotification(NotificationForm Notification)
 {
     Notification.Show();
 }
Esempio n. 7
0
        private void btnGetFollowingChannels_Click(object sender, EventArgs e)
        {
            NotificationForm nfTest = new NotificationForm(ui);
            nfTest.Show();

            //nfTest = new NotificationForm(ui);
            //nfTest.Show();

            //nfTest = new NotificationForm(ui);
            //nfTest.Show();

            //nfTest = new NotificationForm(ui);
            //nfTest.Show();
        }