Example #1
0
        public override HResult Initialize()
        {
            try
            {
                var hr = base.Initialize();

                if (ErrorUtil.Failure(hr))
                {
                    return(hr);
                }

                ErrorUtil.ThrowOnFailure(Frame.SetCaption(Labels.Notifications));

                _control = new NotificationsControl
                {
                    Site = new SiteProxy(this),
                    Dock = DockStyle.Fill
                };

                Controls.Add(_control);

                return(HResult.OK);
            }
            catch (Exception ex)
            {
                return(ErrorUtil.GetHResult(ex));
            }
        }
Example #2
0
        public override HResult Initialize()
        {
            try
            {
                var hr = base.Initialize();

                if (ErrorUtil.Failure(hr))
                    return hr;

                ErrorUtil.ThrowOnFailure(Frame.SetCaption(Labels.Notifications));

                _control = new NotificationsControl
                {
                    Site = new SiteProxy(this),
                    Dock = DockStyle.Fill
                };

                Controls.Add(_control);

                return HResult.OK;
            }
            catch (Exception ex)
            {
                return ErrorUtil.GetHResult(ex);
            }
        }
            public Item(NotificationsControl control, NotificationItem item)
            {
                _control = control;
                _item    = item;

                BorderThickness = new Thickness(4, 0, 0, 0);
                Background      = Brush.Transparent;
                Padding         = new Thickness(5);
                Cursor          = Cursor.Hand;

                switch (item.Priority)
                {
                case NiNotificationItemPriority.Informational:
                    BorderBrush = new SolidBrush((GdiPresentation.Color)WarningColor);
                    break;

                case NiNotificationItemPriority.Critical:
                    BorderBrush = new SolidBrush((GdiPresentation.Color)ErrorColor);
                    break;

                default:
                    BorderBrush = Brush.Transparent;
                    break;
                }

                var grid = new Grid
                {
                    ColumnDefinitions =
                    {
                        new ColumnDefinition(new GridLength(GridUnitType.Star, 1)),
                        new ColumnDefinition(GridLength.Auto)
                    },
                    RowDefinitions =
                    {
                        new RowDefinition(GridLength.Auto)
                    }
                };

                Content = grid;

                var information = new StackPanel
                {
                    Orientation = Orientation.Vertical
                };

                grid.Children.Add(information);

                _subject = new TextBlock
                {
                    FontStyle    = FontStyle.Bold,
                    TextTrimming = TextTrimming.CharacterEllipsis
                };
                information.Children.Add(_subject);

                _message = new TextBlock
                {
                    Wrap = true
                };
                Grid.SetRow(_message, 1);
                information.Children.Add(_message);

                _created = new TextBlock
                {
                    ForeColor    = (GdiPresentation.Color)SystemColors.GrayText,
                    TextTrimming = TextTrimming.CharacterEllipsis,
                    Margin       = new Thickness(0, 2, 0, 0)
                };
                Grid.SetColumnSpan(_created, 2);
                Grid.SetRow(_created, 2);
                information.Children.Add(_created);

                _close = new GdiPresentation.Image
                {
                    Margin            = new Thickness(3),
                    Bitmap            = NotificationClose,
                    Cursor            = Cursor.Arrow,
                    Visibility        = Visibility.Hidden,
                    Background        = Brush.Transparent,
                    VerticalAlignment = VerticalAlignment.Top
                };
                _close.MouseUp += _close_MouseUp;
                Grid.SetColumn(_close, 1);
                grid.Children.Add(_close);

                UpdateFromItem();
            }