小编oco*_*odo的帖子

WPF按钮isPressed和isEnabled问题

更新:使用Expression Blend 3

我正在尝试为WPF应用程序中的一类按钮设置IsPressed和IsEnabled(false)属性触发器的样式.

这是一个带有Button的UserControl,使用样式...

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="Kiosk.ButtonTest"
    x:Name="UserControl">

    <Grid x:Name="LayoutRoot">
        <Button HorizontalAlignment="Left" Style="{DynamicResource BlueButton}" VerticalAlignment="Top" Width="155" Content="Button" Height="52.9"/>
    </Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

这是风格片段......

   <!-- Blue Button -->
   <Style x:Key="BlueButton" TargetType="{x:Type Button}">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="{DynamicResource BlueGradient3}"/>
        </Trigger>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="{DynamicResource DarkGradient1}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource BlueGradient3}"/>
        </Trigger>
        <Trigger Property="IsPressed" Value="True">
            <Setter Property="Background" Value="{DynamicResource DarkGradient1}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource BlueGradient1}"/>
        </Trigger>
    </Style.Triggers>
    <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
    <Setter Property="Background" Value="{DynamicResource BlueGradient1}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource BlueGradient2}"/> …
Run Code Online (Sandbox Code Playgroud)

wpf xaml wpf-controls expression-blend

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

WPF:XAML属性声明没有通过Setters设置?

我有一个WPF应用程序,我在代码隐藏中使用依赖属性,我想通过XAML声明设置.

例如

<l:SelectControl StateType="A" Text="Hello"/>
Run Code Online (Sandbox Code Playgroud)

所以在这个例子中我有一个UserControl被调用的SelectControl,它有一个属性StateType,在它的setter中操作一些其他的属性.

为了帮助说明问题,我Text在示例中调用了另一个属性,继续阅读,我将进一步解释.

Codebehind摘录......

public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(String), typeof(SelectControl));

public String Text
{
  get { return (String)GetValue(TextProperty); }
  set { SetValue(TextProperty, value); }
}

public static readonly DependencyProperty StateTypeProperty = DependencyProperty.Register("StateType", typeof(String), typeof(SelectControl));

