private void CountControlButtonOnClick(object sender, RoutedEventArgs e)
 {
     if (m_countTimer.IsRunning)
     {
         m_countTimer.Stop();
     }
     else
     {
         m_countTimer.Start();
     }
 }
        private void GetTwitchCount()
        {
            Regex     rx = new Regex("viewers_count.*?(\\d*?)\\,");
            WebClient wc = new WebClient();

            wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler((b, a) => {
                if (a.Error == null)
                {
                    //{"average_bitrate": 0, "viewers_count": 272, "streams_count": 1}

                    Match m = rx.Match(a.Result);
                    if (m.Success)
                    {
                        Header = "[Twitch] Зрителей: " + m.Groups[1].Value + ", " + StreamerNick;
                        int h;
                        if (int.TryParse(m.Groups[1].Value, out h))
                        {
                            History.Add(new KeyValuePair <DateTime, int>(DateTime.Now, h));
                            if (History.Count > 10)
                            {
                                History.RemoveAt(0);
                            }
                        }
                    }
                }
                CountTimer.Start();
            });
            wc.DownloadStringAsync(new Uri(
                                       //http://api.justin.tv/api/stream/summary.json?channel=Knjazevdesu&jsonp=
                                       string.Format("http://api.justin.tv/api/stream/summary.json?channel={0}&jsonp=", StreamerNick), UriKind.RelativeOrAbsolute));
        }
        private void GetCyberCount()
        {
            Regex     rx = new Regex("viewers.*?\\:\\\"(.*?)\\\"");
            WebClient wc = new WebClient();

            wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler((b, a) => {
                if (a.Error == null)
                {
                    Match m = rx.Match(a.Result);
                    if (m.Success)
                    {
                        Header = "[Cyber] Зрителей: " + m.Groups[1].Value + ", " + StreamerNick;
                        int h;
                        if (int.TryParse(m.Groups[1].Value, out h))
                        {
                            History.Add(new KeyValuePair <DateTime, int>(DateTime.Now, h));
                            if (History.Count > 10)
                            {
                                History.RemoveAt(0);
                            }
                        }
                    }
                }
                CountTimer.Start();
            });
            wc.DownloadStringAsync(new Uri(
                                       string.Format("http://api.cybergame.tv/w/streams.php?channel={0}", StreamerNick), UriKind.RelativeOrAbsolute));
        }
        //cap

        void CountTimer_Tick(object sender, EventArgs e)
        {
            CurPollSeconds--;
            if (CurPollSeconds < 0)
            {
                CurPollSeconds = PollSeconds;

                CountTimer.Stop();
                if (!string.IsNullOrEmpty(StreamerNick))
                {
                    switch (_CounterSource)
                    {
                    case CounterSource.Twitch:
                        GetTwitchCount();
                        break;

                    case CounterSource.Cybergame:
                        GetCyberCount();
                        break;
                    }
                }
                else
                {
                    CountTimer.Start();
                }
            }
        }
Example #5
0
 public MainForm()
 {
     InitializeComponent();
     DBSetup();
     InitDataTable();
     CountTimer.Start();
 }
Example #6
0
    // Use this for initialization
    void Start()
    {
        ct            = new CountTimer(5);
        ct.TotalCount = 5;

        ct.Elapsed += HandleElapsed;
        ct.Start();
    }
Example #7
0
 void HandleElapsed(float nowCount)
 {
     Debug.Log(nowCount);
     if (nowCount == ct.TotalCount)
     {
         ct.Close();
         ct.Elapsed += HandleElapsed;
         ct.Start();
     }
 }
Example #8
0
    void HandleSpawnElapsed(float nowCount)
    {
        T obj = pool.GetOne();

        borns.Add(obj);
        CountTimer putBackTimer = new CountTimer(10, 1);

        ptTimers.Add(putBackTimer);
        putBackTimer.Elapsed += delegate {
            pool.PutBack(obj);
            ptTimers.Remove(putBackTimer);
            borns.Remove(obj);
        };
        putBackTimer.Start();
    }
            public void Dead()
            {
                if (Invincible)
                {
                    return;
                }

                lifeChange.Value -= 1;
                invincibleTimer.Start();
                Invincible = true;

                if (lifeChange.Value <= 0)
                {
                    Invincible = false;
                    GameFacade.ViewFlow.Forward("GameOverView");
                    GameFacade.GameFlow.Stop();
                }
            }