Esempio n. 1
0
            private void LayoutAnimateWindow(Rectangle rect)
            {
                Bounds = DockPanel.GetAutoHideWindowBounds(rect);

                Rectangle rectClient = ClientRectangle;

                if (DockState == DockState.DockLeftAutoHide)
                {
                    ActivePane.Location = new Point(rectClient.Right - 2 - Measures.SplitterSize - ActivePane.Width, ActivePane.Location.Y);
                }
                else if (DockState == DockState.DockTopAutoHide)
                {
                    ActivePane.Location = new Point(ActivePane.Location.X, rectClient.Bottom - 2 - Measures.SplitterSize - ActivePane.Height);
                }
            }
Esempio n. 2
0
            private void AnimateWindow(bool show)
            {
                if (!FlagAnimate && Visible != show)
                {
                    Visible = show;
                    return;
                }

                Parent.SuspendLayout();

                Rectangle rectSource = GetRectangle(!show);
                Rectangle rectTarget = GetRectangle(show);
                int       dxLoc, dyLoc;
                int       dWidth, dHeight;

                dxLoc = dyLoc = dWidth = dHeight = 0;
                if (DockState == DockState.DockTopAutoHide)
                {
                    dHeight = show ? 1 : -1;
                }
                else if (DockState == DockState.DockLeftAutoHide)
                {
                    dWidth = show ? 1 : -1;
                }
                else if (DockState == DockState.DockRightAutoHide)
                {
                    dxLoc  = show ? -1 : 1;
                    dWidth = show ? 1 : -1;
                }
                else if (DockState == DockState.DockBottomAutoHide)
                {
                    dyLoc   = (show ? -1 : 1);
                    dHeight = (show ? 1 : -1);
                }

                if (show)
                {
                    Bounds = DockPanel.GetAutoHideWindowBounds(new Rectangle(-rectTarget.Width, -rectTarget.Height, rectTarget.Width, rectTarget.Height));
                    if (Visible == false)
                    {
                        Visible = true;
                    }
                    PerformLayout();
                }

                SuspendLayout();

                LayoutAnimateWindow(rectSource);
                if (Visible == false)
                {
                    Visible = true;
                }

                int speedFactor = 1;
                int totalPixels = (rectSource.Width != rectTarget.Width) ?
                                  Math.Abs(rectSource.Width - rectTarget.Width) :
                                  Math.Abs(rectSource.Height - rectTarget.Height);
                int      remainPixels = totalPixels;
                DateTime startingTime = DateTime.Now;

                while (rectSource != rectTarget)
                {
                    DateTime startPerMove = DateTime.Now;

                    rectSource.X      += dxLoc * speedFactor;
                    rectSource.Y      += dyLoc * speedFactor;
                    rectSource.Width  += dWidth * speedFactor;
                    rectSource.Height += dHeight * speedFactor;
                    if (Math.Sign(rectTarget.X - rectSource.X) != Math.Sign(dxLoc))
                    {
                        rectSource.X = rectTarget.X;
                    }
                    if (Math.Sign(rectTarget.Y - rectSource.Y) != Math.Sign(dyLoc))
                    {
                        rectSource.Y = rectTarget.Y;
                    }
                    if (Math.Sign(rectTarget.Width - rectSource.Width) != Math.Sign(dWidth))
                    {
                        rectSource.Width = rectTarget.Width;
                    }
                    if (Math.Sign(rectTarget.Height - rectSource.Height) != Math.Sign(dHeight))
                    {
                        rectSource.Height = rectTarget.Height;
                    }

                    LayoutAnimateWindow(rectSource);
                    if (Parent != null)
                    {
                        Parent.Update();
                    }

                    remainPixels -= speedFactor;

                    while (true)
                    {
                        TimeSpan time           = new TimeSpan(0, 0, 0, 0, ANIMATE_TIME);
                        TimeSpan elapsedPerMove = DateTime.Now - startPerMove;
                        TimeSpan elapsedTime    = DateTime.Now - startingTime;
                        if (((int)((time - elapsedTime).TotalMilliseconds)) <= 0)
                        {
                            speedFactor = remainPixels;
                            break;
                        }
                        else
                        {
                            speedFactor = remainPixels * (int)elapsedPerMove.TotalMilliseconds / (int)((time - elapsedTime).TotalMilliseconds);
                        }
                        if (speedFactor >= 1)
                        {
                            break;
                        }
                    }
                }
                ResumeLayout();
                Parent.ResumeLayout();
            }