Ejemplo n.º 1
0
 /// <summary>
 /// ActionScheduleを初期化する
 /// </summary>
 /// <param name="schedule">PlayerIDの並びで行動の順番を格納するキュー</param>
 /// <param name="players">Player情報の配列、この配列の順番が行動の順番となる</param>
 private static void ResetActionSchedule(ListQueue <int> schedule, IReadOnlyList <Player> players)
 {
     schedule.Clear();
     for (var i = 0; i < players.Count * 3; i++)
     {
         schedule.Enqueue(players[i % players.Count].PlayerID);
     }
 }
Ejemplo n.º 2
0
        public void CheckClearQueue()
        {
            MyQueue <int> queueArray = new ArrayQueue <int>();
            MyQueue <int> queueList  = new ListQueue <int>();

            for (int i = 1; i < 11; i++)
            {
                queueArray.Enqueue(i);
                queueList.Enqueue(i);
            }

            queueArray.Clear();
            queueList.Clear();

            Assert.Equal(0, queueArray.Count());
            Assert.Equal(0, queueList.Count());
        }
Ejemplo n.º 3
0
        static void Main()
        {
            var listQueue = new ListQueue <int>();

            listQueue.Enqueue(1);
            listQueue.Enqueue(3);
            listQueue.Enqueue(4);
            listQueue.Enqueue(6);
            listQueue.Enqueue(9);
            DisplayQueue(listQueue);
            Console.WriteLine("Добавим в очередь элемент '7'");
            listQueue.Enqueue(7);
            DisplayItem(listQueue);
            listQueue.Clear();
            DisplayQueue(listQueue);

            var arrayQueue = new ArrayQueue <string>(10);

            arrayQueue.Enqueue("1");
            arrayQueue.Enqueue("2");
            arrayQueue.Enqueue("5");
            arrayQueue.Enqueue("6");
            arrayQueue.Enqueue("ten");
            DisplayQueue(arrayQueue);
            Console.WriteLine("Добавим в очередь элемент 'seven'");
            arrayQueue.Enqueue("seven");
            DisplayItem(arrayQueue);
            arrayQueue.Clear();
            DisplayQueue(arrayQueue);

            var linkedListQueue = new LinkedQueue <int>();

            linkedListQueue.Enqueue(1);
            linkedListQueue.Enqueue(3);
            linkedListQueue.Enqueue(4);
            linkedListQueue.Enqueue(6);
            linkedListQueue.Enqueue(9);
            DisplayQueue(linkedListQueue);
            Console.WriteLine("Добавим в очередь элемент '7'");
            linkedListQueue.Enqueue(7);
            DisplayItem(linkedListQueue);
            linkedListQueue.Clear();
            DisplayQueue(linkedListQueue);

            var listDeque = new ListDeque <int>();

            listDeque.AddFirst(1);
            listDeque.AddFirst(3);
            listDeque.AddFirst(4);
            listDeque.AddLast(6);
            listDeque.AddLast(9);
            DisplayItem(listDeque);
            DisplayQueue(listDeque);
            Console.WriteLine();
            listDeque.AddLast(5);
            DisplayItem(listDeque);
            Console.WriteLine(listDeque.RemoveFirst());
            DisplayItem(listDeque);


            var linkedDeque = new LinkedListDeque <int>();

            linkedDeque.AddFirst(1);
            linkedDeque.AddFirst(3);
            linkedDeque.AddFirst(4);
            linkedDeque.AddLast(6);
            linkedDeque.AddLast(9);
            DisplayItem(linkedDeque);
            DisplayQueue(linkedDeque);
            Console.WriteLine();
            linkedDeque.AddLast(5);
            DisplayItem(linkedDeque);
            Console.WriteLine(linkedDeque.RemoveFirst());
            DisplayItem(linkedDeque);
        }
