小编Nic*_*rin的帖子

Visual Studio XAML编辑器忽略属性选项卡中的按键

有时,Window在XAML编辑器中编辑我的时候,属性选项卡只是锁定它自己接收任何键盘按下,我甚至无法添加事件,我必须重新启动VS再次工作.我仍然可以使用XAML代码进行编辑,但属性变为只读.

我是唯一一个遇到这个问题的人吗?任何解决方法?

顺便说一句:桌面WPF

wpf xaml visual-studio-2013

13
推荐指数
1
解决办法
3955
查看次数

使用InkCanvas中的Strokes剪辑BitmapImage

我的任务是创建一个"Cinemagraph"功能,用户必须使用a InkCanvas来选择所需的区域,以便为动画/视频的其余部分绘制应保持不变的所选像素(或者,选择应该"活着"的像素").

例: 来自JohanBlomström

我正在考虑Stroke从中获取集合InkCanvas并使用它来剪切图像并与未触及的图像合并.

我怎样才能做到这一点?我可以轻松地从磁盘加载图像,但如何根据笔划剪切图像?

更多细节:

绘制并选择应保持静态的像素后,我有一个Stroke集合.我可以得到Geometry每个人Stroke,但我可能需要合并所有几何.

基于合并Geometry,我需要反转(Geometry)并使用剪辑我的第一帧,稍后剪辑的图像准备好,我需要与所有其他帧合并.

我的代码到目前为止:

//Gets the BitmapSource from a String path:
var image = ListFrames[0].ImageLocation.SourceFrom();
var rectangle = new RectangleGeometry(new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(image.Width, image.Height)));
Geometry geometry = Geometry.Empty;

foreach(Stroke stroke in CinemagraphInkCanvas.Strokes)
{
    geometry = Geometry.Combine(geometry, stroke.GetGeometry(), GeometryCombineMode.Union, null);
}

//Inverts the geometry, to clip the other unselect pixels of the BitmapImage.
geometry = Geometry.Combine(geometry, rectangle, GeometryCombineMode.Exclude, null); …
Run Code Online (Sandbox Code Playgroud)

c# wpf canvas clip

11
推荐指数
1
解决办法
828
查看次数

Avalonia 的透明度和点击率

我正在考虑将我在 WPF 中制作的应用程序移植到 Avalonia。

我的第一个要求是启用点击透明度(与<Window Background="{x:Null}" WindowStyle="None" AllowsTransparency="True"WPF 中相同)。

我已经尝试过了,但它看起来不起作用(至少在 Windows 上)。

ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaChromeHints="NoChrome"
ExtendClientAreaTitleBarHeightHint="-1"
TransparencyBackgroundFallback="Transparent"
Background="{x:Null}"
Run Code Online (Sandbox Code Playgroud)

目标操作系统将是 Windows、macOS 和 Linux。因此,在将其安装在虚拟机中或购买新设备之前,我需要知道是否可以在所有操作系统中都具有该功能。

.net cross-platform avaloniaui avalonia

8
推荐指数
1
解决办法
1497
查看次数

甚至是现代应用程序的最佳选择

我有一个记录程序,TopMost除了打开一个Modern app (Windows 8)或那个时,它一直都在Start Screen.

可以使桌面应用程序保持在现代应用程序之上,例如Magnifying Glass工具:

最顶层

现在,问题是在WPF窗口中使用TopMost选项和/或API调用将无法与现代应用程序一起使用.

我在尝试什么:

static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
static readonly IntPtr HWND_TOP = new IntPtr(0);
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int …
Run Code Online (Sandbox Code Playgroud)

c# wpf topmost

7
推荐指数
1
解决办法
215
查看次数

从Github存储库上次更新文件时获取

我可以使用GitHub v3 API获取文件内容(如果它是文件夹,我可以获取文件列表). 例:

https://api.github.com/repos/[Owner]/[Repository]/contents/[Folder]
Run Code Online (Sandbox Code Playgroud)

但是如何知道文件上次更新的时间?那有API吗?

github github-api

7
推荐指数
2
解决办法
1182
查看次数

从 Windows API 获取正确的光标图像

我正在尝试使用 获取光标数据(掩码和颜色,如果可用)作为字节数组GetDIBits(),具有正确的大小和正确的动画帧,但事实证明它是不可靠的。

另外,我希望获得或能够模拟光标中可用的多个帧,例如使用DrawIconEx()传递cursorStep 参数时可能发生的情况。

基本上,我试图模拟的是 的行为的一部分IDXGIOutputDuplication::GetFramePointerShape(),即获取包含当前光标内容的缓冲区(byte[]),而无需依赖 DirectX 库。

所以,我想要:

  1. 获取光标数据作为 a byte[],即使掩码工作(已解决)。
  2. 获取正确大小的光标数据,而不是固定的 32x32px 光标。
  3. 获取光标的实际动画帧。

