コード例 #1
0
        // 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;
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 private void AddApplicationMenu()
 {
     if (AppSupportsCommands)
     {
         var toolsMenu   = GetToolsMenu();
         var rootCommand = new AppCommand(MenuIdRoot, "Custom Prop Editor");
         rootCommand.Click += RootCommand_Click;
         toolsMenu.Add(rootCommand);
     }
 }
コード例 #4
0
        public override void Unloading()
        {
            if (_AppSupportsCommands)
            {
                _inputManagement.Stop();

                AppCommand toolsMenu = _GetToolsMenu();
                toolsMenu.Remove(ROOT_ID);
            }
        }
コード例 #5
0
        private void _AddMenu()
        {
            if (_application != null &&
                _application.AppCommands != null)
            {
                var mainMenu = new AppCommand(ID_MENU, "Instrumentation");
                mainMenu.Click += OnMainMenuOnClick;

                _application.AppCommands.Add(mainMenu);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: Module.cs プロジェクト: komby/vixen
        private AppCommand _GetToolsMenu()
        {
            AppCommand toolsMenu = _application.AppCommands.Find("Tools");

            if (toolsMenu == null)
            {
                toolsMenu = new AppCommand("Tools", "Tools");
                _application.AppCommands.Add(toolsMenu);
            }
            return(toolsMenu);
        }
コード例 #8
0
 /// <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;
     }
 }
コード例 #9
0
 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},
     };
 }
コード例 #10
0
ファイル: Module.cs プロジェクト: Jchuchla/vixen-sall-vixen
        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);
            }
        }
コード例 #11
0
ファイル: AppsController.cs プロジェクト: alexisbssn/squidex
        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);
        }
コード例 #12
0
ファイル: LoginViewModel.cs プロジェクト: sadboykaka/Winsta
 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();
 }
コード例 #13
0
ファイル: Module.cs プロジェクト: komby/vixen
        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);
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 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();
     };
 }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
 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);
     }
 }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
 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);
     }
 }
コード例 #20
0
ファイル: Module.cs プロジェクト: komby/vixen
        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);
        }
コード例 #21
0
ファイル: VixenApplication.cs プロジェクト: thorhs/vixen
        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);
        }
コード例 #22
0
        /// <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);
                }
            });
        }
コード例 #23
0
        /// <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);
                }
            });
        }
コード例 #24
0
 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();
 }
コード例 #25
0
 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();
 }
コード例 #26
0
ファイル: Module.cs プロジェクト: Jchuchla/vixen-sall-vixen
        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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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();
        }
コード例 #29
0
 /// <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";
         }
     });
 }
コード例 #30
0
        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();
            }
        }
コード例 #31
0
        /// <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);
                }
            });
        }
コード例 #32
0
 protected virtual void OnAppCommand(AppCommand cmd)
 {
     
 }
コード例 #33
0
ファイル: MainForm.cs プロジェクト: abibell/mysql-workbench
        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;
        }
コード例 #34
0
ファイル: ProcessManager.cs プロジェクト: kobyb1988/PhotoBox
 private void SpawnProcess(AppCommand command)
 {
     Process process = _processes.FirstOrDefault(x => x.ProcessName == command.ProcessName);
 }
コード例 #35
0
 private bool IsDuplicateMediaKeyEvent(AppCommand cmd)
 {
   
     return IsMediaCommand(cmd) && MatchCommandWithWindowsKey(cmd) ;
 }
コード例 #36
0
        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);
                }
            }
        }
コード例 #37
0
 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;
     }
 }