protected virtual void Completed(GetItemInfoFromAmazonCompletedEventArgs e) { if (GetItemInfoFromAmazonCompleted != null) { GetItemInfoFromAmazonCompleted(this, e); } }
private void SendCompletedEvent(string result, XElement itemInfo) { GetItemInfoFromAmazonCompletedEventArgs completedEvent = new GetItemInfoFromAmazonCompletedEventArgs(); completedEvent.Result = result; completedEvent.XmlItemInfo = itemInfo; //completedEvent.Item = itemData; Completed(completedEvent); }
//自作イベントのイベントハンドラ。 //getItemInfoFromAmazonToXmlDBが完了したときにイベントが発行される。 //成功のときも失敗のときも。 public void aws_GetItemInfoFromAmazonCompleted(object sender, GetItemInfoFromAmazonCompletedEventArgs e) { //string Namespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01"; //XNamespace ns = aws.NameSpace; XElement xmlItemInfo = e.XmlItemInfo; XNamespace ns = xmlItemInfo.Name.Namespace; Grid_Notice.Visibility = Visibility.Visible; SystemTray.GetProgressIndicator(this).IsVisible = false; switch (e.Result) { case "Completed": modifyBookModelByDownloadedData(e.XmlItemInfo); System.Diagnostics.Debug.WriteLine("Completed: "); TextBlock_Notice.Text = "Download Completed."; //textBlock2.Text = e.Item.Title; // 分離ストレージから画像ファイルを読み込み。確認用。画面右下に表示するため。 //image1.Source = e.Item.GetItemImage(); break; case "NoNetwork": System.Diagnostics.Debug.WriteLine("No Network: "); //image1.Source = e.Item.GetItemImage(); TextBlock_Notice.Text = "No network."; break; case "NoItemFound": System.Diagnostics.Debug.WriteLine("No Item : "); TextBlock_Notice.Text = "Item not found."; break; case "GotImage": System.Diagnostics.Debug.WriteLine("Got Image Successfully: "); initImage(); break; case "HTMLLoginPage": TextBlock_Notice.Text = "No network."; break; default: TextBlock_Notice.Text = "Failure."; break; } //イベントハンドラの削除 //aws.GetItemInfoFromAmazonCompleted -= aws_GetItemInfoFromAmazonCompleted; }
public void aws_GetItemInfoFromAmazonCompleted(object sender, GetItemInfoFromAmazonCompletedEventArgs e) { XElement xmlItemInfo = e.XmlItemInfo; XNamespace ns = xmlItemInfo.Name.Namespace; switch (e.Result) { case "Completed": AddBookInfoToBookView(e.XmlItemInfo); System.Diagnostics.Debug.WriteLine("Completed: "); // 分離ストレージから画像ファイルを読み込み。確認用。画面右下に表示するため。 //image1.Source = e.Item.GetItemImage(); break; case "NoNetwork": System.Diagnostics.Debug.WriteLine("No Network: " + xmlItemInfo.Element("EAN")); AddBookInfoOnlyEAN(xmlItemInfo); //image1.Source = e.Item.GetItemImage(); break; case "NoItemFound": System.Diagnostics.Debug.WriteLine("No Item : "); AddBookInfoOnlyEAN(xmlItemInfo); break; case "GotImage": System.Diagnostics.Debug.WriteLine("GotImage: "); break; case "HTMLLoginPage": AddBookInfoOnlyEAN(xmlItemInfo); break; default: AddBookInfoOnlyEAN(xmlItemInfo); break; } //itemDB.DBManipulationCompleted += new ItemDataBase.DBManipulationCompletedEventHandler(this.ItemDB_DBManipulationCompleted); //itemDB.AddByAuto(xmlItemInfo); //アマゾンからデータを取得するインスタンスにイベントハンドラを削除 //aws.GetItemInfoFromAmazonCompleted -= aws_GetItemInfoFromAmazonCompleted; }