private void Darkener_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { NotificationsPanelDarkener darkener = (NotificationsPanelDarkener)sender; _boundNotificationButton.Toggled = false; this.HideMe(); darkener.PreviewMouseLeftButtonUp -= Darkener_PreviewMouseLeftButtonUp; }
public NotificationsPanel(double width, double height) { MainWidth = width; MainHeight = height; PanelWidth = 300; PanelHeight = MainHeight - 20; Height = MainHeight; Width = MainWidth; Canvas.SetZIndex(this, 100); Visibility = Visibility.Collapsed; #region Darkener _darkener = new NotificationsPanelDarkener() { Width = MainWidth, Height = MainHeight }; _darkener.PreviewMouseLeftButtonDown += _darkener_PreviewMouseLeftButtonDown; this.Children.Add(_darkener); #endregion #region MainNotificationCanvas _notificationsMainCanvas = new Canvas() { Width = PanelWidth, Height = PanelHeight, }; _notificationsMainCanvas.BeginInit(); Panel.SetZIndex(_notificationsMainCanvas, 101); Canvas.SetTop(_notificationsMainCanvas, 5); _notificationsMainCanvas.Effect = new DropShadowEffect { Direction = 320, ShadowDepth = 0, Opacity = 0.4, BlurRadius = 8 }; this.Children.Add(_notificationsMainCanvas); #endregion #region BlueArrow Image blueArrowImage = new Image() { Source = ImageHelper.UriToImageSource(new Uri(@"pack://application:,,,/resources/blue_arrow.png")), Width = 20, Height = 10, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, }; RenderOptions.SetBitmapScalingMode(blueArrowImage, BitmapScalingMode.HighQuality); Canvas.SetTop(blueArrowImage, 0); Canvas.SetRight(blueArrowImage, 10); _notificationsMainCanvas.Children.Add(blueArrowImage); #endregion #region NotificationInnerDock DockPanel notificationInnerDock = new DockPanel() { Width = PanelWidth, Height = PanelHeight - 10, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Background = new SolidColorBrush(ColorScheme.MenuLight) }; Canvas.SetTop(notificationInnerDock, 10); _notificationsMainCanvas.Children.Add(notificationInnerDock); #endregion #region TitlePanel StackPanel titlePanel = new StackPanel() { Height = 30, Width = width, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Stretch, Background = new SolidColorBrush(ColorScheme.GlobalBlue), Orientation = Orientation.Horizontal }; DockPanel.SetDock(titlePanel, Dock.Top); notificationInnerDock.Children.Add(titlePanel); Label titleTextBlock = new Label() { Height = 30, FontSize = 15, Margin = new Thickness(10, 0, 0, 0), Foreground = new SolidColorBrush(ColorScheme.GlobalWhite), Content = "Powiadomienia", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center }; titlePanel.Children.Add(titleTextBlock); #endregion #region NotificationsScroll ScrollViewer notificationsScroll = new ScrollViewer() { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Top, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, }; #endregion #region NotificationsStackPanel _notificationsStackPanel = new StackPanel() { Background = new SolidColorBrush(ColorScheme.MenuLight), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Vertical, }; notificationsScroll.Content = _notificationsStackPanel; notificationInnerDock.Children.Add(notificationsScroll); #endregion }
private void _darkener_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { NotificationsPanelDarkener darkener = (NotificationsPanelDarkener)sender; darkener.PreviewMouseLeftButtonUp += Darkener_PreviewMouseLeftButtonUp; }