コード例 #1
0
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(TextBox_ConfigPassword.Password) && !string.IsNullOrWhiteSpace(TextBox_ConfigPort.Text))
            {
                pass        = TextBox_ConfigPassword.Password;
                defaultPort = int.Parse(TextBox_ConfigPort.Text);
                InitControlSocket();
                InitKeyboardSocket();
                InitClipboardSocket();

                CListener = new ClipboardListener(this);

                CListener.ClipboardChange += new RawClipboardEventHandler(CListener_ClipboardChange);

                controlSocket.Listen(1);

                AsyncCallback aCallback = new AsyncCallback(AcceptCallback);
                controlSocket.BeginAccept(aCallback, controlSocket);
                Start_Button.IsEnabled = false;
                Close_Button.IsEnabled = true;
            }
            else
            {
                System.Windows.MessageBox.Show("Fill All fields", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #2
0
        public ClipboardManager()
        {
            _listener = new ClipboardListener();
            _listener.ClipboardChanged += _listener_ClipboardChanged;

            _history = new Stack <ClipboardItem>();
        }
コード例 #3
0
        public void ShowWindow()
        {
            if (string.IsNullOrWhiteSpace(_configuration.AzureCognitiveServicesTextTranslationApiKey))
            {
                MessageBox.Show("You have not entered an Azure Cognitive Services Text Translation API Key, please right-click the icon in the notification tray, select \"Settings\", and provide an appropriate key.", Program.MESSAGEBOX_TITLE, MessageBoxButtons.OK);
                return;
            }

            MainForm form = new MainForm(_configuration.AzureCognitiveServicesTextTranslationApiKey, ClipboardListener.GetClipboardText(), _sourceLanguageId, _destinationLanguageId, _cultures.Except(_configuration.DisabledLanguages));
            int      x    = Control.MousePosition.X - 30; // Offset to button
            int      y    = Control.MousePosition.Y - 190;

            if (x + form.Width > Screen.PrimaryScreen.Bounds.Width)
            {
                x = Screen.PrimaryScreen.Bounds.Width - form.Width;
            }
            if (y + form.Height > Screen.PrimaryScreen.Bounds.Height)
            {
                y = Screen.PrimaryScreen.Bounds.Height - form.Height;
            }

            form.Location = new Point(x, y);
            if (form.ShowDialog() == DialogResult.OK)
            {
                _destinationLanguageId = form.DestinationLanguageId;
                ClipboardListener.SetClipboardText(form.Translation);
                form.SendToClipboard();
            }
        }
コード例 #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _listener?.Dispose();
         _listener = null;
     }
 }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: robbinsa530/Qlip
        //~MainWindow()
        //{
        //    Dispose();
        //}

        public void Dispose()
        {
            _hotKeyListenerPaste.Unregiser();
            bool success = ClipboardListener.RemoveClipboardFormatListener(_sponge.Handle);

            if (!success)
            {
                MessageBox.Show("Error removing clipboard format listener!", "Qlip Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #6
0
ファイル: MainWindow.xaml.cs プロジェクト: robbinsa530/Qlip
        /// <summary>
        /// On closing, unregister hot key listener
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            _hotKeyListenerPaste.Unregiser();
            bool success = ClipboardListener.RemoveClipboardFormatListener(_sponge.Handle);

            if (!success)
            {
                MessageBox.Show("Error removing clipboard format listener!", "Qlip Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: robbinsa530/Qlip
        /// <summary>
        /// On load, register hot key listener
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _hotKeyListenerPaste = new HotKey(KeyCodes.CTRL + KeyCodes.SHIFT + KeyCodes.NO_REPEAT,
                                              KeyCodes.V,
                                              _sponge.Handle);
            _pasteListenerId = _hotKeyListenerPaste.getId();

            bool success = ClipboardListener.AddClipboardFormatListener(_sponge.Handle);

            if (!success)
            {
                MessageBox.Show("Error adding clipboard format listener!", "Qlip Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            RegisterPaste();
            this.Hide();
        }
コード例 #8
0
        private static void Main(string[] args)
        {
            // this basic implemetation of Clipboard manager extends Windows clipboard to be able to sequentially copy&paste clipboard data
            // for example: copy (file1), copy (file2), copy (file3). and then, paste (file1), paste (file2), paste (file3), paste (file1) etc..
            // the program is built as Windows Application executable so it will be able to run siliently as a Background process without User Interaction

            ClipboardManager.IsLoopPaste = false;

            KeyboardListener.OnPaste = ClipboardManager.TryPaste;
            ClipboardListener.OnCopy = ClipboardManager.TryCopy;

            using (var clipboardHook = new WindowHookBase <ClipboardHook>()) {
                ClipboardListener.Start(clipboardHook);
                using (var keyboardHook = new WindowHookBase <KeyboardHook>()) {
                    KeyboardListener.Start(keyboardHook);
                    // waiting forever to halt termination of the program
                    SpinWait.SpinUntil(() => { return(false); });
                    KeyboardListener.Stop(keyboardHook);
                }
                ClipboardListener.Stop(clipboardHook);
            }
        }
コード例 #9
0
ファイル: FrmMain.cs プロジェクト: guojianbin/buffalobro
        public FrmMain()
        {
            _wp           = new WordPicture();
            _wp.Fcolor    = Color.Black;
            _wp.LineAlpha = 200;
            _wp.Font      = new Font("宋体", 12, FontStyle.Bold);
            _qrcode       = new QRCodeUnit();

            InitializeComponent();
            _config = ConfigSave.ReadConfig();

            _toolItems = new ToolStripMenuItem[] { itemFont, itemQRCode, itemQRCodeEncry };
            _listener  = new ClipboardListener(this.Handle);

            _listener.OnClipboardWrite += new DelOnWndProc(_listener_OnClipboardWrite);
            if (_config.ListenClipboard)
            {
                _listener.Listen();
            }
            InitSelectItem();

            ReSetConfig();
        }
コード例 #10
0
 protected override void StartService()
 {
     _listener = new ClipboardListener();
     _listener.AddHandler(ClipBoardChangedHandler);
 }
コード例 #11
0
 public DeltintegerLanguageServer()
 {
     _debugger = new ClipboardListener(this);
 }
コード例 #12
0
        private void MainWindowSourceInitialized(object sender, EventArgs e)
        {
            CommandBindings.Add
            (
                new CommandBinding
                (
                    ApplicationCommands.Save,
                    SaveCmdExecuted,
                    CmdCanExecute
                )
            );
            MenuItemSave.Command = ApplicationCommands.Save;
            ButtonSave.Command   = ApplicationCommands.Save;
            CommandBindings.Add
            (
                new CommandBinding
                (
                    ApplicationCommands.Print,
                    PrintCmdExecuted,
                    CmdCanExecute
                )
            );
            MenuItemPrint.Command = ApplicationCommands.Print;
            ButtonPrint.Command   = ApplicationCommands.Print;
            CommandBindings.Add
            (
                new CommandBinding
                (
                    ApplicationCommands.Delete,
                    DeleteCmdExecuted,
                    CmdCanExecute
                )
            );
            MenuItemClipboardClear.Command = ApplicationCommands.Delete;
            ButtonClipboardClear.Command   = ApplicationCommands.Delete;
//
            if (IsAutorun)
            {
                TrayMinimize = true;
            }
            cl = new ClipboardListener
                 (
                this,
                new List <string>()
            {
                DataFormats.Rtf,
                DataFormats.UnicodeText,
                DataFormats.Text,
                DataFormats.OemText,
                DataFormats.FileDrop,
                "FileNameW",
                "FileName",
                DataFormats.Bitmap,
                DataFormats.Dib,
                "Format17"
            },
                ClipboardUpdated
                 );
            MenuItemSwitchListen.RaiseEvent
            (
                new RoutedEventArgs(MenuItem.ClickEvent)
            );
        }