Exemple #1
0
        public Task Save(Bitmap Image, ImageFormat Format, string FileName, RecentViewModel Recents)
        {
            try
            {
                _settings.EnsureOutPath();

                var extension = Format.Equals(ImageFormat.Icon) ? "ico"
                    : Format.Equals(ImageFormat.Jpeg) ? "jpg"
                    : Format.ToString().ToLower();

                var fileName = _settings.GetFileName(extension, FileName);

                Image.Save(fileName, Format);

                Recents.Add(fileName, RecentItemType.Image, false);

                // Copy path to clipboard only when clipboard writer is off
                if (_settings.CopyOutPathToClipboard && !ServiceProvider.Get <ClipboardWriter>().Active)
                {
                    fileName.WriteToClipboard();
                }

                _systemTray.ShowScreenShotNotification(fileName);
            }
            catch (Exception e)
            {
                _messageProvider.ShowException(e, _loc.NotSaved);
            }

            return(Task.CompletedTask);
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.RecentView);

            recentViewModel = ViewModel as RecentViewModel;
        }
Exemple #3
0
        public Task Save(Bitmap Image, ImageFormat Format, string FileName, RecentViewModel Recents)
        {
            Image.WriteToClipboard(Format.Equals(ImageFormat.Png));

            _systemTray.ShowNotification(false).PrimaryText = _loc.ImgSavedClipboard;

            return(Task.CompletedTask);
        }
Exemple #4
0
        public IActionResult Index()
        {
            var model = new RecentViewModel();

            model.RecentFiles = _recent.GetRecentFiles();

            return(View(model));
        }
Exemple #5
0
 public MePage()
 {
     InitializeComponent();
     Updater();
     (lvRecent.Parent as Frame).BackgroundColor = Color.FromRgba(1, 1, 1, 0.05);
     WebHandler.UpdateMe = new Action(async() => await Update());
     BindingContext      = viewModel = new RecentViewModel();
     s = System.Diagnostics.Stopwatch.StartNew();
     System.Threading.ThreadPool.QueueUserWorkItem((e) => { System.Threading.Thread.Sleep(300); TimeBox.Text = s.Elapsed.TotalSeconds.ToString(); });
 }
        public UserDetailPage()
        {
            InitializeComponent();

            DataContext = new RecentViewModel();
        }
Exemple #7
0
        public async Task Save(Bitmap Image, ImageFormat Format, string FileName, RecentViewModel Recents)
        {
            var progressItem = _systemTray.ShowProgress();

            progressItem.PrimaryText = _loc.ImgurUploading;

            using (var w = new WebClient {
                Proxy = _settings.Proxy.GetWebProxy()
            })
            {
                w.UploadProgressChanged += (s, e) =>
                {
                    progressItem.Progress = 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");
                    }
                }
                catch (Exception e)
                {
                    progressItem.Finished = true;
                    progressItem.Success  = false;

                    progressItem.PrimaryText = _loc.ImgurFailed;

                    if (!_diskWriter.Active)
                    {
                        ServiceProvider.Get <IMainWindow>().IsVisible = true;

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

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

                    return;
                }

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

                // Copy path to clipboard only when clipboard writer is off
                if (_settings.CopyOutPathToClipboard && !ServiceProvider.Get <ClipboardWriter>().Active)
                {
                    link.WriteToClipboard();
                }

                Recents.Add(link, RecentItemType.Link, false);

                progressItem.Finished      = true;
                progressItem.Success       = true;
                progressItem.PrimaryText   = _loc.ImgurSuccess;
                progressItem.SecondaryText = link;

                progressItem.RegisterClick(() => Process.Start(link));
            }
        }
Exemple #8
0
 public RecentPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = new RecentViewModel();
 }
Exemple #9
0
 public RecentDatabasesPage()
 {
     InitializeComponent();
     ViewModel = new RecentViewModel();
 }