예제 #1
0
        //Haal de tijd op
        public String getTime()
        {
            //Secondes uit de system time halen
            String seconds = DateTime.Now.Second.ToString();

            //Als de secondes maar de lengte van een heeft er een 0 voorplakken
            if (seconds.Length == 1)
            {
                seconds = "0" + seconds;
            }

            //"
            String minutes = DateTime.Now.Minute.ToString();

            if (minutes.Length == 1)
            {
                minutes = "0" + minutes;
            }
            //"
            int Hour = DateTime.Now.Hour;

            //Als de tijdnotatie een 12 uur klok is
            if (timeNotation == 12)
            {
                //Als de uur hoger dan 12 is wordt het Past Morning en anders At Morning
                if (Hour >= 12)
                {
                    tz = "PM";
                }
                else
                {
                    tz = "AM";
                }
                //Tijdzone instellen
                form.setTimeZone(tz);

                //Als het 13 uur is de tijd splitsen.
                if (Hour >= 13)
                {
                    Hour = (Hour % 12);
                }
            }
            else
            {
                //Timezone op 0 zetten, dus 24 uur notatie(default)
                form.setTimeZone("0");
            }

            //van de uren een string maken
            String SHour = Hour.ToString();

            //Controle op lengte
            if (SHour.Length == 1)
            {
                SHour = "0" + SHour;
            }

            //Alles in een string achter elkaar terug sturen.
            return(SHour + "" + minutes + "" + seconds);
        }
예제 #2
0
        public void ButtonCenterPressed()
        {
            if (mode == "setTimeNotation" && option == 0)
            {
                option = 1;
                gui.displayText("24 uur notatie?");
            }
            else if (mode == "setTimeNotation" && option > 0)
            {
                if (option == 1)
                {
                    //24
                    CommandPattern command = new CommandPattern("24", time, gui);
                }
                else
                {
                    CommandPattern command = new CommandPattern("12", time, gui);
                }

                this.resetToTime();
            }
            else if (mode == "setColor" && option == 0)
            {
                option = 2;
                gui.displayText("Red");
            }
            else if (mode == "setColor" && option > 0)
            {
                if (option == 2)
                {
                    CommandPattern command = new CommandPattern("RED", time, gui);
                }
                else if (option == 3)
                {
                    CommandPattern command = new CommandPattern("Green", time, gui);
                }
                else if (option == 1)
                {
                    CommandPattern command = new CommandPattern("Blue", time, gui);
                }

                this.resetToTime();

                option = 0;
            }
            else if (mode == "setStopwatch" && option == 0)
            {
                time.pauzeTimer();
                gui.resetDisplay();

                try
                {
                    CommandPattern com = new CommandPattern("", time, gui, orig);
                    TimeEplapsed = com.getState(orig);
                    gui.updateStopwatch(TimeEplapsed);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                gui.displayText("");
                gui.timeVisible(true);
                gui.setTimeZone("0");

                option = 1;
            }
            else if (mode == "setStopwatch" && option == 1 || option == 2)
            {
                if (option == 1)
                {
                    //start
                    option = 2;//is gestart
                    Stopwatch.Start();
                }
                else if (option == 2)
                {
                    option = 1;//is gestopt
                    Stopwatch.Stop();
                }
            }
        }