Exemple #1
0
        public static PageContent CreatePrintPageContent(Size pageSize, FrameworkElement tabCtrlCanvas,
                                                         TabControl tabCtrl, int startIndex, int endIndex, string header)
        {
            var page = new FixedPage {
                Width = pageSize.Width, Height = pageSize.Height
            };
            Size panelSize = new Size {
                Width = pageSize.Width, Height = pageSize.Height / (endIndex - startIndex + 1)
            };
            StackPanel stack = new StackPanel();

            for (int i = startIndex; i <= endIndex; i++)
            {
                tabCtrl.SelectedIndex = i;
                tabCtrl.SelectedItem  = tabCtrl.Items[i];
                tabCtrl.Measure(tabCtrl.RenderSize);
                tabCtrl.Arrange(new Rect(tabCtrl.RenderSize));
                tabCtrl.UpdateLayout();
                System.Windows.Controls.Image img = ConvertControlToImage(tabCtrlCanvas, panelSize);
                stack.Children.Add(img);
            }

            GroupBox grpBox = new GroupBox();

            grpBox.Header  = header;
            grpBox.Content = stack;
            page.Children.Add(grpBox);
            page.Measure(pageSize);
            page.Arrange(new Rect(new Point(), pageSize));
            page.UpdateLayout();
            var pageContent = new PageContent();

            ((IAddChild)pageContent).AddChild(page);
            return(pageContent);
        }
 private void SwitchTab(TabControl tabCtrl, int tabIndex)
 {
     tabCtrl.SelectedIndex = tabIndex;
     tabCtrl.SelectedItem  = tabCtrl.Items[tabIndex];
     tabCtrl.Measure(mainTabCtrl.RenderSize);
     tabCtrl.Arrange(new Rect(mainTabCtrl.RenderSize));
     tabCtrl.UpdateLayout();
 }
Exemple #3
0
 private void Prepare(TabControl target)
 {
     ApplyTemplate(target);
     target.Measure(Size.Infinity);
     target.Arrange(new Rect(target.DesiredSize));
 }