Exemple #1
0
        /// <summary>
        /// 设置吸附时的初始位置
        /// </summary>
        private void SetAdsorbLocation(AdsorbOrientation adsorbOrientation)
        {
            switch (adsorbOrientation)
            {
            case AdsorbOrientation.None:
                Topmost = false;
                Height  = OriginalHeight;
                Width   = OriginalWidth;
                break;

            case AdsorbOrientation.Left:
                Topmost = true;
                Left    = 0 - BorderThickness.Left + Offsize;
                Top     = 0;
                Height  = SystemParameters.WorkArea.Height;
                break;

            case AdsorbOrientation.Top:
                Topmost = true;
                Top     = 0 - BorderThickness.Top + Offsize;
                break;

            case AdsorbOrientation.Right:
                Topmost = true;
                Left    = SystemParameters.WorkArea.Width - ActualWidth - Offsize + BorderThickness.Right;
                Top     = 0;
                Height  = SystemParameters.WorkArea.Height;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        /// <summary>
        /// 收缩
        /// </summary>
        /// <param name="adsorbOrientation"></param>
        private void ShrinkAnimatable(AdsorbOrientation adsorbOrientation)
        {
            switch (adsorbOrientation)
            {
            case AdsorbOrientation.Left:
                AdsorbAnimatable(0 - ActualWidth - Offsize + BorderThickness.Left, new PropertyPath(Window.LeftProperty));
                break;

            case AdsorbOrientation.Top:
                AdsorbAnimatable(0 - ActualHeight - Offsize + BorderThickness.Top, new PropertyPath(Window.TopProperty));
                break;

            case AdsorbOrientation.Right:
                AdsorbAnimatable(SystemParameters.WorkArea.Width - BorderThickness.Right + Offsize, new PropertyPath(Window.LeftProperty));
                break;
            }
        }
Exemple #3
0
        /// <summary>
        /// 设置窗口位置
        /// </summary>
        /// <param name="adsorbOrientation"></param>
        /// <param name="current"></param>
        /// <param name="reference"></param>
        private void SetWindowLocation(AdsorbOrientation adsorbOrientation, Point current, Point reference)
        {
            switch (adsorbOrientation)
            {
            case AdsorbOrientation.None:
                Left = Left + current.X - reference.X;
                Top  = Top + current.Y - reference.Y;
                break;

            case AdsorbOrientation.Left:
                break;

            case AdsorbOrientation.Top:
                Left = Left + current.X - reference.X;
                break;

            case AdsorbOrientation.Right:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }