Exemple #1
0
        private async void upscaleBtn_Click(object sender, EventArgs e)
        {
            if (Program.busy)
            {
                return;
            }

            if (!MainUIHelper.HasValidModelSelection())
            {
                Program.ShowMessage("Invalid model selection.\nMake sure you have selected a model and that the file still exists.", "Error");
                return;
            }

            bool useNcnn = (Config.Get("cudaFallback").GetInt() == 2 || Config.Get("cudaFallback").GetInt() == 3);

            if (useNcnn && !Program.mainForm.HasValidNcnnModelSelection())
            {
                Program.ShowMessage("Invalid model selection - NCNN does not support interpolation or chaining.", "Error");
                return;
            }

            if (Config.GetBool("reloadImageBeforeUpscale"))
            {
                ReloadImage();
            }
            UpdateResizeMode();
            if (htTabControl.SelectedIndex == 0)
            {
                await MainUIHelper.UpscaleImage();
            }
            if (htTabControl.SelectedIndex == 1)
            {
                await BatchUpscaleUI.Run(preprocessMode.SelectedIndex == 0);
            }
        }
Exemple #2
0
 public MainForm()
 {
     CheckForIllegalCrossThreadCalls = false;
     InitializeComponent();
     MainUIHelper.Init(previewImg, model1TreeBtn, model2TreeBtn, prevOutputFormatCombox, prevOverwriteCombox);
     BatchUpscaleUI.Init(batchOutDir, batchFileList);
     Program.mainForm = this;
     WindowState      = FormWindowState.Maximized;
 }
Exemple #3
0
 public MainForm()
 {
     CheckForIllegalCrossThreadCalls = false;
     InitializeComponent();
     PreviewUI.Init(previewImg, model1TreeBtn, model2TreeBtn, imageOutputFormat, prevOverwriteCombox);
     BatchUpscaleUI.Init(batchOutDir, batchFileList, batchDirLabel);
     VideoUpscaleUI.Init(videoOutDir, videoLogBox, videoPathLabel, videoOutputFormat);
     Program.mainForm = this;
     WindowState      = FormWindowState.Maximized;
 }
Exemple #4
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.");
        }
Exemple #5
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.");
        }
Exemple #6
0
 private void htTabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Program.busy)
     {
         htTabControl.SelectedIndex = lastTabIndex;
         return;
     }
     lastTabIndex = htTabControl.SelectedIndex;
     videoOutputFormat.Visible = false;
     if (htTabControl.SelectedIndex == 0)
     {
         PreviewUI.TabSelected();
     }
     if (htTabControl.SelectedIndex == 1)
     {
         BatchUpscaleUI.TabSelected();
     }
     if (htTabControl.SelectedIndex == 2)
     {
         VideoUpscaleUI.TabSelected();
         videoOutputFormat.Visible = true;
     }
 }