Windows phone 8 椭圆颜色随时间的变化

Windows phone 8 椭圆颜色随时间的变化,windows-phone-8,Windows Phone 8,我正在尝试制作一个wp8应用程序,告诉你交通灯变绿前多长时间。有一个函数叫做go。在后台调用时,比较所有4条车道上的车辆数量。第一次叫它的时候,它会给你两条最高的车道,最多的是m车道,第二的是q车道。但随后,无论何时调用它,它都只给出一个车道数,其中车辆最多,并且该值在每次函数调用中交替保存在m和q之间。在我的xaml上,我有4个椭圆,每15秒我必须更改它们的颜色。我将在下面粘贴我的xaml.cs代码。灯在60秒后没有正确变化,但在前60秒内工作正常。请帮我弄清楚。l1、l2、l3和;4是椭圆

我正在尝试制作一个wp8应用程序,告诉你交通灯变绿前多长时间。有一个函数叫做go。在后台调用时,比较所有4条车道上的车辆数量。第一次叫它的时候,它会给你两条最高的车道,最多的是m车道,第二的是q车道。但随后,无论何时调用它,它都只给出一个车道数,其中车辆最多,并且该值在每次函数调用中交替保存在m和q之间。在我的xaml上,我有4个椭圆,每15秒我必须更改它们的颜色。我将在下面粘贴我的xaml.cs代码。灯在60秒后没有正确变化,但在前60秒内工作正常。请帮我弄清楚。l1、l2、l3和;4是椭圆

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Threading;
using System.Windows.Threading;
using System.Windows.Media;



namespace TrafficGuru
{
    public partial class Page2 : PhoneApplicationPage
    {
        DispatcherTimer countDownTimer;
        int check;
        int gofncalledcount = 1;

        public void setclr()
        {
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();
            SolidColorBrush green = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
            SolidColorBrush red = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
            SolidColorBrush yellow = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0));
            l1.Fill = red;
            l2.Fill = red;
            l3.Fill = red;
            l4.Fill = red;

