Пример #1
0
        void OnPauseExecute()
        {
            if (RecorderState == RecorderState.Paused)
            {
                _systemTray.HideNotification();

                _recorder.Start();
                _timing?.Start();
                _timer?.Start();

                RecorderState          = RecorderState.Recording;
                Status.LocalizationKey = nameof(LanguageManager.Recording);
            }
            else
            {
                _recorder.Stop();
                _timer?.Stop();
                _timing?.Pause();

                RecorderState          = RecorderState.Paused;
                Status.LocalizationKey = nameof(LanguageManager.Paused);

                _systemTray.ShowTextNotification(Loc.Paused, null);
            }
        }
Пример #2
0
        public async Task SaveScreenShot(Bitmap Bmp, string FileName = null)
        {
            if (Bmp != null)
            {
                var allTasks = _videoViewModel.AvailableImageWriters
                               .Where(M => M.Active)
                               .Select(M => M.Save(Bmp, SelectedScreenShotImageFormat, FileName, _recentViewModel));

                await Task.WhenAll(allTasks).ContinueWith(T => Bmp.Dispose());
            }
            else
            {
                _systemTray.ShowTextNotification(Loc.ImgEmpty, null);
            }
        }
Пример #3
0
        public async void Save(Bitmap Image, ImageFormat Format, string FileName, TextLocalizer Status, RecentViewModel Recents)
        {
            var ritem = Recents.Add($"{_loc.ImgurUploading} (0%)", RecentItemType.Link, true);

            using (var w = new WebClient {
                Proxy = _settings.Proxy.GetWebProxy()
            })
            {
                w.UploadProgressChanged += (s, e) =>
                {
                    ritem.Display = $"{_loc.ImgurUploading} ({e.ProgressPercentage}%)";
                };

                w.Headers.Add("Authorization", $"Client-ID {ApiKeys.ImgurClientId}");

                NameValueCollection values;

                using (var ms = new MemoryStream())
                {
                    Image.Save(ms, Format);

                    values = new NameValueCollection
                    {
                        { "image", Convert.ToBase64String(ms.ToArray()) }
                    };
                }

                XDocument xdoc;

                try
                {
                    var response = await w.UploadValuesTaskAsync("https://api.imgur.com/3/upload.xml", values);

                    xdoc = XDocument.Load(new MemoryStream(response));

                    var xAttribute = xdoc.Root?.Attribute("success");

                    if (xAttribute == null || int.Parse(xAttribute.Value) != 1)
                    {
                        throw new Exception("Response indicates Failure");
                    }

                    Image.Dispose();
                }
                catch (Exception E)
                {
                    ritem.Display          = _loc.ImgurFailed;
                    Status.LocalizationKey = nameof(LanguageManager.ImgurFailed);

                    var yes = _messageProvider.ShowYesNo($"{_loc.ImgurFailed}\n{E.Message}\n\nDo you want to Save to Disk?", "Imgur Upload Failed");

                    if (yes)
                    {
                        _diskWriter.Save(Image, Format, FileName, Status, Recents);
                    }

                    return;
                }

                var link = xdoc.Root.Element("link").Value;

                if (_settings.CopyOutPathToClipboard)
                {
                    link.WriteToClipboard();
                }

                ritem.FilePath = ritem.Display = link;
                ritem.Saved();

                _systemTray.ShowTextNotification($"{_loc.ImgurSuccess}: {link}", _settings.UI.ScreenShotNotifyTimeout, () => Process.Start(link));

                Status.LocalizationKey = nameof(LanguageManager.ImgurSuccess);
            }
        }