public static void Enqueue(AppCommands commandType, IEntityBase entity, ExecutionTrigger trigger, object value, ModifyAction modifyAction) { var command = new QueuedCommand { CommandType = commandType, Target = entity.UniqueId, Status = ExecutionStatus.Pending, TriggerType = trigger, Value = value.ToString(), ModifyAction = modifyAction, DateCreated = DateTime.Now, DateScheduled = DateTime.Now }; ThreadPool.QueueUserWorkItem(delegate { ClientState.Current.DataService.Save(command); switch (trigger) { case ExecutionTrigger.Connection: EventBroker.Publish(AppEvents.RequestCommands); break; case ExecutionTrigger.Send: EventBroker.Publish(AppEvents.RequestSend); break; case ExecutionTrigger.Receive: EventBroker.Publish(AppEvents.RequestReceive); break; } }); }
protected void InitCommands(AppCommands commands) { var mwi = DataContext as MainWorkItem; InputBindings.Add( new InputBinding( commands.Deactivate, new KeyGesture(Key.Escape) )); InputBindings.Add( new InputBinding( commands.Help, new KeyGesture(Key.F1) ) { CommandParameter = true } ); //InputBindings[0].Command = //ButtonExit.Command = commands.Deactivate; //ButtonHelp.Command = commands.Help; //ButtonHelp.CommandParameter = true; //BtnManageApps.Command = commands.ManageApps; //BtnConfigure.Command = commands.Settings; //InputBindings[0].Command = commands.Deactivate; //InputBindings[1].Command = commands.Help; //InputBindings[1].CommandParameter = false; }
public ExtensionBase(string name, int version, AppCommands command) { Name = name; Version = version; this.command = command; }
public static void Send(AppCommands cmd) { if (frm == null) { Initialize(); } frm.Invoke(new MethodInvoker(() => SendMessage(frm.Handle, WM_APPCOMMAND, frm.Handle, (IntPtr)((int)cmd << 16)))); }
/// <summary> /// Load the mapping for this message /// </summary> /// <param name="msg"></param> /// <returns></returns> public Mapping GetMapping(Message msg) { if (controlEnabled && (msg.Msg == Win32.Const.WM_APPCOMMAND)) { AppCommands command = (AppCommands)Win32.Macro.GET_APPCOMMAND_LPARAM(msg.LParam); return(MapFromAppCommand(command)); } return(null); }
public ServiceEndpointOptionSet(string name, AppCommands appCommand) : base(name) { Command = appCommand; #if DEBUG Add("e|endpoint=", "Service endpoint", e => ServiceEndpoint = e); #endif }
private static IntPtr InternalHookDelegate(int code, int wParam, IntPtr lParam) { try { if (code >= 0 && wParam == 256) { KeyboardHookStruct khs = new KeyboardHookStruct(lParam); int keyCode = khs.virtualKey; AppCommands appCommand = KeyCodeToAppCommand((Keys)khs.virtualKey); if (appCommand == AppCommands.None) { if (khs.virtualKey == (int)Keys.LShiftKey || khs.virtualKey == (int)Keys.LControlKey || khs.virtualKey == (int)Keys.RShiftKey || khs.virtualKey == (int)Keys.RControlKey) { return(CallNextHookEx(_hookHandle, code, wParam, lParam)); } if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { keyCode |= 0x00100000; } if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { keyCode |= 0x01000000; } if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { keyCode |= 0x10000000; } } else { keyCode |= (((int)appCommand) << 8); } if (_registered) { byte[] bytes = IrssMessage.EncodeRemoteEventData("Keyboard", String.Format("{0:X8}", keyCode)); IrssMessage message = new IrssMessage(MessageType.ForwardRemoteEvent, MessageFlags.Notify, bytes); _client.Send(message); } if (_stealAppCommands && appCommand != AppCommands.None) { return(new IntPtr(1)); } } } catch (Exception ex) { IrssLog.Error(ex); } return(CallNextHookEx(_hookHandle, code, wParam, lParam)); }
void MakeSingleton() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } }
public bool WndProc(ref Message msg, out Action action, out char key, out Keys keyCode) { action = null; key = (char)0; keyCode = Keys.A; if (controlEnabled) { // we are only interested in WM_APPCOMMAND if (msg.Msg != 0x0319) { return(false); } AppCommands appCommand = (AppCommands)((msg.LParam.ToInt32() >> 16) & ~0xF000); // find out which request the MCE remote handled last if ((appCommand == InputDevices.LastHidRequest) && (appCommand != AppCommands.VolumeDown) && (appCommand != AppCommands.VolumeUp)) { if (Enum.IsDefined(typeof(AppCommands), InputDevices.LastHidRequest)) { // possible that it is the same request mapped to an app command? if (Environment.TickCount - InputDevices.LastHidRequestTick < 500) { return(true); } } } InputDevices.LastHidRequest = appCommand; if (logVerbose) { Log.Info("HID: Command: {0} - {1}", ((msg.LParam.ToInt32() >> 16) & ~0xF000), InputDevices.LastHidRequest.ToString()); } if (!_inputHandler.MapAction((msg.LParam.ToInt32() >> 16) & ~0xF000)) { return(false); } msg.Result = new IntPtr(1); return(true); } return(false); }
private int InternalHookDelegate(int code, int wParam, IntPtr lParam) { if (code >= 0 && wParam == 256) { KeyboardHookStruct khs = new KeyboardHookStruct(lParam); int keyCode = khs.virtualKey; AppCommands appCommand = KeyCodeToAppCommand((Keys)khs.virtualKey); if (appCommand == AppCommands.None) { if (khs.virtualKey == (int)Keys.LShiftKey || khs.virtualKey == (int)Keys.LControlKey || khs.virtualKey == (int)Keys.RShiftKey || khs.virtualKey == (int)Keys.RControlKey) { return(CallNextHookEx(_hookHandle, code, wParam, lParam)); } if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { keyCode |= 0x00100000; } if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { keyCode |= 0x01000000; } if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { keyCode |= 0x10000000; } } else { keyCode |= (((int)appCommand) << 8); } if (_remoteButtonHandler != null) { _remoteButtonHandler(Name, String.Format("{0:X8}", keyCode)); } if (_stealAppCommands && appCommand != AppCommands.None) { return(1); } } return(CallNextHookEx(_hookHandle, code, wParam, lParam)); }
public MainWorkItem() { AMSetttingsFactory.WorkItem = this; _Settings = AMSetttingsFactory.DefaultSettingsBag.Settings; _Commands = new AppCommands(this); _KbrdHook = new KeyboardHook(); //#if RELEASE //_MsHook = new MouseHook(); //#endif _ImageLoader = new AsyncImageLoader(); _MainWindow = new MainWindow(this); _TrayIcon = new WinForms.NotifyIcon(); _AppData = new AppGroup(); _RecycleBin = new DeletedAppCollection(); UpdateRunning = false; }
public static void SendAppCommand(AppCommands command) { if (isInitialized == false) { Initialize(); if (isInitialized == false) { return; } } form.BeginInvoke((Action) delegate { IntPtr handle = form.Handle; SendMessage(handle, WM_APPCOMMAN, handle, (int)command << 16); }); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnKeyDown(object sender, KeyEventArgs e) { if (GUIGraphicsContext.form != null && GUIGraphicsContext.form.Focused == false) { AppCommands appCommand = KeyCodeToAppCommand(e.KeyCode); if (appCommand != AppCommands.None) { int device = 0; int keys = (((int)appCommand & ~0xF000) | (device & 0xF000)); int lParam = (((keys) << 16) | (((int)e.KeyCode))); // since the normal process involves getting polled via WndProc we have to get a tiny bit dirty // and send a message back to the main form in order to get the key press handled without // duplicating action mapping code from the main app Win32API.SendMessage(GUIGraphicsContext.form.Handle, Win32.Const.WM_APPCOMMAND, (uint)GUIGraphicsContext.form.Handle, (uint)lParam); } } }
/// <summary> /// /// </summary> /// <param name="msg"></param> /// <param name="action"></param> /// <param name="key"></param> /// <param name="keyCode"></param> /// <returns></returns> public bool WndProcAppCommand(ref Message msg, out Mapping mappedCommand, bool shouldRaiseAction = true) { mappedCommand = null; AppCommands appCommand = (AppCommands)Win32.Macro.GET_APPCOMMAND_LPARAM(msg.LParam); // find out which request the MCE remote handled last if ((appCommand == InputDevices.LastHidRequest) && (appCommand != AppCommands.VolumeDown) && (appCommand != AppCommands.VolumeUp)) { if (Enum.IsDefined(typeof(AppCommands), InputDevices.LastHidRequest)) { // possible that it is the same request mapped to an app command? if (Environment.TickCount - InputDevices.LastHidRequestTick < 500) { return(true); } } } InputDevices.LastHidRequest = appCommand; if (logVerbose) { Log.Info("AppCommand: {0} - {1}", appCommand, InputDevices.LastHidRequest.ToString()); } mappedCommand = _inputHandler.GetMapping(((int)appCommand).ToString()); if (shouldRaiseAction) { if (!_inputHandler.MapAction((int)appCommand)) { return(false); } } msg.Result = new IntPtr(1); return(true); }
/// <summary> /// Let everybody know that this HID message may not be handled by anyone else /// </summary> /// <param name="msg">System.Windows.Forms.Message</param> /// <returns>Command handled</returns> public bool WndProc(ref Message msg) { if (_remoteActive) { AppCommands appCommand = (AppCommands)Win32.Macro.GET_APPCOMMAND_LPARAM(msg.LParam); // find out which request the MCE remote handled last if ((appCommand == InputDevices.LastHidRequest) && (appCommand != AppCommands.VolumeDown) && (appCommand != AppCommands.VolumeUp)) { if (Enum.IsDefined(typeof(AppCommands), InputDevices.LastHidRequest)) { // possible that it is the same request mapped to an app command? if (Environment.TickCount - InputDevices.LastHidRequestTick < 500) { return(true); } } } return(MapWndProcMessage(msg) != null); } return(false); }
public static void Send(AppCommands cmd) { if (frm == null) Initialize(); frm.Invoke(new MethodInvoker(() => SendMessage(frm.Handle, WM_APPCOMMAND, frm.Handle, (IntPtr)((int)cmd << 16)))); }
private void OnAddNote(object sender, EventArgs eventArgs) { AppCommands.AddNewKnowledge(); }
public static void Enqueue(AppCommands commandType, IEntityBase entity) { Enqueue(commandType, entity, ExecutionTrigger.Send, String.Empty, ModifyAction.None); }
public ServiceEndpointOptions(string name, string helpMessage, AppCommands command) { Name = name; HelpMessage = helpMessage; _command = command; }
new = CommonCommands(AppCommands.Exit);
/// <summary> /// Let everybody know that this HID message may not be handled by anyone else /// </summary> /// <param name="msg">System.Windows.Forms.Message</param> /// <returns>Command handled</returns> public bool WndProc(ref Message msg) { if (_remoteActive) { if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN || msg.Msg == WM_APPCOMMAND || msg.Msg == WM_LBUTTONDOWN || msg.Msg == WM_RBUTTONDOWN || msg.Msg == WM_MOUSEMOVE) { switch ((Keys)msg.WParam) { case Keys.ControlKey: break; case Keys.ShiftKey: break; case Keys.Menu: break; default: int keycode = (int)msg.WParam; AppCommands appCommand = (AppCommands)((msg.LParam.ToInt32() >> 16) & ~0xF000); // find out which request the MCE remote handled last if ((appCommand == InputDevices.LastHidRequest) && (appCommand != AppCommands.VolumeDown) && (appCommand != AppCommands.VolumeUp)) { if (Enum.IsDefined(typeof(AppCommands), InputDevices.LastHidRequest)) { // possible that it is the same request mapped to an app command? if (Environment.TickCount - InputDevices.LastHidRequestTick < 500) { return(true); } } } InputDevices.LastHidRequest = appCommand; // Due to the non-perfect placement of the OK button we allow the user to remap the joystick to okay. if (_mapMouseButton) { if (msg.Msg == WM_LBUTTONDOWN) { if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped for left mouse button", keycode); } keycode = 13; } if (msg.Msg == WM_RBUTTONDOWN) { if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped for right mouse button", keycode); } keycode = 10069; } } // Since mouse support is semi optimal we have this option to use the joystick like cursor keys if (_mapJoystick && GUIGraphicsContext.Fullscreen) { if (msg.Msg == WM_MOUSEMOVE) { Point p = new Point(msg.LParam.ToInt32()); _ignoreDupMsg++; // since our ResetCursor() triggers a mouse move MSG as well we ignore every second event if (_ignoreDupMsg % 2 == 0) { GUIGraphicsContext.ResetCursor(false); } // we ignore double actions for the configured time if (Environment.TickCount - _lastMouseTick < 400) { return(false); } MouseDirection mmove = OnMouseMoved(p); _lastMouseTick = Environment.TickCount; _ignoreDupMsg = 0; switch (mmove) { case MouseDirection.Up: keycode = 38; break; case MouseDirection.Right: keycode = 39; break; case MouseDirection.Down: keycode = 40; break; case MouseDirection.Left: keycode = 37; break; } if (mmove != MouseDirection.None) { GUIGraphicsContext.ResetCursor(false); if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped for mouse movement", mmove.ToString()); } } } } // The Centarea Remote sends key combos. Therefore we use this trick to get a 1:1 mapping if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { keycode += 1000; } if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { keycode += 10000; } if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { keycode += 100000; } try { // Get & execute Mapping if (_inputHandler.MapAction(keycode)) { if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped", keycode); } } else { if (keycode > 0) { Log.Debug("Centarea: Command \"{0}\" not mapped", keycode); } return(false); } } catch (ApplicationException) { return(false); } msg.Result = new IntPtr(1); break; } return(true); } } return(false); }
public IActionResult Execute([FromServices] AppCommands commands, string commandName) { return(GetResponse(commands, commandName)); }
/// <summary> /// Map an app command to the MCE RemoteButton /// </summary> /// <param name="command"></param> /// <returns></returns> private Mapping MapFromAppCommand(AppCommands command) { Mapping result = null; RemoteButton button = RemoteButton.None; switch (command) { case AppCommands.BrowserBackward: button = RemoteButton.Back; break; case AppCommands.VolumeMute: button = RemoteButton.Mute; break; case AppCommands.VolumeDown: button = RemoteButton.VolumeDown; break; case AppCommands.VolumeUp: button = RemoteButton.VolumeUp; break; case AppCommands.MediaNextTrack: button = RemoteButton.Skip; break; case AppCommands.MediaPreviousTrack: button = RemoteButton.Replay; break; case AppCommands.MediaStop: button = RemoteButton.Stop; break; case AppCommands.MediaPlayPause: button = RemoteButton.Pause; break; case AppCommands.Print: button = RemoteButton.Print; break; case AppCommands.MediaPlay: button = RemoteButton.Play; break; case AppCommands.MediaPause: button = RemoteButton.Pause; break; case AppCommands.MediaRecord: button = RemoteButton.Record; break; case AppCommands.MediaFastForward: button = RemoteButton.Forward; break; case AppCommands.MediaRewind: button = RemoteButton.Rewind; break; case AppCommands.MediaChannelUp: button = RemoteButton.ChannelUp; break; case AppCommands.MediaChannelDown: button = RemoteButton.ChannelDown; break; } if (button != RemoteButton.None) { if (_inputHandler == null) { InitInputHandler(); } if (_inputHandler == null || !_inputHandler.IsLoaded) { return(null); } result = _inputHandler.GetMapping(((int)button).ToString()); // Get the mapping if (result != null) { if (logVerbose) { Log.Info("MCE: Command \"{0}\" mapped from AppCommands {1}", button, command); } } else if (logVerbose) { Log.Info("MCE: Command \"{0}\" not mapped from AppCommands {1}", button, command); } } return(result); }
public MainViewModel(IUnityContainer container, AppCommands commands) { container.RegisterInstance(this); Commands = commands; }
private CommonCommands(AppCommands command) { Command = command; }
public ServiceEndpointCommandLineOptions(Options options, AppCommands command) { Command = command; ServiceEndpoint = options.Endpoint; }
private void AddButtonClick(object sender, RoutedEventArgs e) { AppCommands.AddNewKnowledge(); }
/// <summary> /// Map a WndProc message and optionally execute it /// </summary> /// <param name="msg"></param> /// <returns></returns> private Mapping MapWndProcMessage(Message msg, bool shouldRaiseAction = true) { Mapping result = null; if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN || msg.Msg == Win32.Const.WM_APPCOMMAND || msg.Msg == WM_LBUTTONDOWN || msg.Msg == WM_RBUTTONDOWN || msg.Msg == WM_MOUSEMOVE) { switch ((Keys)msg.WParam) { case Keys.ControlKey: break; case Keys.ShiftKey: break; case Keys.Menu: break; default: int keycode = (int)msg.WParam; AppCommands appCommand = (AppCommands)Win32.Macro.GET_APPCOMMAND_LPARAM(msg.LParam); InputDevices.LastHidRequest = appCommand; // Due to the non-perfect placement of the OK button we allow the user to remap the joystick to okay. if (_mapMouseButton) { if (msg.Msg == WM_LBUTTONDOWN) { if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped for left mouse button", keycode); } keycode = 13; } if (msg.Msg == WM_RBUTTONDOWN) { if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped for right mouse button", keycode); } keycode = 10069; } } // Since mouse support is semi optimal we have this option to use the joystick like cursor keys if (_mapJoystick && GUIGraphicsContext.Fullscreen) { if (msg.Msg == WM_MOUSEMOVE) { Point p = new Point(msg.LParam.ToInt32()); _ignoreDupMsg++; // since our ResetCursor() triggers a mouse move MSG as well we ignore every second event if (_ignoreDupMsg % 2 == 0) { GUIGraphicsContext.ResetCursor(false); } // we ignore double actions for the configured time if (Environment.TickCount - _lastMouseTick < 400) { return(null); } MouseDirection mmove = OnMouseMoved(p); _lastMouseTick = Environment.TickCount; _ignoreDupMsg = 0; switch (mmove) { case MouseDirection.Up: keycode = 38; break; case MouseDirection.Right: keycode = 39; break; case MouseDirection.Down: keycode = 40; break; case MouseDirection.Left: keycode = 37; break; } if (mmove != MouseDirection.None) { GUIGraphicsContext.ResetCursor(false); if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped for mouse movement", mmove.ToString()); } } } } // The Centarea Remote sends key combos. Therefore we use this trick to get a 1:1 mapping if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { keycode += 1000; } if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { keycode += 10000; } if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { keycode += 100000; } try { result = _inputHandler.GetMapping(keycode.ToString()); if (shouldRaiseAction) { // Get & execute Mapping if (_inputHandler.MapAction(keycode)) { if (_verboseLogging) { Log.Debug("Centarea: Command \"{0}\" mapped", keycode); } } else { if (keycode > 0) { Log.Debug("Centarea: Command \"{0}\" not mapped", keycode); } return(null); } } } catch (ApplicationException ex) { Log.Error("CentAreaRemote:MapWndProcMessage: {0}", ex.Message); return(null); } msg.Result = new IntPtr(1); break; } } return(result); }
public AppCommandsTests() { _console = new InMemoryOutput(); _io = new InMemoryIo(); _commands = new AppCommands(_console, _io); }
new = CommonCommands(AppCommands.Help);