Пример #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.textBox_ffmpegPath.Text  = Properties.Settings.Default.ffmpegpath;
            this.textBox_inputstream.Text = Properties.Settings.Default.inputstream;
            this.textBox_audiorate.Text   = Properties.Settings.Default.audiorate;
            this.textBox_videorate.Text   = Properties.Settings.Default.videorate;
            this.textBox_exPort.Text      = Properties.Settings.Default.port;

            if (Properties.Settings.Default.reencode_flag)
            { // 再エンコあり
                radioButton_reencode_1.Checked = true;
                groupBox_reencode.Enabled      = true;
            }
            else
            {
                radioButton_reencode_2.Checked = true;
                groupBox_reencode.Enabled      = false;
            }

            this.textBox_enc_width.Text     = Properties.Settings.Default.enc_width;
            this.textBox_enc_height.Text    = Properties.Settings.Default.enc_height;
            this.textBox_enc_bitrate_v.Text = Properties.Settings.Default.enc_bitrate_v;
            this.textBox_enc_bitrate_a.Text = Properties.Settings.Default.enc_bitrate_a;
            this.textBox_enc_framerate.Text = Properties.Settings.Default.enc_framerate;

            logoutputDelegate = new LogoutputDelegate(logoutput);
            this.button_disconnect.Enabled = false;
            this.textBox_log.AppendText("アプリケーションが開始しました。\r\n");

            // デバイスリストを取得してリストボックスに
            CaptureDevicesCollection myDevices = new CaptureDevicesCollection();

            foreach (DeviceInformation devInfo in myDevices)
            {
                string strDesc   = devInfo.Description;
                Guid   guid      = devInfo.DriverGuid;
                string strModule = devInfo.ModuleName;
                this.textBox_log.AppendText(strDesc + "\r\n");
            }
        }
Пример #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.textBox_ffmpegPath.Text = Properties.Settings.Default.ffmpegpath;
            this.textBox_inputstream.Text = Properties.Settings.Default.inputstream;
            this.textBox_audiorate.Text = Properties.Settings.Default.audiorate;
            this.textBox_videorate.Text = Properties.Settings.Default.videorate;
            this.textBox_exPort.Text = Properties.Settings.Default.port;

            if (Properties.Settings.Default.reencode_flag)
            { // 再エンコあり
                radioButton_reencode_1.Checked = true;
                groupBox_reencode.Enabled = true;
            }
            else {
                radioButton_reencode_2.Checked = true;
                groupBox_reencode.Enabled = false;
            }

            this.textBox_enc_width.Text = Properties.Settings.Default.enc_width;
            this.textBox_enc_height.Text = Properties.Settings.Default.enc_height;
            this.textBox_enc_bitrate_v.Text = Properties.Settings.Default.enc_bitrate_v;
            this.textBox_enc_bitrate_a.Text = Properties.Settings.Default.enc_bitrate_a;
            this.textBox_enc_framerate.Text = Properties.Settings.Default.enc_framerate;

            logoutputDelegate = new LogoutputDelegate(logoutput);
            this.button_disconnect.Enabled = false;
            this.textBox_log.AppendText("アプリケーションが開始しました。\r\n");

            // デバイスリストを取得してリストボックスに
            CaptureDevicesCollection myDevices = new CaptureDevicesCollection();
            foreach (DeviceInformation devInfo in myDevices)
            {

                string strDesc = devInfo.Description;
                Guid guid = devInfo.DriverGuid;
                string strModule = devInfo.ModuleName;
                this.textBox_log.AppendText(strDesc+"\r\n");
            }
        }
