/// <summary>
        /// 
        /// </summary>
        /// <param name="mainWindow">Window on which the notification will be opened</param>
        /// <param name="timeOpened">time(ms) before the notification is closed (0 means no automatic close)</param>
        /// <param name="contentTemplate">Template to display</param>
        /// <param name="notificationWindows"></param>
        /// <param name="text"></param>
        public NotificationWindow(Window mainWindow, int timeOpened, DataTemplate contentTemplate, IEnumerable<NotificationWindow> notificationWindows, string text = null)
        {
            InitializeComponent();

            if (null != contentTemplate)
            {
                Control.ContentTemplate = contentTemplate;
            }

            if (null != text)
            {
                Control.Content = text;
            }

            _timer = new Timer(timeOpened);
            _timer.Elapsed += timer_Elapsed;
            Loaded += NotificationWindow_Loaded;

            if (mainWindow != null)
            {
                var point = mainWindow.PointToScreen(new Point(0, 0));
                point.Offset(mainWindow.ActualWidth - 23, mainWindow.ActualHeight - 50);

                this.Left = point.X;
                this.Top = point.Y;
            }

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
            {
                Visibility = Visibility.Visible;


                if (mainWindow != null)
                {

                    var point = mainWindow.PointToScreen(new Point(0, 0));
                    point.Offset(mainWindow.ActualWidth - 23, mainWindow.ActualHeight - 50);

                    this.Left = point.X - this.ActualWidth;
                    this.Top = point.Y - this.ActualHeight;
                }

                foreach (var notificationWindow in notificationWindows)
                {
                    if (notificationWindow != this)
                    {
                        notificationWindow.Top -= this.ActualHeight + 5;
                    }
                }
            }));
        }
Example #2
0
        private static Point calculateStartup(FrameworkElement content, Window owner)
        {
            int top = Math.Floor(owner.Height/4).Zeroed();
            double left = Math.Floor(owner.Width/2) - content.Width.Zeroed();

            var relative = new Point(top, left);
            return owner.PointToScreen(relative);
        }
Example #3
0
        /// <summary>
        /// AnimatedImageControl constructor
        /// </summary>
        /// <param name="pWindow">Window</param>
        /// <param name="pBitmap">Bitmap</param>
        /// <param name="pBrush">Brush</param>
        public AnimatedImageControl(Window pWindow, Bitmap pBitmap, Brush pBrush)
        {
            mAnimatedImage = pBitmap;
            mHwnd = PresentationSource.FromVisual(pWindow) as HwndSource;
            mBrush = pBrush;
            Width = pBitmap.Width;
            Height = pBitmap.Height;
            mPoint = pWindow.PointToScreen(new Point(0, 0));

            ImageAnimator.Animate(mAnimatedImage, OnFrameChanged);

            Loaded += AnimatedImageControl_Loaded;
        }
Example #4
0
        public Lookup(TextBox parent, Window owner)
            : this()
        {
            _parent = parent;
            Owner = owner;

            var relative = new Point(0, parent.ActualHeight);
            Point desiredLocation = owner.TranslatePoint(relative, parent);

            Point point = Owner.PointToScreen(desiredLocation);

            Top = point.Y;
            Left = point.X;

            Show();
        }
Example #5
0
        private Point ConfigureNewHostSizeAndGetDragStartWindowOffset(Window currentWindow, INewTabHost<Window> newTabHost, DragablzItem dragablzItem)
        {
            var layout = this.VisualTreeAncestory().OfType<Layout>().FirstOrDefault();
            Point dragStartWindowOffset;
            if (layout != null)
            {
                newTabHost.Container.Width = ActualWidth + Math.Max(0, currentWindow.RestoreBounds.Width - layout.ActualWidth);
                newTabHost.Container.Height = ActualHeight + Math.Max(0, currentWindow.RestoreBounds.Height - layout.ActualHeight);
                dragStartWindowOffset = dragablzItem.TranslatePoint(new Point(), this);
                //dragStartWindowOffset.Offset(currentWindow.RestoreBounds.Width - layout.ActualWidth, currentWindow.RestoreBounds.Height - layout.ActualHeight);
            }
            else
            {
                if (newTabHost.Container.GetType() == currentWindow.GetType())
                {
                    newTabHost.Container.Width = currentWindow.RestoreBounds.Width;
                    newTabHost.Container.Height = currentWindow.RestoreBounds.Height;
                    dragStartWindowOffset = dragablzItem.TranslatePoint(new Point(), currentWindow);
                }
                else
                {
                    newTabHost.Container.Width = ActualWidth;
                    newTabHost.Container.Height = ActualHeight;
                    dragStartWindowOffset = dragablzItem.TranslatePoint(new Point(), this);
                    dragStartWindowOffset.Offset(dragablzItem.MouseAtDragStart.X, dragablzItem.MouseAtDragStart.Y);
                    return dragStartWindowOffset;
                }
            }

            dragStartWindowOffset.Offset(dragablzItem.MouseAtDragStart.X, dragablzItem.MouseAtDragStart.Y);
            var borderVector = currentWindow.WindowState == WindowState.Maximized
                ? currentWindow.PointToScreen(new Point()).ToWpf() - new Point()
                : currentWindow.PointToScreen(new Point()).ToWpf() - new Point(currentWindow.Left, currentWindow.Top);
            dragStartWindowOffset.Offset(borderVector.X, borderVector.Y);
            return dragStartWindowOffset;
        }
 /// <summary>
 /// Shows the system menu at the current mouse position.
 /// </summary>
 /// <param name="window">The window for which the system menu should be shown.</param>
 /// <param name="e">The mouse event args.</param>
 public static void ShowSystemMenuPhysicalCoordinates(Window window, MouseButtonEventArgs e)
 {
     var mousePosition = e.GetPosition(window);
     var physicalScreenLocation = window.PointToScreen(mousePosition);
     ShowSystemMenuPhysicalCoordinates(window, e, physicalScreenLocation);
 }