Пример #1
0
        public UpdaterViewModel(VersionDescription versionInfo)
        {
            this.versionInfo = versionInfo;

              download = new Command(
            () => Process.Start(versionInfo.Link.ToString()));
        }
Пример #2
0
 private void OnDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs args)
 {
     if (!args.Cancelled && args.Error==null) {
     var data = System.Text.Encoding.UTF8.GetString(args.Result);
     var doc = XDocument.Parse(data);
     var cur = currentVersion;
     VersionDescription new_version = null;
     foreach (var item in doc.Descendants("item")) {
       var xtitle = item.Element("title");
       var xdate  = item.Element("pubDate");
       var xlink  = item.Element("link");
       var xdesc  = item.Element("description");
       DateTime date;
       Uri    link  = null;
       string title = null;
       string desc  = null;
       if (xtitle!=null && xtitle.Value!=null) {
     title = xtitle.Value;
       }
       if (xlink!=null && xlink.Value!=null) {
     Uri.TryCreate(xlink.Value, UriKind.Absolute, out link);
       }
       if (xdesc!=null && xdesc.Value!=null) {
     desc = xdesc.ToString();
       }
       if (xdate!=null && xdate.Value!=null && DateTime.TryParse(xdate.Value, out date)) {
     if (cur.Date<date.Date) {
       cur = date;
       new_version = new VersionDescription {
         Title       = title,
         PublishDate = date,
         Link        = link,
         Description = desc,
       };
     }
       }
     }
     if (new_version!=null && NewVersionFound!=null) {
       NewVersionFound(this, new NewVersionFoundEventArgs(new_version));
     }
       }
 }
Пример #3
0
 public NewVersionFoundEventArgs(VersionDescription desc)
 {
     this.VersionDescription = desc;
 }
Пример #4
0
 public void ShowNotificationMessage(NotificationMessage msg)
 {
     if (notifyIcon==null) return;
       var timeout = 60000;
       var icon = ToolTipIcon.Info;
       switch (msg.Type) {
       case NotificationMessageType.Normal:  icon = ToolTipIcon.None; timeout = 30000; break;
       case NotificationMessageType.Info:    icon = ToolTipIcon.Info; break;
       case NotificationMessageType.Warning: icon = ToolTipIcon.Warning; break;
       case NotificationMessageType.Error:   icon = ToolTipIcon.Error; break;
       }
       newVersionInfo = null;
       notifyIcon.ShowBalloonTip(
     timeout,
     msg.Title,
     msg.Message,
     icon);
 }