当前位置: 首页>>代码示例>>C#>>正文


C# StackPanel.UpdateLayout方法代码示例

本文整理汇总了C#中System.Windows.Controls.StackPanel.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.UpdateLayout方法的具体用法?C# StackPanel.UpdateLayout怎么用?C# StackPanel.UpdateLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.StackPanel的用法示例。


在下文中一共展示了StackPanel.UpdateLayout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MeasureView

 private void MeasureView(UIElement view)
 {
     if (this.panel.Children.Contains(view))
     {
         this.panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
     }
     else if (VisualTreeHelper.GetParent(view) == null)
     {
         StackPanel stackPanel = new StackPanel();
         stackPanel.Children.Add(view);
         if (view is VirtualizedContainerService.VirtualizingContainer)
         {
             ((VirtualizedContainerService.VirtualizingContainer)view).Populate();
         }
         stackPanel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
         stackPanel.UpdateLayout();
         stackPanel.Children.Remove(view);
         FreeFormPanel.SetChildSize(view, view.DesiredSize);
     }
     else
     {
         Fx.Assert(false, "The view should either be un-rooted or contained in the FreeFormPanel");
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:24,代码来源:FlowchartDesigner.xaml.cs

示例2: AssertValid


//.........这里部分代码省略.........
            WpfGraphicsUtil.GetScreenDpi(m_oNodeXLControl).Width;

        // The NodeXLControl can't be a child of two logical trees, so
        // disconnect it from its parent after saving the current vertex
        // locations.

        m_oLayoutSaver = new LayoutSaver(m_oNodeXLControl.Graph);

        Debug.Assert(m_oNodeXLControl.Parent is Panel);
        m_oParentPanel = (Panel)m_oNodeXLControl.Parent;
        UIElementCollection oParentChildren = m_oParentPanel.Children;
        m_iChildIndex = oParentChildren.IndexOf(m_oNodeXLControl);
        oParentChildren.Remove(m_oNodeXLControl);

        m_oGraphImageScaler = new GraphImageScaler(m_oNodeXLControl);

        m_oGraphImageCenterer = new NodeXLControl.GraphImageCenterer(
            m_oNodeXLControl);

        // The header and footer are rendered as Label controls.  The legend is
        // rendered as a set of Image controls.

        Label oHeaderLabel, oFooterLabel;
        IEnumerable<Image> oLegendImages;
        Double dHeaderHeight, dTotalLegendHeight, dFooterHeight;

        CreateHeaderOrFooterLabel(headerText, compositeWidth, headerFooterFont,
            out oHeaderLabel, out dHeaderHeight);

        CreateLegendImages(legendControls, compositeWidth, out oLegendImages,
            out dTotalLegendHeight);

        CreateHeaderOrFooterLabel(footerText, compositeWidth, headerFooterFont,
            out oFooterLabel, out dFooterHeight);

        m_oNodeXLControl.Width = compositeWidth;

        m_oNodeXLControl.Height = Math.Max(10,
            compositeHeight - dHeaderHeight - dTotalLegendHeight
            - dFooterHeight);

        // Adjust the control's graph scale so that the graph's vertices and
        // edges will be the same relative size in the composite that they are
        // in the control.

        m_oGraphImageScaler.SetGraphScale(
            (Int32)WpfGraphicsUtil.WpfToPx(compositeWidth, dScreenDpi),
            (Int32)WpfGraphicsUtil.WpfToPx(m_oNodeXLControl.Height, dScreenDpi),
            dScreenDpi);

        // Adjust the NodeXLControl's translate transforms so that the
        // composite will be centered on the same point on the graph that the
        // NodeXLControl is centered on.

        m_oGraphImageCenterer.CenterGraphImage( new Size(compositeWidth,
            m_oNodeXLControl.Height) );

        StackPanel oStackPanel = new StackPanel();
        UIElementCollection oStackPanelChildren = oStackPanel.Children;

        // To avoid a solid black line at the bottom of the header or the top
        // of the footer, which is caused by rounding errors, make the
        // StackPanel background color the same as the header and footer.

        oStackPanel.Background = HeaderFooterBackgroundBrush;

        if (oHeaderLabel != null)
        {
            oStackPanelChildren.Add(oHeaderLabel);
        }

        // Wrap the NodeXLControl in a Grid to clip it.

        m_oGrid = new Grid();
        m_oGrid.Width = m_oNodeXLControl.Width;
        m_oGrid.Height = m_oNodeXLControl.Height;
        m_oGrid.ClipToBounds = true;
        m_oGrid.Children.Add(m_oNodeXLControl);

        oStackPanelChildren.Add(m_oGrid);

        foreach (Image oLegendImage in oLegendImages)
        {
            oStackPanelChildren.Add(oLegendImage);
        }

        if (oFooterLabel != null)
        {
            oStackPanelChildren.Add(oFooterLabel);
        }

        Size oCompositeSize = new Size(compositeWidth, compositeHeight);
        Rect oCompositeRectangle = new Rect(new Point(), oCompositeSize);

        oStackPanel.Measure(oCompositeSize);
        oStackPanel.Arrange(oCompositeRectangle);
        oStackPanel.UpdateLayout();

        return (oStackPanel);
    }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:101,代码来源:GraphImageCompositor.cs

示例3: MergeImages

        public void MergeImages(string fl)
        {
            Canvas canvas = new Canvas();

            if (zoom == 3)
            {
                canvas.Width = 512 * 6.5;
                canvas.Height = 512 * 3.25;
            }
            else if (zoom == 2)
            {
                canvas.Width = 512 * 3.25;
                canvas.Height = 512 * 1.625;
            }

            canvas.Measure(new Size((int)canvas.Width, (int)canvas.Height));
            canvas.Arrange(new Rect(new Size((int)canvas.Width, (int)canvas.Height)));
            int Height = ((int)(canvas.ActualHeight));
            int Width = ((int)(canvas.ActualWidth));

            StackPanel mainPanel = new StackPanel();
            mainPanel.Orientation = Orientation.Vertical;

            for (int j = 0; j < limitY; j++)
            {
                StackPanel ph = new StackPanel();
                ph.Orientation = Orientation.Horizontal;
                for (int k = 0; k < limitX; k++)
                {
                    Image stackImg = new Image();
                    stackImg.Source = FromStream(previousJumpBuffStream[j][k]);
                    ph.Children.Add(stackImg);
                }
                mainPanel.Children.Add(ph);
            }

            mainPanel.UpdateLayout();
            canvas.Children.Add(mainPanel);

            canvas.UpdateLayout();

            RenderTargetBitmap _RenderTargetBitmap = new RenderTargetBitmap((int)Width, (int)Height, 96, 96, PixelFormats.Pbgra32);
            _RenderTargetBitmap.Render(mainPanel);

            ImageSource mergedImages = _RenderTargetBitmap;

            SaveImg(mergedImages, fl);

            Stream s = File.OpenRead(fl);
            buffStream.Add(s);
        }
开发者ID:MatejHrlec,项目名称:OculusView,代码行数:51,代码来源:StreetView.xaml.cs

示例4: WrapElement


//.........这里部分代码省略.........
            TimedTextStyle currentStyle = element.CurrentStyle;
            Size size2 = currentStyle.Extent.ToPixelSize(new Size?(effectiveSize));
            double width = size2.Width;
            double height = size2.Height;
            if ((currentStyle.Direction == Direction.RightToLeft) && !directionApplied)
            {
                text = new string(text.ToCharArray().Reverse<char>().ToArray<char>());
            }
            double num3 = ((currentStyle.FontSize.Unit == LengthUnit.PixelProportional) || (currentStyle.FontSize.Unit == LengthUnit.Cell)) ? effectiveSize.Height : height;
            TextBlock textblock = this.GetStyledTextblock(currentStyle, width, num3, false);
            this.SetContent(textblock, text);
            Border border = new Border {
                Background = GetCachedBrush(currentStyle.BackgroundColor)
            };
            FrameworkElement contentElement = null;
            double num4 = currentStyle.OutlineWidth.ToPixelLength(effectiveSize.Height);
            if (this.CaptionsOverrideSettings == null)
            {
                return offset;
            }
            switch (this.CaptionsOverrideSettings.CharacterEdgeAttribute)
            {
                case CaptionsOverrideCharacterEdges.Default:
                    if (num4 <= 0.0)
                    {
                        contentElement = textblock;
                        break;
                    }
                    contentElement = this.ApplyUniformEdge(currentStyle, width, num3, text, textblock);
                    break;

                case CaptionsOverrideCharacterEdges.NoAttribute:
                    contentElement = textblock;
                    break;

                case CaptionsOverrideCharacterEdges.Raised:
                    contentElement = this.ApplyRaisedEdge(currentStyle, width, num3, text, textblock);
                    break;

                case CaptionsOverrideCharacterEdges.Depressed:
                    contentElement = this.ApplyDepressedEdge(currentStyle, width, num3, text, textblock);
                    break;

                case CaptionsOverrideCharacterEdges.Uniform:
                    contentElement = this.ApplyUniformEdge(currentStyle, width, num3, text, textblock);
                    break;

                case CaptionsOverrideCharacterEdges.DropShadow:
                    contentElement = this.ApplyDropShadowEdge(currentStyle, width, num3, text, textblock);
                    break;
            }
            contentElement.Opacity = (currentStyle.Visibility == Visibility.Visible) ? currentStyle.Opacity : 0.0;
            border.Child = contentElement;
            p.Children.Add(border);
            string str = text;
            string str2 = string.Empty;
            double effectiveWidth = textblock.GetEffectiveWidth();
            if (((offset + effectiveWidth) <= size2.Width) || (currentStyle.WrapOption != TextWrapping.Wrap))
            {
                offset += effectiveWidth;
                return offset;
            }
            if ((text.Length <= 0) || (text.IndexOf(' ') >= 0))
            {
                while ((offset + textblock.GetEffectiveWidth()) > size2.Width)
                {
                    int num7 = str.LastIndexOf(' ');
                    if (num7 < 0)
                    {
                        this.SetAllContent(contentElement, text);
                        return 0.0;
                    }
                    str2 = text.Substring(num7 + 1);
                    str = text.Substring(0, num7);
                    this.SetAllContent(contentElement, str);
                }
                p = this.NewPanel(parent, ref offset, element, align);
                return this.WrapElement(parent, ref p, offset, str2, element, align, true);
            }
            if ((offset != 0.0) && (effectiveWidth < size2.Width))
            {
                p.Children.Remove(border);
                p = this.NewPanel(parent, ref offset, element, align);
                return this.WrapElement(parent, ref p, 0.0, text, element, align, true);
            }
            int length = text.Length - 1;
            str = text.Substring(0, length);
            str2 = text.Substring(length);
            this.SetAllContent(contentElement, str);
            while ((offset + textblock.GetEffectiveWidth()) > size2.Width)
            {
                length--;
                str = text.Substring(0, length);
                str2 = text.Substring(length);
                this.SetAllContent(contentElement, str);
                p.UpdateLayout();
            }
            p = this.NewPanel(parent, ref offset, element, align);
            return this.WrapElement(parent, ref p, offset, str2, element, align, true);
        }
