Esempio n. 1
0
        public Start_Exam_View()
        {
            InitializeComponent();

            DataRow[] fr;
            fr = ExamView_s.dt_exam.Select("id=" + ExamView_s.EID);
            if (fr.Length > 0)
            {
                test = 1;
                string QuizName = "";
                switch (fr[0]["q_type"].ToString())
                {
                case "0":
                    QuizName = "Test1";
                    break;

                case "1":
                    QuizName = "Test2";
                    break;

                case "2":
                    QuizName = "Final";
                    break;
                }


                Exam_Name.Text = fr[0]["course_name"].ToString() + " / " + QuizName;
                Exam_det.Text  = fr[0]["des"].ToString();
                DateTime dat2 = DateTime.Parse(fr[0]["dat"].ToString());

                DateTime tim = DateTime.Parse(fr[0]["tim"].ToString());


                CultureInfo us = new CultureInfo("en-US");
                System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("en-US");
                string da = dat2.Date.Day.ToString(new CultureInfo("en-US"));
                string mo = dat2.Date.Month.ToString(new CultureInfo("en-US"));
                string ye = dat2.Date.Year.ToString(new CultureInfo("en-US"));

                DateTime dat = DateTime.Parse(mo + "/" + da + "/" + ye + " " + tim.TimeOfDay.Hours + ":" + tim.TimeOfDay.Minutes + ":" + tim.TimeOfDay.Seconds, cultureinfo);

                //int soc = (dat - DateTime.Now).Days;
                TimeSpan value = dat.Subtract(DateTime.Now);
                int      Sec1, Min1, Hour1, Day1;
                Sec1     = value.Seconds;
                Min1     = value.Minutes;
                Hour1    = value.Hours;
                Day1     = value.Days;
                s1.Text  = Sec1.ToString();
                m1.Text  = Min1.ToString();
                h1.Text  = Hour1.ToString();
                dy1.Text = Day1.ToString();
                StartButton.IsEnabled = true;
                if (Day1 == 0 & Hour1 == 0)
                {
                    if (Min1 <= 1 && Min1 > 0)
                    {
                        StartButton.IsEnabled = true;
                    }
                    if (Min1 <= 0 && Sec1 <= 0)
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Finish Time");

                        Shell.Current.Navigation.PopAsync();
                        return;
                    }
                }

                Device.StartTimer(TimeSpan.FromSeconds(1), () =>
                {
                    try
                    {
                        TimeSpan value2 = dat.Subtract(DateTime.Now);
                        int Sec2, Min2, Hour2, Day2;
                        Sec2  = value2.Seconds;
                        Min2  = value2.Minutes;
                        Hour2 = value2.Hours;
                        Day2  = value2.Days;

                        s1.Text  = Sec2.ToString();
                        m1.Text  = Min2.ToString();
                        h1.Text  = Hour2.ToString();
                        dy1.Text = Day2.ToString();

                        if (Day2 == 0 & Hour2 == 0)
                        {
                            if (Min2 <= 1 && Min2 > 0)
                            {
                                StartButton.IsEnabled = true;
                            }
                            if (Min2 <= 0 && Sec2 <= 0)
                            {
                                DependencyService.Get <IMessage>().ShortAlert("Finish Time");

                                Shell.Current.Navigation.PopAsync();
                                return(false);
                            }
                        }
                    }
                    catch
                    {
                    }

                    return(true);
                });
            }
        }
Esempio n. 2
0
        //显示结果
        private void _2Dimensional_Maps()
        {
            try
            {
                UInt64[][] _68_2Dimensional_MapsInt = new UInt64[9][];
                _68_Dimensional_Maps_toStr = new string[9][];
                UInt64[][] _69_2Dimensional_MapsInt = new UInt64[9][];
                _69_Dimensional_Maps_toStr = new string[9][];
                //////将二维数据截取出来存放在
                string[][] _68_2MapsStr = new string[9][];
                string[][] _69_2MapsStr = new string[9][];
                //初始化数组 指的是全局变量。。。。
                for (int i = 0; i < 9; i++)
                {
                    _68_2Dimensional_MapsInt[i]   = new UInt64[4];
                    _68_Dimensional_Maps_toStr[i] = new string[4];
                    _69_2Dimensional_MapsInt[i]   = new UInt64[4];;
                    _69_Dimensional_Maps_toStr[i] = new string[4];
                    _68_2MapsStr[i] = new string[4];
                    _69_2MapsStr[i] = new string[4];
                }
                string _68_2Maps = _0165_016BS[3].Replace(" ", "").PadRight(296, '0').Substring(4, 288);
                string _69_2Maps = _0165_016BS[4].Replace(" ", "").PadRight(296, '0').Substring(4, 288);
                int    x         = 0;
                for (int No1 = 0; No1 < 9; No1++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        _68_2MapsStr[No1][j] = _68_2Maps.Substring(x, 8);
                        _69_2MapsStr[No1][j] = _69_2Maps.Substring(x, 8);
                        x = x + 8;
                    }
                }
                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        string[] SplitArry1 = new string[4];
                        string[] SplitArry2 = new string[4];
                        int      k          = 0;
                        for (int r = 0; r < 4; r++)
                        {
                            SplitArry1[r] = _68_2MapsStr[i][j].Substring(k, 2);
                            SplitArry2[r] = _69_2MapsStr[i][j].Substring(k, 2);
                            k             = k + 2;
                        }
                        _68_2MapsStr[i][j] = SplitArry1[3] + SplitArry1[2] + SplitArry1[1] + SplitArry1[0];
                        _69_2MapsStr[i][j] = SplitArry2[3] + SplitArry2[2] + SplitArry2[1] + SplitArry2[0];
                    }
                }

                for (int k = 0; k < 9; k++)
                {
                    for (int h = 0; h < 4; h++)
                    {
                        _68_2Dimensional_MapsInt[k][h] = Convert.ToUInt64(_68_2MapsStr[k][h], 16);
                        _69_2Dimensional_MapsInt[k][h] = Convert.ToUInt64(_69_2MapsStr[k][h], 16);
                        UInt64 Colck1, Min1, Second1;
                        UInt64 Colck2, Min2, Second2;
                        Colck1  = _68_2Dimensional_MapsInt[k][h] / 3600;
                        Min1    = _68_2Dimensional_MapsInt[k][h] % 3600 / 60;
                        Second1 = _68_2Dimensional_MapsInt[k][h] % 3600 % 60;
                        _68_Dimensional_Maps_toStr[k][h] = Colck1.ToString() + "h" + Min1.ToString() + "min" + Second1 + "s";
                        ////
                        Colck2  = _69_2Dimensional_MapsInt[k][h] / 3600;
                        Min2    = _69_2Dimensional_MapsInt[k][h] % 3600 / 60;
                        Second2 = _69_2Dimensional_MapsInt[k][h] % 3600 % 60;
                        _69_Dimensional_Maps_toStr[k][h] = Colck2.ToString() + "h" + Min2.ToString() + "min" + Second2 + "s";
                    }
                }
            }
            catch (Exception e) {
                log.Info("2Dimensional error is  :" + e.Message);
            }
        }