示例#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);
        }
示例#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));
        }
示例#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);

        }
示例#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));
        }
示例#5
0
 public BeforePathStartEventArgs(PathEventArgs pathEventArgs)
 {
     PathEventArgs   = pathEventArgs;
     Context         = pathEventArgs.Context;
     ShouldPathStart = true;
 }
示例#6
0
 public PathEventArgs(Point location, GestureContext context)
 {
     Location = location;
     Context  = context;
 }
示例#7
0
 public BeforePathStartEventArgs(PathEventArgs pathEventArgs)
 {
     PathEventArgs = pathEventArgs;
     Context = pathEventArgs.Context;
     ShouldPathStart = true;
 }
示例#8
0
 public PathEventArgs(Point location, GestureContext context)
 {
     Location = location;
     Context = context;
 }