Skip to content

Commit

Permalink
First Cut of #17
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Mar 19, 2018
1 parent 48106f2 commit 0fe036b
Show file tree
Hide file tree
Showing 11 changed files with 804 additions and 11 deletions.
16 changes: 15 additions & 1 deletion TVRename#/Custom Controls/TheTVDBCodeFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace TVRename
{
/// <inheritdoc />
/// <summary>
/// Summary for TheTVDBCodeFinder
/// </summary>
Expand Down Expand Up @@ -62,6 +63,19 @@ public int SelectedCode()
return -1;
}
}
public string SelectedShowName()
{
try
{
if (this.lvMatches.SelectedItems.Count == 0) return "";

return (string)(this.lvMatches.SelectedItems[0].SubItems[1].Text);
}
catch
{
return "";
}
}

private void txtFindThis_TextChanged(object sender, EventArgs e)
{
Expand Down Expand Up @@ -186,4 +200,4 @@ private void lvMatches_ColumnClick(object sender, ColumnClickEventArgs e)
lvMatches.Sort();
}
}
}
}
137 changes: 137 additions & 0 deletions TVRename#/Forms/AutoAddShow.Designer.cs

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

75 changes: 75 additions & 0 deletions TVRename#/Forms/AutoAddShow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Windows.Forms;

namespace TVRename.Forms
{
public partial class AutoAddShow : Form
{
private ShowItem mSI;
private readonly TheTVDBCodeFinder mTCCF;

public AutoAddShow(string hint)
{
InitializeComponent();
this.mSI = new ShowItem();
this.mTCCF = new TheTVDBCodeFinder("") {Dock = DockStyle.Fill};
this.mTCCF.SetHint(hint);
this.mTCCF.SelectionChanged += MTCCF_SelectionChanged;
this.pnlCF.SuspendLayout();
this.pnlCF.Controls.Add(this.mTCCF);
this.pnlCF.ResumeLayout();
this.ActiveControl = this.mTCCF; // set initial focus to the code entry/show finder control

this.cbDirectory.SuspendLayout();
this.cbDirectory.Items.Clear();
this.cbDirectory.Items.AddRange(TVSettings.Instance.MonitorFoldersNames.ToArray());
this.cbDirectory.SelectedIndex = 0;
this.cbDirectory.ResumeLayout();
}

private void MTCCF_SelectionChanged(object sender, EventArgs e)
{
this.lblDirectoryName.Text = System.IO.Path.DirectorySeparatorChar + TVSettings.Instance.FilenameFriendly(FileHelper.MakeValidPath(this.mTCCF.SelectedShowName( )));
}

public ShowItem ShowItem => this.mSI;

private void SetShowItem()
{
int code = this.mTCCF.SelectedCode();


this.mSI.TVDBCode = code;
this.mSI.AutoAdd_FolderBase = this.cbDirectory.Text+this.lblDirectoryName.Text;

}

private void btnOK_Click(object sender, EventArgs e)
{
if (!OkToClose())
{
this.DialogResult = DialogResult.None;
return;
}

SetShowItem();
this.DialogResult = DialogResult.OK;
Close();
}

private bool OkToClose()
{
if (TheTVDB.Instance.HasSeries(this.mTCCF.SelectedCode())) return true;

DialogResult dr = MessageBox.Show("tvdb code unknown, close anyway?", "TVRename Add/Edit Show",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

return dr != DialogResult.No;
}

private void AutoAddShow_Load(object sender, EventArgs e)
{

}
}
}
Loading

0 comments on commit 0fe036b

Please sign in to comment.