开发者ID:BigBri41,项目名称:TWCTVWindowsPhone,代码行数:101,代码来源:VideoPlayerCaptionBlockRegion.cs

示例5: WrapElement

        private double WrapElement(StackPanel parent, ref StackPanel p, double offset, string text, CaptionElement element, TextAlignment align, bool directionApplied = false)
        {
            if (text == null || text == "") return offset;

            var effectiveSize = this.GetEffectiveSize();
            var style = element.CurrentStyle;
            var panelSize = style.Extent.ToPixelSize(effectiveSize);
            double panelWidth = panelSize.Width;
            double panelHeight = panelSize.Height;

            if (style.Direction == Direction.RightToLeft && !directionApplied)
            {
                text = new string(text.ToCharArray().Reverse().ToArray());
            }

            double height = style.FontSize.Unit == LengthUnit.PixelProportional || style.FontSize.Unit == LengthUnit.Cell ? effectiveSize.Height : panelHeight;
            TextBlock textblock = GetStyledTextblock(style, panelWidth, height, false);
            SetContent(textblock, text);

            Border border = new Border();
            border.Background = GetCachedBrush(style.BackgroundColor);
            FrameworkElement contentElement;

            double outlineWidth = style.OutlineWidth.ToPixelLength(effectiveSize.Height);
            if (outlineWidth > 0)
            {
                Grid cnv = new Grid();

                // do outline image up and to left
                TextBlock tb2 = GetStyledTextblock(style, panelWidth, height, true);
                SetContent(tb2, text);
                cnv.Children.Add(tb2);
                tb2.RenderTransform = new TranslateTransform() { X = -1, Y = -1 };

                // do outline image down and to right
                tb2 = GetStyledTextblock(style, panelWidth, height, true);
                SetContent(tb2, text);
                cnv.Children.Add(tb2);
                tb2.RenderTransform = new TranslateTransform() { X = 1, Y = 1 };

                // do outline image up and to right
                tb2 = GetStyledTextblock(style, panelWidth, height, true);
                SetContent(tb2, text);
                cnv.Children.Add(tb2);
                tb2.RenderTransform = new TranslateTransform() { X = 1, Y = -1 };

                // do outline image down and to left
                tb2 = GetStyledTextblock(style, panelWidth, height, true);
                SetContent(tb2, text);
                cnv.Children.Add(tb2);
                tb2.RenderTransform = new TranslateTransform() { X = -1, Y = 1 };

                // add the main text
                cnv.Children.Add(textblock);

                // add the border
                contentElement = cnv;
            }
            else
            {
                contentElement = textblock;
            }

            border.Child = contentElement;
            p.Children.Add(border);

            string head = text;
            string tail = string.Empty;
            double elementWidth = textblock.GetEffectiveWidth();
            if (offset + elementWidth > panelSize.Width && style.WrapOption == TextWrapping.Wrap)
            {
                if (text.Length > 0 && text.IndexOf(' ') < 0)
                {
                    if (offset != 0 && elementWidth < panelSize.Width)
                    {
                        p.Children.Remove(border);
                        p = NewPanel(parent, ref offset, element, align);
                        return WrapElement(parent, ref p, 0, text, element, align, true);
                    }
                    int idx = text.Length - 1;
                    head = text.Substring(0, idx);
                    tail = text.Substring(idx);
                    SetAllContent(contentElement, head);
                    while (offset + textblock.GetEffectiveWidth() > panelSize.Width)
                    {
                        idx--;
                        head = text.Substring(0, idx);
                        tail = text.Substring(idx);
                        SetAllContent(contentElement, head);
                        p.UpdateLayout();
                    }
                    p = NewPanel(parent, ref offset, element, align);
                    return WrapElement(parent, ref p, offset, tail, element, align, true);
                }
                while (offset + textblock.GetEffectiveWidth() > panelSize.Width)
                {
                    int idx = head.LastIndexOf(' ');
                    if (idx < 0)
                    {
                        SetAllContent(contentElement, text);
//.........这里部分代码省略.........
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:101,代码来源:CaptionBlockRegion.xaml.cs

示例6: Print

        private void Print(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                PrintDialog dlg = new PrintDialog();
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new PrintPluginViewModel(configData);
                var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(item.FileName));

                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                System.Printing.PrintCapabilities capabilities = dlg.PrintQueue.GetPrintCapabilities(dlg.PrintTicket);
                var PageWidth = (int)capabilities.PageImageableArea.ExtentWidth;
                var PageHeight = (int)capabilities.PageImageableArea.ExtentHeight;

                var panel = new StackPanel
                {
                    Margin = new Thickness(conf.Margin),
                };

                var image = new Image
                {
                    Source = BitmapLoader.Instance.LoadImage(outfile, PageWidth > PageHeight ? PageWidth : PageHeight, conf.Rotate ? 90 : 0),
                    Width = PageWidth ,
                    Height = PageHeight,
                    Stretch = Stretch.Uniform,
                };

               
                panel.Children.Add(image);
                panel.UpdateLayout();
                panel.Measure(new Size(PageWidth, PageHeight));
                panel.Arrange(new Rect(new Point(0, 0), panel.DesiredSize));
                panel.UpdateLayout();
                dlg.PrintVisual(panel, item.Name);
                image.Source = null;
                panel.Children.Clear();
                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error print file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }

            configData.IsRedy = true;            
        }
开发者ID:avencherus,项目名称:digiCamControl,代码行数:54,代码来源:PrintPlugin.cs


注:本文中的System.Windows.Controls.StackPanel.UpdateLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。