Skip to content
Browse files

pattexing moved to background thread, fixed a bug with MyList add

  • Loading branch information...
1 parent 45e5882 commit 2418d64e2b7b2da8a3dec41a87ea6788047f5e33 @Firethunder Firethunder committed
Showing with 27 additions and 22 deletions.
  1. +1 −1 Glue.cs
  2. +3 −0 Helper/FileRenamer.cs
  3. +7 −8 Login.xaml.cs
  4. +16 −13 MainWindow.xaml.cs
View
2 Glue.cs
@@ -120,7 +120,7 @@ public void run()
anime.FileState = "Finished";
//If state is set, send request to update the list on anidb
- if (mainwin.getAdd() != null || mainwin.getAdd() != false)
+ if (mainwin.getAdd() != null && mainwin.getAdd() != false)
{
conn.query(new API.Model.Request.MyListAddRequest(hash.FileSize, hash.Ed2kHash, state: (API.Model.Request.MyListAddRequest.State)mainwin.getState() ,viewed:mainwin.getViewed(), viewdate:0, source:mainwin.getSource(), storage:mainwin.getStorage(), other:mainwin.getOther()));
mainwin.lbLog_Add("Add to Mylist");
View
3 Helper/FileRenamer.cs
@@ -80,6 +80,7 @@ public void renameTo(Anime animeFile)
{
animeFile.FileState = "moving";
String sPath = animeFile.FileName.Substring(0, animeFile.FileName.LastIndexOf(@"\") + 1);
+ String sOldPath = sPath;
String sType = animeFile.FileName.Substring(animeFile.FileName.LastIndexOf(@"."));
String sRenamed = _Pattern;
episode episodes = db.getEpisode(animeFile.FileHash);
@@ -96,6 +97,8 @@ public void renameTo(Anime animeFile)
if (!Directory.Exists(sPath))
Directory.CreateDirectory(sPath);
File.Move(animeFile.FileName, sPath + sRenamed);
+ if (Directory.GetFiles(sOldPath).Length == 0)
+ Directory.Delete(sOldPath);
animeFile.FileName = sPath + sRenamed;
}
catch (Exception e)
View
15 Login.xaml.cs
@@ -55,14 +55,13 @@ private void LoginCommand_Click(object sender, RoutedEventArgs e)
else
{
this.DialogResult = true;
- /* uncomment if ready to publish
- * if (AniSharp.Properties.Settings.Default.Username != tbUser.Text)
- {
- * AniSharp.Properties.Settings.Default.Username = tbUser.Text;
- * AniSharp.Properties.Settings.Default.Save();
- * }
- */
- }
+
+ if (AniSharp.Properties.Settings.Default.Username != tbUser.Text)
+ {
+ AniSharp.Properties.Settings.Default.Username = tbUser.Text;
+ AniSharp.Properties.Settings.Default.Save();
+ }
+ }
}
/// <summary>
View
29 MainWindow.xaml.cs
@@ -84,6 +84,8 @@ public String FileFilter
}
}
#endregion
+
+ #region window functions
/// <summary>
/// Konstruktor fuer das MainWindow
@@ -105,7 +107,6 @@ public void activateStart()
{
Dispatcher.Invoke(new Action(() => { btStart.IsEnabled = true; }));
}
- #region window functions
/// <summary>
/// Passt die ListBoxen an die größe des Fensters an
/// </summary>
@@ -161,6 +162,7 @@ private void btStart_Click(object sender, RoutedEventArgs e)
{
Glue g = new Glue(s, conn, this);
System.Threading.Thread pattexing = new System.Threading.Thread(g.run);
+ pattexing.IsBackground = true;
pattexing.Start();
}
}
@@ -448,6 +450,16 @@ public void onApiSessionStatusChange(bool loggedIn, bool shouldRetry, string Mes
}
btLogin.IsEnabled = true;
}
+
+ /// <summary>
+ /// Aktualisiert das Move Pattern sobald der Text verändert wird.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void tbMove_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ _fr.setPath(tbMove.Text);
+ }
#endregion
#region CommandEventHandler
@@ -521,19 +533,10 @@ private void PlayCmdExecuted(object sender, ExecutedRoutedEventArgs e)
/// <param name="e"></param>
private void PlayCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
- if(((Anime)lvFiles.SelectedItem).FileName.Contains("Finished"))
+ if(lvFiles.SelectedItem!=null)
+ if(((Anime)lvFiles.SelectedItem).FileState.Contains("Finished"))
e.CanExecute = true;
}
- #endregion
-
- /// <summary>
- /// Aktualisiert das Move Pattern sobald der Text verändert wird.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tbMove_TextChanged(object sender, TextChangedEventArgs e)
- {
- _fr.setPath(tbMove.Text);
- }
+ #endregion
}
}

0 comments on commit 2418d64

Please sign in to comment.
Something went wrong with that request. Please try again.