Пример #1
0
        //Video
        private void Video_TriggerEvent(object sender, EventArgs e)
        {
            var snapshot = (SnapShotEventArgs)e as SnapShotEventArgs;

            new TaskFactory().StartNew(() =>
            {
                AppDataContext.NotifyIconHandler.SetWorkingIcon();
                Thread.Sleep(AppDataContext.Configuration.WaitTimeSeconds * 1000);
                AppDataContext.NotifyIconHandler.SetStandardIcon();
            });


            App.Current.Dispatcher.Invoke((Action) delegate
            {
                AppDataContext.Controllers.SnapShotController.AddSnapShot(snapshot.SnapShot);
            });

            foreach (var action in AppDataContext.Actions)
            {
                switch (action.ActionType)
                {
                case Entities.Enums.ActionTypes.MinimizeProcess:
                    foreach (var process in Process.GetProcessesByName(action.ActionValue))
                    {
                        if (!string.IsNullOrEmpty(process.MainWindowTitle))
                        {
                            User32Wrapper.MinimizeWindow(process.MainWindowHandle);
                        }
                    }
                    break;

                case Entities.Enums.ActionTypes.MaximizeProcess:
                    foreach (var process in Process.GetProcessesByName(action.ActionValue))
                    {
                        if (!string.IsNullOrEmpty(process.MainWindowTitle))
                        {
                            User32Wrapper.MaximizeWindow(process.MainWindowHandle);
                        }
                    }
                    break;

                case Entities.Enums.ActionTypes.ExecuteFile:
                    User32Wrapper.ExecuteFile(action.ActionValue);
                    break;

                case Entities.Enums.ActionTypes.ExecuteCommand:
                    User32Wrapper.ExecuteCommand(action.ActionValue, false);
                    break;

                case Entities.Enums.ActionTypes.ExecuteHiddenCommand:
                    User32Wrapper.ExecuteCommand(action.ActionValue, true);
                    break;
                }
            }
        }