Пример #3
0
        /// <summary>
        /// スレ情報取得
        /// </summary>
        /// <param name="args"></param>
        private void HttpThread(object args)
        {
            string host;
            string strGet = "";
            Encoding enc = Encoding.GetEncoding("shift-jis");
            int bbstype;
            int indexThreadName;
            int indexDate;
            int indexBody;
            int indexName;
            int indexMail;

            object[] argsTmp = (object[])args;
            int bbsCode = (int)argsTmp[0]; // 本/避難所区分
            string strUrl = (string)argsTmp[1]; // スレURL
            string strID = (string)argsTmp[2]; // スレID
            string strNameSpace = (string)argsTmp[3]; //
            string strMailSpace = (string)argsTmp[4]; //
            string strHi = "";
            if (bbsCode == Const.BOARD_HAVEN)
            {
                strHi = "[避]";
            }

            strID = Const.NZ(strID);
            strNameSpace = Const.NZ(strNameSpace);
            strMailSpace = Const.NZ(strMailSpace);

            //JSON構造体
            var serializer = new DataContractJsonSerializer(typeof(DatInfo));

            try
            {
                // logger
                LogoutputDelegate logdlg = new LogoutputDelegate(this.logoutput);

                // datURL取得
                Console.WriteLine(strUrl);
                //Regexオブジェクトを作成
                Regex r1 = new Regex(@"2ch\.net");
                Regex r2 = new Regex(@"jbbs\.shitaraba\.net");
                Regex r3 = new Regex(@"http:\/\/([^:\/]*).*read\.cgi\/([^\/]*)\/([0-9]*)\/?");
                Regex r4 = new Regex(@"http:\/\/([^:\/]*).*read\.cgi\/([^\/]*)\/([0-9]*)\/([0-9]*)\/?");
                Regex r5 = new Regex(@"(\d{4})\/(\d{2})\/(\d{2})\(.*\) (\d{2}):(\d{2}):(\d{2})\.\d{2} ID:(.*)");
                Regex r6 = new Regex(@"(\d{4})\/(\d{2})\/(\d{2})\(.*\) (\d{2}):(\d{2}):(\d{2})");

                if (r1.Match(strUrl).Success)
                {
                    bbstype = Const.BBS_2CH;
                    indexThreadName = 4;
                    indexDate = 2;
                    indexBody = 3;
                    indexName = 0;
                    indexMail = 1;
                    Match m = r3.Match(strUrl);
                    if (!m.Success)
                    {
                        this.BeginInvoke(logdlg, new object[] { "スレッドURLが不正です。" });
                        this.BeginInvoke(new Action(delegate() { this.resetthreaddup(); }), new object[] { });
                        return;
                    }
                    host = m.Groups[1].Value;
                    string board = m.Groups[2].Value;
                    string datid = m.Groups[3].Value;
                    strGet = "http://" + host + "/" + board + "/dat/" + datid + ".dat";
                    Console.WriteLine(strGet);

                    enc = Encoding.GetEncoding("shift-jis");

                }
                else if (r2.Match(strUrl).Success)
                {
                    bbstype = Const.BBS_SHITARABA;
                    indexThreadName = 5;
                    indexDate = 3;
                    indexBody = 4;
                    indexName = 1;
                    indexMail = 2;
                    Match m = r4.Match(strUrl);
                    if (!m.Success)
                    {
                        this.BeginInvoke(logdlg, new object[] { "スレッドURLが不正です。(避難所)" });
                        this.BeginInvoke(new Action(delegate() { this.resetthreaddup(); }), new object[] { });
                        return;
                    }
                    host = m.Groups[1].Value;
                    string bbs = m.Groups[2].Value;
                    string key1 = m.Groups[3].Value;
                    string key2 = m.Groups[4].Value;
                    strGet = @"http://jbbs.shitaraba.net/bbs/rawmode.cgi/" + bbs + "/" + key1 + "/" + key2 + "/";
                    Console.WriteLine(strGet);

                    enc = Encoding.GetEncoding("euc-jp");

                }
                else
                {
                    this.BeginInvoke(logdlg, new object[] { "スレッドURLが不正です。" });
                    this.BeginInvoke(new Action(delegate() { this.resetthreaddup(); }), new object[] { });
                    return;
                }

                // サーバーソケット初期化
                this.BeginInvoke(logdlg, new object[] { "データを取得します。" });
                //HttpWebRequestの作成
                System.Net.HttpWebRequest webreq =
                    (System.Net.HttpWebRequest)
                        System.Net.WebRequest.Create(strGet);

                webreq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                webreq.Proxy = null;

                //サーバーからの応答を受信するためのHttpWebResponseを取得
                System.Net.HttpWebResponse webres =
                    (System.Net.HttpWebResponse)webreq.GetResponse();

                //System.Text.Encoding.GetEncoding("euc-jp");
                //応答データを受信するためのStreamを取得
                System.IO.Stream st = webres.GetResponseStream();
                System.IO.StreamReader sr = new System.IO.StreamReader(st, enc);

                // 一行ずつパース
                Int32 rescnt = 0;
                int news = 0; //新レス数
                while (!sr.EndOfStream)
                {
                    rescnt++;
                    string h = sr.ReadLine();
                    if (bbsCode == Const.BOARD_MAIN && rescnt <= this.resnum) { continue; }
                    if (bbsCode == Const.BOARD_HAVEN && rescnt <= this.resnum_h) { continue; }
                    string[] stArrayData = h.Split(new string[] { "<>" }, StringSplitOptions.None);
                    if (rescnt == 1 && bbsCode == Const.BOARD_HAVEN) // 本スレのみ
                    {
                        this.BeginInvoke(new Action<String>(delegate(String str) { this.threadnameupdate(stArrayData[indexThreadName]); }), new object[] { "" });
                        //this.BeginInvoke(new Action<String>(delegate(String str) { this.idupdate(this.OptionInstanse.strID); }), new object[] { "" });
                    }

                    // 読み込んだレス番号を更新
                    switch (bbsCode)
                    {
                        case Const.BOARD_MAIN:
                            this.BeginInvoke(new Action<Int32>(delegate(Int32 i) { this.resnumupdate(rescnt); }), new object[] { 0 });
                            break;
                        case Const.BOARD_HAVEN:
                            this.BeginInvoke(new Action<Int32>(delegate(Int32 i) { this.resnumhupdate(rescnt); }), new object[] { 0 });
                            break;
                        default:
                            // Invalid code;
                            throw new Exception("Invalid board code.");
                    }

                    string target = "";
                    if (bbstype == Const.BBS_2CH)
                    {
                        Match m = r5.Match(stArrayData[indexDate]);
                        if (!m.Success) { continue; }
                        string aid = m.Groups[7].Value;
                        // filter
                        if (aid.Contains(strID) && stArrayData[indexName].Contains(strNameSpace) && stArrayData[indexMail].Contains(strMailSpace))
                        {
                            // 経過時刻更新
                            DateTime d = DateTime.Parse(
                                m.Groups[1].Value + "/" + m.Groups[2].Value + "/" + m.Groups[3].Value + " " +
                                m.Groups[4].Value + ":" + m.Groups[5].Value + ":" + m.Groups[6].Value);
                            long tick = DateTime.Now.Ticks - d.Ticks;
                            if (this.timersec > tick / 10000000)
                            {
                                this.BeginInvoke(new Action<Int64>(delegate(Int64 i) { this.timersecupdate(tick / 10000000); }), new object[] { 0 });
                            }
                            string body = "";
                            string patternStr = @"<.*?>";
                            body = stArrayData[indexBody];
                            body = body.Replace("<br>", "\r\n");
                            body = Regex.Replace(body, patternStr, string.Empty, RegexOptions.Singleline);

                            // レス更新
                            string name =  stArrayData[indexName] + " " ;
                            string mail =  "[" + stArrayData[indexMail] + "] ";
                            string date = "";
                            DateTime datetime = new DateTime();
                            string id = "";
                            string[] arrDate = stArrayData[indexDate].Split(' ');
                            try
                            {
                                date = arrDate[0] + " " + arrDate[1] + " ";
                                datetime = DateTime.Parse(arrDate[0].Substring(0, 10) + " " + arrDate[1]);
                            }
                            catch (Exception) { }
                            try
                            {
                                id = arrDate[2] + " ";
                            }
                            catch (Exception) { }
                            string num = rescnt.ToString() + " " ;
                            body = WebUtility.HtmlDecode(body);
                            target = strHi + num + name + mail + date + id + "\r\n" + body;
                            //JSONデータを書き込むためのMemoryStreamを作成
                            var jsonDat = new DatInfo()
                            {
                                ThreadDiv = Const.BBS_2CH,
                                Self = 0,
                                Number = rescnt,
                                Name = name,
                                Mail = mail,
                                Date = date,
                                DateTime = datetime,
                                ID = id,
                                Body = body
                            };

                            var stream = new MemoryStream();
                            serializer.WriteObject(stream, jsonDat);
                            stream.Position = 0;
                            var reader = new StreamReader(stream);

                            target = reader.ReadToEnd();

                            stream.Dispose();
                            reader.Dispose();

                            news++;
                        }
                    }
                    else if (bbstype == Const.BBS_SHITARABA)
                    {
                        Match m = r6.Match(stArrayData[indexDate]);
                        if (!m.Success) { continue; }
                        string aid = stArrayData[6];
                        if (aid.Contains(strID) && stArrayData[indexName].Contains(strNameSpace) && stArrayData[indexMail].Contains(strMailSpace))
                        {
                            // 経過時刻更新
                            DateTime d = DateTime.Parse(
                                m.Groups[1].Value + "/" + m.Groups[2].Value + "/" + m.Groups[3].Value + " " +
                                m.Groups[4].Value + ":" + m.Groups[5].Value + ":" + m.Groups[6].Value);
                            long tick = DateTime.Now.Ticks - d.Ticks;
                            if (this.timersec > tick / 10000000)
                            {
                                this.BeginInvoke(new Action<Int64>(delegate(Int64 i) { this.timersecupdate(tick / 10000000); }), new object[] { 0 });
                            }
                            string body = "";
                            string patternStr = @"<.*?>";
                            body = stArrayData[indexBody];
                            body = body.Replace("<br>", "\r\n");
                            body = Regex.Replace(body, patternStr, string.Empty, RegexOptions.Singleline);

                            // レス更新
                            string name =  stArrayData[indexName] + " " ;
                            string mail =  "[" + stArrayData[indexMail] + "] ";
                            string date =  stArrayData[indexDate] + " " ;
                            string id =  "ID:" + aid + " " ;
                            string num =  rescnt.ToString() + " " ;
                            body = WebUtility.HtmlDecode(body);
                            target = strHi + num + name + mail + date + id + "\r\n" + body;

                            news++;
                        }

                    }

                    if (target.Length != 0)
                    {
                        // 排他制御入れる
                        Monitor.Enter(syncObject);
                        try
                        {
                            this.BeginInvoke(new Action<String>(delegate(String str)
                            {
                                this.resoutput(target);
                            }), new object[] { "" });
                            Console.WriteLine(target);
                        }
                        catch (Exception ex)
                        {
                            // 何もしない
                            Console.WriteLine(ex.GetType());
                        }
                        finally
                        {
                            Monitor.Exit(syncObject);
                        }
                    }

                }

                if (news > 0) //レスがあった場合
                {
                    // 開始フラグ
                    this.BeginInvoke(new Action<Boolean>(delegate(Boolean str)
                    {
                        this.resexistupdate(true);
                    }), new object[] { false });

                    this.BeginInvoke(new Action(delegate()
                    {
                        this.resetbasetime();
                    }), new object[] { });
                }

                //閉じる
                //webres.Close()でもよい
                sr.Close();
                this.BeginInvoke(new Action<String>(delegate(String str) { this.logoutput(news.ToString() + "件の安価人レス取得"); }), new object[] { "" });
                this.BeginInvoke(new Action(delegate()
                {
                    this.resetthreaddup();
                }), new object[] { });
            }
            catch (InvalidOperationException ioex)
            {
                // 何もしない
                Console.WriteLine(ioex.Message);
            }
            catch (System.Threading.ThreadAbortException aex)
            {
                // 何もしない(スレッド強制終了時)
                Console.WriteLine(aex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                this.BeginInvoke(new Action<String>(delegate(String str) { this.logoutput("エラー:" + ex.Message); }), new object[] { "" });
                //this.BeginInvoke(new Action(delegate(){ this.resetthreaddup();}), new object[] { });
            }
            finally
            {}
        }
Пример #4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.textBox_ffmpegPath.Text = Properties.Settings.Default.ffmpegpath;
            this.textBox_inputstream.Text = Properties.Settings.Default.inputstream;
            this.textBox_audiorate.Text = Properties.Settings.Default.audiorate;
            this.textBox_videorate.Text = Properties.Settings.Default.videorate;
            this.textBox_exPort.Text = Properties.Settings.Default.port;
            this.textBox_pushAddr.Text = Properties.Settings.Default.push_addr;

            if (Properties.Settings.Default.reencode_flag)
            { // 再エンコあり
                radioButton_reencode_1.Checked = true;
                groupBox_reencode.Enabled = true;
            }
            else {
                radioButton_reencode_2.Checked = true;
                groupBox_reencode.Enabled = false;
            }

            if (Properties.Settings.Default.ffmpegcom_flag)
            { // 再エンコあり
                radioButton_ffmpegcom_1.Checked = true;
                textBox_ffmpegcom.Enabled = true;
            }
            else
            {
                radioButton_ffmpegcom_2.Checked = true;
                textBox_ffmpegcom.Enabled = false;
            }

            this.textBox_enc_width.Text = Properties.Settings.Default.enc_width;
            this.textBox_enc_height.Text = Properties.Settings.Default.enc_height;
            this.textBox_enc_bitrate_v.Text = Properties.Settings.Default.enc_bitrate_v;
            this.textBox_enc_bitrate_a.Text = Properties.Settings.Default.enc_bitrate_a;
            this.textBox_enc_framerate.Text = Properties.Settings.Default.enc_framerate;

            this.textBox_ffmpegcom.Text = Properties.Settings.Default.ffmpegcom;

            this.tbx_Title.Text = Properties.Settings.Default.content_title;
            this.tbx_Auther.Text = Properties.Settings.Default.content_auther;
            this.tbx_Copyright.Text = Properties.Settings.Default.content_copyright;
            this.tbx_Description.Text = Properties.Settings.Default.content_description;
            this.tbx_Rating.Text = Properties.Settings.Default.content_rating;

            logoutputDelegate = new LogoutputDelegate(logoutput);
            connectButtonStateDeligate = new ConnectButtonDelegate(connectButtonState);
            disconnectButtonStateDeligate = new DisconnectButtonDelegate(disconnectButtonState);

            //自分自身のAssemblyを取得
            System.Reflection.Assembly asm =
                System.Reflection.Assembly.GetExecutingAssembly();
            //バージョンの取得
            System.Version ver = asm.GetName().Version;
            this.label_version.Text = "Ver. " + ver.ToString() ;

            this.button_disconnect.Enabled = false;
            this.textBox_log.AppendText("アプリケーションが開始しました。\r\n");
        }