Beispiel #1
0
    void Awake()
    {
        print("老的Awake");

        itemPrefab = transform.parent.parent.parent.FindChild("pvpRankItemPerfab").gameObject;

        m_SV = transform.parent.GetComponent <UIScrollView>();

        m_parent = transform.FindChild("parent").gameObject;

        if (itemPrefab == null || m_SV == null || m_parent == null) //itemParent == null)
        {
            Debug.LogError("Lzh_LoopScrollView.Awake() 有属性没有在inspector中赋值");
        }

        arrangeDirection = ArrangeDirection.Up_to_Down;
        gapDis           = 0f;

        // 设置scrollview的movement
        if (arrangeDirection == ArrangeDirection.Up_to_Down ||
            arrangeDirection == ArrangeDirection.Down_to_Up)
        {
            m_SV.movement = UIScrollView.Movement.Vertical;
        }
        else
        {
            m_SV.movement = UIScrollView.Movement.Horizontal;
        }

        InitScrollView(OnInitItem);
    }
Beispiel #2
0
    void Awake()
    {
        itemPrefab = transform.parent.parent.FindChild("ChatItem").gameObject;

        //itemPrefab.GetComponent<UIWidget>().pivot = UIWidget.Pivot.Bottom;

        scrollView = GetComponent <UIScrollView>();
        itemParent = transform.FindChild("Parent").gameObject;

        if (itemPrefab == null || scrollView == null || itemParent == null)
        {
            Debug.LogError("Lzh_LoopScrollView.Awake() 有属性没有在inspector中赋值");
        }

        arrangeDirection = ArrangeDirection.Down_to_Up;
        gapDis           = 10f;
        panelHeight      = scrollView.GetComponent <UIPanel>().height;
        itemStartPos     = new Vector3(0, -panelHeight / 2 + gapDis, 0);


        // 设置scrollview的movement
        if (arrangeDirection == ArrangeDirection.Up_to_Down ||
            arrangeDirection == ArrangeDirection.Down_to_Up)
        {
            scrollView.movement = UIScrollView.Movement.Vertical;
        }
        else
        {
            scrollView.movement = UIScrollView.Movement.Horizontal;
        }


        InitScrollView();
    }