正如 DXGI 方法在我使用 OutputDuplication 时提供的那样,但就我而言,我没有使用。


1)正确获取光标掩码(已解决):

TL;DR:我的数据解释错误。

我调用GetDIBits()一次,传递 null 作为缓冲区参数以获取颜色/蒙版图像的详细信息,然后第二次调用以获取图像。

它可以正常处理彩色图像,但返回错误的数据大小和掩模图像的错误图像内容。

这是比较和代码示例。以“2”结尾的文件是通过使用创建的,System.Drawing.Bitmap.FromHBitmap()而其他文件是从 获得的GetDiBits()

这是一个比较

由于某种原因,返回掩码的GetDIBits()此数据 ( )。BitmapInfoHeader此外,仅返回 128 个字节(如果蒙版有两个框架,例如 I-Beam/文本光标,则返回 256 个字节),这对于 32x32px 或 32x64px 蒙版来说太小了。

双位数结果

这是我到目前为止的代码(它是 C#):

WindowDeviceContext = User32.GetWindowDC(IntPtr.Zero);

//The parameter passed in the structs is just to be able to calculate the …
Run Code Online (Sandbox Code Playgroud)

c# winapi mouse-cursor

7
推荐指数
1
解决办法
1180
查看次数

具有最大长度的小数的正则表达式

我不确定这是否可以使用正则表达式.我将尝试使用正则表达式,但如果不可能,我将切换到双重验证.

我的数据库(postgresql)接受decimal15,6(最多15位,最多6位小数),所以如果我有10个整数位,我可以有5位小数.小数分隔符被忽略.

我目前有这个正则表达式(逗号是小数点分隔符):

^\d{1,15}(\,\d{1,6})?$

它不验证总长度,只验证左边的数字.但既然用户也可以输入点数(千位分隔符),我有这个怪物:

^((\d+)|(\d{1,3}(\.\d{3})+)|(\d{1,3}(\.\d{3})(\,\d{3})+))((\,\d{4})|(\,\d{3})|(\,\d{2})|(\,\d{1})|(\,))?$

这个不接受超过3位小数.我可以编辑这个以接受6次decimais,但我仍然无法验证总长度.

是否可以验证号码的总长度?忽略点和逗号.

正则表达式应该接受:

1234567890,123456

1.234.567.890,123456

当然还有其他任何中间价值观:

1.234,12,1,0,1...

c# regex

6
推荐指数
1
解决办法
2958
查看次数

使用 IDistributedCache 列出并删除给定组中的所有缓存条目

IDistributedCache我在设置中存储用户生成的一些密钥。

密钥的有效期很长,如果用户知道其中的每一个,则可以由用户手动撤销:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDistributedMemoryCache();
    //...
}

//ControllerBase:

//Adding the key:
await _cache.SetAsync(userKey, userId, new DistributedCacheEntryOptions 
{ 
    AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(10)
});

//Removing the key:
await _cache.RemoveAsync(key);
Run Code Online (Sandbox Code Playgroud)

现在,我想要做的是能够列出缓存中仍然存在的由其中一位用户创建的所有密钥。另外,我希望能够批量删除它们。

现在有这样的功能吗?也许有取消令牌?我怎样才能做到这一点?

c# redis .net-4.7.2 asp.net-core-2.2

6
推荐指数
1
解决办法
5823
查看次数

DesktopDuplication API 中的 ReleaseFrame() 调用无效

我的应用程序的用户在使用DesktopDuplication API.

开始捕获时,应用程序崩溃,因为应用程序无法释放OutputDuplication.

用户的PC详细信息:

Windows 10.0.18362.0, 64 bits
Nvidia GeForce GTX 960, driver version 441.66
Run Code Online (Sandbox Code Playgroud)

错误日志:

? Message - 
HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], 
Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.

? Type - 
    SharpDX.SharpDXException
? Source - 
    SharpDX
? TargetSite - 
    Void CheckError()
? StackTrace …
Run Code Online (Sandbox Code Playgroud)

c# sharpdx desktop-duplication

6
推荐指数
1
解决办法
626
查看次数

类中的 Getter 始终是未定义的

我有一个包含 getter 的打字稿类(它只是多个属性的串联)。

\n

由于某种原因,getter 总是返回 undefined,即使里面的属性都已定义。

\n
import { IdDisplayName } from './';\n\nexport class Person {\n  id?: number;\n  age!: number;\n  personType!: IdDisplayName<number>;\n  name!: string = '';\n\n  public get description() : string {\n    return this.name + ' \xe2\x80\xa2 ' + (this.personType.displayName ?? 'No type')\n      + '/' + this.age;\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我以 Json 形式接收数据并转换为 Person,如下所示:

\n
let person = result as Person;\nlet desc = person.description; //undefined, never enters the description getter code.\n
Run Code Online (Sandbox Code Playgroud)\n

getter undefined typescript

5
推荐指数
1
解决办法
2986
查看次数