private static void W_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Window w = (Window)sender;
            //собираем основную информацию о окне и сохраняем
            PanelItemParametry pip = new PanelItemParametry();

            pip.Element  = w.GetType();
            pip.Bounds   = new Rect(w.Left, w.Top, w.Width, w.Height);
            pip.Position = WindowPositionBehaviour.GetWindowPosition(w);

            PanelSettings.SingleBuild(sender.GetType(), pip);
        }
Exemplo n.º 2
0
        private static void WindowRight_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Window w = sender as Window;

            var size     = System.Windows.Forms.Screen.AllScreens[GetWindowScreen(w)].Bounds.Size;
            var location = System.Windows.Forms.Screen.AllScreens[GetWindowScreen(w)].Bounds.Location;

            Point indent = new Point();

            if (w.Owner != null)
            {
                WindowPosition position = WindowPositionBehaviour.GetWindowPosition(w.Owner);
                switch (WindowPositionBehaviour.GetWindowPosition(w.Owner))
                {
                case WindowPosition.Left:
                case WindowPosition.LeftBottom:
                case WindowPosition.LeftTop:
                    indent.X = (HideButtonBehaviour.GetUseHideButton(w.Owner) ? -30 : 0);
                    break;

                case WindowPosition.Right:
                case WindowPosition.RightBottom:
                case WindowPosition.RightTop:
                    indent.X = -(HideButtonBehaviour.GetUseHideButton(w.Owner) ? 30 - (size.Width - w.Owner.Left - w.Owner.ActualWidth - 6) : -(size.Width - w.Owner.Left - w.Owner.ActualWidth - 6));
                    break;

                case WindowPosition.Top:
                    indent.Y = (HideButtonBehaviour.GetUseHideButton(w.Owner) ? -30 : 0);
                    break;

                case WindowPosition.Bottom:
                    indent.Y = (HideButtonBehaviour.GetUseHideButton(w.Owner) ? 30 : 0);
                    break;
                }
            }

            Thickness th = WindowPositionBehaviour.GetWindowThickness(w);

            w.Left = -(w.Owner != null ? w.Owner.Width + indent.X : 0) + location.X + size.Width - e.NewSize.Width - NTW.Common.GetIndentTaskBar(false) - th.Left - th.Right;
            w.Top  = th.Top;
        }
Exemplo n.º 3
0
        private static void WindowBottom_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Window w = sender as Window;

            var size     = System.Windows.Forms.Screen.AllScreens[GetWindowScreen(w)].Bounds.Size;
            var location = System.Windows.Forms.Screen.AllScreens[GetWindowScreen(w)].Bounds.Location;

            Point indent = new Point();

            if (w.Owner != null)
            {
                WindowPosition position = WindowPositionBehaviour.GetWindowPosition(w.Owner);
                switch (WindowPositionBehaviour.GetWindowPosition(w.Owner))
                {
                case WindowPosition.Left:
                case WindowPosition.LeftBottom:
                case WindowPosition.LeftTop:
                    indent.X = w.Owner.Width + (HideButtonBehaviour.GetUseHideButton(w.Owner) ? -30 : 0);
                    break;

                case WindowPosition.Right:
                case WindowPosition.RightBottom:
                case WindowPosition.RightTop:
                    indent.X = -(w.Owner.Width - (HideButtonBehaviour.GetUseHideButton(w.Owner) ? 30 : 0));
                    break;

                case WindowPosition.Top:
                    indent.Y = w.Owner.Height + (HideButtonBehaviour.GetUseHideButton(w.Owner) ? -30 : 0);
                    break;

                case WindowPosition.Bottom:
                    indent.Y = -w.Owner.Height + (HideButtonBehaviour.GetUseHideButton(w.Owner) ? 30 - ((size.Height - NTW.Common.GetIndentTaskBar(true)) - w.Owner.Top - w.Owner.ActualHeight - 6) : 0);
                    break;
                }
            }

            Thickness th = WindowPositionBehaviour.GetWindowThickness(w);

            w.Left = th.Top;
            w.Top  = location.Y + size.Height - e.NewSize.Height - NTW.Common.GetIndentTaskBar(true) - th.Top - th.Bottom + indent.Y;
        }
