小编Kin*_*pin的帖子

在Treeview中禁用SelectedImageIndex

我在winforms和imagelist中使用treeview-control来显示treeview-elements的不同状态.

但我不想使用所选元素来使用不同的图像.

有没有办法在TreeView控件中禁用SelectedImageIndex?

如果尝试在每次选择后更改selectedimageindex.像这样的东西:

    private void TreeView1AfterSelect(object sender, TreeViewEventArgs e)
    {
        treeView1.SelectedImageIndex = treeView1.SelectedNode.ImageIndex;
    }
Run Code Online (Sandbox Code Playgroud)

但是在每次选择之后,这会导致控件的闪烁非常难看.

c# treeview image winforms

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

在mschart轴上更改日期时间格式

我正在使用mschart在一段时间内显示一些值.

它看起来像这样:

一只忙碌的猫http://img52.imageshack.us/img52/2610/mscharti.jpg

正如您所看到的,第一个值是从15:11开始,最后一个值是从16:10开始但是在x轴上显示的是天数.我怎么能改变这个?

编辑:将XValueType更改为ChartValueType.Time会导致:

一只忙碌的猫http://img525.imageshack.us/img525/7642/timeformat.jpg

c# format datetime linechart mschart

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

将Int转换为BCD字节数组

我想使用BCD将int转换为byte [4]数组.

有问题的int将来自设备ID,他需要通过serialport与设备通话.

是否有任何预制功能可以做到这一点,或者你能给我一个简单的方法吗?

例:

int id= 29068082
Run Code Online (Sandbox Code Playgroud)

输出:

byte[4]{0x82, 0x80, 0x06, 0x29};
Run Code Online (Sandbox Code Playgroud)

.net c# bytearray bcd

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

通过 ssh 远程调试 dotnet 核心应用程序但无法附加

我正在尝试从 Visual Studio 2017 调试另一台机器(linux)上的 dotnet 核心应用程序

我可以通过 ssh 连接到远程机器。我通过以下命令安装了调试器。

sudo apt-get install unzip
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v vs2017u5 -l ~/vsdbg
Run Code Online (Sandbox Code Playgroud)

我无法附加到 dotnet 进程(请参阅日志)。有什么我可以尝试的吗?

附

ProtocolException: Failed to attach to process: Unknown Error: 0x80131c08

Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.PendingRequest`1.InvokeErrorFuncCore(Object args, ProtocolException ex) Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.PendingRequestBase.InvokeErrorFunc(Object args, ProtocolException ex) CallSite.Target(Closure , CallSite , IPendingRequest , Object , ProtocolException ) System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2) Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.HandleIncomingResponse(String msg) Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.HandleIncomingMessage(String msg) Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ProcessMessageBody() Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ReaderThreadProc()

1> ERROR: Failed to attach to process: Unknown Error: 0x80131c08 1> WARNING: …

c# linux remote-debugging visual-studio .net-core

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

使用 FromBody 在 WebAPI 中建模的 JSON 对象和简单类型

我正在创建一个 Web Api 方法,该方法应该接受 JSON 对象和简单类型。但所有参数始终是null.

我的 json 看起来像

{
"oldCredentials" : {
    "UserName" : "user",
    "PasswordHash" : "myCHqkiIAnybMPLzz3pg+GLQ8kM=",
    "Nonce" : "/SeVX599/KjPX/J+JvX3/xE/44g=",
    "Language" : null,
    "SaveCredentials" : false
},
"newPassword" : "asdf"}
Run Code Online (Sandbox Code Playgroud)

我的代码如下所示:

[HttpPut("UpdatePassword")]
[Route("WebServices/UsersService.svc/rest/users/user")]
public void UpdatePassword([FromBody]LoginData oldCredentials, [FromBody]string newPassword)
{
  NonceService.ValidateNonce(oldCredentials.Nonce);

  var users = UserStore.Load();
  var theUser = GetUser(oldCredentials.UserName, users);

  if (!UserStore.AuthenticateUser(oldCredentials, theUser))
  {
    FailIncorrectPassword();
  }

  var iv = Encoder.GetRandomNumber(16);
  theUser.EncryptedPassword = Encoder.Encrypt(newPassword, iv);
  theUser.InitializationVektor = iv;

  UserStore.Save(users);
}
Run Code Online (Sandbox Code Playgroud)

c# json asp.net-core asp.net-core-webapi

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

在运行时确定.NET标准DLL中的框架

在.NET Standard项目中,有一种方法可以确定DLL是在.NET Core中运行还是在运行时运行常规.NET Framework?

我想为不同的.NET平台处理不同的事情.

c# .net-framework-version .net-core .net-standard

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

WPF棱镜中的单元测试确认

我正在使用Prism的Confirmation类来询问用户确认.当我进行单元测试时,确认的返回值始终为false.也许我可以公开InteractionRequest的setter.我的代码现在看起来像这样,我的单元测试应该验证调用this.copyService.Execute.

public InteractionRequest<Confirmation> CopyProjectConfirmationRequest { get; private set; }

    bool confirmationResult = false;
    DialogConfirmation dialogConfirmation = new DialogConfirmation
                                              {
                                                Title = "Copy and Convert Project",
                                                Content = string.Format("This Project was created with Version {0} to be used with currentVersion({1}) it must be converted should it copyed and converted Project", projectVersion, toolVersion),
                                                ConfirmButtonText = "Copy & Convert",
                                                DeclineButtonText = "Cancel"
                                              };

    this.CopyProjectConfirmationRequest .Raise(dialogConfirmation, cb => { confirmationResult = cb.Confirmed; });

    if (confirmationResult)
    {
      this.copyService.Execute(this.Model);
    }
Run Code Online (Sandbox Code Playgroud)

c# wpf unit-testing prism confirmation

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

在AspNetCore中使用GlobalExceptionHandler和自定义中间件

app.UseExceptionHandler(GlobalErrorHandler)在AspNetCore中使用,之后是一个自定义中间件.单独使用它们时它们可以正常工作,但是当同时使用它们时,异常会在我的自定义中间件中抛出并导致调用崩溃.发生这种情况await _next.Invoke(context).我也尝试使用ExceptionFilter,但结果相同.我的全局异常处理看起来像这样.有没有办法阻止异常冒泡?

  app.UseCustomMiddleware();
  app.UseExceptionHandler(GlobalErrorHandler);
  app.UseMvc();


private void GlobalErrorHandler(IApplicationBuilder applicationBuilder)
{
  applicationBuilder.Run(
  async context =>
     {
       context.Response.ContentType = "text/html";
       var ex = context.Features.Get<IExceptionHandlerFeature>();
       if (ex != null)
       {
         string errorMessage;
         var webFault = ex.Error as WebFaultException<string>;
         if (webFault != null)
         {
           context.Response.StatusCode = (int)webFault.StatusCode;
           errorMessage = webFault.Detail;
         }
         else
         {
           if (ex.Error is UnauthorizedAccessException)
           {
             context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
             errorMessage = string.Empty;
           }
           else
           {
             context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
             errorMessage = ex.Error.Message + new StackTrace(ex.Error, true).GetFrame(0).ToString();
           }

           _logger.Error(errorMessage, ex.Error); …
Run Code Online (Sandbox Code Playgroud)

exception-handling asp.net-core asp.net-core-middleware

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

转换角度C#

我想转换转换为另一个系统的圆上的旋转角度.源系统位于左侧,目标位于右侧.我可以通过哪种操作转换这些角度?

在此输入图像描述

c# math geometry angle

0
推荐指数
1
解决办法
151
查看次数