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


C# Rect.ToSize方法代码示例

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


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

示例1: ExportTextShape

        private static void ExportTextShape(RadDiagramTextShape shape, Rect enclosingBounds, RadFixedPage page)
        {
            var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height);

            var transformGroup = new TransformGroup();
            transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 });
            transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y });

            var position = new MatrixPosition(transformGroup.Value);

            FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle), true);
            containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize()));

            if (shape.Content != null)
            {
                var center = bounds.Center();
                ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, center.Y - s.Height / 2); });
            }
        }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:19,代码来源:ExportHelper.cs

示例2: ExportDiagram

        public static RadFixedPage ExportDiagram(RadDiagram diagram, Rect pageSize)
        {
            RadFixedPage page = new RadFixedPage();
            page.Size = pageSize.ToSize();

            var orderedContainers = diagram.Items.Select(i => diagram.ContainerGenerator.ContainerFromItem(i)).OrderBy(c => c.ZIndex);
            foreach (var container in orderedContainers)
            {
                if (container.Visibility != Visibility.Visible) continue;

                var shape = container as RadDiagramShape;
                if (shape != null)
                {
                    ExportShape(shape, pageSize, page);
                    continue;
                }

                var textShape = container as RadDiagramTextShape;
                if (textShape != null)
                {
                    ExportTextShape(textShape, pageSize, page);
                    continue;
                }

                var containerShape = container as RadDiagramContainerShape;
                if (containerShape != null)
                {
                    ExportContainerShape(containerShape, pageSize, page);
                    continue;
                }

                var connection = container as RadDiagramConnection;
                if (connection != null)
                {
                    ExportConnection(connection, pageSize, page);
                    continue;
                }
            }

            return page;
        }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:41,代码来源:ExportHelper.cs

示例3: ExportContent

        private static void ExportContent(ContentControl control, Rect bounds, double angle, RadFixedPage page, Func<Size, Point> positionFunc, string contentString = null)
        {
            string text = contentString ?? control.Content.ToString();
            if (string.IsNullOrWhiteSpace(text)) return;
            FixedContentEditor textEditor = new FixedContentEditor(page);
            var block = new Block();

            // Set the text and graphic properties.
            block.TextProperties.FontSize = control.FontSize;
            block.TextProperties.RenderingMode = RenderingMode.Fill;
            block.TextProperties.TrySetFont(control.FontFamily, control.FontStyle, control.FontWeight);
            block.GraphicProperties.FillColor = ColorHelper.GetColor(control.Foreground, control.Opacity, bounds);
            block.GraphicProperties.StrokeColor = block.GraphicProperties.FillColor;

            // Measure the text.
            block.InsertText(text);
            var boundsSize = bounds.ToSize();
            var availableSize = new Size(boundsSize.Width - control.Padding.Left - control.Padding.Right, boundsSize.Width - control.Padding.Top - control.Padding.Bottom);
            var textSize = block.Measure(availableSize);
            var position = positionFunc(textSize);
            var textGroup = new TransformGroup();
            textGroup.Children.Add(new RotateTransform() { Angle = angle, CenterX = textSize.Width / 2, CenterY = textSize.Height / 2 });
            textGroup.Children.Add(new TranslateTransform() { X = position.X, Y = position.Y });
            textEditor.Position = new MatrixPosition(textGroup.Value);

            textEditor.DrawBlock(block, availableSize);
        }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:27,代码来源:ExportHelper.cs

示例4: ExportContainerShape

        private static void ExportContainerShape(RadDiagramContainerShape container, Rect enclosingBounds, RadFixedPage page)
        {
            var bounds = new Rect(container.Bounds.X - enclosingBounds.X, container.Bounds.Y - enclosingBounds.Y, container.Bounds.Width, container.Bounds.Height);

            var transformGroup = new TransformGroup();
            transformGroup.Children.Add(new RotateTransform() { Angle = container.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 });
            transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y });

            var position = new MatrixPosition(transformGroup.Value);

            FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, container, bounds, container.BorderBrush, container.RotationAngle), true);
            containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize()));

            containerEditor.GraphicProperties.StrokeThickness = 0.5;
            var headerHeight = container.ContentBounds.Y - container.Bounds.Y - DiagramConstants.ContainerMargin;
            containerEditor.DrawRectangle(new Rect(new Point(0, headerHeight), new Size(bounds.Width, 0.5)));

            if (container.IsCollapsible)
            {
                var buttonTop = headerHeight / 2 - 2.5;
                var buttonLeft = bounds.Width - 20;
                if (container.IsCollapsed)
                {
                    containerEditor.DrawLine(new Point(buttonLeft, buttonTop), new Point(buttonLeft + 4, buttonTop + 4));
                    containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop + 4), new Point(buttonLeft + 8, buttonTop));
                    if (container.CollapsedContent != null)
                    {
                        var contentHeight = container.ActualHeight - headerHeight;
                        ExportContent(container, bounds, container.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, bounds.Bottom - contentHeight / 2 - s.Height / 2); }, container.CollapsedContent.ToString());
                    }
                }
                else
                {
                    containerEditor.DrawLine(new Point(buttonLeft, buttonTop + 4), new Point(buttonLeft + 4, buttonTop));
                    containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop), new Point(buttonLeft + 8, buttonTop + 4));
                }
            }

            if (container.Content != null)
            {
                ExportContent(container, bounds, container.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, bounds.Top + headerHeight / 2 - s.Height / 2); });
            }
        }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:43,代码来源:ExportHelper.cs

示例5: MeasureOverride

        protected override Size MeasureOverride(Size availableSize)
        {
            if (Children == null || Children.Count < 1)
             {
            return new Size (0, 0);
             }

             var resultingRect = new Rect ();

             object accumulatedState = null;
             try
             {
            var count = Children.Count;
            for (var iter = 0; iter < count; ++iter)
            {
               var child = Children[iter];
               child.Measure (availableSize);
               var desiredSize = child.DesiredSize;
               var args = new LayoutItemEventArgs
               {
                  LayoutItemState = LayoutItemState.IsMeasuring,
                  UiElement = child,
                  AccumulateState = accumulatedState,
                  State = GetUIElementState (child),
                  AvailableSize = availableSize,
                  DesiredSize = desiredSize,
                  Count = count,
                  Index = iter,
                  Transform = child.RenderTransform,
               };

               OnItemLayout (args);

               accumulatedState = args.AccumulateState;
               var childRect = (args.Transform ?? s_identityTransform).TransformBounds (new Rect (0, 0, desiredSize.Width, desiredSize.Height));
               resultingRect.Union (childRect);
            }

            return availableSize.Merge (resultingRect.ToSize ());
             }
             finally
             {
            Common.Dispose (accumulatedState);
             }
        }
开发者ID:mrange,项目名称:281slides,代码行数:45,代码来源:Panels.cs

示例6: CreateImage

 internal WriteableBitmap CreateImage(Rect bounds)
 {
     return BitmapUtils.CreateWriteableBitmap(this.itemHost as UIElement, bounds, bounds.ToSize(), null, new Thickness());
 }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:4,代码来源:SwimlaneDiagram.cs


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