public CMessageBox(string message, string caption, CColor.Theme theme, CImage.ImageType image, CMessageBoxButton _buttonType) { InitializeComponent(); this.SizeToContent = SizeToContent.Height; SystemSounds.Beep.Play(); //set image string imagePath = CImage.GetImagePath(image); ImageBrush imgBrush = new ImageBrush { ImageSource = new BitmapImage(new Uri(imagePath, UriKind.Absolute)) }; RCT_image.Fill = imgBrush; //set text / caption TBL_message.Text = message; windowheader.C_HeaderText = caption; //set theme in border and header background GRD_border.Background = CColor.GetColorBrush(theme); windowheader.C_BackgroundTheme = theme; //enable button by given buttontype buttonType = _buttonType; switch (buttonType) { case CMessageBoxButton.OK: B_3.Visibility = Visibility.Hidden; B_2.Visibility = Visibility.Hidden; B_1.Content = "OK"; break; case CMessageBoxButton.OK_Cancel: B_3.Visibility = Visibility.Hidden; B_2.Content = "OK"; B_1.Content = "Abbrechen"; break; case CMessageBoxButton.Yes_No: B_3.Visibility = Visibility.Hidden; B_2.Content = "Ja"; B_1.Content = "Nein"; break; case CMessageBoxButton.Yes_No_Cancel: B_3.Content = "Ja"; B_2.Content = "Nein"; B_1.Content = "Abbrechen"; break; default: break; } B_1.Focus(); }
public static void OnIsEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { if (sender is CIconTextHorizontalButton control) { control.UpdateIsEnabled(); } if (!(args.NewValue as bool?).Value) { (sender as CIconTextHorizontalButton).Background = CColor.GetColorBrush(CColor.Theme.Disabled); } }