Beispiel #1
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;
            if (contextAware != null) contextAware.Context = context;

            var parserAware = this.Command as IGestureParserAware;
            if (parserAware != null) parserAware.Parser = gestureParser;

            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                }
                catch (Exception)
                {
                    //ignore errors for now
            #if DEBUG
                    throw;
            #endif
                }
            }//) { IsBackground = false}.Start();

            return new ExecutionResult(null, true);
        }
Beispiel #2
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;

            if (contextAware != null)
            {
                contextAware.Context = context;
            }

            var parserAware = this.Command as IGestureParserAware;

            if (parserAware != null)
            {
                parserAware.Parser = gestureParser;
            }

            //var intentStoreAware = Command as IGestureIntentStoreAware;
            //if (intentStoreAware != null) intentStoreAware.IntentStore = null;


            var shouldInit = this.Command as INeedInit;

            if (shouldInit != null && !shouldInit.IsInitialized)
            {
                shouldInit.Init();
            }

            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                    using (var proc = Process.GetCurrentProcess())
                    {
                        Native.SetProcessWorkingSetSize(proc.Handle, -1, -1);
                    }
                }
                catch (Exception)
                {
                    //ignore errors for now
#if DEBUG
                    throw;
#endif
                }
            }//) { IsBackground = false}.Start();

            return(new ExecutionResult(null, true));
        }
Beispiel #3
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;
            if (contextAware != null) contextAware.Context = context;

            var parserAware = this.Command as IGestureParserAware;
            if (parserAware != null) parserAware.Parser = gestureParser;

            var shouldInit = this.Command as INeedInit;
            if (shouldInit != null && !shouldInit.IsInitialized)
            {
                shouldInit.Init();
            }
            
            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                    using (var proc = Process.GetCurrentProcess())
                    {
                        Native.SetProcessWorkingSetSize(proc.Handle, -1, -1);
                    }
                }
                catch (Exception)
                {
                    //ignore errors for now
#if DEBUG
                    throw;
#endif
                }
            }//) { IsBackground = false}.Start();

            return new ExecutionResult(null, true);

        }
Beispiel #4
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;

            if (contextAware != null)
            {
                contextAware.Context = context;
            }

            var parserAware = this.Command as IGestureParserAware;

            if (parserAware != null)
            {
                parserAware.Parser = gestureParser;
            }


            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            new Thread(() =>
            {
                try
                {
                    Command.Execute();
                }
                catch (Exception)
                {
                    //ignore errors for now
#if DEBUG
                    throw;
#endif
                }
            })
            {
                IsBackground = false
            }.Start();

            return(new ExecutionResult(null, true));
        }
Beispiel #5
0
 public BeforePathStartEventArgs(PathEventArgs pathEventArgs)
 {
     PathEventArgs   = pathEventArgs;
     Context         = pathEventArgs.Context;
     ShouldPathStart = true;
 }
Beispiel #6
0
 public PathEventArgs(Point location, GestureContext context)
 {
     Location = location;
     Context  = context;
 }
Beispiel #7
0
 public BeforePathStartEventArgs(PathEventArgs pathEventArgs)
 {
     PathEventArgs = pathEventArgs;
     Context = pathEventArgs.Context;
     ShouldPathStart = true;
 }
Beispiel #8
0
 public PathEventArgs(Point location, GestureContext context)
 {
     Location = location;
     Context = context;
 }