在使用VisualTreeHelper.HitTest甚至隐藏元素的WPF 中找到.要跳过这些元素并仅返回可见的结果,我创建了HitTestFilter如下内容:
///This Filter should cut all invisible or not HitTest Enabled Elements
private static HitTestFilterBehavior MyHitTestFilter(DependencyObject target)
{
var uiElement = target as UIElement;
if (uiElement != null){
if(!uiElement.IsHitTestVisible || !uiElement.IsVisible))
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
return HitTestFilterBehavior.Continue;
}
Run Code Online (Sandbox Code Playgroud)
这个过滤器完成了他的工作,但我想知道默认的WPF HitTesting在这种情况下做了什么?它是否使用类似的过滤器?这样做还有其他更好的选择吗?
澄清一个简短的描述:

在图像中有
如果我有这样的布局并在Button2的绿色区域中执行鼠标点击,WPF会跳过Button2并且Button1上会出现click事件.
如果我在没有前面描述的过滤器的情况下进行手动HitTesting,我将得到Button2作为结果.
所以问题是,WPF使用的默认行为/过滤器是什么?
在此先感谢您的任何建议.
我正在尝试实现一个能够旋转视频的MFT.旋转本身将在变换函数内完成.为此,我需要更改输出帧大小,但我不知道如何做到这一点.
作为起点,我使用了Microsoft提供的MFT_Grayscale示例.我将此MFT作为转换节点包含在部分拓扑中
HRESULT Player::AddBranchToPartialTopology(
IMFTopology *pTopology,
IMFPresentationDescriptor *pSourcePD,
DWORD iStream
)
{
...
IMFTopologyNode pTransformNode = NULL;
...
hr = CreateTransformNode(CLSID_GrayscaleMFT, &pTransformNode);
...
hr = pSourceNode->ConnectOutput(0, pTransformNode, 0);
hr = pTransformNode->ConnectOutput(0, pOutputNode, 0);
...
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,此代码正在运行.应用灰度mft并按预期工作.无论如何,我想改变这个mft来处理视频旋转.所以我们假设我想将视频旋转90度.为此,必须切换输入框架的宽度和高度.我尝试了不同的东西,但没有一个按预期工作.基于此线程中的第一条注释如何更改Media Foundation Transform输出帧(视频)大小?我开始改变SetOutputType的实现.我在GetOutputType中调用GetAttributeSize来接收实际的frame_size.当我尝试设置新的frame_size时失败(当开始播放时我收到hresult 0xc00d36b4(指定的数据无效,不一致或此对象不支持)
HRESULT CGrayscale::SetOutputType(
DWORD dwOutputStreamID,
IMFMediaType *pType, // Can be NULL to clear the output type.
DWORD dwFlags
)
{ ....
//Receive the actual frame_size of pType (works as expected)
hr = MFGetAttributeSize(
pType,
MF_MT_FRAME_SIZE,
&width,
&height
));
...
//change …Run Code Online (Sandbox Code Playgroud)