Example #1
0
        //private static int ANIMATED_MILLISECONDS_DURATION = 0;

        //private static Logger _logger = LogManager.GetCurrentClassLogger();
        /// <summary>
        /// Save current <see cref="WindowState.Normal"/> state of <see cref="MdiWindow"/>
        /// </summary>
        /// <param name="window"></param>
        private static void SavePreviousPosition(this MdiWindow window)
        {
            window.PreviousLeft   = Canvas.GetLeft(window);
            window.PreviousTop    = Canvas.GetTop(window);
            window.PreviousWidth  = window.ActualWidth;
            window.PreviousHeight = window.ActualHeight;
        }
Example #2
0
        internal static bool HasSnapshot(this MdiWindow window)
        {
            string filename = GetSnapshotfilename(window.Uid);

            return(File.Exists(filename) &&
                   ((new FileInfo(filename)).Length / 1024) > 5);
        }
Example #3
0
        internal static void DeleteSnapshot(this MdiWindow window)
        {
            string filename = GetSnapshotfilename(window.Uid);

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
        }
        public static void Normalize(this MdiWindow window)
        {
            Canvas.SetTop(window, window.LastTop);
            Canvas.SetLeft(window, window.LastLeft);

            AnimateResize(window, window.LastWidth, window.LastHeight, false);

            window.WindowState = WindowState.Normal;
        }
Example #5
0
        internal ImageSource GetSnapshot(MdiWindow window)
        {
            if (window == null)
            {
                throw new ArgumentNullException("GetSnapshot has null window");
            }
            var snapSource = LoadSnapshot(window.Uid) ?? CreateSnapshot(window);

            return(snapSource);
        }
Example #6
0
 public static void ToggleMaximize(this MdiWindow window)
 {
     if (window.WindowState == WindowState.Maximized)
     {
         window.Normalize();
     }
     else
     {
         window.Maximize();
     }
 }
        public static void Maximize(this MdiWindow window)
        {
            if (window.IsResizable)
            {
                Canvas.SetTop(window, 0.0);
                Canvas.SetLeft(window, 0.0);

                AnimateResize(window, window.Container.ActualWidth - 4, window.Container.ActualHeight - 4, true);

                window.WindowState = WindowState.Maximized;
            }
        }
Example #8
0
        /// <summary>
        ///     Execute handler for the MdiCommands.CloseWindow command.
        /// </summary>
        /// <remarks>
        ///     The command is only enabled if the MdiWindow instance is one
        ///     of the containers generated for one of the MdiDemoContent
        ///     instances in Worspace.Content.  When the command is executed,
        ///     the item is removed from the Workspace.Content collection.
        /// </remarks>
        private void CloseWindow_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            MdiWindow window = MainMdiView.ContainerFromElement((DependencyObject)e.OriginalSource);

            if (window != null)
            {
                MdiDemoContent item = MainMdiView.ItemContainerGenerator.ItemFromContainer(window) as MdiDemoContent;
                if (item != null && Workspace.Content.Contains(item))
                {
                    Workspace.Content.Remove(item);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Set WindowState of <see cref="MdiWindow"/> Normal state
        /// </summary>
        /// <param name="window"></param>
        public static void Normalize(this MdiWindow window)
        {
            //_logger.Trace($"Normalize: '{window.Title} go to Normalize from {window.WindowState}");
            if (window.WindowState == WindowState.Maximized)
            {
                window.LoadPreviousPosition();
            }

            //window.DeleteSnapshot();
            Panel.SetZIndex(window, 0);
            //window.PreviousWindowState = window.WindowState;
            window.WindowState = WindowState.Normal;
            window.DoFocus(null);
        }
      private static void AnimateResize(MdiWindow window, double newWidth, double newHeight, bool lockWindow)
      {
         window.LayoutTransform = new ScaleTransform();
       
         var widthAnimation = new DoubleAnimation(window.ActualWidth, newWidth, new Duration(TimeSpan.FromMilliseconds(10)));         
         var heightAnimation = new DoubleAnimation(window.ActualHeight, newHeight, new Duration(TimeSpan.FromMilliseconds(10)));

         if (lockWindow == false)
         {
            widthAnimation.Completed += (s, e) => window.BeginAnimation(FrameworkElement.WidthProperty, null);
            heightAnimation.Completed += (s, e) => window.BeginAnimation(FrameworkElement.HeightProperty, null);
         }

         window.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation, HandoffBehavior.Compose);
         window.BeginAnimation(FrameworkElement.HeightProperty, heightAnimation, HandoffBehavior.Compose);
      }
        private static void AnimateResize(MdiWindow window, double newWidth, double newHeight, bool lockWindow)
        {
            window.LayoutTransform = new ScaleTransform();

            var widthAnimation  = new DoubleAnimation(window.ActualWidth, newWidth, new Duration(TimeSpan.FromMilliseconds(10)));
            var heightAnimation = new DoubleAnimation(window.ActualHeight, newHeight, new Duration(TimeSpan.FromMilliseconds(10)));

            if (lockWindow == false)
            {
                widthAnimation.Completed  += (s, e) => window.BeginAnimation(FrameworkElement.WidthProperty, null);
                heightAnimation.Completed += (s, e) => window.BeginAnimation(FrameworkElement.HeightProperty, null);
            }

            window.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation, HandoffBehavior.Compose);
            window.BeginAnimation(FrameworkElement.HeightProperty, heightAnimation, HandoffBehavior.Compose);
        }
        public static void Minimize(this MdiWindow window)
        {
            var index = window.Container.MinimizedWindowsCount;

            window.LastWidth  = window.ActualWidth;
            window.LastHeight = window.ActualHeight;
            Canvas.SetTop(window, window.Container.ActualHeight - 32);
            Canvas.SetLeft(window, index * 205);

            RemoveWindowLock(window);
            AnimateResize(window, 200, 32, true);

            window.WindowState = WindowState.Minimized;

            window.Tumblr.Source = window.CreateSnapshot();
        }
