/// <summary> /// /// </summary> /// <param name="index">张数</param> private void getImage(int index) { List <BingImage> images = BingWallpaperService.getURL(cbInternational.Checked ? Config.SiteType.International : Config.SiteType.znCN, index); foreach (BingImage iamge in images) { try { BingWallpaperService.saveImage(iamge, tbFileDirectory.Text, cbUseWatermark.Checked); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void GetImage() { tip.Text = ""; if (String.IsNullOrEmpty(tbFileDirectory.Text)) { tip.Text = "请选择文件路径"; tip.ForeColor = Color.OrangeRed; return; } BingImage image = null; try { image = BingWallpaperService.getURL(cbInternational.Checked?Config.SiteType.International : Config.SiteType.znCN, 1)[0]; } catch (Exception ex) { tip.Text = "获取地址失败:" + ex.Message; tip.ForeColor = Color.Red; return; } try { string location = BingWallpaperService.saveImage(image, tbFileDirectory.Text, cbUseWatermark.Checked); if (checkBox1.Checked) { setWallpaperApi(location); tip.Text = "壁纸设置成功"; } else { tip.Text = "保存成功"; } tip.ForeColor = Color.Black; } catch (Exception ex) { tip.Text = "发生错误:" + ex.Message; tip.ForeColor = Color.Red; return; } }