Ejemplo n.º 4
0
        private void Start_OnClick(object sender, RoutedEventArgs e)
        {
            list0 = CustomerHelper.fun1();

            //获取设置
            cpuCount    = AppConfigHelper.GetAppConfigInt("CpuCount");
            threadCount = AppConfigHelper.GetAppConfigInt("ThreadCount");
            //清空当前列表
            ListQueue.Clear();
            //清空进度条
            this.pb.Maximum = 0;
            this.tb.Text    = "0%";
            this.pb.Value   = 0;

            var foldPath     = "";
            var newfoldPath  = "";
            var waterMarkImg = "";

            if (TabControl0.SelectedIndex == 0 || TabControl0.SelectedIndex == 2)
            {
                foldPath    = FileDir.Text;
                newfoldPath = NewFileDir.Text;
                cmdPath     = CommonStatic.FFmpegPath;
                if (TabControl0.SelectedIndex == 2)
                {
                    foldPath     = FileDir2.Text;
                    newfoldPath  = NewFileDir2.Text;
                    waterMarkImg = WaterMarkTextBox.Text.Trim();
                }
            }
            else if (TabControl0.SelectedIndex == 1)
            {
                foldPath    = FileDir1.Text;
                newfoldPath = NewFileDir1.Text;
                cmdPath     = CommonStatic.Qtpath;
            }

            if (TabControl0.SelectedIndex == 2 && string.IsNullOrEmpty(waterMarkImg))
            {
                System.Windows.Forms.MessageBox.Show("请选择要添加水印的图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(foldPath))
            {
                System.Windows.Forms.MessageBox.Show("请选择要转换的视频的路径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(newfoldPath))
            {
                System.Windows.Forms.MessageBox.Show("请输入要转换的视频的新路径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (TabControl0.SelectedIndex == 1 || TabControl0.SelectedIndex == 2)
            {
                //在 【将元信息设置到第一帧】 模式下,生成文件的路径不能够和源文件路径一样,否则会出错
                if (foldPath == newfoldPath)
                {
                    System.Windows.Forms.MessageBox.Show("【生成文件路径】不能够和【源文件路径】一样。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            DirectoryInfo thisOne = new DirectoryInfo(foldPath);

            DeepFileDir(thisOne);

            if (ListQueue.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("该路径下未找到MP4格式的视频", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            LogTextBox.Clear();
            LogTextBox.Text = "该目录下共找到 " + ListQueue.Count + " 个视频,开始进行转换......\n";
            iAmount         = ListQueue.Count;
            iCount          = 0;
            iNow            = 0;
            Thread thread = new Thread(ThreadStart);

            thread.IsBackground = true;
            thread.Start();

            Select.IsEnabled = false;
            Start.IsEnabled  = false;

            Select1.IsEnabled = false;
            Start1.IsEnabled  = false;

            pb.Maximum = ListQueue.Count;
        }
Ejemplo n.º 5
0
        private void StartOnXml_OnClick(object sender, RoutedEventArgs e)
        {
            if (TabControl0.SelectedIndex == 2 && string.IsNullOrEmpty(waterMarkImg))
            {
                System.Windows.Forms.MessageBox.Show("请选择要添加水印的图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //获取设置
            cpuCount    = AppConfigHelper.GetAppConfigInt("CpuCount");
            threadCount = AppConfigHelper.GetAppConfigInt("ThreadCount");
            //清空当前列表
            ListQueue.Clear();
            //清空进度条
            this.pb.Maximum = 0;
            this.tb.Text    = "0%";
            this.pb.Value   = 0;

            //先从根目录下查找xml
            XmlDocument xmldoc = new XmlDocument();

            try
            {
                string xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "watermark.xml";
                xmldoc.Load(xmlPath);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("xml文件加载出错", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LogHelper.AddErrorLog(ex.ToString());
                return;
            }
            //获取节点列表
            XmlNodeList topNode = xmldoc.DocumentElement.ChildNodes;

            foreach (XmlElement element in topNode)
            {
                var str         = element.InnerText;
                var item        = new VideoMp4();
                var oldFilePath = str; // newFilePath.Substring(0,newFilePath.LastIndexOf("."))
                var filename    = oldFilePath.Substring(oldFilePath.LastIndexOf("\\")).Replace("\\", "");
                var fileformat  = filename.Substring(filename.LastIndexOf("."));
                var newfilename = filename.Substring(0, filename.LastIndexOf(".")) + "_znykt_cnki" + fileformat;
                var newFilePath = oldFilePath.Substring(0, oldFilePath.LastIndexOf("\\")) + "\\" + newfilename;
                item.CmdString   = string.Format(" -y -i \"{0}\" -vf \"movie={1},scale=170:60[watermark];[in][watermark]overlay=main_w-overlay_w-10:10[out]\" \"{2}\"", oldFilePath, waterMarkImg, newFilePath);
                item.NewFileName = newfilename;
                item.NewFilePath = newFilePath;
                item.OldFilePath = oldFilePath;
                item.OldfileName = filename;
                ListQueue.Enqueue(item);
            }

            if (ListQueue.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("该路径下未找到MP4格式的视频", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            LogTextBox.Clear();
            LogTextBox.Text = "该目录下共找到 " + ListQueue.Count + " 个视频,开始进行转换......\n";
            iAmount         = ListQueue.Count;
            iCount          = 0;
            iNow            = 0;
            Thread thread = new Thread(ThreadStart);

            thread.IsBackground = true;
            thread.Start();

            Select.IsEnabled = false;
            Start.IsEnabled  = false;

            Select1.IsEnabled = false;
            Start1.IsEnabled  = false;

            pb.Maximum = ListQueue.Count;
        }