Skip to content

Commit

Permalink
Added on-the-fly interpolation and model chaining features
Browse files Browse the repository at this point in the history
  • Loading branch information
N00MKRAD committed Sep 14, 2020
1 parent c1c70ed commit 550cfc2
Show file tree
Hide file tree
Showing 23 changed files with 3,814 additions and 809 deletions.
2 changes: 2 additions & 0 deletions Code/Cupscale.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
<ApplicationIcon>CupscaleLogo1.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BetterTabControl" Version="1.0.19295.1523" />
<PackageReference Include="Costura.Fody" Version="4.1.0" />
<PackageReference Include="CyotekImageBox" Version="1.2.1" />
<PackageReference Include="CyotekTabList" Version="2.0.0" />
<PackageReference Include="DotNetZip" Version="1.13.8" />
<PackageReference Include="Fody" Version="6.2.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
12 changes: 12 additions & 0 deletions Code/Cupscale/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ internal class Logger
{
public static TextBox textbox;

public static string sessionLog;

public static void Log(string s, bool replaceLastLine = false)
{
Console.WriteLine(s);
if (replaceLastLine)
{
textbox.Text = textbox.Text.Remove(textbox.Text.LastIndexOf(Environment.NewLine));
}

sessionLog = sessionLog + s + Environment.NewLine;

s = s.Replace("\n", Environment.NewLine);
/*
if (textbox != null)
{
textbox.AppendText(Environment.NewLine + s);
Expand All @@ -23,6 +29,12 @@ public static void Log(string s, bool replaceLastLine = false)
{
Console.WriteLine("logTbox is null!");
}
*/
}

public static string GetSessionLog ()
{
return sessionLog;
}
}
}
758 changes: 233 additions & 525 deletions Code/Cupscale/MainForm.Designer.cs

Large diffs are not rendered by default.

66 changes: 40 additions & 26 deletions Code/Cupscale/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ImageBox = Cyotek.Windows.Forms.ImageBox;
using Cupscale.Properties;
using System.Drawing.Drawing2D;
using Cupscale.Forms;

namespace Cupscale
{
Expand All @@ -21,16 +22,13 @@ public MainForm()
EsrganData.ReloadModelList();
CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
ConfigTabHelper.LoadEsrganSettings(confTilesize, confAlpha, modelPathBox, confAlphaBgColorTbox);
PreviewTabHelper.Init(previewImg, singleModelBox, prevOutputFormatCombox, prevOverwriteCombox);
UIHelpers.FillModelComboBox(singleModelBox);
PreviewTabHelper.Init(previewImg, modelCombox1, modelCombox2, prevOutputFormatCombox, prevOverwriteCombox);
Program.mainForm = this;
WindowState = FormWindowState.Maximized;
}

private void MainForm_Load(object sender, EventArgs e)
{
Logger.textbox = logTbox;
UIHelpers.InitCombox(prevOverwriteCombox, 0);
UIHelpers.InitCombox(prevOutputFormatCombox, 0);
UIHelpers.InitCombox(prevClipboardTypeCombox, 0);
Expand All @@ -48,11 +46,6 @@ private void refreshModelsBtn_Click(object sender, EventArgs e)
EsrganData.ReloadModelList();
}

private void confSaveEsrganBtn_Click(object sender, EventArgs e)
{
ConfigTabHelper.SaveEsrganSettings(confTilesize, confAlpha, modelPathBox, confAlphaBgColorTbox);
}

private void refreshPrevBtn_Click(object sender, EventArgs e)
{
PreviewTabHelper.UpscalePreview();
Expand All @@ -74,11 +67,6 @@ private void prevToggleFilterBtn_Click(object sender, EventArgs e)
}
}

private void modelTabControl_PageChanged(object sender, PageChangedEventArgs e)
{
PreviewTabHelper.UpdateMode(modelTabControl.SelectedIndex);
}

private void previewImg_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
Expand Down Expand Up @@ -128,11 +116,6 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

