public void Search(string artist, string album, IScriptResults results) { int numberOfResults = 50; results.EstimatedCount = numberOfResults; Random rnd = new Random(); for (int i = 0; i < numberOfResults; i++) { Bitmap thumbnail = new Bitmap(typeof(TestScript), "testThumbnail.jpg"); Bitmap fullSize = new Bitmap(typeof(TestScript), "testFullsize.jpg"); //results.Add(thumbnail, i.ToString(), "notauri", 1000 + rnd.Next(6) * 100, rnd.Next(1, 1600), fullSize, (CoverType)rnd.Next((int)CoverType.Unknown, (int)CoverType.CD + 1)); results.Add(thumbnail, i.ToString(), "notauri", -1, -1, fullSize, (CoverType)rnd.Next((int)CoverType.Unknown, (int)CoverType.CD + 1)); //System.Threading.Thread.Sleep(1000); } }
protected override void SearchInternal(string artist, string album, IScriptResults results) { try { mScript.Search(artist, album, results); } catch (ThreadAbortException) { } //Script was cancelled catch (Exception e) { string message; if (e is System.Reflection.TargetInvocationException) { message = ((System.Reflection.TargetInvocationException)e).InnerException.Message; } else { message = e.Message; } System.Diagnostics.Debug.Fail(String.Format("Script {0} threw an exception while searching: {1}", mScript.Name, message)); } }
/* * private class TestWin : System.Windows.Window * { * public TestWin() * { * var a = new System.Windows.Media.Animation.ThicknessAnimation(); * * * } * }*/ public void Search(string artist, string album, IScriptResults results) { /* * var bitmap = new Bitmap(400, 600); * var g = Graphics.FromImage(bitmap); * g.Clear(SystemColors.Window); * g.DrawString("hello\nthere", SystemFonts.DialogFont, SystemBrushes.WindowText, PointF.Empty); * g.Dispose(); * * results.Add(ConvertImageToStream(bitmap), "test", null); * bitmap.Dispose(); * * return; * */ int numberOfResults = 1; results.EstimatedCount = numberOfResults; Random rnd = new Random(); var assembly = GetType().Assembly; try { for (int i = 0; i < numberOfResults; i++) { //results.Add(thumbnail, i.ToString(), "notauri", 1000 + rnd.Next(6) * 100, rnd.Next(1, 1600), fullSize, (CoverType)rnd.Next((int)CoverType.Unknown, (int)CoverType.CD + 1)); results.Add(assembly.GetManifestResourceStream("TestScript.testThumbnail.jpg"), i.ToString(), "notauri", -1, -1, assembly.GetManifestResourceStream("TestScript.testBadImage.jpg"), (CoverType)rnd.Next((int)CoverType.Unknown, (int)CoverType.Booklet + 1), "gif"); System.Threading.Thread.Sleep(1000); } } catch (ThreadAbortException) { System.Diagnostics.Debug.WriteLine("Exception"); } finally { System.Diagnostics.Debug.WriteLine("finished"); } }
/// <summary> /// Perform the actual internal searching operation /// This should not update any WPF controls, or /// perform any direct modification of property values. /// </summary> protected abstract void SearchInternal(string artist, string album, IScriptResults results);
public void Search(string artist, string album, IScriptResults results) { mGetThumbsMethod.Invoke(null, new object[] { results, artist, album }); }