本文整理汇总了C#中System.Net.DownloadStringCompletedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DownloadStringCompletedEventArgs类的具体用法?C# DownloadStringCompletedEventArgs怎么用?C# DownloadStringCompletedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DownloadStringCompletedEventArgs类属于System.Net命名空间,在下文中一共展示了DownloadStringCompletedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: web_DownloadStringCompleted
void web_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Progress.IsIndeterminate = false;
((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
try
{
PromoCardObject deserializedResponse = JsonConvert.DeserializeObject<PromoCardObject>(e.Result);
if (deserializedResponse.error == null)
{
foreach (Image item in stampCanvas.Children)
{
item.Opacity = 0;
}
for (int i = 0; i < deserializedResponse.data[0].AvaliableCount; i++)
{
stampCanvas.Children[i].Opacity = 1;
}
}
else
{
MessageBox.Show(deserializedResponse.error.Message);
}
}
catch (Exception)
{
MessageBox.Show("İnternet bağlantınızla ilgili bir sorun var");
}
}
示例2: client_DownloadStringCompleted
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
int itemsCount = 7;
xmlReader = XmlReader.Create(new StringReader(e.Result));
feed = SyndicationFeed.Load(xmlReader);
List<RSSItem> itemsList = new List<RSSItem>();
if (feed.Items.Count() < 7)
{
itemsCount = feed.Items.Count();
}
for (int i = 0; i <= itemsCount; i++)
{
RSSItem rssitem = new RSSItem();
rssitem.RSSTitle = feed.Items.ToList()[i].Title.Text;
rssitem.RSSLink = feed.Items.ToList()[i].Links[0].Uri;
itemsList.Add(rssitem);
}
RSS.ItemsSource = itemsList;
}
}
示例3: HandleCompletedDownload
void HandleCompletedDownload(object sender, DownloadStringCompletedEventArgs e, DownloadType type)
{
switch (type)
{
case DownloadType.RecentPlaylist:
{
Parsers.ParseRecentPlaylist(e.Result);
break;
}
case DownloadType.MostPlayedPlaylist:
{
Parsers.ParseMostPlayed(e.Result);
break;
}
case DownloadType.FavoritePlaylist:
{
Parsers.ParseFavorites(e.Result);
break;
}
case DownloadType.BadgeList:
{
Parsers.ParseBadges(e.Result);
break;
}
case DownloadType.FriendList:
{
Parsers.ParseFriends(e.Result);
break;
}
}
}
示例4: handleDownloadStringComplete
private void handleDownloadStringComplete(object sender, DownloadStringCompletedEventArgs e)
{
if (Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable)
{
XNamespace media = XNamespace.Get("http://search.yahoo.com/mrss/");
titles = System.Xml.Linq.XElement.Parse(e.Result).Descendants("title")
.Where(m => m.Parent.Name == "item")
.Select(m => m.Value)
.ToArray();
descriptions = XElement.Parse(e.Result).Descendants("description")
.Where(m => m.Parent.Name == "item")
.Select(m => m.Value)
.ToArray();
images = XElement.Parse(e.Result).Descendants(media + "thumbnail")
.Where(m => m.Parent.Name == "item")
.Select(m => m.Attribute("url").Value)
.ToArray();
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SpeakTextAsync(titles[0]).Completed += new AsyncActionCompletedHandler(delegate(IAsyncAction action, AsyncStatus status)
{
synth.SpeakTextAsync(descriptions[0]);
});
UpdatePrimaryTile(titles[0], images[0]);
}
else
{
MessageBox.Show("No network is available...");
}
}
示例5: Downloaded
/// <summary>
/// Download is completed
/// *Craate list
/// *sent event
/// </summary>
/// <param name="sender"></param>
/// <param name="e">arguments of download call</param>
private void Downloaded(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (!e.Cancelled)
{
var xml = XElement.Parse(e.Result);
var items = xml.Elements("channel").Elements("item").Select(element => new RssFeedItem
{
Description = (ReadElement(element, "description")),
Title = ReadElement(element, "title"),
Link = ReadElement(element, "link"),
PublishDate = DateTime.Parse(ReadElement(element, "pubDate"))
}).ToList();
if (ReadRssCompleted != null)
ReadRssCompleted(this, new ReadFeedCallbackArguments {FeedItems = items});
}
}
catch (Exception)
{
if (ReadRssCompleted != null)
ReadRssCompleted(this, new ReadFeedCallbackArguments {ErrorMessage = "Error occurred..."});
}
}
示例6: webClient_DownloadStringCompleted
/// <summary>
/// Web service completed event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (e.Error == null && e.Result != null && e.Result.Count() != 2)
{
conditionLeaflets = JsonHelper.Deserialize<ConditionSearchCollection>(e.Result);
objConditionSearchViewModel.SearchCollection = conditionLeaflets;
objConditionSearchViewModel.ProgressBarVisibilty = Visibility.Collapsed;
objConditionSearchViewModel.NoLeafletTextVisibility = Visibility.Collapsed;
}
else
{
objConditionSearchViewModel.NoLeafletTextVisibility = Visibility.Visible;
objConditionSearchViewModel.ProgressBarVisibilty = Visibility.Collapsed;
}
}
catch (Exception)
{
objConditionSearchViewModel.ProgressBarVisibilty = Visibility.Collapsed;
MessageBox.Show("Sorry, Unable to process your request.");
}
}
示例7: LoadDescriptionCompleted
private void LoadDescriptionCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string html = e.Result;
try
{
string one = html.Substring(html.IndexOf("Explanation:"));
string two = one.Substring(one.IndexOf(">") + 1);
string three = two.Substring(0, two.IndexOf(@"<p>"));
Explanation.Text = three;
}
catch
{
Explanation.Text = "Visit the NASA web site for a description.";
}
string imgroot = "http://apod.nasa.gov/apod/";
try
{
string four = html.Substring(html.IndexOf("<IMG SRC=") + 10);
string url = four.Substring(0, four.IndexOf('"'));
_todayUrl = imgroot + url;
}
catch
{
_todayUrl = "http://apod.nasa.gov/apod/calendar/today.jpg";
}
}
示例8: webClient_DownloadStringCompleted
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
verifyAuth(e.Result);
}
}
示例9: client_DownloadStringCompleted
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
try
{
JObject json = JObject.Parse(e.Result);
Version current = Assembly.GetExecutingAssembly().GetName().Version;
Version latest = Version.Parse((string)json["win"]["version"]);
Uri latestUrl = new Uri((string)json["win"]["url"], UriKind.Absolute);
if(Completed != null)
{
Completed(this, new UpdateAvailableEventArgs()
{
UpdateAvailable = latest > current,
CurrentVersion = current.ToString(),
NewVersion = latest.ToString(),
NewVersionUri = latestUrl
});
}
}
catch (Exception ex)
{
OnException(ex);
}
}
else
{
OnException(e.Error);
}
}
示例10: verCheck_DownloadStringCompleted
void verCheck_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
try
{
if (e.Result.ToString().Equals(fvi.FileVersion) == false)
{
if (MessageBox.Show("New version availible - " + e.Result.ToString() + ", do you want to visit the download site?", "Download new version?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
string strTarget = "https://github.com/nccgroup/ncccodenavi";
try
{
System.Diagnostics.Process.Start(strTarget);
}
catch (System.ComponentModel.Win32Exception noBrowser)
{
if (noBrowser.ErrorCode == -2147467259) MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
MessageBox.Show(other.Message);
}
}
}
}
catch (Exception)
{
}
}
示例11: WebClient_DownloadStringCompleted
private void WebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null || string.IsNullOrEmpty(e.Result))
return;
// Deserialize the list of layouts
XmlSerializer serializer = new XmlSerializer(typeof(LayoutInfoCollection));
LayoutInfoCollection layoutList = null;
using (TextReader reader = new StringReader(e.Result))
{
layoutList = (LayoutInfoCollection)serializer.Deserialize(reader);
}
// Update UI with layouts list
if (layoutList != null && layoutList.Layouts != null)
{
LayoutsListBox.ItemsSource = Layouts.ItemsSource = layoutList.Layouts;
if (layoutList.Layouts.Count > 0)
{
CurrentSelectedLayoutInfo = layoutList.Layouts.ElementAtOrDefault(0);
if (CurrentSelectedLayoutInfo != null)
LayoutsListBox.SelectedItem = Layouts.SelectedItem = CurrentSelectedLayoutInfo;
}
}
}
示例12: ClientPlacesDownloadStringCompleted
void ClientPlacesDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (e.Error == null)
{
using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result)))
{
//It doesn't work in Windows Phone, I should change the name of the properties y the models
//DataContractJsonSerializerSettings settings =
// new DataContractJsonSerializerSettings();
//settings.UseSimpleDictionaryFormat = true;
DataContractJsonSerializer serializer =
new DataContractJsonSerializer(typeof(List<Place>));
this.Places = serializer.ReadObject(stream) as List<Place>;
}
this.DownloadDataResult = Enumerations.Result.Successful;
}
else
{
this.DownloadDataResult = Enumerations.Result.ServiceError;
}
}
catch (Exception)
{
this.DownloadDataResult = Enumerations.Result.ApplicationError;
}
}
示例13: webClient_DownloadStringCompleted
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (e != null && e.Error == null)
{
var data = e.Result;
XmlDocument _doc = new XmlDocument();
_doc.LoadXml(data);
if (_doc.GetElementsByTagName("zigbeeData").Count > 0)
{
string zigbeeData = _doc.GetElementsByTagName("zigbeeData")[0].InnerText;
Zigbit zigbit = _zigbitService.CollectData(zigbeeData);
if (zigbit != null)
{
UpdateZigbit(zigbit);
}
}
}
}
catch (Exception ex)
{
ErrorHandlingService.PersistError("GatewayService - webClient_DownloadStringCompleted", ex);
}
}
示例14: NewsDownloaded
void NewsDownloaded(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Result == null || e.Error != null)
{
MessageBox.Show("There was an error downloading the XML-file!");
}
else
{
// Deserialize if download succeeds
XmlSerializer serializer = new XmlSerializer(typeof(Articles));
XDocument document = XDocument.Parse(e.Result);
var news = from query in document.Descendants("item")
select new Article
{
Title = (string)query.Element("title"),
Description = (string)query.Element("description").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", "").Replace("<p>", "").Replace("</p>", "").Replace("\n", "").Replace("\t", "").Replace("<p style=", "").Replace("text-align: justify; ", "").Replace(">", "").Replace(@"""", "").Substring(0, 20) + "...",
Description1 = (string)query.Element("description").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", ""),
Pubdate = (string)query.Element("pubdate")
//Title = (query.Element("title") == null) ? "" : (string)query.Element("title").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", ""),
//Pubdate = (query.Element("pubdate") == null) ? "" : (string)query.Element("pubdate").Value.ToString()
};
newsList.ItemsSource = news;
}
}
示例15: webClient_DownloadStringCompleted
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
toolStripStatusLabel1.Text = "";
htmlSource = e.Result;
initializeManga();
}