public PendingBoxWindow(Window owner, bool interopOwnersMask, Rect?ownerRect, string message, string caption, bool canCancel, string windowStyle, string cancelButtonStyle, string spinnerStyle, string contentTemplate, object cancelButtonContent, PendingHandlerImpl handler)
        {
            _captionText = caption;
            _messageText = message;
            _canCancel   = canCancel;

            _cancelButtonContent = cancelButtonContent;

            _handler = handler;
            _handler.SetWindow(this);


            Style              = XamlUtil.FromXaml <Style>(windowStyle);
            ContentTemplate    = XamlUtil.FromXaml <DataTemplate>(contentTemplate);
            _cancelButtonStyle = XamlUtil.FromXaml <Style>(cancelButtonStyle);
            _spinnerStyle      = XamlUtil.FromXaml <Style>(spinnerStyle);

            if (ownerRect == null)
            {
                WindowStartupLocation = owner == null
                  ? WindowStartupLocation.CenterScreen
                  : WindowStartupLocation.CenterOwner;
            }

            if (ownerRect == null)
            {
                Owner = owner;
            }
            else
            {
                _ownerRect = ownerRect;
                Topmost    = true;
            }
            if (owner is WindowX ownerX && interopOwnersMask)
            {
                ownerX.Dispatcher.BeginInvoke(new Action(() =>
                {
                    ownerX.IsMaskVisible = true;
                }));
                _owner = ownerX;
            }
            Loaded += PendingBoxWindow_Loaded;
        }
示例#2
0
 public INoticeHandler AddItem(string message, string caption, MessageBoxIcon icon, ImageSource imageIcon, int?duration, bool canClose, TimeSpan animationDuration, string noticeBoxItemStyle)
 {
     return((INoticeHandler)Dispatcher.Invoke(new Func <INoticeHandler>(() =>
     {
         var noticeBoxItem = new NoticeBoxItem(animationDuration, duration)
         {
             Style = XamlUtil.FromXaml <Style>(noticeBoxItemStyle),
             Caption = caption,
             Message = message,
             Icon = icon,
             ImageIcon = imageIcon,
             CanClose = canClose,
         };
         noticeBoxItem.Closed += NoticeBoxItem_Closed;
         noticeBoxItem.Click += NoticeBoxItem_Click;
         _noticeHandler = new NoticeHandlerImpl(noticeBoxItem);
         _astkItems.Children.Add(noticeBoxItem);
         return _noticeHandler;
     })));
 }