Ejemplo n.º 1
0
        private void ThirdTabAlarmSettings(TabItem item)
        {
            item.Header = "Alarm Settings";
            StackPanel sp = new StackPanel();

            sp.Background = Brushes.Transparent;



            Grid g = new Grid();

            g.Background = Brushes.Transparent;
            RowDefinition rdef1 = new RowDefinition();
            RowDefinition rdef2 = new RowDefinition();
            RowDefinition rdef3 = new RowDefinition();

            g.RowDefinitions.Add(rdef1);
            g.RowDefinitions.Add(rdef2);
            g.RowDefinitions.Add(rdef3);

            ColumnDefinition cd1 = new ColumnDefinition();
            GridLength       gdl = new GridLength(300);

            cd1.Width = gdl;
            ColumnDefinition cd2 = new ColumnDefinition();

            g.ColumnDefinitions.Add(cd1);
            g.ColumnDefinitions.Add(cd2);


            Label l1 = new Label();

            l1.Background = sp.Background;
            l1.Content    = "Date (mm/dd/yyyy)";


            TextBox date = new TextBox();

            date.Text = "/2006";
            date.Name = "date";
            //if (Alarm.CompareTo(DateTime.Now) >= 0)
            //{
            //    date.Text = Alarm.Date.ToShortDateString();
            //}

            if (AlarmRepetition.Contains("null"))
            {
                if ((Alarm.CompareTo(DateTime.Now) >= 0) || (((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) < 8) &&
                                                             ((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) >= 0)))
                {
                    date.Text = Alarm.Date.ToShortDateString();
                }
            }
            else
            {
                date.Text = Alarm.Date.ToShortDateString();
            }


            Grid.SetRow(l1, 0);
            Grid.SetColumn(l1, 0);
            Grid.SetRow(date, 0);
            Grid.SetColumn(date, 1);


            Label l2 = new Label();

            l2.Background = sp.Background;
            l2.Content    = "Time (hr:min:sec)";

            TextBox time = new TextBox();

            time.Text = "00:00:00";
            time.Name = "time";

            if (AlarmRepetition.Contains("null"))
            {
                if ((Alarm.CompareTo(DateTime.Now) >= 0) || (((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) < 8) &&
                                                             ((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) >= 0)))
                {
                    time.Text = Alarm.TimeOfDay.ToString();
                }
            }
            else
            {
                time.Text = Alarm.TimeOfDay.ToString();
            }



            Grid.SetRow(l2, 1);
            Grid.SetColumn(l2, 0);
            Grid.SetRow(time, 1);
            Grid.SetColumn(time, 1);



            g.Children.Add(l1);
            g.Children.Add(date);
            g.Children.Add(l2);
            g.Children.Add(time);

            Label l3 = new Label();

            l3.Background = sp.Background;
            l3.Content    = "Repeat Every:";

            TextBox repeatNumber = new TextBox();

            repeatNumber.Text         = "0";
            repeatNumber.Name         = "repeat";
            repeatNumber.MaxLength    = 3;
            repeatNumber.TextChanged += new TextChangedEventHandler(repeatNumber_TextChanged);
            if (alarmRepetition.Contains("null") == false)
            {
                repeatNumber.Text = alarmRepetition.Substring(1);
            }

            Label space = new Label();

            space.Background = sp.Background;
            space.Content    = " ";

            CheckBox daysCheck = new CheckBox();

            daysCheck.IsChecked         = false;
            daysCheck.VerticalAlignment = VerticalAlignment.Center;
            daysCheck.Name     = "daysCheck";
            daysCheck.Checked += new RoutedEventHandler(daysCheck_Checked);


            Label l4 = new Label();

            l4.Background = sp.Background;
            l4.Content    = "Day(s)";

            Label space1 = new Label();

            space.Background = sp.Background;
            space.Content    = " ";

            CheckBox weeksCheck = new CheckBox();

            weeksCheck.IsChecked         = false;
            weeksCheck.VerticalAlignment = VerticalAlignment.Center;
            weeksCheck.Name     = "weeksCheck";
            weeksCheck.Checked += new RoutedEventHandler(weeksCheck_Checked);
            try
            {
                if (alarmRepetition.Contains("null") == false)
                {
                    char[] charr = alarmRepetition.ToCharArray(0, 1);
                    switch (charr[0])
                    {
                    case 'D':
                        daysCheck.IsChecked = true;
                        break;

                    case 'W':
                        weeksCheck.IsChecked = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception) { }
            Label l5 = new Label();

            l5.Background = sp.Background;
            l5.Content    = "Week(s)";

            WrapPanel wp = new WrapPanel();

            wp.Children.Add(l3);
            wp.Children.Add(repeatNumber);
            wp.Children.Add(space);
            wp.Children.Add(daysCheck);
            wp.Children.Add(l4);
            wp.Children.Add(space1);
            wp.Children.Add(weeksCheck);
            wp.Children.Add(l5);



            Label status = new Label();

            status.Background = sp.Background;
            status.Name       = "statusThirdTab";

            sp.Children.Add(g);
            sp.Children.Add(wp);
            sp.Children.Add(status);

            item.Content = sp;
        }
Ejemplo n.º 2
0
        private void ThirdTabAlarmSettings(TabItem item)
        {
            item.Header = "Alarm Settings";
            var sp = new StackPanel {
                Background = Brushes.Transparent
            };


            var g = new Grid {
                Background = Brushes.Transparent
            };
            var rdef1 = new RowDefinition();
            var rdef2 = new RowDefinition();
            var rdef3 = new RowDefinition();

            g.RowDefinitions.Add(rdef1);
            g.RowDefinitions.Add(rdef2);
            g.RowDefinitions.Add(rdef3);

            var cd1 = new ColumnDefinition();
            var gdl = new GridLength(300);

            cd1.Width = gdl;
            var cd2 = new ColumnDefinition();

            g.ColumnDefinitions.Add(cd1);
            g.ColumnDefinitions.Add(cd2);


            var l1 = new Label
            {
                Background = sp.Background,
                Content    = "Date (mm/dd/yyyy)"
            };


            var date = new TextBox
            {
                Text = "/2006",
                Name = "date"
            };

            //if (Alarm.CompareTo(DateTime.Now) >= 0)
            //{
            //    date.Text = Alarm.Date.ToShortDateString();
            //}

            if (AlarmRepetition.Contains("null"))
            {
                if ((Alarm.CompareTo(DateTime.Now) >= 0) ||
                    (((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) < 8) &&
                     ((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) >= 0)))
                {
                    date.Text = Alarm.Date.ToShortDateString();
                }
            }
            else
            {
                date.Text = Alarm.Date.ToShortDateString();
            }


            Grid.SetRow(l1, 0);
            Grid.SetColumn(l1, 0);
            Grid.SetRow(date, 0);
            Grid.SetColumn(date, 1);


            var l2 = new Label
            {
                Background = sp.Background,
                Content    = "Time (hr:min:sec)"
            };

            var time = new TextBox
            {
                Text = "00:00:00",
                Name = "time"
            };

            if (AlarmRepetition.Contains("null"))
            {
                if ((Alarm.CompareTo(DateTime.Now) >= 0) ||
                    (((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) < 8) &&
                     ((DateTime.Now.TimeOfDay.Hours - Alarm.TimeOfDay.Hours) >= 0)))
                {
                    time.Text = Alarm.TimeOfDay.ToString();
                }
            }
            else
            {
                time.Text = Alarm.TimeOfDay.ToString();
            }


            Grid.SetRow(l2, 1);
            Grid.SetColumn(l2, 0);
            Grid.SetRow(time, 1);
            Grid.SetColumn(time, 1);


            g.Children.Add(l1);
            g.Children.Add(date);
            g.Children.Add(l2);
            g.Children.Add(time);

            var l3 = new Label
            {
                Background = sp.Background,
                Content    = "Repeat Every:"
            };

            var repeatNumber = new TextBox
            {
                Text      = "0",
                Name      = "repeat",
                MaxLength = 3
            };

            repeatNumber.TextChanged += repeatNumber_TextChanged;
            if (AlarmRepetition.Contains("null") == false)
            {
                repeatNumber.Text = AlarmRepetition.Substring(1);
            }

            var space = new Label
            {
                Background = sp.Background,
                Content    = " "
            };

            var daysCheck = new CheckBox
            {
                IsChecked         = false,
                VerticalAlignment = VerticalAlignment.Center,
                Name = "daysCheck"
            };

            daysCheck.Checked += daysCheck_Checked;


            var l4 = new Label
            {
                Background = sp.Background,
                Content    = "Day(s)"
            };

            var space1 = new Label();

            space.Background = sp.Background;
            space.Content    = " ";

            var weeksCheck = new CheckBox
            {
                IsChecked         = false,
                VerticalAlignment = VerticalAlignment.Center,
                Name = "weeksCheck"
            };

            weeksCheck.Checked += weeksCheck_Checked;
            try
            {
                if (AlarmRepetition.Contains("null") == false)
                {
                    var charr = AlarmRepetition.ToCharArray(0, 1);
                    switch (charr[0])
                    {
                    case 'D':
                        daysCheck.IsChecked = true;
                        break;

                    case 'W':
                        weeksCheck.IsChecked = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }
            var l5 = new Label
            {
                Background = sp.Background,
                Content    = "Week(s)"
            };

            var wp = new WrapPanel();

            wp.Children.Add(l3);
            wp.Children.Add(repeatNumber);
            wp.Children.Add(space);
            wp.Children.Add(daysCheck);
            wp.Children.Add(l4);
            wp.Children.Add(space1);
            wp.Children.Add(weeksCheck);
            wp.Children.Add(l5);


            var status = new Label
            {
                Background = sp.Background,
                Name       = "statusThirdTab"
            };

            sp.Children.Add(g);
            sp.Children.Add(wp);
            sp.Children.Add(status);

            item.Content = sp;
        }