问题列表 - 第33537页

查询Android中的噪音级别

我想开发一个小型Android应用来测量当前的噪音水平(可能是dB).但是我不知道在libs中要寻找什么.我不想记录噪音.有人可以给我一个指针,看看哪些类?

android microphone noise

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

在32位计算机上编译.NET 4.0框架时,SetWindowsHookEx返回0

即使应用程序没有对焦,我也试图设置一个低级别的Windows键盘钩子来抓住三个按键.为此,我将SetWindowsHookEx称为

// Create an instance of HookProc.
KeyboardHookProcedure = new HookProc(KeyboardHookProc);
//install hook
hKeyboardHook = SetWindowsHookEx(
    WH_KEYBOARD_LL,
    KeyboardHookProcedure,
    Marshal.GetHINSTANCE(
        Assembly.GetExecutingAssembly().GetModules()[0]),
    0);
//If SetWindowsHookEx fails.
if (hKeyboardHook == 0)
{
    //Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set. 
    int errorCode = Marshal.GetLastWin32Error();
    //do cleanup
    Stop(false, true, false);
    //Initializes and throws a new instance of the Win32Exception class with the specified error. 
    throw new Win32Exception(errorCode);
}
Run Code Online (Sandbox Code Playgroud)

这曾经使用.NET Framework 3.5在32位和64位计算机上运行,​​但在升级到.NET Framework …

keyboard-hook com-interop setwindowshookex c#-4.0

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

Emacs中键映射的两种方法

我发现有两种方法可以在emacs中设置密钥:golbal-set-key和define-key.它们是一样的吗?或者两种方法之间是否有任何利弊?