Example #13
0
        public static RenderTargetBitmap CreateSnapshot(this MdiWindow window)
        {
            var bitmap        = new RenderTargetBitmap((int)Math.Round(window.ActualWidth), (int)Math.Round(window.ActualHeight), 96, 96, PixelFormats.Default);
            var drawingVisual = new DrawingVisual();

            using (var context = drawingVisual.RenderOpen())
            {
                var brush = new VisualBrush(window);
                context.DrawRectangle(brush, null, new Rect(new Point(), new Size(window.ActualWidth, window.ActualHeight)));
                context.Close();
            }

            bitmap.Render(drawingVisual);

            return(bitmap);
        }
Example #14
0
        public GridWindowCmd(IWindowManager windowManager)
        {
            base.Key = _baseKey;

            _uiUserControl = new UIUserControl();
            _uiUserControl._reoGridHost.Saved += _reoGridHost_Saved;
            _mdiWindow = windowManager.CreateMdiWindow(_windowKey, _windowTitle, _uiUserControl);

            _mdiWindow.Closing += _mdiWindow_Closing;

            this.ExecuteOnCheckedChange = false;

            _mdiWindow.Form.TopMost = false;

            //Console.WriteLine("MdiWindowCmd created for Gridx");
        }
Example #15
0
        /// <summary>
        /// Set WindowState of <see cref="MdiWindow"/> Maximized state
        /// </summary>
        /// <param name="window"></param>
        public static void Maximize(this MdiWindow window)
        {
            if (window.IsResizable)
            {
                if (window.WindowState == WindowState.Normal)
                {
                    window.SavePreviousPosition();
                }

                Canvas.SetTop(window, 0.0);
                Canvas.SetLeft(window, 0.0);
                AnimateResize(window, window.Container.ActualWidth - 4, window.Container.ActualHeight - 4, true);
                Panel.SetZIndex(window, 10);

                window.PreviousWindowState = window.WindowState;
                window.WindowState         = WindowState.Maximized;
            }
        }
Example #16
0
        internal static RenderTargetBitmap CreateSnapshot(this MdiWindow window)
        {
            double width     = window.ActualWidth > 0 ? window.ActualWidth : window.Width;
            double height    = window.ActualHeight > 0 ? window.ActualHeight : window.Height;
            int    widthInt  = (int)Math.Round(width);
            int    heightInt = (int)Math.Round(height);

            var bitmap        = new RenderTargetBitmap(widthInt, heightInt, 96, 96, PixelFormats.Pbgra32);
            var drawingVisual = new DrawingVisual();

            using (var context = drawingVisual.RenderOpen())
            {
                var brush = new VisualBrush(window);
                context.DrawRectangle(brush, null, new Rect(new Point(), new Size(width, height)));
                context.Close();
            }
            bitmap.Render(drawingVisual);

            SaveSnapshot(bitmap, window.Uid);
            return(bitmap);
        }
Example #17
0
        public static void ToggleMinimize(this MdiWindow window)
        {
            if (window.WindowState != WindowState.Minimized)
            {
                window.Minimize();
            }
            else
            {
                switch (window.PreviousWindowState)
                {
                case WindowState.Maximized:
                    window.Maximize();
                    break;

                case WindowState.Normal:
                    window.Normalize();
                    break;

                default:
                    throw new NotSupportedException("Invalid WindowState");
                }
            }
        }
Example #18
0
 internal static void AnimateResize(MdiWindow window, double newWidth, double newHeight, bool lockWindow)
 {
     window.LayoutTransform = new ScaleTransform();
     window.Height          = newHeight;
     window.Width           = newWidth;
 }
Example #19
0
 /// <summary>
 /// Set WindowState of <see cref="MdiWindow"/> Minimized state
 /// </summary>
 /// <param name="window"></param>
 public static void Minimize(this MdiWindow window)
 {
     window.WindowState = WindowState.Minimized;
 }
Example #20
0
 internal bool HasSnapshot(MdiWindow window)
 {
     return(File.Exists(GetSnapshotfilename(window.Uid)));
 }
Example #21
0
 /// <summary>
 /// Load previous <see cref="WindowState.Normal"/> state of <see cref="MdiWindow"/>
 /// </summary>
 /// <param name="window"></param>
 private static void LoadPreviousPosition(this MdiWindow window)
 {
     Canvas.SetLeft(window, window.PreviousLeft);
     Canvas.SetTop(window, window.PreviousTop);
     AnimateResize(window, window.PreviousWidth, window.PreviousHeight, false);
 }
Example #22
0
 public static void RemoveWindowLock(this MdiWindow window)
 {
     window.BeginAnimation(FrameworkElement.WidthProperty, null);
     window.BeginAnimation(FrameworkElement.HeightProperty, null);
 }