小编Dev*_*per的帖子

WPF应用程序中的任务栏丑陋图标

在我的WPF应用程序中,任务栏中的图标看起来非常难看.

设计师给我发了一些PNG,比如:

32x32,64x64,96x96,128x128,192x192,256x256,512x512.

我需要做什么才能获得goodloking任务栏图标?

谢谢!

wpf icons

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

ThreadStart和Action之间的区别

有人知道之间的区别

Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(() =>
{
Run Code Online (Sandbox Code Playgroud)

Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
Run Code Online (Sandbox Code Playgroud)

.net c# wpf

10
推荐指数
2
解决办法
1209
查看次数

WPF中的多个转换效果

我需要在WPF中通过c#应用多个转换效果.

我在下面尝试过代码,但我只看到了最后一个效果,而不是两者一起.

任何线索,如果有可能吗?

XAML

<Grid>
   <Rectangle Fill="#FFF4F4F5" Name="rect" HorizontalAlignment="Left" Height="225" Margin="84,39,0,0" Stroke="Black" VerticalAlignment="Top" Width="299"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

C#

SkewTransform skewTransform1 = new SkewTransform(45, 0, -50, 50);
rect.RenderTransform = skewTransform1;

RotateTransform rotateTransform  = new RotateTransform(30);
rect.RenderTransform = rotateTransform;
Run Code Online (Sandbox Code Playgroud)

.net c# wpf transform

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

针对Self Host Web API Windows服务验证HTTP .NET客户端

我通过Self Host Web API 找到了关于客户端/服务器实现的精彩文章http://www.asp.net/web-api/overview/older-versions/self-host-a-web-api

我想知道这个模型(Self Host Web API)的正确身份验证方法.

我是否使用了承载令牌身份验证?还有其他方法吗?

或者例如http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api

我有以下工作要求:

  1. C#http客户端必须连接到Self Host Web API Windows服务并发送文件.

  2. 连接必须100%安全.

那么如何保护WebAPI,任何线索?

.net asp.net self-host-webapi

10
推荐指数
1
解决办法
1060
查看次数

如何在ASP.NET Core项目中包含对程序集的引用

我有这条线

string sConnectionString = ConfigurationManager.ConnectionStrings["Hangfire"].ConnectionString;
Run Code Online (Sandbox Code Playgroud)

它需要包含 System.Configuration

我必须在项目的哪个地方添加引用,System.Configuration因为我找不到一个经典的地方去做呢References

在此输入图像描述

.net c# assembly-references visual-studio-2015 asp.net-core

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

使用AForge.Net在WPF应用程序上实现WebCam

我正在写一个WPF应用程序,我需要显示一个Webcam feed.我能够使用AForge框架轻松完成这项工作.但是当我从计算机更改为另一台计算机时,相同的代码不能以相同的方式工作.

在第一个网络摄像头提供完美的工作,但在另一个,这不会发生,饲料有很多延迟,应用程序无法正常工作.

这是代码:

    private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Bitmap img = (Bitmap)eventArgs.Frame.Clone();

        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Render, (SendOrPostCallback)delegate
            {
                IntPtr hBitmap = img.GetHbitmap();
                System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    hBitmap,
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());

                DeleteObject(hBitmap);

                img.Dispose();
                GC.Collect();
                image1.Source = bitmapSource;

            }, null);

    }
Run Code Online (Sandbox Code Playgroud)

这段代码非常简单,它以一种形式从网络摄像头获取一个new_frame Bitmap,我需要做的是将它转换为一个BitmapSource,所以我可以在WPF的图像框架中显示.我认为这种转换是造成这种混乱的原因,但我不明白为什么它在计算机中起作用而在另一种情况下却不起作用.

计算机规格几乎相同,处理器是相同的,以及系统内存.

我的问题是关于性能,这个代码在一台计算机上运行顺畅,网络摄像头提供应该呈现,当我将它移植到另一台PC时,这不会发生.

