Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        static void OnVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ToolWindow window = d as ToolWindow;

            Canvas.SetTop(window, window.VerticalOffset);
        }
Exemplo n.º 3
0
        void WriteWinItem(Pane p_item, XmlWriter p_writer)
        {
            p_writer.WriteStartElement("Pane");

            if (p_item.ReadLocalValue(Pane.PosProperty) != DependencyProperty.UnsetValue)
            {
                p_writer.WriteAttributeString("Pos", p_item.Pos.ToString());
            }

            if (!double.IsNaN(p_item.ActualWidth) && p_item.ActualWidth > 0)
            {
                p_writer.WriteAttributeString("InitWidth", p_item.ActualWidth.ToString());
            }
            else if (p_item.ReadLocalValue(Pane.InitWidthProperty) != DependencyProperty.UnsetValue)
            {
                p_writer.WriteAttributeString("InitWidth", p_item.InitWidth.ToString());
            }

            if (!double.IsNaN(p_item.ActualHeight) && p_item.ActualHeight > 0)
            {
                p_writer.WriteAttributeString("InitHeight", p_item.ActualHeight.ToString());
            }
            else if (p_item.ReadLocalValue(Pane.InitHeightProperty) != DependencyProperty.UnsetValue)
            {
                p_writer.WriteAttributeString("InitHeight", p_item.InitHeight.ToString());
            }

            if (p_item.ReadLocalValue(Pane.OrientationProperty) != DependencyProperty.UnsetValue)
            {
                p_writer.WriteAttributeString("Orientation", p_item.Orientation.ToString());
            }

            ToolWindow win = p_item.Parent as ToolWindow;

            if (win != null)
            {
                p_writer.WriteAttributeString("FloatLocation", string.Format("{0},{1}", Math.Ceiling(win.HorizontalOffset), Math.Ceiling(win.VerticalOffset)));
                p_writer.WriteAttributeString("FloatSize", string.Format("{0},{1}", Math.Ceiling(win.ActualWidth), Math.Ceiling(win.ActualHeight)));
            }
            else
            {
                if (p_item.ReadLocalValue(Pane.FloatLocationProperty) != DependencyProperty.UnsetValue)
                {
                    p_writer.WriteAttributeString("FloatLocation", string.Format("{0},{1}", p_item.FloatLocation.X, p_item.FloatLocation.Y));
                }
                else if (p_item.ReadLocalValue(Pane.FloatPosProperty) != DependencyProperty.UnsetValue)
                {
                    p_writer.WriteAttributeString("FloatPos", p_item.FloatPos.ToString());
                }

                if (p_item.ReadLocalValue(Pane.FloatSizeProperty) != DependencyProperty.UnsetValue)
                {
                    p_writer.WriteAttributeString("FloatSize", string.Format("{0},{1}", p_item.FloatSize.Width, p_item.FloatSize.Height));
                }
            }

            if (p_item.IsInCenter)
            {
                p_writer.WriteAttributeString("IsInCenter", "True");
            }

            if (p_item.IsInWindow)
            {
                p_writer.WriteAttributeString("IsInWindow", "True");
            }

            foreach (object obj in p_item.Items)
            {
                if (obj is Tabs tabs)
                {
                    WriteTabs(tabs, p_writer);
                }
                else if (obj is Pane wi)
                {
                    WriteWinItem(wi, p_writer);
                }
            }
            p_writer.WriteEndElement();
        }
Exemplo n.º 4
0
        static void OnHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ToolWindow window = d as ToolWindow;

            Canvas.SetLeft(window, window.HorizontalOffset);
        }