Esempio n. 1
0
        /// <summary>
        /// Creates a plugin panel for the plugin
        /// </summary>
        public void CreatePluginPanel()
        {
            this.pluginUI      = new PluginUI(this);
            this.pluginUI.Text = LocaleHelper.GetString("Title.PluginPanel");
            this.pluginPanel   = PluginBase.MainForm.CreateDockablePanel(this.pluginUI, this.pluginGuid, this.pluginImage, DockState.DockRight);

            try
            {
                StringBuilder   sb         = new StringBuilder();
                byte[]          buf        = new byte[8192];
                HttpWebRequest  request    = (HttpWebRequest)WebRequest.Create("http://jeanlouis.persat.free.fr/fd/check.php");
                HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
                Stream          resStream  = response.GetResponseStream();
                string          tempString = null;
                int             count      = 0;

                do
                {
                    // fill the buffer with data
                    count = resStream.Read(buf, 0, buf.Length);

                    // make sure we read some data
                    if (count != 0)
                    {
                        // translate from bytes to ASCII text
                        tempString = Encoding.ASCII.GetString(buf, 0, count);

                        // continue building the string
                        sb.Append(tempString);
                    }
                }while (count > 0);

                Assembly     assem            = Assembly.GetExecutingAssembly();
                AssemblyName assemName        = assem.GetName();
                string       __currentVersion = assemName.Version.Major.ToString() + assemName.Version.Minor.ToString() + assemName.Version.Build.ToString();
                __currentVersion = __currentVersion.Replace(".", "");

                string __availableVersion = sb.ToString().Replace(".", "");

                int result = decimal.Compare(Convert.ToDecimal(__currentVersion), Convert.ToDecimal(__availableVersion));
                if (result < 0)
                {
                    this.pluginUI.CheckVersion.Text    = String.Format(LocaleHelper.GetString("Info.New"), sb.ToString());
                    this.pluginUI.CheckVersion.Enabled = true;
                }
                else
                {
                    this.pluginUI.CheckVersion.Text    = LocaleHelper.GetString("Info.Latest");
                    this.pluginUI.CheckVersion.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                this.pluginUI.CheckVersion.Text    = LocaleHelper.GetString("Info.Inaccessible");
                this.pluginUI.CheckVersion.Enabled = false;
            }

            this.pluginUI.Changed  += VersionChanged;
            this.pluginUI.SVNCheck += checkSVN;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a plugin panel for the plugin
        /// </summary>
        public void CreatePluginPanel()
        {
            this.pluginUI = new PluginUI(this);
            this.pluginUI.Text = LocaleHelper.GetString("Title.PluginPanel");
            this.pluginPanel = PluginBase.MainForm.CreateDockablePanel(this.pluginUI, this.pluginGuid, this.pluginImage, DockState.DockRight);

            try
            {
                StringBuilder sb = new StringBuilder();
                byte[] buf = new byte[8192];
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://jeanlouis.persat.free.fr/fd/check.php");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream resStream = response.GetResponseStream();
                string tempString = null;
                int count = 0;

                do
                {
                    // fill the buffer with data
                    count = resStream.Read(buf, 0, buf.Length);

                    // make sure we read some data
                    if (count != 0)
                    {
                        // translate from bytes to ASCII text
                        tempString = Encoding.ASCII.GetString(buf, 0, count);

                        // continue building the string
                        sb.Append(tempString);
                    }
                }
                while (count > 0);

                Assembly assem = Assembly.GetExecutingAssembly();
                AssemblyName assemName = assem.GetName();
                string __currentVersion = assemName.Version.Major.ToString() + assemName.Version.Minor.ToString() + assemName.Version.Build.ToString();
                __currentVersion = __currentVersion.Replace(".", "");

                string __availableVersion = sb.ToString().Replace(".", "");

                int result = decimal.Compare(Convert.ToDecimal(__currentVersion), Convert.ToDecimal(__availableVersion));
                if (result < 0)
                {
                    this.pluginUI.CheckVersion.Text = String.Format(LocaleHelper.GetString("Info.New"), sb.ToString());
                    this.pluginUI.CheckVersion.Enabled = true;
                }
                else
                {
                    this.pluginUI.CheckVersion.Text = LocaleHelper.GetString("Info.Latest");
                    this.pluginUI.CheckVersion.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                this.pluginUI.CheckVersion.Text = LocaleHelper.GetString("Info.Inaccessible");
                this.pluginUI.CheckVersion.Enabled = false;
            }

            this.pluginUI.Changed += VersionChanged;
            this.pluginUI.SVNCheck += checkSVN;
        }