command

WPF: Bind to command from ControlTemplate

让人想犯罪 __ 提交于 2019-12-04 04:03:00
I am trying to add a button to a custom ListView (MyListView) which triggers a command (MyCustomCommand) defined in MyListView. I have added the button (and a title text) by applying a ControlTemplate. The problem is that I have not found a way to trigger MyCustomCommand when clicking the button. What I eventually want to achieve is to open a Popup or ContextMenu where I can select which columns should be visible in the ListView. Here's my template source: <Style TargetType="local:MyListView"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:MyListView"> <Border

How to combine “lsof -i :port” and “kill pid” in bash

丶灬走出姿态 提交于 2019-12-04 03:40:02
问题 How do i combine these two commands in the bash: lsof -i :port kill pid The first one returns the PID i want to kill to release the port. The second one kills the returned PID. I am doing this because I don´t know of any way to kill a jetty webserver within the Netbeans IDE on OSX. Is there a way? 回答1: You can use $(): kill $(lsof -t -i:port) 回答2: You can use kill -9 `lsof -t -i:port` 来源: https://stackoverflow.com/questions/33101725/how-to-combine-lsof-i-port-and-kill-pid-in-bash

Find files and print only their parent directories

落花浮王杯 提交于 2019-12-04 00:49:30
I have the following commands. Wherever the .user.log file is present, we need to print the parent directories (i.e hht and wee1 .) How can this be done? $ cd /nfs//office/ && find . -name '.user.log' ./hht/info/.user.log ./wee1/info/.user.log Am I missing something here. Surely all this regex and/or looping is not necessary, a one-liner will do the job. Also "for foo in $()" solutions will fail when there are spaces in the path names. Just use dirname twice with xargs, to get parent's parent... # make test case mkdir -p /nfs/office/hht/info mkdir -p /nfs/office/wee1/info touch /nfs/office/hht

Binding commands to ToggleButton Checked and Unchecked events

别来无恙 提交于 2019-12-04 00:26:33
问题 I have a ToggleButton in my C# WPF application where I would like to bind one Command to the Checked event and one Command to the Unchecked event. What I have currently is the following: <ToggleButton Name="btnOpenPort" Style="{StaticResource myOnOffBtnStyle}" Content="Open Port" Checked="btnOpenPort_Checked" Unchecked="btnOpenPort_Unchecked" IsChecked="{Binding Path=PortViewModel.PortIsOpen, Mode=OneWay}" Canvas.Left="75" Canvas.Top="80" Height="25" Width="100"/> But this is not what I aim

How to run “brew” command in windows..?

☆樱花仙子☆ 提交于 2019-12-03 23:39:13
It shows " 'brew' is not recognized as an internal or external command " in windows command prompt. I am trying to install codeigniter-reactjs-example from github , where first command is brew . How to run this command to install that project in Windows..? Vivek Homebrew is MacOSX only command line installer application and it doesn't exist for Windows. The Windows alternatives are: Chocolatey Npackd Scoop OneGet for Windows 10 Source: https://laracasts.com/discuss/channels/laravel/homebrew-install-on-windows-os It shows "'brew' is not recognized as an internal or external command" in windows

How to decouple mode switching and commands

邮差的信 提交于 2019-12-03 22:50:23
问题 How to decouple a Mode (normally expressed by enums) from its implementation in commands and their relationship? Is their a good pattern describing the loose binding between a mode switch (int, enum, string, ...) and its command calls? I want to add modes via config, so this must be (dynamically) easy extendable (without programming). I already know the command pattern (ICommand in C#/.Net). It could be an Dictionary of Commands and their related mode number, but what about the switching

How to use NSTask run terminal commands in loop in consistent environment?

◇◆丶佛笑我妖孽 提交于 2019-12-03 22:30:54
I want to use NSTask to simulate the Terminal to run commands. The codes as follows. It can get input in loop and return the process output. int main(int argc, const char * argv[]) { @autoreleasepool { while (1) { char str[80] = {0}; scanf("%s", str); NSString *cmdstr = [NSString stringWithUTF8String:str]; NSTask *task = [NSTask new]; [task setLaunchPath:@"/bin/sh"]; [task setArguments:[NSArray arrayWithObjects:@"-c", cmdstr, nil]]; NSPipe *pipe = [NSPipe pipe]; [task setStandardOutput:pipe]; [task launch]; NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile]; [task waitUntilExit];

Java Runtime.getRunTime().exec(CMD) not supporting pipes

有些话、适合烂在心里 提交于 2019-12-03 22:22:57
问题 I'm attempting to write a program that will display and be able to update your IP address settings using a JFrame window. I am looking at running this purely on windows so I'm attempting to be able to use the netsh windows command to retrieve/set details. The windows command: netsh interface ip show config name="Local Area Connection" | Find "IP" returns exactly what I want it to, however the code I have written will not work past the pipe, it will only work if I write up to the "Local Area

WPF Routed Commands and ShowDialog Windows

心已入冬 提交于 2019-12-03 22:15:52
I was wondering how a window opened through ShowDialog is treated in the Visual Tree. For example, Window A opens Window B through a ShowDialog. When firing a routed command on Window B, Window A does not receieve the command (even though it is listening for it). Is there any way to make this work? Thanks! Jon We run into this situation all the time in our application. We use the Window.Owner property and ICommandSource.CommandTarget property for this. For example, in Window A: DialogWindow windowB = new DialogWindow(); windowB.Owner = this; windowB.ShowDialog(); Then, in DialogWindow, all the

Customizing PowerShell Prompt - Equivalent to CMD's $M$P$_$+$G?

感情迁移 提交于 2019-12-03 20:57:44
I've started to "play around" with PowerShell and am trying to get it to "behave". One of the things I'd like to do is to customize the PROMPT to be "similar" to what "$M$P$_$+$G" do on MS-Dos: A quick rundown of what these do: Character | Description $m The remote name associated with the current drive letter or the empty string if current drive is not a network drive. $p Current drive and path $_ ENTER-LINEFEED $+ Zero or more plus sign (+) characters depending upon the depth of the pushd directory stack, one character for each level pushed $g > (greater-than sign) So the final output is