示例#1
0
        public static bool QueueGuiLockingTask(string taskName, WaitCallback callback, object state)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (MainForm == null)
            {             //execute directly
                callback(state);
                return(true);
            }

            if (LockedGUIForm == null)
            {
                LockedGUIForm = new FreeCL.Forms.LockedGuiForm();
                LockedGUIForm.Init();
            }

            waitMessage = taskName;
            return(TaskConveyer.QueueExtTask(
                       taskName,
                       callback,
                       state,
                       new WaitCallback(OnStartGuiLockingTask),
                       new WaitCallback(OnEndGuiLockingTask),
                       new WaitCallback(OnExceptionInGuiLockingTask)
                       ));
        }
        public void Run()
        {
            WorkerEventHandler workerDelegate = new WorkerEventHandler(TranslateManager.TranslateWorker);

            int cnt = 0;

            foreach (ServiceItemSetting ts in translatorsSettings)
            {
                cnt++;
                int delay = GetDelayBeforeRun(ts);
                if (delay == 0)
                {
                    workerDelegate.BeginInvoke(
                        ts,
                        this,
                        null,
                        null);
                }
                else
                {
                    string timerName = ts.ServiceItem.FullName + "_" +
                                       Environment.TickCount.ToString() + "_" + cnt.ToString();
                    TaskConveyer.QueueTimer(timerName, DelayedProcess, ts, delay, Timeout.Infinite);
                    timers.Add(timerName);
                }
            }
        }
示例#3
0
            private static bool CheckShourcut()
            {
                if (shortcut == Keys.None && mouseShortcut == MouseButtons.None)
                {
                    return(false);
                }

                bool mouseSet     = mouseButtons == mouseShortcut;
                bool modifiersSet = (modifierKeys & Keys.Modifiers) == (shortcut & Keys.Modifiers);

                bool keySet = true;
                Keys key    = (shortcut & Keys.KeyCode);

                if (key != Keys.None)
                {
                    bool keydata = false;
                    keys.TryGetValue(key, out keydata);
                    keySet = keydata;
                }

                bool result = false;

                //System.Diagnostics.Trace.Write("Mouse : " + mouseButtons.ToString());
                //System.Diagnostics.Trace.Write("hook catched : " + mouseSet + modifiersSet + keySet);
                if (mouseSet && modifiersSet && keySet)
                {
                    TaskConveyer.QueueTask("hook", HookCalledThreadProcAdv, null);
                    result = true;
                    mouseButtonsToSkipUp = mouseButtons;
                }
                return(result);
            }
示例#4
0
            private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
            {
                if (ignoreHookProcessing)
                {
                    return(CallNextHookEx(hookID, nCode, wParam, lParam));
                }

                if (nCode >= 0)
                {
                    Keys key;
                    if (wParam == (IntPtr)WM_KEYDOWN)
                    {
                        modifierKeys = Control.ModifierKeys;
                        key          = (Keys)Marshal.ReadInt32(lParam);
                        keys[key]    = true;

                        if (Keys.C == key && Keys.Control == modifierKeys &&
                            KeyboardHook.ControlCC
                            )
                        {
                            if (controlCClickTime + ticksInSecond > DateTime.Now.Ticks)
                            {
                                TaskConveyer.QueueTask("hook", HookCalledThreadProc, null);
                                controlCClickTime = 0;
                            }
                            else
                            {
                                controlCClickTime = DateTime.Now.Ticks;
                            }
                        }

                        if (Keys.Insert == key && Keys.Control == modifierKeys &&
                            KeyboardHook.ControlInsIns
                            )
                        {
                            if (controlInsClickTime + ticksInSecond > DateTime.Now.Ticks)
                            {
                                TaskConveyer.QueueTask("hook", HookCalledThreadProc, null);
                                controlInsClickTime = 0;
                            }
                            else
                            {
                                controlInsClickTime = DateTime.Now.Ticks;
                            }
                        }

                        CheckShourcut();
                    }
                    else if (wParam == (IntPtr)WM_KEYUP)
                    {
                        key       = (Keys)Marshal.ReadInt32(lParam);
                        keys[key] = false;
                    }

                    //System.Diagnostics.Trace.Write("Keys : " + key.ToString());
                }
                return(CallNextHookEx(hookID, nCode, wParam, lParam));
            }
 public void RemoveTimers()
 {
     foreach (string name in timers)
     {
         try
         {
             TaskConveyer.StopTimer(name);
         } catch (Exception) {
         }
     }
 }