我有一个像心脏或任何随机形状的不规则形状的图片.我可以在视觉上使它透明,但我需要让它只在形状区域上可点击.我听说我应该使用"Region",但我无法弄清楚如何.
我试图搜索所有非空,透明或空的像素,并用它们创建一个点数组,但我无法创建/重塑当前控制区域.我正在尝试制作一个自定义控件,你可以选择一个按钮或图片,它们是不规则形状并且彼此靠近.
这是我正在处理的事情:
正如您在图片中看到的,有8个不同的部分(假设右侧和左侧组合).正如你所看到的,它们彼此接近,其中一些甚至适合其他人之间的空白区域.
我的目标是,例如,如果我点击Pectorals(图中的红色区域),它将变为彩色版本,并且会运行一堆其他代码.
问题是,默认情况下,当我们添加任何带有a的图片时PictureBox
,它将Rectangle
从它的边界开始围绕该图片创建.因此,如果我将两张图片(如图所示)放在一起,则一个空区域会阻止我点击另一张图片.
ClickEvent
由于这个问题,它也引发了错误的对象.
我正在尝试设置"提升事件区域",我假设我们Graphic Region
在图片存在的地方调用它.我可以用一个循环来收集像素的位置,该循环确定该图片的哪个坐标具有"颜色"(意味着它是图片的一部分,我想要点击的区域)但是我不能用该数据限制该区域.
我正在努力实现的一个例子:https://www.youtube.com/watch?v = K_JzL4kzCoE
做这个的最好方式是什么?
A级
class A{
...
}
Run Code Online (Sandbox Code Playgroud)
B级
class B:A{
...
}
Run Code Online (Sandbox Code Playgroud)
C级
class C:A{
B[] bArray{get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我想检查 T 是否具有 S 的属性类型,创建 S 的实例并分配给该属性:
public Initial<T,S>() where T,S : A{
if(T.has(typeof(S))){
S s=new S();
T.s=s;
}
}
Run Code Online (Sandbox Code Playgroud) 我已经安装了最新版本的 JetBrains Rider 1 EAP 并使用 VS2015 创建的 project.json 打开 .NetCore 项目,我已成功加载,但是当创建新的 .NetCore Web 项目或在旧版本中使用 .csproj 添加新的 .NetCore 类库时项目与project.json库加载失败
Project 'ClassLibrary' load failed: Cannot load the project with the current MSBuild toolset.
Please ensure MSBuild 15.0 is installed.
Run Code Online (Sandbox Code Playgroud)
我还安装了microsoft的 .NetCore SDK 和运行时
如何在带有scan
扩展的程序集中注册所有接口,而无需在 ASP.NET Core 2 中将所有接口分开写入?
在结构图中:
Scan(_ =>
{
// Declare which assemblies to scan
_.Assembly("StructureMap.Testing");
});
Run Code Online (Sandbox Code Playgroud)
在巡查员中:
collection.Scan(scan => scan
// We start out with all types in the assembly of ITransientService
.FromAssemblyOf<ITransientService>()
// AddClasses starts out with all public, non-abstract types in this
// assembly. These types are then filtered by the delegate passed to the
// method. In this case, we filter out only the classes that are assignable
// to ITransientService.
.AddClasses(classes => classes.AssignableTo<ITransientService>()) …
Run Code Online (Sandbox Code Playgroud) dependency-injection inversion-of-control .net-core asp.net-core scrutor
c# ×3
.net-core ×2
asp.net-core ×2
controls ×1
generics ×1
msbuild ×1
properties ×1
reflection ×1
region ×1
rider ×1
scrutor ×1
transparency ×1
typeof ×1
winforms ×1