如何创造可移动的“自由浮动”面板可以在画布上自由移动并且部分透明
场景是我希望用户在打开的小面板中创建一个形状(添加的形状稍后可以放置在画布上),但为了更好的参考,我希望用户能够移动半透明将面板放在画布上的某个位置,然后使用准确的参考进行绘制。
请告诉我:
使用哪种面板类型
如何通过在移动按钮上单击鼠标来使其移动(不是整个面板,因为拖动将用于绘制线条) )并移动它。
如何使其半透明。
如何让它出现和消失(这应该很简单)
如何以某种方式限制它在画布内的移动,使其不能在功能区上移动
我真的非常希望 WPF 中有一些内置的东西我能够使用,而且我会不必采用困难的方式,即创建一个矩形,然后进行自定义点击对其进行测试以允许用户在该矩形的顶部进行绘制,使该矩形透明,并为该矩形“面板”上的按钮和控件添加图形项。
我问这个问题是因为我从未在任何 Windows 应用程序中看到过这样的功能,并且我不知道为此目的使用什么以及如何实现它。最接近我想要的东西是在 Adobe Acrobat Pro 中,它是当我双击鼠标中键时出现的页面的小预览。它不会移动,也不透明或可以绘制,但在规模和形状方面我想要类似的东西。
The scenario is that i want the user to create a shape in a small panel that opens (the added shape can later be placed on the canvas), but for a better reference, i want the user to be able to move the semi-transparent panel somewhere on the canvas and then draw with the accurate reference.
Please tell me:
Which panel type to use
How to make it moving by clicking the mouse on the move button (not the whole panel as dragging will be used for drawing lines) and move it around.
How to make it semi transparent.
How to make it appear and disappear (this should be pretty simple)
How to somehow limit its movement inside the canvas so it cannot move on the ribbon
And I really really hope there will be something built-in in WPF that i'll be able to use, and i will not have to do it the hard way i.e. create a rectangle, and do customized hit testing on it to allow the user to draw on top of that rectangle, make that rectangle transparent, and add graphics items for the buttons and controls on that rectangle "panel".
I am asking this because i have never seen such feature in any Windows application and i have no idea what to use for this purpose and how to implement it. The closest thing to what i want is in Adobe Acrobat Pro, which is the small preview of the page that appears when i double click with the middle mouse button. It doesn't move, nor it is transparent or can be drawn upon, but scale and shape wise i want something similar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够在主画布内放置第二个
Canvas
,并在其中放置您想要的任何 UserControl 和“视图”。您必须自己处理鼠标单击/拖动才能移动它,但除此之外,它应该非常简单。
You should be able to place a second
Canvas
inside of your main canvas, and place whatever UserControl you'd like with your "view" inside of it.You'll have to handle the mouse click/drag for moving it around yourself, but otherwise, it should be very straightforward.