Пример #1
0
        private async void SendScreenshotButton_Click(object sender, RoutedEventArgs e)
        {
            bool receiverExists = await _connectionService.ReceiverExists(PartnerId.Text);

            if (!receiverExists)
            {
                System.Windows.MessageBox.Show("Partner was not found",
                                               "Error",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Error);
                return;
            }

            Thread.Sleep(200);
            WindowState = WindowState.Minimized;
            Thread.Sleep(200);

            string url = string.Empty;

            using (var memoryStreamScreenshot = new MemoryStream())
            {
                _connectionService.GetScreenShot(memoryStreamScreenshot);
                url = await _connectionService.UploadScreenshotToImageHosting(memoryStreamScreenshot);

                //ShowScreenshot(memoryStreamScreenshot);
            }

            await _connectionService.CreateConnection(url, YourId.Text, PartnerId.Text);

            _notifyIcon.ShowBalloonTip(2000, "Done", "Image was successfully sent", ToolTipIcon.Info);
        }
Пример #2
0
        private void HiddenWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (!_keyWorkBinding.ContainsKey(e.KeyCode))
            {
                return;
            }

            if (_keyWorkBinding[e.KeyCode] == Work.CreateAndUploadHotkey)
            {
                using (var memoryStreamScreenshot = new MemoryStream())
                {
                    _connectionService.GetScreenShot(memoryStreamScreenshot);
                    _backgroundWorker.RunWorkerAsync(memoryStreamScreenshot);
                }
            }
            else if (_keyWorkBinding[e.KeyCode] == Work.CreateAndSaveHotkey)
            {
                using (var memoryStreamScreenshot = new MemoryStream())
                {
                    _connectionService.GetScreenShot(memoryStreamScreenshot);

                    Image  image    = Image.FromStream(memoryStreamScreenshot);
                    string fileName =
                        string.Format(
                            "\\{0}-{1}.{2}",
                            Translation.GetTranslation(Translation.Phrases.Screenshot, _language),
                            DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss-fff"),
                            _imageFormat.ToString().ToLower());

                    image.Save(PathForScreenshotsTextBox.Text + fileName, _imageFormat);
                    _notifyIcon.ShowBalloonTip(
                        2000,
                        Translation.GetTranslation(Translation.Phrases.Done, _language),
                        string.Format("{0} \"{1}\"",
                                      Translation.GetTranslation(Translation.Phrases.ImageWasSaved, _language),
                                      PathForScreenshotsTextBox.Text.Remove(0, PathForScreenshotsTextBox.Text.LastIndexOf("\\") + 1)),
                        ToolTipIcon.Info);
                    memoryStreamScreenshot.Close();
                }
            }
        }