예제 #1
0
        private void menuItemModulliste_Click(object sender, System.EventArgs e)
        {
            this.What="modppc";
            this.labelInfo.Text="Lade Modulliste ...";
            this.labelInfo.Refresh();
            FileStream fileStream=null;
            try
            {
                string TargetFile=this.DataDirectory+@"\zefmodsppc.xml";
                fileStream = new FileStream(TargetFile,FileMode.Create,FileAccess.Write);

            }
            catch(Exception ex)
            {

                MessageBox.Show(ex.Message,"Zefania PPC");
                // FileStream schließen
                try
                {
                    fileStream.Close();

                }
                catch{}

                return;

            }
            // Datei asynchron herunterladen
            try
            {

                WebDownload ModulList=new WebDownload();
                string TargetURL=@"http://zefania-sharp.sourceforge.net/zefmodppc.xml";
                ModulList.DownloadSync(TargetURL,fileStream,1024,
                    new WebDownload.DownloadProgress(this.DownloadProgressHandler),
                    new WebDownload.DownloadEnd(this.DownloadEndHandler),
                    new WebDownload.DownloadError(this.DownloadErrorHandler));

            }
            catch(Exception ex)
            {

                MessageBox.Show(ex.Message,"Zefania PPC");
            }
        }
예제 #2
0
        //*****
        //*****
        private void DownMirrorPage()
        {
            this.What="mirror";
            FileStream fileStream=null;
            try
            {
                string TargetFile=this.DataDirectory+@"\mirrorpage.html";
                fileStream = new FileStream(TargetFile,FileMode.Create,FileAccess.Write);

            }
            catch(Exception ex)
            {

                MessageBox.Show(ex.Message,"Zefania PPC");
                // FileStream schließen
                try
                {
                    fileStream.Close();

                }
                catch{}

                return;

            }
            // Datei asynchron herunterladen
            try
            {

                WebDownload ModulList=new WebDownload();

                ModulList.DownloadSync(DownURL,fileStream,1024,
                    new WebDownload.DownloadProgress(this.DownloadProgressHandler),
                    new WebDownload.DownloadEnd(this.DownloadEndHandler),
                    new WebDownload.DownloadError(this.DownloadErrorHandler));

            }
            catch(Exception ex)
            {

                MessageBox.Show(ex.Message,"Zefania PPC");
            }
        }
예제 #3
0
        //****
        //*****
        private void DownModul()
        {
            this.What="downppc";
            this.labelInfo.Text="Lade Modul ...";
            this.labelInfo.Refresh();
            FileStream fileStream=null;
            try
            {

                string TargetFile=this.DataDirectory+@"\"+Path.GetFileName(GetModulURL());
                this.LatestModul=TargetFile;
                fileStream = new FileStream(TargetFile,FileMode.Create,FileAccess.Write);

            }
            catch(Exception ex)
            {

                MessageBox.Show(ex.Message,"Zefania PPC");
                // FileStream schließen
                try
                {
                    fileStream.Close();

                }
                catch{}

                return;

            }
            // Datei asynchron herunterladen
            try
            {

                WebDownload ModulList=new WebDownload();

                ModulList.DownloadSync(this.GetModulURL(),fileStream,4096,
                    new WebDownload.DownloadProgress(this.DownloadProgressHandler),
                    new WebDownload.DownloadEnd(this.DownloadEndHandler),
                    new WebDownload.DownloadError(this.DownloadErrorHandler));

            }
            catch(Exception ex)
            {

                MessageBox.Show(ex.Message,"Zefania PPC");
            }
        }
예제 #4
0
        public void DownloadProgressHandler(WebDownload.DownloadState downloadstate,int currentBytes,long totalBytes)
        {
            lock(this)
            {
                switch(downloadstate)
                {
                    case WebDownload.DownloadState.OpeningConnection:
                        this.progressBar1.Value=0;

                        break;

                    case WebDownload.DownloadState.ReadingData:

                        int progress =(int)((currentBytes/(double)totalBytes)*100);
                        if(progress<-0){progress=0;}
                        this.progressBar1.Value=progress;

                        break;

                    case WebDownload.DownloadState.DataReady:
                        this.progressBar1.Value=0;

                        break;

                }
            }
        }