如何在WPF中获得围绕多个形状的单个边界矩形 [英] How to get a single Bounding rectangle around multiple shapes in WPF

查看:201
本文介绍了如何在WPF中获得围绕多个形状的单个边界矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在画布上有多个形状.我需要围绕所有选定的形状生成一个边界矩形,而无需更改它们的现有位置.而且我也应该能够调整大小和旋转它们.当我调整整个组的大小时,比例应适用于内部的所有形状.现在,我无法选择多个形状,也可以一次调整它们的大小,但是对于这些选定的形状,我没有公共的边界矩形.
我是WPF的初学者.请发布有关此问题的任何想法.提前谢谢.

Revanth M.

Hi, I have multiple shapes on canvas. I need to generate a bounding rectangle around all the selected shapes without altering their existing positions. And I should be able resize and rotate them as well. When i resize the whole group the scale should apply to all the shapes inside. Right now Im able to select multiple shapes and able to resize them at a time as well, but i dont have common bounding rectangle for those selected shapes.
Im a beginner for WPF.Kindly post any ideas regarding the issue. Thanks in advance.

Revanth M.

推荐答案

请查看这是否适合您的解决方案:

<边框
BorderThickness ="2"
BorderBrush ="Black">
<画布>
您的形状
</画布>
</Border>

在边界上使用ScaleTransform.

(如果打算使用ScaleTransform + LinearTransform,请将它们包装在TransformGroup中)

示例:
< Border BorderBrush ="Black" BorderThickness ="2" Height ="200" Width ="200">
<画布>
< Ellipse Width ="150" Height ="150" StrokeThickness ="2" Stroke ="Black"/>
</画布>
< Border.RenderTransform>
< ScaleTransform ScaleX ="0.5" ScaleY ="0.5"/>
</Border.RenderTransform>
</Border>

让我知道是否需要进一步的澄清,将很乐意为您提供帮助!

如果解决,请标记为答案! :)

谢谢!
Please see if this suits your solution:

<Border
BorderThickness="2"
BorderBrush="Black">
<Canvas>
Your shapes
</Canvas>
</Border>

Use ScaleTransform on your border.

(If you intend to use ScaleTransform + LinearTransform, wrap them in TransformGroup)

Example:
<Border BorderBrush="Black" BorderThickness="2" Height="200" Width="200">
<Canvas>
<Ellipse Width="150" Height="150" StrokeThickness="2" Stroke="Black"/>
</Canvas>
<Border.RenderTransform>
<ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
</Border.RenderTransform>
</Border>

Let me know if you need any more clarifications, will be happy to help!

Mark as answer if this solves! :)

Thanks!


谢谢大家的回复.....无论如何,我都为我的问题找到了解决方案.我得到了用于分组和旋转以及分别调整大小的代码.我做了一些工作,并且能够将它们混合在一起.并尝试使代码更可靠.以下是对我有帮助的链接.再次感谢.


WPF图表设计器:第1部分 [ WPF图表设计器-第4部分 [
Thanks guys for your replies..... Anyways I got the solution for my problem. I got code for grouping and rotation and resize separately. I did some work and able to mix them both into one. And trying to make the code more fool proof. Here are the links that helped me. Thanks once again.


WPF Diagram Designer: Part 1[^]


WPF Diagram Designer - Part 4[^]


这篇关于如何在WPF中获得围绕多个形状的单个边界矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