public String StateType
{
  get { return (String)GetValue(StateTypeProperty) }
  set
    {
      switch (value)
      {
        case "A":
          AnotherPropertyBoolean = true;
          break;
        case "B":
          AnotherPropertyBoolean = false;
          break;
       default:
         // this is only …
Run Code Online (Sandbox Code Playgroud)

wpf setter xaml dependency-properties

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

Bash:重定向已经运行的进程的输出?

可能重复:
使用命令行重定向进程启动后的STDERR/STDOUT?

在Bash中,有一种方法可以在进程运行后捕获/重定向进程的输出(和stderr?)吗?

unix bash pipe process

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

Emacs lisp - 如何尝试/ catch处理错误?

在以下defun ...

(defun re-backward-match-group (rexp &optional n)
  "Grab the previous matches of regexp and return the contents of
  the n match group (first group match if no n arg is specified)"
  (save-excursion
  (unless n
    (setq n 1))
  (when (numberp n)
    (when (re-search-backward-lax-whitespace rexp)
      (when  (= (+ 2 (* n 2)) (length (match-data)))
        (match-string-no-properties n))))))
Run Code Online (Sandbox Code Playgroud)

如果未找到匹配项,则会引发错误 re-search-backward-lax-whitespace

我如何捕获该错误并返回nil或""

emacs error-handling elisp

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

Emacs .dir-locals.el - 设置键绑定

我不确定这是否可行,但我想通过使用设置一些项目特定的键绑定 .dir-locals.el

当然.dir-locals.el要包含一个特殊的设置列表,所以我做不到:

(global-set-key [24 down] 'move-text-down)
Run Code Online (Sandbox Code Playgroud)

我有没有办法注入lambda来运行任意代码或其他一些方法来设置键绑定.dir-locals.el

emacs elisp emacs24

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

Emacs是否有可能在emacs lisp中获得Cx C-(减少缓冲区字体大小)的操作?

我想使用Emacs lisp减少缓冲区的默认字体大小.

目前我正在运行基于进程的缓冲区作为基于emacs-lisp的小应用程序,我希望字体大小C-x C--与应用程序创建缓冲区时的方式相同.

该应用程序有自己的主要模式,所以我应该只设置一个自定义基本面?

(注意:我尝试过,C-x ESC ESC但它显示了之前执行的命令C-x C--.)

emacs elisp

4
推荐指数
2
解决办法
565
查看次数

精炼key-chord.el触发

真的很喜欢,key-chord.el但我只需要短暂的延迟开始按键击键时触发它,在此期间我没有做任何事情.我想知道修改它是否容易key-chord.el.

为什么我希望这很简单,我会尽可能轻松地解释它:

  • 我确实希望将键盘分配给我的"强"手指(没有小指)并且在我的主行(我做触摸式)上的键.因此,当我打字时,我可能会创建一些可能与常用单词/代码冲突的键盘.

  • 我意识到每次发生碰撞时(即键盘都在我不想要的时候踢),这是因为我正在疯狂地修改缓冲区.

这是一个例子......

我是一个快速打字员,所以如果我进入,比如说,"持有",那么在我添加"持有"的"e"和我输入"l"之间永远不会有很长的延迟.所以在这种情况下,当我输入'ld'时,我不希望键和弦开始,这应该是"显而易见的".但是,如果有一个停顿和如果 "LD"是分配的主和弦,然后我打"LD",那么它是非常不可能的,我写的代码/将与"LD"首发文本.所以在后面这种情况下(因为我已经将'ld'分配给了一个键和弦),我确实希望它能够进入.

现在不要误会我的意思:我不是说这会消除每一个案件中可能发生的每一次冲突.我所说的就是,就我而言,这可能会消除99.9%的(已经罕见的)冲突."时间丢失"应该发生一次冲突仍然发生在键和弦的变化与键和弦使我获得的时间量相比可以忽略不计.

代码key-chord.el非常小所以也许这样的添加不会太难?

有没有人知道如何修改key-chord.el以提供这样的功能?(我希望我能正确解释我想做什么)

这是key-chord.el的代码,其中一半是注释:

http://emacswiki.org/emacs/key-chord.el

emacs elisp keyboard-shortcuts

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

Bizzare方法签名,带有未命名的参数(obj-c)

我不知道这个语法是有效的.

+ (void) methodName:(TypeObject *)typeObject1:(TypeObject *)typeObject2;
Run Code Online (Sandbox Code Playgroud)

然后这样称为:

[object methodName:obj1:obj2];
Run Code Online (Sandbox Code Playgroud)

我发现它很丑陋和令人不安,但它构建了.

有人能指出我的参考资料,解释为什么这是有效的.

FWIW这个来自的代码库(继承),充斥着草率,懒惰的东西,几十个拼写错误,看起来像是由没有必要再次阅读它的人格式化.(再次谢谢你解开.)

objective-c method-names

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

通过 ssh 调用远程命令,使用 Ruby,改进语法?

目前我正在使用反引号方法调用远程脚本,它可以工作,但感觉错误且令人讨厌......

`ssh user@host $(echo "~/bin/command \\\"#{parameter}\\\"")`
Run Code Online (Sandbox Code Playgroud)

有人可以给我更好的表达方式吗?

非常感谢。

ruby ssh

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

Rake任务无法加载:环境正常

我正在运行自定义rake任务......

namespace :import do

  desc "Import terms of service as HTML from stdin"
  task :terms => :environment do
    html = STDIN.read
    settings = ApplicationWideSetting.first
    settings.terms_and_conditions = html
    if settings.save
      puts "Updated terms of service"
    else
      puts "There was an error updating terms of service"
    end
  end

end
Run Code Online (Sandbox Code Playgroud)

production环境中运行任务时,ApplicationWideSetting模型报告为未定义 .但是,运行在其它环境(即任务时development,staging,test.)任务运行正常.

在所有环境中,在rails控制台中运行该过程都可以.

有谁知道发生了什么,我可以检查的事情?

注意:我运行任务

puts Rails.env 
Run Code Online (Sandbox Code Playgroud)

要检查shell环境var RAILS_ENV是否正确设置/读取.我也尝试过:环境依赖声明周围有和没有方括号.

其他信息: Rails v3.2.14

进一步的信息:我已经设置了一个全新的rails应用程序,该脚本在任何环境下都能正常运行.由于有问题的安装是一个真实的生产环境,我将不得不设置另一个部署并彻底检查它.更多信息,因为我找到它.

ruby rake ruby-on-rails rake-task

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