private void singleModelBox_DropDown(object sender, EventArgs e)
{
UIHelpers.FillModelComboBox(singleModelBox);
}

private void copyComparisonClipboardBtn_Click(object sender, EventArgs e)
{
if(prevClipboardTypeCombox.SelectedIndex == 0) ClipboardPreview.CopyToClipboardSideBySide();
Expand All @@ -150,17 +133,48 @@ void UpdatePreviewInfo ()
PreviewTabHelper.UpdatePreviewLabels(prevZoomLabel, prevSizeLabel, prevCutoutLabel);
}

private void confAlphaBgColorBtn_Click(object sender, EventArgs e)
private void refreshPrevFullBtn_Click(object sender, EventArgs e)
{
alphaBgColorDialog.ShowDialog();
string colorStr = ColorTranslator.ToHtml(Color.FromArgb(alphaBgColorDialog.Color.ToArgb())).Replace("#", "") + "FF";
confAlphaBgColorTbox.Text = colorStr;
Config.Set("alphaBgColor", colorStr);
PreviewTabHelper.UpscalePreview(true);
}

private void refreshPrevFullBtn_Click(object sender, EventArgs e)
private void settingsBtn_Click(object sender, EventArgs e)
{
PreviewTabHelper.UpscalePreview(true);
SettingsForm settingsForm = new SettingsForm();
}

private void singleModelRbtn_CheckedChanged(object sender, EventArgs e)
{
UpdateModelMode();
}

private void interpRbtn_CheckedChanged(object sender, EventArgs e)
{
UpdateModelMode();
}

private void chainRbtn_CheckedChanged(object sender, EventArgs e)
{
UpdateModelMode();
}

public void UpdateModelMode()
{
modelCombox2.Enabled = (interpRbtn.Checked || chainRbtn.Checked);
interpConfigureBtn.Visible = interpRbtn.Checked;
if (singleModelRbtn.Checked) PreviewTabHelper.currentMode = PreviewTabHelper.Mode.Single;
if (interpRbtn.Checked) PreviewTabHelper.currentMode = PreviewTabHelper.Mode.Interp;
if (chainRbtn.Checked) PreviewTabHelper.currentMode = PreviewTabHelper.Mode.Chain;
}

private void interpConfigureBtn_Click(object sender, EventArgs e)
{
if (modelCombox1.SelectedIndex == -1 || modelCombox2.SelectedIndex == -1)
{
MessageBox.Show("Please select two models for interpolation.", "Message");
return;
}
InterpForm interpForm = new InterpForm(modelCombox1.Text.Trim(), modelCombox2.Text.Trim());
}
}
}
4 changes: 2 additions & 2 deletions Code/Cupscale/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="alphaBgColorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>47</value>
<value>31</value>
</metadata>
</root>
160 changes: 160 additions & 0 deletions Code/Forms/InterpForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions Code/Forms/InterpForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Cupscale.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Cupscale.Forms
{
public partial class InterpForm : Form
{
string leftModelName;
string rightModelName;

public InterpForm(string leftModel, string rightModel)
{
leftModelName = leftModel;
rightModelName = rightModel;
InitializeComponent();
Show();
CenterToParent();
}

private void InterpForm_Load(object sender, EventArgs e)
{
interpSlider.Value = PreviewTabHelper.interpValue / 5;
UpdateLabels();
}

private void saveBtn_Click(object sender, EventArgs e)
{
PreviewTabHelper.interpValue = interpSlider.Value * 5;
Close();
}

private void interpSlider_ValueChanged(object sender, EventArgs e)
{
UpdateLabels();
}

void UpdateLabels ()
{
leftModelLabel.Text = leftModelName + ": " + (100 - interpSlider.Value * 5) + "%";
rightModelLabel.Text = rightModelName + ": " + interpSlider.Value * 5 + "%";
}
}
}
Loading

0 comments on commit 550cfc2

Please sign in to comment.