Ejemplo n.º 1
0
 void SetWindowDimensions()
 {
     try
     {
         if (WindowChrome.GetIsMiniModeActive(mainWindowChrome))
         {
             if (WindowState == WindowState.Maximized)
             {
                 WindowState = WindowState.Normal;
             }
             AnimateHeight(kMiniModeHeight);
         }
         else
         {
             AnimateHeight(iUIOptions.WindowSize.Height);
             WindowState = iUIOptions.Fullscreen ? WindowState.Maximized : WindowState.Normal;
         }
         Width = iUIOptions.WindowSize.Width;
         Top   = iUIOptions.WindowLocation.Y;
         Left  = iUIOptions.WindowLocation.X;
     }
     catch
     {
         // ignore issues in setting window dimensions
     }
 }
Ejemplo n.º 2
0
 private void KompactExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (!mainWindowChrome.IsAnimating)
     {
         WindowChrome.SetIsMiniModeActive(mainWindowChrome, !WindowChrome.GetIsMiniModeActive(mainWindowChrome));
     }
 }
Ejemplo n.º 3
0
 void Window_StateChanged(object sender, EventArgs args)
 {
     if (!WindowChrome.GetIsMiniModeActive(mainWindowChrome))
     {
         iUIOptions.Fullscreen = WindowState == WindowState.Maximized;
     }
 }
Ejemplo n.º 4
0
        private void AnimateHeight(double aNewHeight)
        {
            mainWindowChrome.IsAnimating = true;
            MinHeight = 0;
            ClearValue(Control.MaxHeightProperty);
            Storyboard      storyBoard = new Storyboard();
            DoubleAnimation animation  = new DoubleAnimation(Height, aNewHeight, new Duration(TimeSpan.FromMilliseconds(kAnimationTimeMilliseconds)), FillBehavior.Stop);

            Storyboard.SetTarget(animation, this);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Height"));
            storyBoard.Children.Add(animation);

            EventHandler handler = null;

            handler = (d, e) =>
            {
                Height = aNewHeight;
                var t = d as DispatcherTimer;
                MinHeight = WindowChrome.GetIsMiniModeActive(mainWindowChrome) ? kMiniModeHeight : kMinHeight;
                if (WindowChrome.GetIsMiniModeActive(mainWindowChrome))
                {
                    MaxHeight = kMiniModeHeight;
                }
                else
                {
                    ClearValue(Control.MaxHeightProperty);
                }
                storyBoard.Completed -= handler;
                storyBoard.Remove();
                mainWindowChrome.IsAnimating = false;
            };
            storyBoard.Completed += handler;

            storyBoard.Begin();
        }
Ejemplo n.º 5
0
        public void ToggleMiniMode(object sender, RoutedEventArgs args)
        {
            WindowChrome source = (sender as FrameworkElement).FindVisualAncestor <WindowChrome>();

            if (!source.IsAnimating)
            {
                WindowChrome.SetIsMiniModeActive(source, !WindowChrome.GetIsMiniModeActive(source));
            }
        }
Ejemplo n.º 6
0
 void mainWindowChrome_MiniModeActiveChanged(object sender, EventArgs e)
 {
     iMiniModeChanging         = true;
     iUIOptions.MiniMode       = WindowChrome.GetIsMiniModeActive(mainWindowChrome);
     kompactMenuItem.IsChecked = iUIOptions.MiniMode;
     SetWindowDimensions();
     iMiniModeChanging = false;
     if (iUIOptions.MiniMode && viewKinsky.ShowFullScreenArtwork)
     {
         viewKinsky.ShowFullScreenArtwork = false;
     }
 }
Ejemplo n.º 7
0
 private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (WindowChrome.GetIsMiniModeActive(mainWindowChrome))
     {
         iUIOptions.WindowSize = new Size(Width, iUIOptions.WindowSize.Height);
     }
     else
     {
         iUIOptions.WindowSize = new Size(Width, Height);
     }
     iUIOptions.WindowLocation = new Point(Left, Top);
 }
Ejemplo n.º 8
0
        private void topPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DateTime clickTime = DateTime.Now;

            if (clickTime.CompareTo(iLastTopPanelMouseDown.AddMilliseconds(iMouseDoubleClickTime)) < 0)
            {
                WindowChrome mainWindowChrome = this.FindVisualAncestor <WindowChrome>();
                if (!mainWindowChrome.IsAnimating)
                {
                    WindowChrome.SetIsMiniModeActive(mainWindowChrome, !WindowChrome.GetIsMiniModeActive(mainWindowChrome));
                }
                clickTime = DateTime.MinValue;
            }
            else
            {
                iLastTopPanelMouseDown = clickTime;
            }
        }