Beispiel #3
0
        public void SystemInformation_ArrangeDirection_Get_ReturnsExpected()
        {
            ArrangeDirection direction = SystemInformation.ArrangeDirection;

            Assert.Equal((ArrangeDirection)0, direction & ~(ArrangeDirection.Up | ArrangeDirection.Down | ArrangeDirection.Left | ArrangeDirection.Right));
            Assert.Equal(direction, SystemInformation.ArrangeDirection);
        }
        MoveToPosition GetMoveToPosition(ArrangeDirection arrangeDirection, System.Drawing.Rectangle screenRectangle, int centerWindowSize, int leftRightWindowSize, ScreenPositions screenPostions)
        {
            MoveToPosition mtp = MoveToPosition.Undecided;
            var            awr = GetActiveWindowRectangle();
// needed 1px on 34" uwqhd 21:9 3440x1440 @ 100%, 2px on 25" wqhd 16:9 2560x1440 @ 125% [ , 3px on 13" wqhd @ 175% scale ] and ease of access [ win+u ] | display | make text bigger = 100% (default)
// using 3px appeared to break behavior back on 25" display where win+leftarrow state ctrl+leftarrow cycled to right 3rd instead of left 2/3rds and visa versa for starting with win+rightarrow state
            const int pixelError = 2;

            if (arrangeDirection == ArrangeDirection.Left)
            {
                if (screenPostions == ScreenPositions.LeftCenterRight)
                {
                    if (awr.Left - pixelError > screenRectangle.Left + leftRightWindowSize + centerWindowSize)
                    {
                        mtp = MoveToPosition.Right;
                    }
                    else if (awr.Left > screenRectangle.Left + leftRightWindowSize)
                    {
                        mtp = MoveToPosition.Center;
                    }
                    else if (awr.Left == screenRectangle.Left + leftRightWindowSize && Math.Abs(awr.Right - (screenRectangle.Left + leftRightWindowSize + centerWindowSize)) > pixelError)
                    {
                        mtp = MoveToPosition.Center;
                    }
                    else if (awr.Left == screenRectangle.Left + leftRightWindowSize && awr.Right <= screenRectangle.Left + leftRightWindowSize + centerWindowSize)
                    {
                        mtp = MoveToPosition.Left;
                    }
                    else if (awr.Left > screenRectangle.Left)
                    {
                        mtp = MoveToPosition.Left;
                    }
                    else if (awr.Left <= screenRectangle.Left && awr.Right > screenRectangle.Left + leftRightWindowSize)
                    {
                        mtp = MoveToPosition.Left;                                                                                                  // store apps repro the <=
                    }
                    else /* if (awr.Left <= screeRectangle.Left && awr.Right <= screenRectangle.Left + leftRightWindowSize) */ mtp {
Beispiel #5
0
        public static void ArrangeItems(IEnumerable <DesignItem> items, ArrangeDirection arrangeDirection)
        {
            var collection = items;

            var _context = collection.First().Context as XamlDesignContext;

            var container = collection.First().Parent;

            if (collection.Any(x => x.Parent != container))
            {
                return;
            }

            var placement = container.Extensions.OfType <IPlacementBehavior>().FirstOrDefault();

            if (placement == null)
            {
                return;
            }

            var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);

            //var changeGroup = container.OpenGroup("Arrange Elements");

            List <ItemPos> itemList = new List <ItemPos>();

            foreach (var item in collection)
            {
                itemList.Add(GetItemPos(operation, item));
            }

            var xmin  = itemList.Min(x => x.Xmin);
            var xmax  = itemList.Max(x => x.Xmax);
            var mpos  = (xmax - xmin) / 2 + xmin;
            var ymin  = itemList.Min(x => x.Ymin);
            var ymax  = itemList.Max(x => x.Ymax);
            var ympos = (ymax - ymin) / 2 + ymin;

            foreach (var item in collection)
            {
                switch (arrangeDirection)
                {
                case ArrangeDirection.Left:
                {
                    if (container.Component is Canvas)
                    {
                        if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
                        {
                            item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(xmin);
                        }
                        else
                        {
                            var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double)((FrameworkElement)item.Component).ActualWidth);
                            item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
                        }
                    }
                    else if (container.Component is Grid)
                    {
                        if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
                        {
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Left = xmin;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                        else
                        {
                            var pos    = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double)((FrameworkElement)item.Component).ActualWidth);
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Right = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                    }
                }
                break;

                case ArrangeDirection.HorizontalMiddle:
                {
                    if (container.Component is Canvas)
                    {
                        if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
                        {
                            if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
                            {
                                item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(mpos - (((FrameworkElement)item.Component).ActualWidth) / 2);
                            }
                            else
                            {
                                var pp  = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
                                var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
                                item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
                            }
                        }
                    }
                    else if (container.Component is Grid)
                    {
                        if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
                        {
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Left = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                        else
                        {
                            var pp     = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
                            var pos    = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Right = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                    }
                }
                break;

                case ArrangeDirection.Right:
                {
                    if (container.Component is Canvas)
                    {
                        if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
                        {
                            var pos = xmax - (double)((FrameworkElement)item.Component).ActualWidth;
                            item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(pos);
                        }
                        else
                        {
                            var pos = (double)((Panel)item.Parent.Component).ActualWidth - xmax;
                            item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
                        }
                    }
                    else if (container.Component is Grid)
                    {
                        if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
                        {
                            var pos    = xmax - (double)((FrameworkElement)item.Component).ActualWidth;
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Left = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                        else
                        {
                            var pos    = (double)((Panel)item.Parent.Component).ActualWidth - xmax;
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Right = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                    }
                }
                break;

                case ArrangeDirection.Top:
                {
                    if (container.Component is Canvas)
                    {
                        if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
                        {
                            item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
                        }
                        else
                        {
                            var pos = (double)((Panel)item.Parent.Component).ActualHeight - (ymin + (double)((FrameworkElement)item.Component).ActualHeight);
                            item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
                        }
                    }
                    else if (container.Component is Grid)
                    {
                        if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
                        {
                            item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Top = ymin;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                        else
                        {
                            var pos    = (double)((Panel)item.Parent.Component).ActualHeight - (ymin + (double)((FrameworkElement)item.Component).ActualHeight);
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Bottom = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                    }
                }
                break;

                case ArrangeDirection.VerticalMiddle:
                {
                    if (container.Component is Canvas)
                    {
                        if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
                        {
                            item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ympos - (((FrameworkElement)item.Component).ActualHeight) / 2);
                        }
                        else
                        {
                            var pp  = mpos - (((FrameworkElement)item.Component).ActualHeight) / 2;
                            var pos = (double)((Panel)item.Parent.Component).ActualHeight - pp - (((FrameworkElement)item.Component).ActualHeight);
                            item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
                        }
                    }
                    else if (container.Component is Grid)
                    {
                        if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
                        {
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Top = ympos - (((FrameworkElement)item.Component).ActualHeight) / 2;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                        else
                        {
                            var pp     = mpos - (((FrameworkElement)item.Component).ActualHeight) / 2;
                            var pos    = (double)((Panel)item.Parent.Component).ActualHeight - pp - (((FrameworkElement)item.Component).ActualHeight);
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Bottom = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                    }
                }
                break;

                case ArrangeDirection.Bottom:
                {
                    if (container.Component is Canvas)
                    {
                        if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
                        {
                            var pos = ymax - (double)((FrameworkElement)item.Component).ActualHeight;
                            item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(pos);
                        }
                        else
                        {
                            var pos = (double)((Panel)item.Parent.Component).ActualHeight - ymax;
                            item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
                        }
                    }
                    else if (container.Component is Grid)
                    {
                        if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
                        {
                            var pos    = ymax - (double)((FrameworkElement)item.Component).ActualHeight;
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Top = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                        else
                        {
                            var pos    = (double)((Panel)item.Parent.Component).ActualHeight - ymax;
                            var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
                            margin.Bottom = pos;
                            item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
                        }
                    }
                }
                break;
                }
            }

            operation.Commit();
        }
Beispiel #6
0
		public static void ArrangeItems(IEnumerable<DesignItem> items, ArrangeDirection arrangeDirection)
		{
			var collection = items;

			var _context = collection.First().Context as XamlDesignContext;

			var container = collection.First().Parent;

			if (collection.Any(x => x.Parent != container))
				return;

			var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
			if (placement == null)
				return;

			var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);
			
			//var changeGroup = container.OpenGroup("Arrange Elements");

			List<ItemPos> itemList = new List<ItemPos>();
			foreach (var item in collection)
			{
				itemList.Add(GetItemPos(operation, item));
			}

			var xmin = itemList.Min(x => x.Xmin);
			var xmax = itemList.Max(x => x.Xmax);
			var mpos = (xmax - xmin) / 2 + xmin;
			var ymin = itemList.Min(x => x.Ymin);
			var ymax = itemList.Max(x => x.Ymax);
			var ympos = (ymax - ymin) / 2 + ymin;

			foreach (var item in collection)
			{
				switch (arrangeDirection)
				{
					case ArrangeDirection.Left:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
								{
									item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(xmin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double) ((FrameworkElement) item.Component).ActualWidth);
									item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
								}
							}
							else if (container.Component is Grid)
							{
								if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
								{
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Left = xmin;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double)((FrameworkElement)item.Component).ActualWidth);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Right = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
					case ArrangeDirection.HorizontalMiddle:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
								{
									if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
									{
										item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(mpos - (((FrameworkElement)item.Component).ActualWidth) / 2);
									}
									else
									{
										var pp = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
										var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
										item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
									}
								}
							}
							else if (container.Component is Grid)
							{
								if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
								{
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Left = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pp = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Right = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
					case ArrangeDirection.Right:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
								{
									var pos = xmax - (double)((FrameworkElement)item.Component).ActualWidth;
									item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(pos);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - xmax;
									item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
								}
							}
							else if (container.Component is Grid)
							{
								if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
								{
									var pos = xmax - (double)((FrameworkElement)item.Component).ActualWidth;
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Left = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - xmax;
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Right = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
					case ArrangeDirection.Top:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
								{
									item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualHeight - (ymin + (double)((FrameworkElement)item.Component).ActualHeight);
									item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
								}
							}
							else if (container.Component is Grid)
							{
								if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
								{
									item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Top = ymin;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualHeight - (ymin + (double)((FrameworkElement)item.Component).ActualHeight);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Bottom = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
					case ArrangeDirection.VerticalMiddle:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
								{
									item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ympos - (((FrameworkElement)item.Component).ActualHeight) / 2);
								}
								else
								{
									var pp = mpos - (((FrameworkElement)item.Component).ActualHeight) / 2;
									var pos = (double)((Panel)item.Parent.Component).ActualHeight - pp - (((FrameworkElement)item.Component).ActualHeight);
									item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
								}
							}
							else if (container.Component is Grid)
							{
								if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
								{
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Top = ympos - (((FrameworkElement)item.Component).ActualHeight) / 2;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pp = mpos - (((FrameworkElement)item.Component).ActualHeight) / 2;
									var pos = (double)((Panel)item.Parent.Component).ActualHeight - pp - (((FrameworkElement)item.Component).ActualHeight);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Bottom = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
					case ArrangeDirection.Bottom:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
								{
									var pos = ymax - (double)((FrameworkElement)item.Component).ActualHeight;
									item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(pos);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualHeight - ymax;
									item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
								}
							}
							else if (container.Component is Grid)
							{
								if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
								{
									var pos = ymax - (double)((FrameworkElement)item.Component).ActualHeight;
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Top = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualHeight - ymax;
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Bottom = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
				}
			}

			operation.Commit();
		}
        /// <summary>
        /// Take current active window and place it in left or right 3rd of screen area.
        /// </summary>
        /// <param name="centerPercentageOfTotalWidth">Percentage of total width to use when moving window, default is 34, with suggested alternatives being 36-38-40.</param>
        /// <param name="topBottomBorder">Number of pixels to use as border across top and bottom, default is 0.</param>
        /// <param name="screenPostions">defines type of screen positions scenario to base action on, default is LeftCenterRight.</param>
        public void PlaceActiveWindowPosition(ArrangeDirection arrangeDirection, int centerPercentageOfTotalWidth = 34, int topBottomBorder = 0, ScreenPositions screenPositions = ScreenPositions.LeftCenterRight)
        {
            //if (arrangeDirection == ArrangeDirection.Up || arrangeDirection == ArrangeDirection.Down)
            //{
            //        throw new ApplicationException("unsupported arrange direction specified");
            //}

            var awh = GetActiveWindowHandle();

// if you resize active window that is currently in SW_MAXIMIZE state it ends up not resizing it at all, e.g. in case of chrome, or
// resizing it but with an appx 7px space across top and bottom of window and if you minimize it and then restore it comes back as
// SW_MAXIMIZE state not expected SW_SHOW[NORMAL] state. so we check for SW_MAXIMIZE state and change to SW_SHOW[NORMAL] before
// resizing
            /* if (!IsWindowInNormalState(awh)) */ PutWindowIntoNormalState(awh);

            var primaryScreen = Screen.PrimaryScreen;
//#if DEBUG
//            var allScreens = Screen.AllScreens; var heightOfTaskbar = primaryScreen.Bounds.Bottom - primaryScreen.WorkingArea.Bottom;
//#endif
            //var sr = GetScreenRectangle(); // doesn't account for taskbar which you'd have to hardcode depending on display | scale and layout | size of . . .  + resolution settings
            var sr = primaryScreen.WorkingArea; // accounts for taskbar

            // splitting screen into 3rds is always going to require center 3rd to be rounded up to even number to end up with integer/whole numbers for left and right 3rds
            var centerWindowSize = (sr.Right - sr.Left) * centerPercentageOfTotalWidth / 100;
            var leftRightPercentageOfTotalWidth = (100 - centerPercentageOfTotalWidth) / 2;
            var leftRightWindowSize             = (sr.Right - sr.Left) * leftRightPercentageOfTotalWidth / 100;
            //var centerWindowSize = (sr.Right - sr.Left) - (leftRightWindowSize * 2);

            var position = new Rect()
            {
                Top = sr.Top + topBottomBorder
            };

            position.Bottom = sr.Bottom - topBottomBorder - position.Top; // change in y not absolution y position

            MoveToPosition mtp = GetMoveToPosition(arrangeDirection, sr, centerWindowSize, leftRightWindowSize, screenPositions);

            if (mtp == MoveToPosition.Left)
            {
                position.Left  = 0;
                position.Right = leftRightWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.LeftTwoThirds)
            {
                position.Left  = 0;
                position.Right = leftRightWindowSize + centerWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.Center)
            {
                position.Left = sr.Left + leftRightWindowSize;
                //position.Left = sr.Right - leftRightWindowSize - centerWindowSize; // alternative calculation
                position.Right = centerWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.RightTwoThirds)
            {
                position.Left = sr.Right - leftRightWindowSize - centerWindowSize;
                //position.Left = sr.Left + leftRightWindowSize; // alternative calculation
                position.Right = centerWindowSize + leftRightWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.Right)
            {
                position.Left = sr.Right - leftRightWindowSize;
                //position.Left = sr.Left + leftRightWindowSize + centerWindowSize; // alternative calculation
                position.Right = leftRightWindowSize; // change in x not absolution x position
            }

            // here is a a couple ways to add/subtract from top/bottom position settings in special app cases or uwp vs desktop app cases
            //var awt = GetActiveWindowTitle();
            //if (awt.EndsWith("- Special App Case 1") || awt.EndsWith("- Special App Case 2")) position.Bottom += 7;
            //var awh = GetActiveWindowHandle(); // this approach throws exceptions in IsUwpApp cases not seen in unit test runs that needs to be debugged
            //foreach (var process in Process.GetProcesses()) { if (process.MainWindowHandle == awh && process.IsUwpApp()) { position.Bottom += 7; break; } }

            SetActiveWindowPosition(position.Left, position.Top, position.Right, position.Bottom);
        }