Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            // Sur appel du délégué, la méthode UpdateProgressBar est donc appelé
            updateProgressBar = new DelegateUpdateProgressBar(UpdateProgressBar);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据文件URL下载到本地文件夹
        /// </summary>
        private void DownSaveFile(FileUpdate fileUpdate)
        {
            try
            {
                DlgUpdateCurrentBar = new DelegateUpdateProgressBar(UpdateCurrentBarPosition);

                /*保证相对路径最后一个字符都加上\!!*/
                /*如果是根目录,则其相对路径存一个字符:\*/
                /*相对路径首字符必须是\,否则路径拼接要出错。*/
                /*例子:*/
                /*Name:Mix.Core.WinForm.dll    NameAlias:Mix.Core.WinForm.dll    filePath:\ItemPics\    srcFilePath:http://mixtrade.wisecode.com.cn/UpdateData/.*/
                string srcFilePath = fileUpdate.SrcFilePath + fileUpdate.FileName;
                //string destFile = fileUpdate.FilePath + fileUpdate.FileName;

                string filePath = string.Empty;
                if (!Directory.Exists(Application.StartupPath + "\\UpdateData\\"))
                {
                    Directory.CreateDirectory(Application.StartupPath + "\\UpdateData\\");
                }
                /*下载的文件直接使用别名,如果不需要别名,fileUpdate.FileName必须等于fileUpdate.FileNameAlias*/
                filePath = Application.StartupPath + "\\UpdateData\\" + fileUpdate.FileNameAlias;

                System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(srcFilePath);
                webRequest.Method = "GET";
                System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse();
                System.IO.Stream           stream      = webResponse.GetResponseStream();
                long        length     = webResponse.ContentLength;
                List <byte> list       = new List <byte>();
                int         c          = 0;
                int         percentage = 0;
                while (true)
                {
                    int data = stream.ReadByte();
                    if (data == -1)
                    {
                        break;
                    }
                    else
                    {
                        byte b = (byte)data;
                        list.Add(b);
                        c++;
                        int temp = percentage;
                        percentage = (int)((float)c * 100 / (float)length);
                        if (percentage != temp)
                        {
                            DlgUpdateCurrentBar.BeginInvoke(progressBarCurrent, percentage, null, null);
                        }
                    }
                }
                byte[] bb = list.ToArray();
                System.IO.File.WriteAllBytes(filePath, bb);
                stream.Close();//别忘了关闭
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message.ToString());
            }
        }
Ejemplo n.º 3
0
        public ConverterForm()
        {
            InitializeComponent();

            this.StartPosition = FormStartPosition.CenterScreen;

            sm_Event = new AutoResetEvent(false);

            m_DelegateAddString         = new DelegateAddString(this.AddString);
            m_DelegateUpdateProgressbar = new DelegateUpdateProgressBar(this.UpdateProgressBar);
            m_DelegateShowCurrentWord   = new DelegateShowCurrentWord(this.ShowCurrentWord);
            m_DelegateSignalCompletion  = new DelegateSignalCompletion(this.OnConversionEnd);

            buttonOK.Enabled = false;

            if (numericUpDownStopAfter.Enabled)
            {
                m_iStopAfter = (int)numericUpDownStopAfter.Value;
            }
            else
            {
                m_iStopAfter = -1;
            }

            m_iSelectedTab     = tabControl.SelectedIndex;
            m_bSaveTempData    = false;
            m_bTextBoxOverflow = false;

            textBoxSourcePath.Text      = Properties.Settings.Default.SourcePath;
            textBoxDbLocation.Text      = Properties.Settings.Default.DbPath;
            textBoxLogPath.Text         = Properties.Settings.Default.LogPath;
            textBoxUnprocessedPath.Text = Properties.Settings.Default.UnprocessedPath;
            textBoxSearchSource.Text    = Properties.Settings.Default.SearchSourcePath;
            textBoxSearchLog.Text       = Properties.Settings.Default.SearchLogPath;
            textBoxSearchString.Text    = Properties.Settings.Default.SearchString;
        }
Ejemplo n.º 4
0
        public ConverterForm()
        {
            InitializeComponent();

            this.StartPosition = FormStartPosition.CenterScreen;

            sm_Event = new AutoResetEvent (false);

            m_DelegateAddString = new DelegateAddString (this.AddString);
            m_DelegateUpdateProgressbar = new DelegateUpdateProgressBar (this.UpdateProgressBar);
            m_DelegateShowCurrentWord = new DelegateShowCurrentWord (this.ShowCurrentWord);
            m_DelegateSignalCompletion = new DelegateSignalCompletion (this.OnConversionEnd);

            buttonOK.Enabled = false;

            if (numericUpDownStopAfter.Enabled)
            {
                m_iStopAfter = (int)numericUpDownStopAfter.Value;
            }
            else
            {
                m_iStopAfter = -1;
            }

            m_iSelectedTab = tabControl.SelectedIndex;
            m_bSaveTempData = false;
            m_bTextBoxOverflow = false;

            textBoxSourcePath.Text = Properties.Settings.Default.SourcePath;
            textBoxDbLocation.Text = Properties.Settings.Default.DbPath;
            textBoxLogPath.Text = Properties.Settings.Default.LogPath;
            textBoxUnprocessedPath.Text = Properties.Settings.Default.UnprocessedPath;
            textBoxSearchSource.Text = Properties.Settings.Default.SearchSourcePath;
            textBoxSearchLog.Text = Properties.Settings.Default.SearchLogPath;
            textBoxSearchString.Text = Properties.Settings.Default.SearchString;
        }