Exemplo n.º 1
0
        void AtualizaJanela(object sender, EventArgs e)
        {
            if (ServidorON == true)
            {
                BTConectaAoServidor.IsEnabled    = false;
                BTDesconectaDoServidor.IsEnabled = true;
                TBEnvia.IsEnabled = true;
                BTEnvia.IsEnabled = true;
            }
            else
            {
                BTConectaAoServidor.IsEnabled    = true;
                BTDesconectaDoServidor.IsEnabled = false;
                TBEnvia.IsEnabled = false;
                BTEnvia.IsEnabled = false;

                if (tx != null && receptor != null)
                {
                    tx.Close();
                    receptor.Interrupt();
                }
            }

            if (linhaAtual < linhas.Count())
            {
                for (int i = linhaAtual; i < linhas.Count(); i++)
                {
                    TBLog.AppendText(linhas[i] + '\n');
                    linhaAtual++;
                }
                TBLog.ScrollToEnd();
            }
        }
Exemplo n.º 2
0
        private void BtnStartClick(object sender, EventArgs e)
        {
            if (pPhotoList.Count <= 0)
            {
                MessageBox.Show("Не инициализирована коллекция.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Обнуляем глобальный индекс
            pIndexPhotoList = 0;

            // Очищаем лог
            TBLog.Clear();

            // Получаем кол-во запускаемых потоков
            int countThread = Convert.ToInt32(NumericThreadCount.Value);

            // Создаём массив потоков
            Thread[] threads = new Thread[countThread];

            // Циклом создаём потоки
            for (int i = 0; i < countThread; i++)
            {
                threads[i]      = new Thread(new ThreadStart(DoThread));
                threads[i].Name = "Поток № " + i;
                threads[i].Start();
            }
        }
Exemplo n.º 3
0
        private void OutputToTextBox(string log)
        {
            //if (TBLog.GetLineFromCharIndex(TBLog.Text.Length) > 100)
            //    TBLog.Text = "";

            TBLog.AppendText(DateTime.Now.ToString("HH:mm:ss  ") + log + "\r\n");
        }
Exemplo n.º 4
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public new DialogResult ShowDialog(IWin32Window owner, string ErrorLogText)
        {
            TBLog.Text = ErrorLogText;
            TBLog.Select(0, 0); // jinak je nove pridany text vyselectovany ?

            return(base.ShowDialog(owner));
        }
Exemplo n.º 5
0
 public void AppendLog(string text)
 {
     Dispatcher.Invoke(() =>
     {
         TBLog.AppendText(text + Environment.NewLine);
         TBLog.ScrollToEnd();
     });
 }
Exemplo n.º 6
0
 void AtualizaJanela(object sender, EventArgs e)
 {
     if (linhaAtual < linhas.Count())
     {
         for (int i = linhaAtual; i < linhas.Count(); i++)
         {
             TBLog.AppendText(linhas[i] + '\n');
             linhaAtual++;
         }
         TBLog.ScrollToEnd();
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Метод потока.
        /// </summary>
        private void DoThread()
        {
            Random rnd = new Random();

            // Получаем ID и Имя потока
            int    threadId   = Thread.CurrentThread.ManagedThreadId;
            string threadName = Thread.CurrentThread.Name;

            TBLog.Invoke((MethodInvoker)(() =>
            {
                TBLog.Text += "Запущен " + threadName + Environment.NewLine;
            }));

            string photo = string.Empty;

            // Создаём бесконечный цикл
            while (true)
            {
                photo = string.Empty;
                // Открываем объект синхронизации
                lock (pLock)
                {                 // Код в этих скобках будет обрабатывать только один поток, остальные потоки будут ждать, пока текущий поток обработает этот код
                    // Проверяем возможность взять фотографию из коллекции (Если индекс фото >= общего кол-ва фото, значит завершаем поток)
                    if (pIndexPhotoList >= pPhotoList.Count)
                    {
                        break;                         // Завершаем цикл потока
                    }
                    // Берём фотографию из списка
                    photo = pPhotoList[pIndexPhotoList];
                    // Увеличиваем индекс
                    pIndexPhotoList++;
                }

                // Псевдо загрузка фото
                TBLog.Invoke((MethodInvoker)(() =>
                {
                    TBLog.Text += threadName + " загружает " + photo + Environment.NewLine;
                }));
                // Псевдо задержка
                Thread.Sleep(rnd.Next(100, 500));
            }
        }
Exemplo n.º 8
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            excelApp         = new Microsoft.Office.Interop.Excel.Application();
            excelApp.Visible = true;
            workbook1        = excelApp.Workbooks.Open(filepath.Text);
            worksheet1       = workbook1.ActiveSheet;
            while (!Equals(((Range)worksheet1.Cells[n, 1]).Text, ""))
            {
                string a = ((Range)worksheet1.Cells[n, 1]).Text;
                names.Add(a);
                n++;
            }
            TBLog.Clear();
            foreach (var name in names)
            {
                var temp = false;

                foreach (var file in AllFileNames)
                {
                    if (file.Contains(name))
                    {
                        //FileInfo fi1 = new FileInfo(file);
                        // fi1.CopyTo(TBTargetFolderPath+@"\" + System.IO.Path.GetFileName(file));
                        var a = System.IO.Path.GetFileName(file);
                        var b = TBTargetFolderPath.Text + @"\" + a;
                        System.IO.File.Copy(file, b, true);
                        temp = true;
                    }
                }
                if (!temp)
                {
                    i++;
                    TBLog.AppendText(i + ":" + name + "未找到\n");
                    //System.Windows.MessageBox.Show(i + ":" + name + "未找到\n");
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Log textbox focus enter (only for Tab key) handler
 /// Select all text
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TBLog_Enter(object sender, EventArgs e)
 {
     TBLog.SelectAll();
 }
Exemplo n.º 10
0
        private void BtnCopy_Click(object sender, EventArgs e)
        {
            string framePath = TbFrame.Text.Trim();

            if (CBFrameCode.Checked || CBFrameSource.Checked)
            {
                if (!Directory.Exists(framePath))
                {
                    MessageBox.Show("框架目录不是有效文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            TBLog.Text = "";
            TBLog.Refresh();
            OutputToTextBox("===================================");
            OutputToTextBox("开始拷贝");

            string platformPath = TbPlatform.Text.Trim();

            BtnCopy.Enabled = false;
            if (CBFrameSource.Checked)
            {
                OutputToTextBox("开始框架资源拷贝");
                //string srcpath = platformPath + "\\gameFrameworks\\src";
                //Directory.Delete(srcpath, true);
                //OutputToTextBox("删除目录:" + srcpath);
                //string respath = platformPath + "\\gameFrameworks\\res";
                //Directory.Delete(respath, true);
                //OutputToTextBox("删除目录:" + respath);

                string fromsrcpath = framePath + "\\src";
                string tosrcpath   = platformPath + "\\gameFrameworks\\src";
                Constant.CopyDir(fromsrcpath, tosrcpath);
                OutputToTextBox("拷贝目录:" + fromsrcpath);

                string fromrespath = framePath + "\\res";
                string torespath   = platformPath + "\\gameFrameworks\\res";
                Constant.CopyDir(fromrespath, torespath);
                OutputToTextBox("拷贝目录:" + fromrespath);
                OutputToTextBox("框架资源拷贝完成");
            }

            if (CBFrameCode.Checked)
            {
                OutputToTextBox("开始框架c++拷贝");
                string fromrespath = framePath + "\\c\\frameworks";
                string torespath   = platformPath + "\\frameworks";
                Constant.CopyDir(fromrespath, torespath);
                OutputToTextBox("拷贝目录:" + fromrespath);
                OutputToTextBox("框架c++拷贝完成");
            }

            BtnCopy.Enabled = true;

            ListView.CheckedListViewItemCollection checkedItems = LVPlatGames.CheckedItems;
            if (checkedItems == null || checkedItems.Count == 0)
            {
                return;
            }

            string releasePath = TbRelease.Text.Trim();

            if (!Directory.Exists(releasePath))
            {
                OutputToTextBox("发布目录不是有效文件夹,游戏拷贝失败");
                return;
            }

            List <int> copys = new List <int>();

            OutputToTextBox("检测拷贝的游戏");
            foreach (ListViewItem item in checkedItems)
            {
                if (item.SubItems[1].Text == Constant.MATCH_NAME_FAIL)
                {
                    OutputToTextBox(item.SubItems[0].Text + "没有匹配游戏");
                    continue;
                }
                if (item.SubItems[3].Text == "")
                {
                    OutputToTextBox(item.SubItems[0].Text + "没有选择更新版本");
                    continue;
                }

                if (!Directory.Exists(releasePath + "\\" + item.SubItems[1].Text + "\\" + item.SubItems[3].Text))
                {
                    OutputToTextBox(item.SubItems[0].Text + "没有对应版本目录" + releasePath + "\\" + item.SubItems[1].Text + "\\" + item.SubItems[3].Text);
                    continue;
                }
                copys.Add(item.Index);
                Console.WriteLine(item.SubItems[0].Text + " " + item.SubItems[1].Text + " " + item.SubItems[2].Text + " " + item.SubItems[3].Text);
            }

            if (copys.Count == 0)
            {
                OutputToTextBox("有效游戏数量为0");
                return;
            }

            BtnCopy.Enabled = false;
            OutputToTextBox("进行游戏拷贝");

            int    processvalue   = 0;
            string autoPushCommit = "更新游戏";

            foreach (int index in copys)
            {
                ListViewItem item    = LVPlatGames.Items[index];
                string       srcpath = platformPath + "\\src\\game\\game\\" + item.Tag;
                Directory.Delete(srcpath, true);
                OutputToTextBox("删除目录:" + srcpath);
                string respath = platformPath + "\\res\\game\\" + item.Tag;
                Directory.Delete(respath, true);
                OutputToTextBox("删除目录:" + respath);

                string fromsrcpath = releasePath + "\\" + item.SubItems[1].Text + "\\" + item.SubItems[3].Text + "\\src";
                string tosrcpath   = platformPath + "\\src";
                Constant.CopyDir(fromsrcpath, tosrcpath);
                OutputToTextBox("拷贝目录:" + fromsrcpath);

                string fromrespath = releasePath + "\\" + item.SubItems[1].Text + "\\" + item.SubItems[3].Text + "\\res";
                string torespath   = platformPath + "\\res";
                Constant.CopyDir(fromrespath, torespath);
                OutputToTextBox("拷贝目录:" + fromrespath);
                OutputToTextBox(item.SubItems[1].Text + "拷贝成功");
                processvalue++;
                PBCopy.Value = 100 * processvalue / copys.Count;

                string commit = item.SubItems[0].Text;
                commit          = commit.Substring(commit.IndexOf('[') + 1, commit.IndexOf(']') - commit.IndexOf('[') - 1);
                autoPushCommit += " " + commit;
            }
            OutputToTextBox("游戏拷贝完成");
            BtnCopy.Enabled = true;
            LoadPlatormGames();

            if (!CopyCheckWork.IsBusy)
            {
                CopyCheckWork.RunWorkerAsync(new MyArgument(platformPath, MyArgument.WorkType.COPY_CHECK, autoPushCommit + "[本次提交由-" + this.Text + "-自动完成]"));
            }
        }