// We need to handle 2 case of multiple key sequences for a single commmand // // its made a little more complex depending on wether the keydown event comes from a global hook or a window hook. The two // hooks use different types for there Key code enums. // // For now we just processing using a multiple methods and boolean constructs. We will move it to more generic // table drive logic when we refactor the key code mangtement to use a more sophisiphated key mapping architecture // // 1. some remotes produce a APPCOMMAND followed by a System.Windows.Forms.Keys Keycode or System.Windows.Input.Key Key (depending on hook method) // // Media Key types equivenlance table for media keys // APPCOMMAND code System.Windows.Forms.Keys System.Windows.Input.Key // APPCOMMAND_MEDIA_PLAY_PAUSE (14) MediaPlayPause (179) MediaPlayPause (135) // APPCOMMAND_MEDIA_STOP (13) MediaStop (178) MediaStop = (134) // APPCOMMAND_MEDIA_NEXTTRACK (11) MediaNextTrack (176) MediaNextTrack = (132) // APPCOMMAND_MEDIA_PREVIOUSTRACK (12) MediaPreviousTrack(177) MediaPreviousTrack = (133) // // 2. some remotes produce 2 Keycodes in sequence for 1 the one event, notably for left and right arrow // Right & LControlKey, LShiftKey, F for fwd (>>) // Left & LControlKey, LSHiftKey, B for backward (<<) // // We dont currently handle Left & Right so we can ignore this condition for now // // A number of remote controls send a KeyDown event and then a command event via WndProc for the following // media keys, PlayPause, Stop, Next, Previous, Fwd, Backwards. THis effect of this is to replicate the command // for these key. This double the effect of Next, Previous, Fwd, Backwards and starts & stops or stops and then starts // for PlayPause. // We therefore remember that type and time of the last media keyDown event and when we get a Media Key APPCOMMAND // get check if the correcponsing KetDown just occured and if it did ignore the APPCommand event private bool IsMediaCommand(AppCommand cmd) { return cmd == AppCommand.APPCOMMAND_MEDIA_NEXTTRACK || cmd == AppCommand.APPCOMMAND_MEDIA_PREVIOUSTRACK || cmd == AppCommand.APPCOMMAND_MEDIA_STOP || cmd == AppCommand.APPCOMMAND_MEDIA_PLAY_PAUSE; }
public MainViewModel() { NewCommand = new AppCommand(OnNewCommand); ReceiveCommand = new AppCommand(OnReceiveCommand); UpdateCommand = new AppCommand(OnUpdateCommand); SendCommand = new AppCommand(OnSendCommand, OnCanSendCommand); Messages = new ObservableCollection <MessageModel>(); DBContext = new AppDBContext(); UpdateCommand.Execute(null); }
private void AddApplicationMenu() { if (AppSupportsCommands) { var toolsMenu = GetToolsMenu(); var rootCommand = new AppCommand(MenuIdRoot, "Custom Prop Editor"); rootCommand.Click += RootCommand_Click; toolsMenu.Add(rootCommand); } }
public override void Unloading() { if (_AppSupportsCommands) { _inputManagement.Stop(); AppCommand toolsMenu = _GetToolsMenu(); toolsMenu.Remove(ROOT_ID); } }
private void _AddMenu() { if (_application != null && _application.AppCommands != null) { var mainMenu = new AppCommand(ID_MENU, "Instrumentation"); mainMenu.Click += OnMainMenuOnClick; _application.AppCommands.Add(mainMenu); } }
public AppCommand GetSchedulerMenu() { AppCommand menu = _application.AppCommands.Find(MENU_ID_ROOT); if (menu == null) { menu = new AppCommand(MENU_ID_ROOT, MENU_ID_NAME); _application.AppCommands.Add(menu); } return(menu); }
private AppCommand _GetToolsMenu() { AppCommand toolsMenu = _application.AppCommands.Find("Tools"); if (toolsMenu == null) { toolsMenu = new AppCommand("Tools", "Tools"); _application.AppCommands.Add(toolsMenu); } return(toolsMenu); }
/// <summary> /// Função que será executada a partir do atalho de teclas pressionado /// </summary> private void HandleHotkey(AppCommand appCommand) { try { Invoke(new MethodInvoker(() => SendMessage(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr)((int)appCommand << 16)))); } catch (Exception) { throw; } }
public EditPetViewModel() { SavePetCommand = new AppCommand(SavePet); AiTypeSelection = new List<ComboBoxNode<int>> { new ComboBoxNode<int> {Title = "胆小", Value = 0}, new ComboBoxNode<int> {Title = "谨慎", Value = 1}, new ComboBoxNode<int> {Title = "忠诚", Value = 2}, new ComboBoxNode<int> {Title = "精明", Value = 3}, new ComboBoxNode<int> {Title = "勇猛", Value = 4}, }; }
private void _AddApplicationMenu() { if (_AppSupportsCommands()) { AppCommand toolsMenu = _GetToolsMenu(); AppCommand rootCommand = new AppCommand(MENU_ID_ROOT, "Web Server"); rootCommand.Add(_showCommand ?? (_showCommand = _CreateShowCommand())); toolsMenu.Add(rootCommand); } }
private async Task <AppDto> InvokeCommandAsync(AppCommand command) { var context = await CommandBus.PublishAsync(command); var userOrClientId = HttpContext.User.UserOrClientId(); var userPermissions = HttpContext.Permissions(); var result = context.Result <IAppEntity>(); var response = AppDto.FromApp(result, userOrClientId, userPermissions, appPlansProvider, this); return(response); }
public LoginViewModel() { LoginCmd = AppCommand.GetInstance(); FacebookLoginCmd = AppCommand.GetInstance(); FacebookCloseCmd = AppCommand.GetInstance(); RegisterCmd = AppCommand.GetInstance(); LoginCmd.ExecuteFunc = RunLogin; FacebookLoginCmd.ExecuteFunc = RunFacebookLogin; FacebookCloseCmd.ExecuteFunc = RunFacebookClose; RegisterCmd.ExecuteFunc = RunRegister; Dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; LoadPage(); }
private void _AddApplicationMenu() { if (_AppSupportsCommands()) { var toolsMenu = _GetToolsMenu(); var rootCommand = new AppCommand(MENU_ID_ROOT, "Version Control"); rootCommand.Add(_enabledCommand ?? (_enabledCommand = _CreateEnabledCommand())); rootCommand.Add(new AppCommand("s1", "-")); rootCommand.Add(_showCommand ?? (_showCommand = _CreateShowCommand())); toolsMenu.Add(rootCommand); } }
private async Task <object?> PublishIdempotentAsync(AppCommand command) { var result = await PublishAsync(command); var previousSnapshot = sut.Snapshot; var previousVersion = sut.Snapshot.Version; await PublishAsync(command); Assert.Same(previousSnapshot, sut.Snapshot); Assert.Equal(previousVersion, sut.Snapshot.Version); return(result); }
public MaterialItemListViewModel() { AddMaterialCommand = new AppCommand(ShowAddMaterialDialog, CanAddItem); AddGemCommand = new AppCommand(ShowAddGemDialog, CanAddItem); EditItemCommand = new AppCommand(ShowEditDialog, CanEditItem); CopyItemCommand = new AppCommand(ProcessCopy, CanCopyItem); DeleteItemCommand = new AppCommand(ProcessDelete); ItemList.CollectionChanged += (sender, e) => { AddMaterialCommand.RaiseCanExecuteChanged(); AddGemCommand.RaiseCanExecuteChanged(); CopyItemCommand.RaiseCanExecuteChanged(); }; }
private void _AddApplicationMenu() { if (_AppSupportsCommands()) { AppCommand toolsMenu = _GetToolsMenu(); AppCommand rootCommand = new AppCommand(MENU_ID_ROOT, "Simple Scheduler"); rootCommand.Add(_enabledCommand ?? (_enabledCommand = _CreateEnabledCommand())); rootCommand.Add(new AppCommand("s1", "-")); rootCommand.Add(_showCommand ?? (_showCommand = _CreateShowCommand())); toolsMenu.Add(rootCommand); } }
private void _AddMenu() { if (_application != null && _application.AppCommands != null) { AppCommand toolsMenu = _application.AppCommands.Find("Tools"); if (toolsMenu == null) { toolsMenu = new AppCommand("Tools", "Tools"); _application.AppCommands.Add(toolsMenu); } var myMenu = new AppCommand(MenuId, "Export Wizard"); myMenu.Click += OnMainMenuOnClick; toolsMenu.Add(myMenu); } }
private bool MatchCommandWithWindowsKey(AppCommand cmd) { if ((cmd == AppCommand.APPCOMMAND_MEDIA_NEXTTRACK && _lastKeyDown == Key.MediaNextTrack) || (cmd == AppCommand.APPCOMMAND_MEDIA_PREVIOUSTRACK && _lastKeyDown == Key.MediaPreviousTrack) || (cmd == AppCommand.APPCOMMAND_MEDIA_STOP && _lastKeyDown == Key.MediaStop) || (cmd == AppCommand.APPCOMMAND_MEDIA_PLAY_PAUSE && _lastKeyDown == Key.MediaPlayPause)) { // its the same command, did it occur in the last DuplicateCommandPeriod Milliseconds TimeSpan span = DateTime.Now - _lastKeyDownTime; return(span.TotalMilliseconds < DuplicateCommandPeriod); } else { return(false); } }
private void _AddMenu() { if (_application != null && _application.AppCommands != null) { AppCommand toolsMenu = _application.AppCommands.Find("Tools"); if (toolsMenu == null) { toolsMenu = new AppCommand("Tools", "Tools"); _application.AppCommands.Add(toolsMenu); } var myMenu = new AppCommand(ID_MENU, "Instrumentation..."); myMenu.Click += OnMainMenuOnClick; toolsMenu.Add(myMenu); } }
private AppCommand _CreateShowCommand() { AppCommand showCommand = new AppCommand("VersionControl", "Browse"); showCommand.Click += (sender, e) => { using (Versioning cs = new Versioning((Data)StaticModuleData, repo)) { if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { } } }; return(showCommand); }
public VixenApplication() { InitializeComponent(); //Get rid of the ugly grip that we dont want to show anyway. //Workaround for a MS bug statusStrip.Padding = new Padding(statusStrip.Padding.Left, statusStrip.Padding.Top, statusStrip.Padding.Left, statusStrip.Padding.Bottom); Icon = Resources.Icon_Vixen3; string[] args = Environment.GetCommandLineArgs(); foreach (string arg in args) { _ProcessArg(arg); } StartJITProfiler(); if (_rootDataDirectory == null) { ProcessProfiles(); } _applicationData = new VixenApplicationData(_rootDataDirectory); stopping = false; PopulateVersionStrings(); AppCommands = new AppCommand(this); Execution.ExecutionStateChanged += executionStateChangedHandler; VixenSystem.Start(this, _openExecution, _disableControllers, _applicationData.DataFileDirectory); InitStats(); // other modules look for and create it this way... AppCommand toolsMenu = AppCommands.Find("Tools"); if (toolsMenu == null) { toolsMenu = new AppCommand("Tools", "Tools"); AppCommands.Add(toolsMenu); } var myMenu = new AppCommand("Options", "Options..."); myMenu.Click += optionsToolStripMenuItem_Click; toolsMenu.Add(myMenu); }
/// <summary> /// /// </summary> public void LaunchWebsite() { AppCommand.EnqueueTask(app => { var doc = app.ActiveUIDocument.Document; var centralPath = FileInfoUtil.GetCentralFilePath(doc); if (string.IsNullOrWhiteSpace(centralPath)) { return; } if (MissionControlSetup.Projects.ContainsKey(centralPath)) { Process.Start(ServerUtilities.RestApiBaseUrl + "/#/projects/healthreport/" + MissionControlSetup.Projects[centralPath].Id); } }); }
/// <summary> /// /// </summary> public void LaunchWebsite() { AppCommand.EnqueueTask(app => { var doc = app.ActiveUIDocument.Document; var centralPath = FileInfoUtil.GetCentralFilePath(doc); if (string.IsNullOrEmpty(centralPath)) { return; } if (MissionControlSetup.Projects.ContainsKey(centralPath)) { Process.Start("http://missioncontrol.hok.com/#/projects/healthreport/" + MissionControlSetup.Projects[centralPath].Id); } }); }
public override void ExecuteRefreshCommand() { try { IsBusy = true; AppCommand.ShowMessage("Getting old application report"); Items = _client.GetOldApplicationReport().Object; IsBusy = false; } catch (Exception ex) { IsBusy = false; EnqueMessage("Failed to get old application report"); Log.Debug(ex, "Failed to get old application report"); } AppCommand.HideMessage(); }
public override void ExecuteRefreshCommand() { try { AppCommand.ShowMessage("Getting applicable issues"); IsBusy = true; Items = _client.GetApplicableIssues().Object; IsBusy = false; } catch (Exception ex) { IsBusy = false; Log.Debug(ex, "Failed to get applicable issues"); EnqueMessage("Failed to get applicable issues"); } AppCommand.HideMessage(); }
private AppCommand _CreateShowCommand() { AppCommand showCommand = new AppCommand("WebserverConfigure", "Configure"); showCommand.Click += (sender, e) => { using (Settings cs = new Settings(_data)) { cs.SettingsChanged += cs_SettingsChanged; if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _data.HttpPort = cs.Port; _data.IsEnabled = cs.WebServerEnabled; } _SetServerEnableState(_data.IsEnabled, _data.HttpPort); } }; return(showCommand); }
private AppCommand _CreateShowCommand() { AppCommand showCommand = new AppCommand("SimpleSchedulerShow", "Show"); showCommand.Click += (sender, e) => { using (ConfigureSchedule cs = new ConfigureSchedule(_data)) { if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _enabledCommand.IsChecked = _data.IsEnabled; _Timer.Enabled = false; _stateMachine.Refresh(_data.ScheduledItems); _Timer.Enabled = _data.IsEnabled; } } }; return(showCommand); }
public VixenApplication() { string[] args = Environment.GetCommandLineArgs(); foreach (string arg in args) { _ProcessArg(arg); } _applicationData = new VixenApplicationData(_rootDataDirectory); stopping = false; InitializeComponent(); labelVersion.Text = _GetVersionString(VixenSystem.AssemblyFileName); AppCommands = new AppCommand(this); Execution.ExecutionStateChanged += executionStateChangedHandler; VixenSystem.Start(this, _openExecution, _disableControllers, _applicationData.DataFileDirectory); InitStats(); }
/// <summary> /// Communicator Image can only be set when we are done loading the app. /// </summary> public static void SetCommunicatorImage() { // (Konrad) This needs to run after the doc is opened, because UI elements don't get created until then. AppCommand.EnqueueTask(app => { var dpid = new DockablePaneId(new Guid(Properties.Resources.CommunicatorGuid)); var dp = app.GetDockablePane(dpid); var assembly = Assembly.GetExecutingAssembly(); if (dp != null) { AppCommand.Instance.CommunicatorButton.LargeImage = ButtonUtil.LoadBitmapImage(assembly, "HOK.MissionControl", dp.IsShown() ? "communicatorOn_32x32.png" : "communicatorOff_32x32.png"); AppCommand.Instance.CommunicatorButton.ItemText = dp.IsShown() ? "Hide" + Environment.NewLine + "Communicator" : "Show" + Environment.NewLine + "Communicator"; } }); }
public override void Loading() { if (_AppSupportsCommands) { AppCommand toolsMenu = _GetToolsMenu(); AppCommand rootMenuItem = new AppCommand(ROOT_ID, "Input Effect Router"); rootMenuItem.Click += (sender, e) => { if (_inputManagement.ShowForm() == DialogResult.OK) { _data.Map = _inputManagement.InputEffects; _data.InputModules = _inputManagement.InputModules; } }; toolsMenu.Add(rootMenuItem); _inputManagement.Start(); } }
/// <summary> /// Creates an idling task that will bind our own Reload Latest command to existing one. /// </summary> public static void CreateReloadLatestOverride() { AppCommand.EnqueueTask(app => { try { var commandId = RevitCommandId.LookupCommandId("ID_WORKSETS_RELOAD_LATEST"); if (commandId == null || !commandId.CanHaveBinding) { return; } var binding = app.CreateAddInCommandBinding(commandId); binding.Executed += OnReloadLatest; } catch (Exception e) { Log.AppendLog(LogMessageType.EXCEPTION, e.Message); } }); }
protected virtual void OnAppCommand(AppCommand cmd) { }
public String ApplicationCommand(AppCommand command, String str) { if (IsDisposed || Disposing) return ""; String result = ""; switch (command) { case AppCommand.AppQuit: // Not yet used. Close(); break; case AppCommand.AppGetResourcePath: result = GetIconPath(str); break; case AppCommand.AppSetStatusText: StatusBarText = str; break; } return result; }
private void SpawnProcess(AppCommand command) { Process process = _processes.FirstOrDefault(x => x.ProcessName == command.ProcessName); }
private bool IsDuplicateMediaKeyEvent(AppCommand cmd) { return IsMediaCommand(cmd) && MatchCommandWithWindowsKey(cmd) ; }
public void input_AppCommand(object sender, AppCommandEventArgs appCommandEventArgs) { var appCommand = MapAppCommand(appCommandEventArgs.Cmd); _logger.Debug("input_AppCommand: {0} {1}", appCommandEventArgs.Cmd, appCommand == null ? "null" : appCommand.ToString()); if (appCommand != null) { if (IsDuplicateMediaKeyEvent(appCommand.Value)) { _logger.Debug("input_AppCommand: IsDuplicate - cmd {0} after key {1}", appCommand, _lastKeyDown); appCommandEventArgs.Handled = false; } else { if (_commandReceived != null) { var command = _inputCommandMaps.GetMappedCommand(appCommand.Value); var commandEventArgs = new CommandEventArgs { Command = command, Handled = appCommandEventArgs.Handled}; _commandReceived.Invoke(null, commandEventArgs); appCommandEventArgs.Handled = commandEventArgs.Handled; } } if (appCommandEventArgs.Handled) { _lastCmd = appCommand.Value; _lastCmdTime = DateTime.Now; } else { _logger.Debug("input_AppCommand {0}, command not handled", appCommand); } } }
private bool MatchCommandWithWindowsKey(AppCommand cmd) { if ((cmd == AppCommand.APPCOMMAND_MEDIA_NEXTTRACK && _lastKeyDown == Key.MediaNextTrack) || (cmd == AppCommand.APPCOMMAND_MEDIA_PREVIOUSTRACK && _lastKeyDown == Key.MediaPreviousTrack) || (cmd == AppCommand.APPCOMMAND_MEDIA_STOP && _lastKeyDown == Key.MediaStop) || (cmd == AppCommand.APPCOMMAND_MEDIA_PLAY_PAUSE && _lastKeyDown == Key.MediaPlayPause)) { // its the same command, did it occur in the last DuplicateCommandPeriod Milliseconds TimeSpan span = DateTime.Now - _lastKeyDownTime; return span.TotalMilliseconds < DuplicateCommandPeriod; } else { return false; } }