            if (gofncalledcount % 2 != 0)
            {
                if (global.m == 0)
                {
                    l1.Fill = green;
                    if (global.q == 1)
                    {
                        l2.Fill = yellow;
                        l3.Fill = red;
                        l4.Fill = red;
                    }
                    else if (global.q == 2)
                    {
                        l2.Fill = red;
                        l3.Fill = yellow;
                        l4.Fill = red;
                    }
                    else if (global.q == 3)
                    {
                        l2.Fill = red;
                        l3.Fill = red;
                        l4.Fill = yellow;
                    }
                }
                if (global.m == 1)
                {
                    l2.Fill = green;
                    if (global.q == 0)
                    {
                        l1.Fill = yellow;
                        l3.Fill = red;
                        l4.Fill = red;
                    }
                    else if (global.q == 2)
                    {
                        l1.Fill = red;
                        l3.Fill = yellow;
                        l4.Fill = red;
                    }
                    else if (global.q == 3)
                    {
                        l1.Fill = red;
                        l3.Fill = red;
                        l4.Fill = yellow;
                    }
                }
                else if (global.m == 2)
                {
                    l3.Fill = green;
                    if (global.q == 0)
                    {
                        l1.Fill = yellow;
                        l2.Fill = red;
                        l4.Fill = red;
                    }
                    else if (global.q == 1)
                    {
                        l1.Fill = red;
                        l2.Fill = yellow;
                        l4.Fill = red;
                    }
                    else if (global.q == 3)
                    {
                        l1.Fill = red;
                        l2.Fill = red;
                        l4.Fill = yellow;
                    }
                }
                else if (global.m == 3)
                {
                    l4.Fill = green;
                    if (global.q == 0)
                    {
                        l1.Fill = yellow;
                        l2.Fill = red;
                        l3.Fill = red;
                    }
                    else if (global.q == 1)
                    {
                        l1.Fill = red;
                        l2.Fill = yellow;
                        l3.Fill = red;
                    }
                    else if (global.q == 2)
                    {
                        l1.Fill = red;
                        l2.Fill = red;
                        l3.Fill = yellow;
                    }
                }
            }
            else
            {
                if (global.q == 0)
                {
                    l1.Fill = green;
                    if (global.m == 1)
                    {
                        l2.Fill = yellow;
                        l3.Fill = red;
                        l4.Fill = red;
                    }
                    else if (global.m == 2)
                    {
                        l2.Fill = red;
                        l3.Fill = yellow;
                        l4.Fill = red;
                    }
                    else if (global.m == 3)
                    {
                        l2.Fill = red;
                        l3.Fill = red;
                        l4.Fill = yellow;
                    }
                }
                if (global.q == 1)
                {
                    l2.Fill = green;
                    if (global.m == 0)
                    {
                        l1.Fill = yellow;
                        l3.Fill = red;
                        l4.Fill = red;
                    }
                    else if (global.m == 2)
                    {
                        l1.Fill = red;
                        l3.Fill = yellow;
                        l4.Fill = red;
                    }
                    else if (global.m == 3)
                    {
                        l1.Fill = red;
                        l3.Fill = red;
                        l4.Fill = yellow;
                    }
                }
                else if (global.q == 2)
                {
                    l3.Fill = green;
                    if (global.m == 0)
                    {
                        l1.Fill = yellow;
                        l2.Fill = red;
                        l4.Fill = red;
                    }
                    else if (global.m == 1)
                    {
                        l1.Fill = red;
                        l2.Fill = yellow;
                        l4.Fill = red;
                    }
                    else if (global.m == 3)
                    {
                        l1.Fill = red;
                        l2.Fill = red;
                        l4.Fill = yellow;
                    }
                }
                else if (global.q == 3)
                {
                    l4.Fill = green;
                    if (global.n == 0)
                    {
                        l1.Fill = yellow;
                        l2.Fill = red;
                        l3.Fill = red;
                    }
                    else if (global.m == 1)
                    {
                        l1.Fill = red;
                        l2.Fill = yellow;
                        l3.Fill = red;
                    }
                    else if (global.m == 2)
                    {
                        l1.Fill = red;
                        l2.Fill = red;
                        l3.Fill = yellow;
                    }
                }

            }


        }
        public Page2()
        {
            InitializeComponent();

            setclr();


            tbl.Text = global.str;

            if (global.str == "YOUR LIGHT IS ON FOR : ")
            {
                check = 0;
            }
            if (global.str == "YOUR LIGHT WILL BE ON IN:")
            {
                check = 1;
            }
            if (global.str == "YOUR LIGHT WILL NOT BE ON FOR UNTIL ATLEAST " + global.x * 15 + " MORE SECS.YOU WILL GET AN UPDATE IN:")
            {
                check = 2;
            }
            countDownTimer = new DispatcherTimer();
            countDownTimer.Interval = new TimeSpan(0, 0, 0, 1);
            countDownTimer.Tick += new EventHandler(countDownTimerEvent);





            countDownTimer.Start();



            test.Content = "";

        }


        int count = global.cdt;
        int g = 0;

        void test_Click(object sender, EventArgs e) { }
        void countDownTimerEvent(object sender, EventArgs e)
        {
            g++;
            if (g==16 )
            {
                g = 0;
                global.go();
                gofncalledcount++;
                setclr();


            }
            test.Content = count + " Seconds";


            if (count > 0)
            {
                count--;
            }
            else if (count == 0)
            {
                count = global.cdt;
                countDownTimer.Stop();
                if (check == 0)
                {



                    test.Content = "STOP!!";
                    /*
                    NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.RelativeOrAbsolute));*/


                }
                else if (check == 1)
                {


                    test.Content = "GO!!!";/*
                NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.RelativeOrAbsolute));*/

                }

                else
                {

                    //setclr();

                    tbl.Text = global.str;
                    if (global.str == "YOUR LIGHT IS ON FOR : ")
                    {
                        check = 0;
                    }
                    if (global.str == "YOUR LIGHT WILL BE ON IN:")
                    {
                        check = 1;
                    }
                    if (global.str == "YOUR LIGHT WILL NOT BE ON FOR UNTIL ATLEAST " + global.x * 15 + " MORE SECS.YOU WILL GET AN UPDATE IN:")
                    {
                        check = 2;
                    }



                    countDownTimer.Start();



                    //NavigationService.Navigate(new Uri("/Page3.xaml", UriKind.RelativeOrAbsolute));

                }
            }
        }
    }
}

你能减少这个问题吗?您已经粘贴了很多可能与问题无关的代码。此外,如果您编辑了您的问题文本,我们将不胜感激:我不认为任何代码都是不必要的,我想做的是每15秒调用一次setclr函数和go函数,我正在这样做,但它并没有正常工作,所以我将整个过程发布给大家,以检查复制问题所需的最小代码量是多少?你的问题文本很难理解。