Click here to Skip to main content
15,896,493 members
Articles / Desktop Programming / WPF

PlantUML Editor: A Fast and Simple UML Editor using WPF

Rate me:
Please Sign up or sign in to vote.
4.98/5 (65 votes)
11 Jun 2011CPOL16 min read 240K   6.4K   233  
A WPF smart client to generate UML diagrams from plain text using plantuml tool
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace Utilities
{
    public class UpdateChecker
    {

        public static Action<DownloadProgressChangedEventArgs> DownloadProgressChanged;
        public static Action<System.ComponentModel.AsyncCompletedEventArgs> DownloadCompleted;
        public static string DownloadedLocation;

        public static bool HasUpdate(string downloadUrl)
        {
            HttpWebRequest request = WebRequest.Create(downloadUrl) as HttpWebRequest;
            using (var response = request.GetResponse())
            {
                var lastModifiedDate = default(DateTime);
                if (DateTime.TryParse(response.Headers["Last-Modified"], out lastModifiedDate))
                {
                    var path = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    var localFileDateTime = File.GetLastWriteTime(path);

                    return (localFileDateTime < lastModifiedDate.AddDays(-1));
                }
            }

            return false;
        }

        public static void DownloadLatestUpdate(string downloadUrl, string localPath)
        {
            DownloadedLocation = localPath;
            using (WebClient client = new WebClient())
            {
                client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted);
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                client.DownloadFileAsync(new Uri(downloadUrl), localPath);
            }
        }

        static void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            DownloadProgressChanged(e);
        }

        static void client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            DownloadCompleted(e);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

Comments and Discussions