Esempio n. 1
0
        async Task DragNDrop(string [] files)
        {
            Logger.Log("[MainUI] Dropped " + files.Length + " file(s), files[0] = " + files[0]);
            IOUtils.ClearDir(Paths.tempImgPath.GetParentDir());
            string     path = files[0];
            DialogForm loadingDialogForm = null;

            if (IOUtils.IsPathDirectory(path))
            {
                htTabControl.SelectedIndex = 1;
                int compatFilesAmount = IOUtils.GetAmountOfCompatibleFiles(path, true);
                batchDirLabel.Text = "Loaded " + path.Wrap() + " - Found " + compatFilesAmount + " compatible files.";
                BatchUpscaleUI.LoadDir(path);
                upscaleBtn.Text = "Upscale " + compatFilesAmount + " Images";
                return;
            }
            if (files.Length > 1)
            {
                htTabControl.SelectedIndex = 1;
                int compatFilesAmount = IOUtils.GetAmountOfCompatibleFiles(files);
                BatchUpscaleUI.LoadImages(files);
                batchDirLabel.Text = "Loaded " + compatFilesAmount + " compatible files.";
                upscaleBtn.Text    = "Upscale " + compatFilesAmount + " Images";
                return;
            }
            upscaleBtn.Text            = "Upscale And Save";
            htTabControl.SelectedIndex = 0;
            previewImg.Text            = "";
            SetProgress(0f, "Loading image...");
            loadingDialogForm = new DialogForm("Loading " + Path.GetFileName(path) + "...");
            await Task.Delay(20);

            MainUIHelper.ResetCachedImages();
            if (!MainUIHelper.DroppedImageIsValid(path))
            {
                SetProgress(0f, "Ready.");
                await Task.Delay(1);

                Program.CloseTempForms();
                return;
            }
            Program.lastFilename = path;
            ReloadImage(false);
            if (failed)
            {
                FailReset(); return;
            }
            SetHasPreview(false);
            loadingDialogForm.Close();
            SetRefreshPreviewBtns(true);
            SetProgress(0f, "Ready.");
        }
Esempio n. 2
0
        async Task LoadImages(string [] files)
        {
            Logger.Log("[MainUI] Dropped " + files.Length + " file(s), files[0] = " + files[0]);
            IOUtils.ClearDir(Paths.tempImgPath.GetParentDir());
            string path = files[0];

            if (IOUtils.IsPathDirectory(path))
            {
                htTabControl.SelectedIndex = 1;
                BatchUpscaleUI.LoadDir(path);
                return;
            }
            if (files.Length > 1)
            {
                htTabControl.SelectedIndex = 1;
                BatchUpscaleUI.LoadImages(files);
                return;
            }
            upscaleBtn.Text            = "Upscale And Save";
            htTabControl.SelectedIndex = 0;
            previewImg.Text            = "";
            SetProgress(0f, "Loading image...");
            PreviewUI.ResetCachedImages();
            if (!PreviewUI.DroppedImageIsValid(path))
            {
                SetProgress(0f, "Ready.");
                await Task.Delay(1);

                Program.CloseTempForms();
                return;
            }
            Program.lastImgPath = path;
            ReloadImage(false);
            if (failed)
            {
                FailReset(); return;
            }
            SetHasPreview(false);
            ImageLoadedChanged(true);
            SetProgress(0f, "Ready.");
        }