示例#1
0
        protected override void Initialize()
        {
#if TODO_XAML
            content = new swc.DockPanel();
#else
            content = new Panel();
#endif
            base.Initialize();
            Control.SizeToContent       = sw.SizeToContent.WidthAndHeight;
            Control.SnapsToDevicePixels = true;
            Control.UseLayoutRounding   = true;
#if TODO_XAML
            main = new swc.DockPanel();
#endif
            menuHolder = new swc.ContentControl {
                IsTabStop = false
            };
            toolBarHolder = new swc.ContentControl {
                IsTabStop = false
            };
            content.Background = Windows.UI.Xaml.SystemColors.ControlBrush;
            swc.DockPanel.SetDock(menuHolder, swc.Dock.Top);
            swc.DockPanel.SetDock(toolBarHolder, swc.Dock.Top);
#if TODO_XAML
            main.Children.Add(menuHolder);
            main.Children.Add(toolBarHolder);
            main.Children.Add(content);
            Control.Content = main;
#endif
            Control.Loaded += delegate
            {
                SetResizeMode();
                if (initialClientSize != null)
                {
                    initialClientSize = null;
                    SetContentSize();
                }
                // stop form from auto-sizing after it is shown
                Control.SizeToContent = sw.SizeToContent.Manual;
                Control.MoveFocus(new swi.TraversalRequest(swi.FocusNavigationDirection.Next));
            };
            // needed to handle Application.Terminating event
            HandleEvent(Window.ClosingEvent);
        }
示例#2
0
        public TabPageHandler()
        {
            Control = new swc.TabItem();
            var header = new swc.StackPanel {
                Orientation = swc.Orientation.Horizontal
            };

            headerImage = new swc.Image {
                MaxHeight = 16, MaxWidth = 16
            };
            headerText = new swc.TextBlock();
            header.Children.Add(headerImage);
            header.Children.Add(headerText);
            Control.Header = header;

            Control.Content = content = new swc.DockPanel {
                LastChildFill = true
            };
        }
示例#3
0
        public SplitterHandler()
        {
            Control = new swc.Grid();
            Control.ColumnDefinitions.Add(new swc.ColumnDefinition());
            Control.ColumnDefinitions.Add(new swc.ColumnDefinition {
                Width = sw.GridLength.Auto
            });
            Control.ColumnDefinitions.Add(new swc.ColumnDefinition());
            Control.RowDefinitions.Add(new swc.RowDefinition());
            Control.RowDefinitions.Add(new swc.RowDefinition {
                Height = sw.GridLength.Auto
            });
            Control.RowDefinitions.Add(new swc.RowDefinition());

            splitter = new swc.GridSplitter
            {
                //Background = sw.SystemColors.ControlLightLightBrush,
                ResizeBehavior = swc.GridResizeBehavior.PreviousAndNext
            };
            pane1 = new swc.DockPanel {
                LastChildFill = true
            };
            pane2 = new swc.DockPanel {
                LastChildFill = true
            };


            Control.Children.Add(pane1);
            Control.Children.Add(splitter);
            Control.Children.Add(pane2);

            style = new sw.Style();
            style.Setters.Add(new sw.Setter(sw.FrameworkElement.VerticalAlignmentProperty, sw.VerticalAlignment.Stretch));
            style.Setters.Add(new sw.Setter(sw.FrameworkElement.HorizontalAlignmentProperty, sw.HorizontalAlignment.Stretch));

            UpdateOrientation();
            Control.Loaded += delegate
            {
                // controls should be stretched to fit panels
                SetStretch(panel1);
                SetStretch(panel2);
                UpdateColumnSizing();
                if (FixedPanel == SplitterFixedPanel.Panel2)
                {
                    var size = panel2.GetPreferredSize(Conversions.PositiveInfinitySize);
                    var currentOrientation = Orientation;
                    if (currentOrientation == SplitterOrientation.Horizontal)
                    {
                        var width = (int)Control.ActualWidth;
                        position = position ?? (int)(width - size.Width);
                        Position = Size.Width - (width - position.Value);
                    }
                    else if (currentOrientation == SplitterOrientation.Vertical)
                    {
                        var height = (int)Control.ActualHeight;
                        position = position ?? (int)(height - size.Height);

                        Position = Size.Height - (height - position.Value);
                    }
                    else if (position != null)
                    {
                        Position = position.Value;
                    }
                }
                else if (position != null)
                {
                    Position = position.Value;
                }
            };
        }