Ejemplo n.º 1
0
        public ValueChange(Int32 NumberOfChild, params string[] parameters)
        {
            InitializeComponent();
            datevalue         = parameters[0];
            morningvalue      = parameters[1];
            dayvalue          = parameters[2];
            eveningvalue      = parameters[3];
            nightvalue        = parameters[4];
            number            = NumberOfChild.ToString();
            this.Close.Click += (sender, RoutedEventArgs) => { this.Close(); };

            this.Changed.Click += (sender, RoutedEventArgs) =>
            {
                InfoAboutWeather Owner      = this.Owner as InfoAboutWeather;
                var   AllTextBlocks         = TreeVisualHelp.FindVisualChildren <TextBlock>(Owner.InfoAbout.InfoList).ToList();
                Int32 NumberOfTextBlockDate = 0;
                foreach (TextBlock txt in AllTextBlocks)
                {
                    NumberOfTextBlockDate++;
                    if (txt.Text == DateTime.Now.AddDays(Int32.Parse(Number)).ToString("dd MM yyyy"))
                    {
                        AllTextBlocks[NumberOfTextBlockDate + 4].Text = MorningValue;
                        AllTextBlocks[NumberOfTextBlockDate + 5].Text = DayValue;
                        AllTextBlocks[NumberOfTextBlockDate + 6].Text = EveningValue;
                        AllTextBlocks[NumberOfTextBlockDate + 7].Text = NightValue;
                        break;
                    }
                }
                this.Close();
            };

            this.Change.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) =>
            {
                this.DragMove();
            };

            this.DataContext = this;
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var           TextBlocks = TreeVisualHelp.FindVisualChildren <TextBlock>(sender as Button).ToList();
            List <string> DateList   = new List <string>();

            var AllTextBlocks = TreeVisualHelp.FindVisualChildren <TextBlock>(InfoList).ToList();

            foreach (TextBlock txt in AllTextBlocks)
            {
                if (txt.Name == "Date")
                {
                    DateList.Add(txt.Text);
                }
            }
            string Date    = TextBlocks[0].Text.ToString();
            string Morning = TextBlocks[5].Text.ToString();
            string Day     = TextBlocks[6].Text.ToString();
            string Evening = TextBlocks[7].Text.ToString();
            string Night   = TextBlocks[8].Text.ToString();

            //индекс визуального элемента, на котором произошел клик
            Int32 NumberOfChild = 0;

            foreach (string date in DateList)
            {
                NumberOfChild++;
                if (date == Date)
                {
                    break;
                }
            }

            ValueChange newWindow = new ValueChange(NumberOfChild, Date, Morning, Day, Evening, Night);

            newWindow.Owner = this;
            newWindow.ShowDialog();
        }