/// <summary> /// 构造ToolWindow承载Pane /// </summary> /// <param name="p_winItem"></param> /// <returns></returns> ToolWindow OpenInWindow(Pane p_winItem) { ToolWindow win = _owner.CreateWindow(p_winItem.FloatSize, p_winItem.FloatLocation); if (p_winItem.ReadLocalValue(Pane.FloatLocationProperty) == DependencyProperty.UnsetValue) { // 默认位置 switch (p_winItem.FloatPos) { case FloatPosition.Center: win.HorizontalOffset = Math.Ceiling((SysVisual.ViewWidth - p_winItem.FloatSize.Width) / 2); win.VerticalOffset = Math.Ceiling((SysVisual.ViewHeight - p_winItem.FloatSize.Height) / 2); break; case FloatPosition.TopLeft: win.HorizontalOffset = 0; win.VerticalOffset = 0; break; case FloatPosition.TopRight: win.HorizontalOffset = SysVisual.ViewWidth - p_winItem.FloatSize.Width; win.VerticalOffset = 0; break; case FloatPosition.BottomLeft: win.HorizontalOffset = 0; win.VerticalOffset = SysVisual.ViewHeight - p_winItem.FloatSize.Height; break; case FloatPosition.BottomRight: win.HorizontalOffset = SysVisual.ViewWidth - p_winItem.FloatSize.Width; win.VerticalOffset = SysVisual.ViewHeight - p_winItem.FloatSize.Height; break; } } win.Content = p_winItem; win.Show(); return(win); }