Esempio n. 1
0
//#7------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void Threadhandler()
        {
            try
            {
                BenchTimer.Start();
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Minimum = s; }), 0);
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Maximum = s; }), 1);
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), 0);
                AllFilesToConvert.Clear();
                AllActionMessages.Clear();
                if (FilePath.Length > 0)
                {
                    ConvertString(FilePath);
                    ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), 1);
                }
                if (FolderPath.Length > 0)
                {
                    CheckSubFolders(FolderPath);
                    ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Maximum = s; }), AllFilesToConvert.Count - 1);
                    for (int i = 0; i < AllFilesToConvert.Count; i++)
                    {
                        ConvertString(AllFilesToConvert[i]);
                        ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), i);
                    }
                }
                MethodInvoker AddItems = delegate
                {
                    for (int i = 0; i < AllActionMessages.Count; i++)
                    {
                        ActionBox.Items.Add(AllActionMessages[i]);
                    }
                };
                ActionBox.BeginInvoke(AddItems);
                BenchTimer.Stop();
                MessageBox.Show(string.Format(FinalMessage, ChangeCount, ChangedFileCount, BenchTimer.ElapsedMilliseconds.ToString()));
                BenchTimer.Reset();
                FileBrowse.Invoke(new Action <bool>(s => { FileBrowse.Enabled = s; }), true);
                FolderBrowse.Invoke(new Action <bool>(s => { FolderBrowse.Enabled = s; }), true);
                ConvertButton.Invoke(new Action <bool>(s => { ConvertButton.Enabled = s; }), true);
                OldStringTextBox.Invoke(new Action <bool>(s => { OldStringTextBox.Enabled = s; }), true);
                NewStringTextBox.Invoke(new Action <bool>(s => { NewStringTextBox.Enabled = s; }), true);
                CaseSensitiveCheckBox.Invoke(new Action <bool>(s => { CaseSensitiveCheckBox.Enabled = s; }), true);
                WholeWordCheckBox.Invoke(new Action <bool>(s => { WholeWordCheckBox.Enabled = s; }), true);
                if (!SourceFilePathBox.Text.Equals(TempPath))
                {
                    SourceBrowse.Invoke(new Action <bool>(s => { SourceBrowse.Enabled = s; }), true);
                    DownloadSourceButton.Invoke(new Action <bool>(s => { DownloadSourceButton.Enabled = s; }), true);
                }
            }
            catch
            {
            }
        }
Esempio n. 2
0
//#19-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        void client1_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            DownloadSourceButton.Invoke(new Action <bool>(s => { DownloadSourceButton.Enabled = s; }), true);
            DownloadSourceButton.Invoke(new Action <string>(s => { DownloadSourceButton.Text = s; }), "Download");
            if (!File.ReadAllText(TempPath).Equals(string.Empty))
            {
                SourceFilePathBox.Invoke(new Action <string>(s => { SourceFilePathBox.Text = s; }), TempPath);
            }
            else
            {
                MessageBox.Show(DownloadErrorMesssage);
            }
        }
Esempio n. 3
0
//#18-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void DownloadSource()
        {
            try
            {
                if (File.Exists(TempPath))
                {
                    File.Delete(TempPath);
                }
                WebClient client1 = new WebClient();
                client1.Headers.Add("User-Agent", string.Format("ArmA String Converter - Version: {0}", OwnVersion));
                client1.Headers.Add("Accept", "*/*");
                client1.DownloadFileAsync(new Uri("https://dl.dropboxusercontent.com/u/19329173/ChangeText.txt"), TempPath);
                client1.DownloadFileCompleted += new AsyncCompletedEventHandler(client1_DownloadFileCompleted);
            }
            catch
            {
                MessageBox.Show(DownloadErrorMesssage);
                DownloadSourceButton.Invoke(new Action <bool>(s => { DownloadSourceButton.Enabled = s; }), false);
                DownloadSourceButton.Invoke(new Action <string>(s => { DownloadSourceButton.Text = s; }), "Download");
            }
        }