Beispiel #1
0
        private void set_TextBox_RemainingTime(Fertilize_Pump pump, TextBox textBox)
        {
            if (Time_Service.isTimeSet)
            {
                Fertilize_Job job        = pump.Get_Nearest_Fertilize_Job();
                DateTime      actualTime = new DateTime(0).AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute);

                if (job != null)
                {
                    if (actualTime < job.StartTime)
                    {
                        TimeSpan remainingTimeToStart = job.StartTime - actualTime;
                        textBox.Text = remainingTimeToStart.Hours.ToString("D2") + ":" + remainingTimeToStart.Minutes.ToString("D2");
                    }
                    else
                    {
                        DateTime remainingTimeToStart = job.StartTime + (new DateTime(0).AddHours(24) - actualTime);
                        textBox.Text = remainingTimeToStart.Hour.ToString("D2") + ":" + remainingTimeToStart.Minute.ToString("D2");
                    }
                }
                else
                {
                    textBox.Text = "--:--";
                }
            }
            else
            {
                textBox.Text = "--:--";
            }

            textBox.Invalidate();
        }
Beispiel #2
0
        void set_TextBox_NextFertilizeJob(Fertilize_Pump pump, TextBox textBox)
        {
            string        nextStartTime = "--:--";
            Fertilize_Job job           = pump.Get_Nearest_Fertilize_Job();

            if (job != null)
            {
                nextStartTime = job.StartTime.Hour.ToString("D2") + ":" + job.StartTime.Minute.ToString("D2");
            }

            textBox.Text = nextStartTime;
        }