Beispiel #1
0
 internal void Grab(ListeneerGrabType grabType, bool force)
 {
     if (!this._blockedByCheckbox && !this._blockedByMouseHover && !this._blockedByPasteOperation)
     {
         if (force)
         {
             lock (_tickSyncObject)
             {
                 GrabUnprotected(grabType);
             }
         }
         else
         {
             if (Monitor.TryEnter(_tickSyncObject))
             {
                 try
                 {
                     GrabUnprotected(grabType);
                 }
                 finally
                 {
                     Monitor.Exit(_tickSyncObject);
                 }
             }
         }
     }
 }
Beispiel #2
0
        private void GrabUnprotected(ListeneerGrabType grabType)
        {
            //BuildingBlocks.UI.Console.BeepInNewThread(20000, 300);
            string selection = null;

            try
            {
                switch (grabType)
                {
                case ListeneerGrabType.Selection: selection = this._service.GetUnicodeSelection();
                    break;

                case ListeneerGrabType.Clipboard:
                    string clipboardText = CraftSynth.BuildingBlocks.IO.Clipboard.GetTextFromClipboard();
                    if (clipboardText == this._lastTextOnClipboard)
                    {
                        selection = null;
                    }
                    else
                    {
                        selection = clipboardText;
                        this._lastTextOnClipboard = selection;
                    }
                    break;
                }
            }
            catch
            {
                selection = null;
            }

            if (selection != null)
            {
                FineTuneSelection(ref selection);
                if (IsSelectionGoodEnough(selection))
                {
                    AddSelectionToQueue(selection);
                }
            }
            //BuildingBlocks.UI.Console.BeepInNewThread(10000, 200);
        }