Exemplo n.º 4
0
        private static void WindowParametryChanged(DependencyObject d, DependencyPropertyChangedEventArgs a)
        {
            if (d is Window)
            {
                Window w = d as Window;

                var size     = System.Windows.Forms.Screen.AllScreens[GetWindowScreen(w)].Bounds.Size;
                var location = System.Windows.Forms.Screen.AllScreens[GetWindowScreen(w)].Bounds.Location;

                WindowPosition position = GetWindowPosition(d);

                w.SizeChanged -= WindowRight_SizeChanged;
                w.SizeChanged -= WindowBottom_SizeChanged;

                Thickness th     = GetWindowThickness(w);
                Point     indent = new Point();
                if (w.Owner != null)
                {
                    position = WindowPositionBehaviour.GetWindowPosition(w.Owner);
                    switch (WindowPositionBehaviour.GetWindowPosition(w.Owner))
                    {
                    case WindowPosition.Left:
                    case WindowPosition.LeftBottom:
                    case WindowPosition.LeftTop:
                        indent.X = w.Owner.Width + (HideButtonBehaviour.GetUseHideButton(w.Owner) ? -30 + w.Owner.Left - location.X - 6 : 0);
                        break;

                    case WindowPosition.Right:
                    case WindowPosition.RightBottom:
                    case WindowPosition.RightTop:
                        indent.X = -(w.Owner.Width - (HideButtonBehaviour.GetUseHideButton(w.Owner) ? 30 : 0));
                        break;

                    case WindowPosition.Top:
                        indent.Y = w.Owner.Height + (HideButtonBehaviour.GetUseHideButton(w.Owner) ? -30 + w.Owner.Top - location.Y - 6 : 0);
                        break;

                    case WindowPosition.Bottom:
                        indent.Y = -w.Owner.Height + (HideButtonBehaviour.GetUseHideButton(w.Owner) ? 30 : 0);
                        break;
                    }
                }

                switch (position)
                {
                case WindowPosition.Left:
                    w.SizeToContent = SizeToContent.Height;
                    w.Left          = location.X + th.Left + indent.X;
                    w.Top           = location.Y + th.Top + indent.Y;;

                    w.SizeChanged -= WindowRightBottom_SizeChanged;
                    w.SizeChanged -= WindowRight_SizeChanged;
                    w.SizeChanged -= WindowBottom_SizeChanged;
                    break;

                case WindowPosition.Right:
                    w.SizeToContent = SizeToContent.Height;

                    w.Left = location.X + size.Width + th.Left - th.Right - NTW.Common.GetIndentTaskBar(false) + indent.X;
                    w.Top  = location.Y + th.Top + indent.Y;

                    w.SizeChanged -= WindowRightBottom_SizeChanged;
                    w.SizeChanged -= WindowBottom_SizeChanged;

                    w.SizeChanged += WindowRight_SizeChanged;
                    break;

                case WindowPosition.Top:
                    w.SizeToContent = SizeToContent.Width;

                    w.Left = location.X + th.Left + indent.X;
                    w.Top  = location.Y + th.Top + indent.Y;

                    w.SizeChanged -= WindowRightBottom_SizeChanged;
                    w.SizeChanged -= WindowRight_SizeChanged;
                    w.SizeChanged -= WindowBottom_SizeChanged;
                    break;

                case WindowPosition.Bottom:
                    w.SizeToContent = SizeToContent.Width;

                    w.Left = location.X + th.Left + indent.X;
                    w.Top  = location.Y * 2 + size.Height + th.Top - th.Bottom - NTW.Common.GetIndentTaskBar(true) + indent.Y;

                    w.SizeChanged -= WindowRightBottom_SizeChanged;
                    w.SizeChanged -= WindowRight_SizeChanged;

                    w.SizeChanged += WindowBottom_SizeChanged;
                    break;

                case WindowPosition.None:
                    break;

                case WindowPosition.LeftTop:
                    w.SizeToContent = SizeToContent.WidthAndHeight;

                    w.Left = location.X + th.Left + indent.X;
                    w.Top  = location.Y + th.Top + indent.Y;

                    w.SizeChanged -= WindowRightBottom_SizeChanged;
                    w.SizeChanged -= WindowRight_SizeChanged;
                    w.SizeChanged -= WindowBottom_SizeChanged;
                    break;

                case WindowPosition.LeftBottom:
                    w.SizeToContent = SizeToContent.WidthAndHeight;

                    w.Left = location.X + th.Left + indent.X;
                    w.Top  = location.Y + size.Height + th.Top - th.Bottom - NTW.Common.GetIndentTaskBar(true) + indent.Y;

                    w.SizeChanged -= WindowRightBottom_SizeChanged;
                    w.SizeChanged -= WindowRight_SizeChanged;

                    w.SizeChanged += WindowBottom_SizeChanged;
                    break;

                case WindowPosition.RightTop:
                    w.SizeToContent = SizeToContent.WidthAndHeight;

                    w.Left = location.X + size.Width + th.Left - th.Right - NTW.Common.GetIndentTaskBar(false) + indent.X;
                    w.Top  = location.Y + th.Top + indent.Y;

                    w.SizeChanged -= WindowBottom_SizeChanged;
                    w.SizeChanged -= WindowRightBottom_SizeChanged;

                    w.SizeChanged += WindowRight_SizeChanged;
                    break;

                case WindowPosition.RightBottom:
                    w.SizeToContent = SizeToContent.WidthAndHeight;

                    w.Left = location.X + size.Width + th.Left - th.Right - NTW.Common.GetIndentTaskBar(false) + indent.X;
                    w.Top  = location.Y + size.Height + th.Top - th.Bottom - NTW.Common.GetIndentTaskBar(true) + indent.Y;

                    w.SizeChanged -= WindowRight_SizeChanged;
                    w.SizeChanged -= WindowBottom_SizeChanged;

                    w.SizeChanged += WindowRightBottom_SizeChanged;
                    break;
                }
            }
        }
        protected static void SetParametry(FrameworkElement fe, int procent, bool UsePosition, AgeType at, TypeSize type)
        {
            Size primarySize = new Size(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);

            if (GetUseParentSize(fe))
            {
                if (fe.Parent is FrameworkElement)
                {
                    var parent = (FrameworkElement)fe.Parent;
                    primarySize = new Size(parent.Width == 0 ? parent.ActualWidth : parent.Width, parent.Height == 0 ? parent.ActualHeight : parent.Height);
                }
                else if (fe.Parent is Decorator)
                {
                    var parent = (Decorator)fe.Parent;
                    primarySize = new Size(parent.Width == 0 ? parent.ActualWidth : parent.Width, parent.Height == 0 ? parent.ActualHeight : parent.Height);
                }
            }

            fe.Width     = double.NaN;
            fe.MinWidth  = 0;
            fe.MaxWidth  = double.PositiveInfinity;
            fe.Height    = double.NaN;
            fe.MinHeight = 0;
            fe.MaxHeight = double.PositiveInfinity;

            if (!GetUsePosition(fe))
            {
                switch (at)
                {
                case AgeType.Width:
                    switch (type)
                    {
                    case TypeSize.Current:
                        fe.Width  = primarySize.Width * procent / 100;
                        fe.Height = double.NaN;
                        break;

                    case TypeSize.Static:
                        fe.Width     = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                        fe.Height    = double.NaN;
                        fe.MinHeight = 0;
                        fe.MaxHeight = double.PositiveInfinity;
                        break;

                    case TypeSize.Max:
                        fe.MaxWidth  = primarySize.Width * procent / 100;
                        fe.MaxHeight = double.PositiveInfinity;
                        break;

                    case TypeSize.Min:
                        fe.MinWidth  = primarySize.Width * procent / 100;
                        fe.MinHeight = 0;
                        break;
                    }
                    break;

                case AgeType.Height:
                    switch (type)
                    {
                    case TypeSize.Current:
                        fe.Width  = double.NaN;
                        fe.Height = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Static:
                        fe.Width  = fe.MinWidth = fe.MaxWidth = double.NaN;
                        fe.Height = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Max:
                        fe.MaxWidth  = double.PositiveInfinity;
                        fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Min:
                        fe.MinWidth  = 0;
                        fe.MinHeight = primarySize.Height * procent / 100;
                        break;
                    }
                    break;

                case AgeType.FullSize:
                    switch (type)
                    {
                    case TypeSize.Current:
                        fe.Width  = primarySize.Width * procent / 100;
                        fe.Height = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Static:
                        fe.Width  = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                        fe.Height = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Max:
                        fe.MaxWidth  = primarySize.Width * procent / 100;
                        fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Min:
                        fe.MinWidth  = primarySize.Width * procent / 100;
                        fe.MinHeight = primarySize.Height * procent / 100;
                        break;
                    }
                    break;
                }
            }
            else
            {
                Window parent = NTW.Common.FindAncestor <Window>(fe);
                if (parent != null)
                {
                    switch (WindowPositionBehaviour.GetWindowPosition(parent))
                    {
                    case Data.WindowPosition.Left:
                    case Data.WindowPosition.LeftBottom:
                    case Data.WindowPosition.LeftTop:
                    case Data.WindowPosition.Right:
                    case Data.WindowPosition.RightBottom:
                    case Data.WindowPosition.RightTop:
                        switch (type)
                        {
                        case TypeSize.Current:
                            fe.Width  = double.NaN;
                            fe.Height = primarySize.Height * procent / 100;
                            break;

                        case TypeSize.Static:
                            fe.Width    = double.NaN;
                            fe.MinWidth = 0;
                            fe.MaxWidth = double.PositiveInfinity;
                            fe.Height   = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                            break;

                        case TypeSize.Max:
                            fe.MaxWidth  = double.PositiveInfinity;
                            fe.MaxHeight = primarySize.Height * procent / 100;
                            break;

                        case TypeSize.Min:
                            fe.MinWidth  = 0;
                            fe.MinHeight = primarySize.Height * procent / 100;
                            break;
                        }
                        break;

                    case Data.WindowPosition.Top:
                    case Data.WindowPosition.Bottom:
                        switch (type)
                        {
                        case TypeSize.Current:
                            fe.Width  = primarySize.Width * procent / 100;
                            fe.Height = double.NaN;
                            break;

                        case TypeSize.Static:
                            fe.Width     = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                            fe.Height    = double.NaN;
                            fe.MinHeight = 0;
                            fe.MaxHeight = double.PositiveInfinity;
                            break;

                        case TypeSize.Max:
                            fe.MaxWidth  = primarySize.Width * procent / 100;
                            fe.MaxHeight = double.PositiveInfinity;
                            break;

                        case TypeSize.Min:
                            fe.MinWidth  = primarySize.Width * procent / 100;
                            fe.MinHeight = 0;
                            break;
                        }
                        break;
                    }
                }
                else
                {
                    Popup pParent = NTW.Common.FindAncestor <Popup>(fe);

                    if (pParent != null)
                    {
                        switch (FrameworkElementPositionBehaviour.GetFrameworkElementPosition(pParent))
                        {
                        case Data.WindowPosition.Left:
                        case Data.WindowPosition.LeftBottom:
                        case Data.WindowPosition.LeftTop:
                        case Data.WindowPosition.Right:
                        case Data.WindowPosition.RightBottom:
                        case Data.WindowPosition.RightTop:
                            switch (type)
                            {
                            case TypeSize.Current:
                                fe.Width  = double.NaN;
                                fe.Height = primarySize.Height * procent / 100;
                                break;

                            case TypeSize.Static:
                                fe.Width  = fe.MinWidth = fe.MaxWidth = double.NaN;
                                fe.Height = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                                break;

                            case TypeSize.Max:
                                fe.MaxWidth  = double.NaN;
                                fe.MaxHeight = primarySize.Height * procent / 100;
                                break;

                            case TypeSize.Min:
                                fe.MinWidth  = double.NaN;
                                fe.MinHeight = primarySize.Height * procent / 100;
                                break;
                            }
                            break;

                        case Data.WindowPosition.Top:
                        case Data.WindowPosition.Bottom:
                            switch (type)
                            {
                            case TypeSize.Current:
                                fe.Width  = primarySize.Width * procent / 100;
                                fe.Height = double.NaN;
                                break;

                            case TypeSize.Static:
                                fe.Width  = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                                fe.Height = fe.MinHeight = fe.MaxHeight = double.NaN;
                                break;

                            case TypeSize.Max:
                                fe.MaxWidth  = primarySize.Width * procent / 100;
                                fe.MaxHeight = double.NaN;
                                break;

                            case TypeSize.Min:
                                fe.MinWidth  = primarySize.Width * procent / 100;
                                fe.MinHeight = double.NaN;
                                break;
                            }
                            break;
                        }
                    }
                }
            }
        }