コード例 #1
0
        private void Button_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(sender is Button button))
            {
                return;
            }

            if ((bool)e.NewValue == true)
            {
                button.Effect = ControlsFactory.CreateDropShadowEffect();

                if (button == ButtonContinue)
                {
                    button.Foreground = BindingValues.Instance.BrushTextTitleForeground;
                }
                else
                {
                    button.Foreground = BindingValues.Instance.BrushTextForeground;
                }
            }
            else
            {
                button.Effect     = null;
                button.Foreground = BindingValues.Instance.BrushTextDisabledForeground;
            }
        }
        private void DrawPatients()
        {
            int row = 0;

            foreach (ItemPatient patient in patients)
            {
                if (row > 1)
                {
                    GridMultiplePatientsInner.RowDefinitions.Add(new RowDefinition());
                }

                Grid grid = new Grid {
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };

                grid.RowDefinitions.Add(new RowDefinition());
                grid.RowDefinitions.Add(new RowDefinition());

                ColumnDefinition col0 = new ColumnDefinition {
                    Width = new GridLength(90, GridUnitType.Star)
                };
                grid.ColumnDefinitions.Add(col0);

                ColumnDefinition col1 = new ColumnDefinition {
                    Width = new GridLength(10, GridUnitType.Star)
                };
                grid.ColumnDefinitions.Add(col1);

                string textTop    = patient.Name;
                string textBottom = "дата рождения: " + patient.Birthday.ToLongDateString();

                TextBlock textBlockTop = ControlsFactory.CreateTextBlock(textTop);
                textBlockTop.Foreground = BindingValues.Instance.BrushTextForeground;
                textBlockTop.Margin     = new Thickness(20, 0, 0, 0);

                TextBlock textBlockBottom = ControlsFactory.CreateTextBlock(textBottom);
                textBlockBottom.Foreground = BindingValues.Instance.BrushTextDisabledForeground;
                textBlockBottom.Margin     = new Thickness(20, 0, 0, 0);
                Grid.SetRow(textBlockBottom, 1);

                Image image = ControlsFactory.CreateImage(
                    ControlsFactory.ImageType.NotificationOk,
                    horizontalAlignment: HorizontalAlignment.Right,
                    margin: new Thickness(20));

                Grid.SetColumn(image, 1);
                Grid.SetRowSpan(image, 2);
                image.Visibility = Visibility.Hidden;

                grid.Children.Add(textBlockTop);
                grid.Children.Add(textBlockBottom);
                grid.Children.Add(image);

                Button button = new Button {
                    Tag     = patient,
                    Style   = BindingValues.Instance.StyleRoundCornerStretch,
                    Content = grid,
                    Margin  = new Thickness(20)
                };

                button.Effect = ControlsFactory.CreateDropShadowEffect();
                button.Click += ButtonPatient_Click;

                Grid.SetRow(button, row);
                GridMultiplePatientsInner.Children.Add(button);

                button.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                patient.CheckStateImage           = image;

                row++;
            }
        }