小编Nic*_*rin的帖子

Windows 10如何检测是否应该使用黑色或白色标题?

使用Windows 10(10586)的最新稳定版本,Win32窗口标题的颜色会根据窗口镶边的颜色而变化.

例如,如果窗口颜色较暗,则标题使用白色.反之亦然.

所以,既然我想要那种行为,我必须得到窗口铬的颜色亮度.

通过使用此方法:

public static int GetBrightness(this Color c)
{
    return (int)Math.Sqrt(
    c.R * c.R * .241 +
    c.G * c.G * .691 +
    c.B * c.B * .068);
}
Run Code Online (Sandbox Code Playgroud)

而我正在使用其他方法:

public static float GetBrightness2(this Color color)
{
    float num = ((float)color.R) / 255f;
    float num2 = ((float)color.G) / 255f;
    float num3 = ((float)color.B) / 255f;
    float num4 = num;
    float num5 = num;
    if (num2 > num4)
        num4 = num2;
    if (num3 > …
Run Code Online (Sandbox Code Playgroud)

c# colors brightness windows-10

5
推荐指数
0
解决办法
111
查看次数

如何检测证书类型(A1或A3)?

我的机器上有两种类型的证书,一种是A1,另一种是A3,当将其中一种加载到一个X509Certificate2对象中时,如何以编程方式检测它是A1还是A3?

我知道如果没有插入A3证书,则无法访问私钥.考虑到两个证书都有效/已安装并已插入.

编辑

我刚刚发现了这些类型A1并且A3是由特定的国家立法(巴西)定义的,所以让我解释一下有什么区别:

ICP-Brasil允许8种类型的数字证书,分为2个系列(A和S).

A系列(A1,A2,A3和4)由数字签名证书组成,用于Web身份验证,电子邮件,虚拟专用网络(VPN)和电子文档,并验证其信息的完整性.
S系列(S1,S2,S3和S4)包括机密性证书,用于编码文件,数据库,消息和其他机密电子信息.这八种类型根据使用,安全级别和有效性进行区分.
(Gisele Ribeiro,来源)

证书类型

因此,为了更新我的问题,我希望检测证书是否来自具有密钥生成功能的智能卡.

c# certificate .net-4.0 x509certificate2

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

EnumWindows返回已关闭的Windows应用商店应用程序

使用此代码:

internal static List<DetectedWindow> EnumerateWindows()
{
    var shellWindow = GetShellWindow();

    var windows = new List<DetectedWindow>();

    EnumWindows(delegate (IntPtr handle, int lParam)
    {
        if (handle == shellWindow)
            return true;

        if (!IsWindowVisible(handle))
            return true;

        if (IsIconic(handle))
            return true;

        var length = GetWindowTextLength(handle);

        if (length == 0)
            return true;

        var builder = new StringBuilder(length);

        GetWindowText(handle, builder, length + 1);
        GetWindowRect(handle, out Rect rect);

        windows.Add(new DetectedWindow(handle, rect.ToRect(), builder.ToString()));

        return true;
    }, IntPtr.Zero);

    return windows;
}
Run Code Online (Sandbox Code Playgroud)

熟悉的课程:

public class DetectedWindow
{
    public IntPtr Handle { get; …
Run Code Online (Sandbox Code Playgroud)

c# winapi

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

使文本在自动宽度 div 内换行

我在垂直列表上有一堆响应式 img 元素(它们根据图像和视口大小调整大小)。

每个图像都需要在底部进行描述,但不应水平扩展容器。(我目前无法将文本换行到新行)

在第一个示例中,文本扩展了容器的宽度。对于第二个示例,我必须添加<br>标签来模拟我想要的。

例子

有没有办法控制文本元素的换行(通过使用 CSS)?

顺便说一句,这是本示例的 JSFiddle。

html css word-wrap twitter-bootstrap

4
推荐指数
1
解决办法
9045
查看次数

更改 Xamarin.Forms 应用中顶部和底部栏(ControlsBar、StatusBar)的颜色

无论如何,即使需要平台特定的代码,也可以更改顶部栏(蓝色)和底部栏(黑色)的颜色?

我希望添加对明暗模式的支持,因此我希望能够在运行时进行更改。

安卓

c# xaml xamarin.forms

4
推荐指数
1
解决办法
1896
查看次数

图像的无限横向滚动动画

我正在尝试来回动画(或无限向右滚动)一堆图像,但我面临一个问题,当动画开始(以及当它反转时)时,图像隐藏在视图之外。

那是因为我正在使用translate(-100%).

如果可能的话,我希望不依赖于了解图像大小或限制视口大小来完成这项工作。

(忽略动画的速度,稍后我将设置更长的持续时间)

 .slideshow {
  height: 150px;
  /*max-width: 800px;*/ /*The width of the page cannot be a problem*/
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}

.slideshow > div {
  height: 150px;
  width: 2000px; /*I don't want to have to input a width.*/
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  transform: translate3d(0, 0, 0);
}

.move > img {
  height: 150px;
}

.slideshow .move {
animation: moveSlideshow 10s linear infinite alternate-reverse;
} …
Run Code Online (Sandbox Code Playgroud)

html css animation css-animations

4
推荐指数
1
解决办法
2474
查看次数

如何只获取可以复制的文件?

我有这行代码:(使用LINQ)

//string folder <-- folder browser dialog.
listFiles = Directory.GetFiles(folder, "*.xml",
              SearchOption.AllDirectories).Select(
                    fileName => Path.GetFullPath(fileName)).ToList();
Run Code Online (Sandbox Code Playgroud)

但有时我的程序会找到受保护的文件,例如系统文件甚至无法打开的系统文件夹.

我怎样才能超越这个问题:

只获取打开/免费文件夹的文件名.

c# file .net-3.5 winforms

3
推荐指数
1
解决办法
188
查看次数

了解ConfigureAwait

试图了解我什么时候应该使用ConfigureAwait().
根据书:

当一个async方法在等待后恢复时,默认情况下它将在相同的上下文中恢复执行。如果该上下文是 UI 上下文并且大量异步方法在 UI 上下文上恢复,则这可能会导致性能问题。

解决方案

为避免在上下文中恢复,请等待结果ConfigureAwait()并为其continueOnCapturedContext参数传递 false :

async Task ResumeWithoutContextAsync()
{
    await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);

    //This method discards its context when it resumes.
}
Run Code Online (Sandbox Code Playgroud)

什么是上下文以及如何查看ConfigureAwait()示例应用程序中的变化:

static async Task ResumeWithoutContextAsync()
{
    await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(true);
    Console.WriteLine("ManagedThreadId {0}", Thread.CurrentThread.ManagedThreadId);

    //This method discards its context when it resumes.
}

static void Main(string[] args)
{
    ResumeWithoutContextAsync();

    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

我以为上下文是Thread,但事实并非如此。

c# asynchronous

3
推荐指数
1
解决办法
2742
查看次数

这些 FFmpeg APNG 编码器预测方法是什么意思?

通过运行ffmpeg -h encoder=apng,我得到了这个:

APNG encoder AVOptions:
  -dpi               <int>        E..V..... Set image resolution (in dots per inch) (from 0 to 65536) (default 0)
  -dpm               <int>        E..V..... Set image resolution (in dots per meter) (from 0 to 65536) (default 0)
  -pred              <int>        E..V..... Prediction method (from 0 to 5) (default none)
     none                         E..V.....
     sub                          E..V.....
     up                           E..V.....
     avg                          E..V.....
     paeth                        E..V.....
     mixed                        E..V.....
Run Code Online (Sandbox Code Playgroud)

这些用 指定的预测方法有什么区别-pred

我在 ffmpeg.org 或其他地方找不到任何文档。

png ffmpeg image-compression apng

3
推荐指数
1
解决办法
1172
查看次数

如何在 WPF 中创建斜角渐变边框

我正在尝试创建一个带有斜角边框的圆形末端进度条。我的进度条看起来像我想要的,但我很难使边框看起来是斜角的。有人可以帮我解决这个问题吗?

我试图让它看起来像这样的图像就在这里!斜角边框

我当前的 Window XAML 代码如下:

<Window x:Class="SplashDemo2.ProgressBarWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ProgressBarWindow" Height="100" Width="500">

    <Window.Resources>
        <Style x:Key="ProgressBarStyle" TargetType="ProgressBar">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ProgressBar">
                        <Border BorderBrush="#1D4276" BorderThickness="5" 
                                CornerRadius="15" Padding="0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0.9" StartPoint="0.5,0">
                                    <GradientStop Color="#FFEAEAEA" Offset="0.9"/>
                                    <GradientStop Color="#FF646464"/>
                                </LinearGradientBrush>
                            </Border.Background>

                            <Grid x:Name="PART_Track" >
                                <Rectangle x:Name="PART_Indicator" 
                                           HorizontalAlignment="Left" 
                                           RadiusX="10" RadiusY="10">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.5,0.9" StartPoint="0.5,0">
                                            <GradientStop Color="#FF226494" Offset="0.9"/>
                                            <GradientStop Color="#FFEBEFFA"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

    <ProgressBar Value="50" Width="380" Height="25" 
                 Style="{StaticResource ProgressBarStyle}" 
                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Window>
Run Code Online (Sandbox Code Playgroud)

谁能帮我让边框看起来像图片一样?非常感谢。

wpf xaml linear-gradients

2
推荐指数
1
解决办法
1万
查看次数