(global-set-key (kbd "C-c C-f") 'my-find-file)
(define-key global-map
  "\C-ck" 'hello)
Run Code Online (Sandbox Code Playgroud)

emacs

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

如何在ItemsControls中使用AlternationIndex?

我已经看到一些文章,展示了如何使用AlternationIndexListBoxES或ListViewS,但我花了几个小时试图让基交替背景色ItemsControl类和似乎没有任何工作.ListBox我看到的所有样本都ListBoxItem用作设置背景的样式的目标类型AlternationIndex- 就像MSDN中的这样:

<Grid>
    <Grid.Resources>
        <Style x:Key="alternatingWithTriggers" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="Blue"/>
            <Setter Property="Foreground" Value="White"/>
            <Style.Triggers>
                <Trigger Property="ListBox.AlternationIndex" Value="1">
                    <Setter Property="Background" Value="CornflowerBlue"/>
                    <Setter Property="Foreground" Value="Black"/>
                </Trigger>
                <Trigger Property="ListBox.AlternationIndex" Value="2">
                    <Setter Property="Background" Value="LightBlue"/>
                    <Setter Property="Foreground" Value="Navy"/>
                </Trigger>
            </Style.Triggers>
        </Style>

    </Grid.Resources>
    <ListBox AlternationCount="3" ItemsSource="{StaticResource data}" 
             ItemContainerStyle="{StaticResource alternatingWithTriggers}">
    </ListBox>
</Grid>
Run Code Online (Sandbox Code Playgroud)

我想使用它,ItemsControl因为我不想要选择功能,我认为重新设置a ListBox来隐藏它可能不是最好的选择.

这是我尝试的事情之一:

<DataTemplate DataType="{x:Type vm:ObservableCollectionItem}">
    <Grid>
        <!-- some content here -->
    </Grid>
</DataTemplate>

<!-- …
Run Code Online (Sandbox Code Playgroud)

wpf styles itemscontrol mvvm

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

无法让自己的主机在NServiceBus上工作

使用版本2.0.0.1219

我试图通过NServiceBus和VS2010自我托管订阅者和发布者.程序运行并初始化但我无法获取消息.发布者表现得像是发帖,没有错误,但订阅者什么都没收到.

这是订户配置

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
  </configSections>

  <!-- in order to configure remote endpoints use the format: "queue@machine" 
       input queue must be on the same machine as the process feeding off of it.
       error queue can (and often should) be on a different machine.
  -->

  <MsmqTransportConfig InputQueue="loads" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>

  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="NServiceMessage" Endpoint="loads"/>
    </MessageEndpointMappings>
  </UnicastBusConfig>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Run Code Online (Sandbox Code Playgroud)

和发布者配置

<?xml version="1.0"?>
<configuration>

  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
    <section name="UnicastBusConfig" …
Run Code Online (Sandbox Code Playgroud)

.net c# nservicebus servicebus

6
推荐指数
2
解决办法
2224
查看次数

如何读取linux etc/passwd文件并比较C中用于身份验证的用户输入名称

这是我写的程序,任何人都可以告诉它有什么问题,因为无论我给出什么输入,它都显示有效的用户.

#include<stdio.h>
#include<string.h>
#define max_size 20
void main()
{
 File *Fptr;
 char username[max_size];
 char line[20];
 if((fptr=fopen("/etc/passwd","r"))==NULL)
 { 
   printf("cannot open file");
 }
 else
  {
      fptr=fopen("/etc/passwd","r");
      fputs("enter the username",stdout);
      fflush(stdout);
      fgets(username,sizeof username,stdin);
      while((fgets(line,sizeof(line),fptr))!=NULL)
      { 
          if(strcmp(line,username))
          {
             printf("%s valid user",username);
             break; 
          }
          else
            {
              printf("%s not valid user",username);
            }    
      } 
   fclose(fptr);
  }
}
Run Code Online (Sandbox Code Playgroud)

c

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

Grails的泛型

我要做的是定义一个要求特定类型(List<Integer>)的列表.在类的初始化期间,我放入一个列表,String我希望它抛出一些运行时转换错误.但事实并非如此 - 它运行良好.

这可能是grails 101的东西我确定但有人可以解释为什么这工作,以及我如何强制某些类型在列表中使用?

class Test {
    String name
    List<Integer> numbers
}

def myList = ['a','b','c']
Test myTest = new Test(name:'test', numbers:myList) 
myTest.numbers.each() { print " $it" }

Output:
a  b  c
Run Code Online (Sandbox Code Playgroud)

generics grails groovy

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

使用jquery从span获取文本

给这个HTML,当我点击它时,我想从中获取"August":

<span class="ui-datepicker-month">August</span>
Run Code Online (Sandbox Code Playgroud)

我试过了

$(".ui-datepicker-month").live("click", function () {
    var monthname =  $(this).val();
    alert(monthname);
});
Run Code Online (Sandbox Code Playgroud)

但似乎没有奏效

html jquery

93
推荐指数
4
解决办法
24万
查看次数

更改使用wsimport生成的Web服务客户端上的URL

我正在尝试为访问WSDL描述的Web服务的Java应用程序编写一个模块.源WSDL直接从我认为是ASP.NET Web服务下载; 服务URL以.asmx扩展名结尾,在浏览器中查看服务URL显示可用于下载WSDL的链接.

对我而言,一个关键要求是能够在不重新编译的情况下切换服务URL.给我的URL显然是一个测试服务器,我知道在生产中我将获得一个生产URL使用.我还希望能够自己创建一个模拟服务器进行测试,并保留将来指定新URL的功能,而无需在移动服务时重新编译.实际上,我希望我们的应用程序的安装能够在不同的URL 实例化web服务的多个实例.

但我的概念似乎与wsimport工具为我做的事情不相符.继f1sh的答案在这里,我生成的Java代码从我用这个命令下载WSDL:

wsimport -Xnocompile -keep -b binding.xml wsdlFile.wsdl
Run Code Online (Sandbox Code Playgroud)

我发现生成的代码对我下载的wsdlFile.wsdl有一个硬编码的引用,其中包含服务URL.我们的应用程序不会以通过在运行时编辑WSDL文件来配置它的方式运行.我需要在构建时将代码编译到我的应用程序中,并且可以在实例化时设置服务URL.

我不完全确定为什么WSDL甚至需要在运行时解析; 我的理解是WSDL提供了足够的信息来生成可以访问web服务的代码,所以我不确定它为服务URL以外的生成代码提供了什么,我不知道为什么服务URL没有提供构造函数或可通过生成的Web服务类上的方法进行配置.我肯定错过了什么.

这种情况的一般做法是什么?大多数人会为他们将要使用的每个URL重新生成代码吗?代码是在运行时生成的吗?是否有另一个我可以使用的WSDL工具,它将使用可配置的URL构建客户端代码?

java wsdl web-services wsimport

12
推荐指数
2
解决办法
8929
查看次数

为什么有些对象属性是UnaryExpression和其他的MemberExpression?

根据我使用lambda而不是字符串属性名称问题选择模型属性的答案,想要向集合添加属性,如下所示:

var props = new ExportPropertyInfoCollection<JobCard>();
props.Include(model => model.BusinessInstallNumber).Title("Install No").Width(64).KeepZeroPadding(true);
props.Include(model => model.DeviceName).Title("Device").Width(70);
props.Include(model => model.DateRequested).Title("Request Date").Format("{0:dd/MM/yyyy}").Width(83);
Run Code Online (Sandbox Code Playgroud)

我在Include方法中编写了以下代码:

public class PropertyCollection<T>
{
    public void Include(Expression<Func<T, object>> expression)
    {
        var memberExpression = expression.Body as MemberExpression;
        if (memberExpression != null)
        {
            var pes = new ExportPropertyInfoBuilder {Property = new ExportPropertyInfo {Property = memberExpression.Member as PropertyInfo}};
            Properties.Add(pes.Property.Property.Name, pes.Property);
            return pes;
    }
Run Code Online (Sandbox Code Playgroud)

但是,在运行代码时,我发现一些lambda会按预期产生MemberExpression值,但是其他一些产生了UnaryExpression值.在使用lambdas添加所有属性之前,我必须将第一行代码更改为以下代码:

var memberExpression = expression.Body as MemberExpression ?? ((UnaryExpression) expression.Body).Operand as MemberExpression; …
Run Code Online (Sandbox Code Playgroud)

.net linq linq-expressions

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