问题标签 [design-surface]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
260 浏览

c# - 需要从 .NET Winforms 控件的 PropertyGrid 中隐藏仅设计器的属性(第二部分)

这是一个后续问题:Need To Hide A Designer-Only Property From PropertyGrid For A .NET Winforms Control

我已经用我自己的实现替换了默认的 TypeDescriptorFilterService(太酷了!),并且 FilterProperties 事件处理程序正在触发。我看到上一个问题如何帮助隐藏那些特定的 TableLayoutPanel 属性。

现在我对隐藏某些属性的项目有更一般的要求。我目前的具体目标是隐藏我的子类 Windows 窗体对象的“(名称)”属性(我的 .NET 项目利用设计器在内部管理对象名称,并且不希望允许用户在某些条件下更改甚至查看该值)。为了隐藏 Name 属性(实际上显示(Name)在属性网格上),我添加了以下代码:

我的MyExtendedDesignerObjects.Form继承自 System.Windows.Forms.Form。虽然我的 Form 对象 ( MyExtendedDesignerObjects.Form) 也是一个 IDesignerFilter,但我不知道如何/在何处连接其设计器的 PreFilterProperties 事件处理程序。

我想一旦我可以连接这个预过滤器逻辑,那么我就可以管理我为这个项目制定的所有属性网格属性可见性目标。

感谢您的阅读。

0 投票
1 回答
179 浏览

c# - BeginResize/EndResize Event for Control on WinForms Design Surface

TLDR: I would like to know how I can create a hook into a begin-resize and an end-resize event for a design-time control instance on the designer surface.


Detail: Specifically, I am working with a design surface produced by a BasicLoader in the System.Design and System.Component.Design .NET namespaces. Specifically, I'm working a design-time instance of the TableLayoutPanel. That control exposes a SizeChanged event and a Resize event--alas, both fire during the resize operation--that is, while the control is being resized--as well as when the resize operation is complete. I therefore have no way of know when the resize operation began and when it officially ended.

One way to tackle this would be to detect a mouse-down event along with a resize event--but it's unclear to me how I can detect a mouse-down event on any of the grab handles of a control being resized.

For the records, I revisited the BehaviorService and saw that it exposes BeginDrag, EndDrag, and Synchronize--I see nothing in that service that would help me with BeginResize/EndResize events.

So, ideally, I would like to subscribe to BeginResize/EndResize events for any designer instance of a Winform control, but I would be happy if the provided answer covered only my need to have these events attached to a designer instance of the TableLayoutPanel control...

Any thoughts?

0 投票
1 回答
217 浏览

c# - 在 Winforms Designer 中为选定控件保留装饰字形

TLDR:我正在寻找正确的方法来为设计表面上的特定控件的并列图形的渲染计时,以便在选择该控件时始终在装饰字形之前绘制图形。

这个问题与 Winforms 的控件设计者有关:当用户将控件放置在设计图面上时,我想在控件的客户区上方显示一个图形。通过覆盖其 OnPaint 事件处理程序,然后使用可用于绘制桃色矩形的 e.Graphics 对象,我在某种程度上成功地为 TableLayoutPanel (TLP) 控件做到了这一点。下面是显示结果的图像:跨越控件宽度且高 35 像素的绘制图形 - 请记住,这是放置在设计图面上的控件的设计器实例(使用 BasicLoader 创建):

在此处输入图像描述

但是,在设计器中,如果我调整控件的大小,图形总是在调整大小的字形下方(上面有北/南和西/东箭头的字形):

在此处输入图像描述

在某些情况下,我尝试创建和维护各种布尔标志来抑制 OnPaint 消息。例如,我设置了一个标志来指示控件刚刚调整大小(要了解我是如何做到的,请参阅我最近的问题:BeginResize/EndResize Event for Control on WinForms Design Surface)以抑制图形的绘制,但是这不起作用,因为在我清除标志后不可避免地会引发 OnPaint 事件。我不想用我尝试使用/设置它们的所有标志和位置的详细信息来回答这个问题,但我只想说我煞费苦心地花了几个小时进行实验——但无济于事。我得出结论,一定有更好的方法。

当我绘制图形时,如何确保字形保持在顶部?

谢谢!

0 投票
0 回答
36 浏览

c# - 自定义 Win Forms Designer 的主要快捷键

尝试在自定义 Win Forms 设计器中使快捷键适用于标准选择命令(剪切、复制、粘贴)。

我已经重写了 IMenuCommandService 以生成适用于剪切、复制、粘贴命令的 ContextMenuStrip。但是,分配给每个 ToolStripMenuItem 的快捷方式仅在 ContextMenuStrip 已经可见/具有焦点时才起作用:

要使快捷键正常工作还需要什么额外的功能?