wpf webcam aforge

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

如何从模态窗口调用主WPF窗口的方法?

如何从模态窗口调用主WPF窗口的方法?

(事实上​​,当我关闭一些模型窗口时,我想启动MainWindow.xaml.cs的一些计时器.)

谢谢!

c# wpf

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

如何处理WPF WebBrowser控件导航异常

假设WPF WebBrowser control显示一些导航错误并且页面未显示.

所以有一个例外WPF WebBrowser control.

我在这里发现了一些类似的问题,但这不是我需要的.

事实上,我需要一些方法和对象,有一个例外,以获得它如何.

我们如何处理它?

谢谢!

PS WinForm WebBrowser控件有一些方法......我们可以做类似的WPF WebBrowser控制吗?

public Form13()
{
     InitializeComponent();

     this.webBrowser1.Navigate("http://blablablabla.bla");

      SHDocVw.WebBrowser axBrowser = (SHDocVw.WebBrowser)this.webBrowser1.ActiveXInstance;
      axBrowser.NavigateError +=
           new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(axBrowser_NavigateError);
}

void axBrowser_NavigateError(object pDisp, ref object URL,
       ref object Frame, ref object StatusCode, ref bool Cancel)
{
     if (StatusCode.ToString() == "404")
     {
         MessageBox.Show("Page no found");
     }
}
Run Code Online (Sandbox Code Playgroud)

PS#2在WPF App下托管WinForm WebBrowser控件不是我认为的答案.

.net c# wpf

9
推荐指数
2
解决办法
7301
查看次数

无法访问OnActionExecuting下的User.Identity(ActionExecutingContext filterContext)

我不知道我错过了什么,但我真的不能参考 User.IdentityOnActionExecuting(ActionExecutingContext filterContext)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using System.Web.Routing;

.....

    public class RealUserAttribute : ActionFilterAttribute
    {
            public override void OnActionExecuting(ActionExecutingContext filterContext)
            {
                 /// if (User.Identity.IsAuthenticated)
Run Code Online (Sandbox Code Playgroud)

有任何线索如何修复它?

.net c# asp.net-mvc authorization authorize-attribute

9
推荐指数
2
解决办法
5005
查看次数

如何在PC中区分耳机与集成音频

我正在使用惊人的NAudio框架来获取音频设备列表.

但正如我所看到的那样,音频设备是PC的集成音频和耳机是不可能的.我的意思是他们有相同的名字,只有当我们插入耳机它才会进入Active状态.

想象一下,如果我使用插入式耳机启动应用程序,我如何知道当前设备是耳机而不是PC的集成音频?

我的意思是我们可以通过NAduio检测到插入的音频设备是外部音频设备并且是耳机本身吗?

var enumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();

// Allows you to enumerate rendering devices in certain states
var endpoints = enumerator.EnumerateAudioEndPoints(
    DataFlow.Render,
    DeviceState.Unplugged | DeviceState.Active);
foreach (var endpoint in endpoints)
{
    Console.WriteLine("{0} - {1}", endpoint.DeviceFriendlyName, endpoint.State);
}

// Aswell as hook to the actual event
enumerator.RegisterEndpointNotificationCallback(new NotificationClient());
Run Code Online (Sandbox Code Playgroud)

NotificationClient的实现方式如下:

class NotificationClient : NAudio.CoreAudioApi.Interfaces.IMMNotificationClient
{
    void IMMNotificationClient.OnDeviceStateChanged(string deviceId, DeviceState newState)
    {
        Console.WriteLine("OnDeviceStateChanged\n Device Id -->{0} : Device State {1}", deviceId, newState);
    }

    void IMMNotificationClient.OnDeviceAdded(string pwstrDeviceId) …
Run Code Online (Sandbox Code Playgroud)

c# naudio headphones audio-device naudio-framework

9
推荐指数
1
解决办法
606
查看次数