コード例 #1
0
        public void loadConf()
        {
            try
            {
                List <string> lines = new List <string>();

                foreach (string line in FileTools.readAllLines(getConfFile(), StringTools.ENCODING_SJIS))
                {
                    if (line != "" && line[0] != ';')
                    {
                        lines.Add(line);
                    }
                }

                int c = 0;

                // items >

                ffmpegOptAudio  = lines[c++];
                ffmpegOptVideo  = lines[c++];
                plCountMax      = IntTools.toInt(lines[c++], 1);
                bciCountMax     = IntTools.toInt(lines[c++], 1);
                rFileSizeMax_MB = IntTools.toInt(lines[c++], 1);
                keepDiskFree_MB = IntTools.toInt(lines[c++], 1);

                // < items
            }
            catch
            { }
        }
コード例 #2
0
ファイル: Ground.cs プロジェクト: stackprobe/natsuedit
		public void saveData()
		{
			try
			{
				List<string> lines = new List<string>();

				// items >

				lines.Add(ffmpegDir);
				lines.Add(lastOpenedFile);
				lines.Add("" + mainWin_L);
				lines.Add("" + mainWin_T);
				lines.Add("" + mainWin_W);
				lines.Add("" + mainWin_H);
				lines.Add(StringTools.toString(mainWinMaximized));
				lines.Add("" + IntTools.toInt(selectingColor));
				lines.Add("" + IntTools.toInt(selectColor));
				lines.Add(StringTools.toString(_ファイルを閉じるとき保存するか確認しない));
				lines.Add(StringTools.toString(_起動時にffmpegのパスを設定する));
				lines.Add(StringTools.toString(_映像をJPEGで保存する));
				lines.Add("" + _映像をJPEGで保存する時の画質);

				// < items

				File.WriteAllLines(getDataFile(), lines, Encoding.UTF8);
			}
			catch
			{ }
		}
コード例 #3
0
ファイル: EffectBokashi.cs プロジェクト: stackprobe/natsuedit
 public Color getColor()
 {
     return(Color.FromArgb(
                IntTools.toInt((double)_r / _count),
                IntTools.toInt((double)_g / _count),
                IntTools.toInt((double)_b / _count)
                ));
 }
コード例 #4
0
ファイル: MkAndPrintWin.cs プロジェクト: stackprobe/SudokuGen
 private LTRB getMaringLTRB()
 {
     return(new LTRB(
                IntTools.toInt(this.marginL.Text, 0, 9999, 100),
                IntTools.toInt(this.marginT.Text, 0, 9999, 100),
                IntTools.toInt(this.marginR.Text, 0, 9999, 100),
                IntTools.toInt(this.marginB.Text, 0, 9999, 100)
                ));
 }
コード例 #5
0
ファイル: Utils.cs プロジェクト: stackprobe/natsuedit
        public static void fillRectangle(Graphics g, Rect rect, Color color)
        {
            // (rect.l, rect.t) から (rect.getR() - 1, rect.getB() - 1) の範囲を塗りつぶしたい。

            g.FillRectangle(
                new SolidBrush(color),
                IntTools.toInt(rect.l),
                IntTools.toInt(rect.t),
                IntTools.toInt(rect.w),
                IntTools.toInt(rect.h)
                );
        }
コード例 #6
0
        public void loadData()
        {
            try
            {
                string[] lines = File.ReadAllLines(getDataFile(), Encoding.UTF8);
                int      c     = 0;

                // items >

                lastPIIndex       = int.Parse(lines[c++]);
                lastDifficulty    = int.Parse(lines[c++]);
                lastPrinterName   = lines[c++];
                lastPaperSizeName = lines[c++];

                {
                    string line = lines[c++];

                    if (line != "")
                    {
                        List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true);

                        lastMargin = new LTRB(
                            IntTools.toInt(tokens[0], 0, 9999),
                            IntTools.toInt(tokens[1], 0, 9999),
                            IntTools.toInt(tokens[2], 0, 9999),
                            IntTools.toInt(tokens[3], 0, 9999)
                            );
                    }
                    else
                    {
                        lastMargin = null;
                    }
                }

                lastPrintProblem         = StringTools.toFlag(lines[c++]);
                lastPrintAnswer          = StringTools.toFlag(lines[c++]);
                lv1Color                 = IntTools.toColor(int.Parse(lines[c++]));
                lv2Color                 = IntTools.toColor(int.Parse(lines[c++]));
                lv3Color                 = IntTools.toColor(int.Parse(lines[c++]));
                lv4Color                 = IntTools.toColor(int.Parse(lines[c++]));
                ansColor                 = IntTools.toColor(int.Parse(lines[c++]));
                _合体ナンプレの重なった部分に成丈数字を置かない = StringTools.toFlag(lines[c++]);

                // < items
            }
            catch
            { }
        }
コード例 #7
0
        public void saveData()
        {
            try
            {
                List <string> lines = new List <string>();

                // items >

                lines.Add("" + lastPIIndex);
                lines.Add("" + lastDifficulty);
                lines.Add(lastPrinterName);
                lines.Add(lastPaperSizeName);

                {
                    string line;

                    if (lastMargin != null)
                    {
                        line = String.Join(", ", lastMargin.l, lastMargin.t, lastMargin.r, lastMargin.b);
                    }
                    else
                    {
                        line = "";
                    }

                    lines.Add(line);
                }

                lines.Add(StringTools.toString(lastPrintProblem));
                lines.Add(StringTools.toString(lastPrintAnswer));
                lines.Add("" + IntTools.toInt(lv1Color));
                lines.Add("" + IntTools.toInt(lv2Color));
                lines.Add("" + IntTools.toInt(lv3Color));
                lines.Add("" + IntTools.toInt(lv4Color));
                lines.Add("" + IntTools.toInt(ansColor));
                lines.Add(StringTools.toString(_合体ナンプレの重なった部分に成丈数字を置かない));

                // < items

                File.WriteAllLines(getDataFile(), lines, Encoding.UTF8);
            }
            catch
            { }
        }
コード例 #8
0
        public VideoSelectWin(Bitmap frameImage, Rect ownerRect)
        {
            _frameImage = frameImage;
            _ownerRect  = ownerRect;

            InitializeComponent();

            this.MinimumSize    = this.Size;
            this.imgFrame.Image = _frameImage;

            {
                Rect rect = getInitSelectRect();

                txtL.Text = "" + IntTools.toInt(rect.l);
                txtT.Text = "" + IntTools.toInt(rect.t);
                txtW.Text = "" + IntTools.toInt(rect.w);
                txtH.Text = "" + IntTools.toInt(rect.h);
            }
        }
コード例 #9
0
        // < items

        public void loadData()
        {
            if (File.Exists(getDataFile()) == false)
            {
                Utils.WriteLog("no data file");
                return;
            }

            try
            {
                string[] lines = File.ReadAllLines(getDataFile(), Encoding.UTF8);
                int      c     = 0;

                // items >

                portNo = IntTools.toInt(lines[c++]);

                {
                    string line = lines[c++];

                    if (line != "")
                    {
                        key = new KeyData();
                        FieldsSerializer.deserialize(key, StringTools.decodeLines(line));
                    }
                    else
                    {
                        key = null;
                    }
                }

                passphrase    = lines[c++];
                forwardPortNo = int.Parse(lines[c++]);

                // < items
            }
            catch (Exception e)
            {
                Utils.WriteLog(e);
            }
        }
コード例 #10
0
ファイル: Ground.cs プロジェクト: stackprobe/natsuedit
		public void loadConf()
		{
			try
			{
				List<string> lines = new List<string>();

				foreach (string line in FileTools.readAllLines(getConfFile(), StringTools.ENCODING_SJIS))
					if (line != "" && line[0] != ';')
						lines.Add(line);

				int c = 0;

				// items >

				rFileSizeWarning_MB = IntTools.toInt(lines[c++], 1);

				// < items
			}
			catch
			{ }
		}
コード例 #11
0
ファイル: Ground.cs プロジェクト: stackprobe/UnrealRemoco
        public void loadConf()
        {
            try
            {
                List <string> lines = new List <string>();

                foreach (string line in FileTools.readAllLines(getConfFile(), StringTools.ENCODING_SJIS))
                {
                    if (line != "" && line[0] != ';')
                    {
                        lines.Add(line);
                    }
                }

                int c = 0;

                if (int.Parse(lines[c++]) != lines.Count)
                {
                    throw new Exception("Bad item count");
                }

                // items >

                consoleWinStyle    = (ProcessTools.WindowStyle_e) int.Parse(lines[c++]);
                passphraseSuffix   = lines[c++];
                screen_w_min       = IntTools.toInt(lines[c++], 1);
                screen_h_min       = IntTools.toInt(lines[c++], 1);
                screen_w_max       = IntTools.toInt(lines[c++], screen_w_min);
                screen_h_max       = IntTools.toInt(lines[c++], screen_h_min);
                serverInfoCountMax = IntTools.toInt(lines[c++], 1);
                clearLogCycle      = long.Parse(lines[c++]);

                // < items
            }
            catch (Exception e)
            {
                Utils.WriteLog(e);
            }
        }
コード例 #12
0
        private Rect getInputRect()
        {
            try
            {
                Rect rect = new Rect(
                    IntTools.toInt(this.txtL.Text),
                    IntTools.toInt(this.txtT.Text),
                    IntTools.toInt(this.txtW.Text),
                    IntTools.toInt(this.txtH.Text)
                    );

                rect.l = IntTools.toRange((int)rect.l, 0, _frameImage.Width - Consts.VIDEO_SELECT_W_MIN);
                rect.t = IntTools.toRange((int)rect.t, 0, _frameImage.Height - Consts.VIDEO_SELECT_H_MIN);
                rect.w = IntTools.toRange((int)rect.w, Consts.VIDEO_SELECT_W_MIN, _frameImage.Width - (int)rect.l);
                rect.h = IntTools.toRange((int)rect.h, Consts.VIDEO_SELECT_H_MIN, _frameImage.Height - (int)rect.t);

                return(rect);
            }
            catch
            { }

            return(null);
        }
コード例 #13
0
ファイル: EffectBokashi.cs プロジェクト: stackprobe/natsuedit
        private Color getBokashiDotColor(Bitmap img, int trgX, int trgY)
        {
            int r     = 0;
            int g     = 0;
            int b     = 0;
            int count = 0;

            for (int sx = -_bokashi_rad; sx <= _bokashi_rad; sx++)
            {
                for (int sy = -_bokashi_rad; sy <= _bokashi_rad; sy++)
                {
                    if (sx * sx + sy * sy <= _bokashi_rad * _bokashi_rad)
                    {
                        int x = trgX + sx;
                        int y = trgY + sy;

                        if (
                            IntTools.isRange(x, 0, img.Width - 1) &&
                            IntTools.isRange(y, 0, img.Height - 1)
                            )
                        {
                            Color color = img.GetPixel(x, y);

                            r += color.R;
                            g += color.G;
                            b += color.B;
                            count++;
                        }
                    }
                }
            }
            r = IntTools.toInt((double)r / count);
            g = IntTools.toInt((double)g / count);
            b = IntTools.toInt((double)b / count);

            return(Color.FromArgb(r, g, b));
        }
コード例 #14
0
ファイル: MainWin.cs プロジェクト: stackprobe/natsuedit
        private void refreshStatus()
        {
            try
            {
                List <string> tokens = new List <string>();

                if (_currFrame != null)
                {
                    tokens.Add(_currFrame.Width + "x" + _currFrame.Height);
                }
                if (Gnd.i.md != null)
                {
                    int fps = Gnd.i.md.getTargetVideoStream().fps;

                    tokens.Add(
                        Utils.millisToTimeStamp(IntTools.toInt(this.seekBar.Value * 1000.0 / fps)) +
                        " / " +
                        Utils.millisToTimeStamp(IntTools.toInt(this.seekBar.Maximum * 1000.0 / fps)) +
                        " (" +
                        this.seekBar.Value +
                        " / " +
                        this.seekBar.Maximum +
                        ")"
                        );
                    tokens.Add(fps + " fps");
                    tokens.Add(Gnd.i.md.getWavHz() + " hz");

                    if (Gnd.i.md.ed.v.selectRect != null)
                    {
                        Rect rect = Gnd.i.md.ed.v.selectRect;

                        tokens.Add(
                            "画面選択=(" +
                            IntTools.toInt(rect.l) +
                            ", " +
                            IntTools.toInt(rect.t) +
                            ", " +
                            (IntTools.toInt(rect.getR()) - 1) +
                            ", " +
                            (IntTools.toInt(rect.getB()) - 1) +
                            ")"
                            );
                    }
                    if (Gnd.i.md.ed.v.isSelecting())
                    {
                        Rect rect = Gnd.i.md.ed.v.getSelectingRect();

                        if (rect == null)
                        {
                            tokens.Add("画面選択中...");
                        }
                        else
                        {
                            tokens.Add(
                                "画面選択中=(" +
                                IntTools.toInt(rect.l) +
                                ", " +
                                IntTools.toInt(rect.t) +
                                ", " +
                                (IntTools.toInt(rect.getR()) - 1) +
                                ", " +
                                (IntTools.toInt(rect.getB()) - 1) +
                                ")"
                                );
                        }
                    }
                    if (Gnd.i.md.ed.a.selectEnd != -1)
                    {
                        tokens.Add(
                            "時間選択=" +
                            Utils.millisToTimeStamp(IntTools.toInt(Gnd.i.md.ed.a.selectBegin * 1000.0 / fps)) +
                            " (" +
                            Gnd.i.md.ed.a.selectBegin +
                            ") ~ " +
                            Utils.millisToTimeStamp(IntTools.toInt(Gnd.i.md.ed.a.selectEnd * 1000.0 / fps)) +
                            " (" +
                            Gnd.i.md.ed.a.selectEnd +
                            ")"
                            );
                    }
                    else if (Gnd.i.md.ed.a.selectBegin != -1)
                    {
                        tokens.Add(
                            "時間選択中=" +
                            Utils.millisToTimeStamp(IntTools.toInt(Gnd.i.md.ed.a.selectBegin * 1000.0 / fps)) +
                            " (" +
                            Gnd.i.md.ed.a.selectBegin +
                            ")..."
                            );
                    }
                }

                {
                    string state = string.Join(", ", tokens);

                    if (this.lblStatus.Text != state)
                    {
                        this.lblStatus.Text = state;
                    }
                }
            }
            catch (Exception e)
            {
                this.lblStatus.Text = e.Message;
            }

            refreshTimeSelection();
        }
コード例 #15
0
        public void perform()
        {
            if (Gnd.i.md == null)
            {
                return;
            }

            if (Gnd.i.md.ed.v.selectRect == null)             // ? ! 画面選択完了
            {
                throw new FailedOperation("画面選択を行って下さい。");
            }

            {
                Rect rect = Gnd.i.md.ed.v.selectRect;

                _l = IntTools.toInt(rect.l);
                _t = IntTools.toInt(rect.t);
                _w = IntTools.toInt(rect.w);
                _h = IntTools.toInt(rect.h);
            }

            if (_w < Consts.VIDEO_W_MIN)
            {
                throw new FailedOperation("選択範囲の幅が短すぎます。\n" + Consts.VIDEO_W_MIN + "px以上必要");
            }

            if (_h < Consts.VIDEO_H_MIN)
            {
                throw new FailedOperation("選択範囲の高さが短すぎます。\n" + Consts.VIDEO_H_MIN + "px以上必要");
            }

            int count = Gnd.i.md.ed.v.getCount();

            for (int index = 0; index < count; index++)
            {
                Gnd.i.progressMessage.post("枠外切り捨て... " + index + " / " + count);

                Bitmap img     = Gnd.i.md.ed.v.getImage(index);
                Bitmap destImg = new Bitmap(_w, _h, PixelFormat.Format24bppRgb);                 // 24 bit じゃないと、ffmpeg で動画に変換できない!

#if true
                using (Graphics g = Graphics.FromImage(destImg))
                {
                    Rectangle srcRect  = new Rectangle(_l, _t, _w, _h);
                    Rectangle destRect = new Rectangle(0, 0, _w, _h);

                    g.DrawImage(
                        img,
                        destRect,
                        srcRect,
                        GraphicsUnit.Pixel
                        );
                }
#else // same 遅い
                for (int x = 0; x < _w; x++)
                {
                    for (int y = 0; y < _h; y++)
                    {
                        destImg.SetPixel(x, y, img.GetPixel(_l + x, _t + y));
                    }
                }
#endif

                string file = Gnd.i.md.ed.v.getFile(index);

                destImg.Save(file, Consts.V_IMG_FORMAT);
                GC.Collect();
            }

            // 動画の情報変更
            {
                Gnd.i.md.getTargetVideoStream().w = _w;
                Gnd.i.md.getTargetVideoStream().h = _h;
            }
        }
コード例 #16
0
ファイル: EffectBokashi.cs プロジェクト: stackprobe/natsuedit
        public void perform(bool strongMode = false)
        {
            _strongMode = strongMode;

            if (Gnd.i.md == null)
            {
                return;
            }

            if (Gnd.i.md.ed.v.selectRect == null)             // ? ! 画面選択完了
            {
                throw new FailedOperation("画面選択を行って下さい。");
            }

            if (Gnd.i.md.ed.a.selectEnd == -1)             // ? ! 時間選択完了
            {
                throw new FailedOperation("時間を選択して下さい。");
            }

            {
                Rect rect = Gnd.i.md.ed.v.selectRect;

                _bokashi_l = IntTools.toInt(rect.l);
                _bokashi_t = IntTools.toInt(rect.t);
                _bokashi_r = IntTools.toInt(rect.getR()) - 1;                 // l + w の直前までなので、-1
                _bokashi_b = IntTools.toInt(rect.getB()) - 1;                 // t + h の直前までなので、-1
            }

            {
                int video_w = Gnd.i.md.getTargetVideoStream().w;
                int video_h = Gnd.i.md.getTargetVideoStream().h;

                if (_strongMode)
                {
                    _bokashi_rad = Math.Max(40, Math.Min(video_w, video_h) / 10);
                }
                else
                {
                    _bokashi_rad = Math.Max(10, Math.Min(video_w, video_h) / 40);
                }
            }

            Gnd.i.logger.writeLine("_bokashi_rad: " + _bokashi_rad);

            _startIndex = Gnd.i.md.ed.a.selectBegin;         // ここから
            _endIndex   = Gnd.i.md.ed.a.selectEnd;           // ここまで、ぼかしを入れる。
            _currIndex  = _startIndex;

            Thread[] ths = new Thread[getThCount()];

            for (int index = 0; index < ths.Length; index++)
            {
                ths[index] = new Thread((ThreadStart) delegate
                {
                    try
                    {
                        doBokashi();
                    }
                    catch
                    { }
                });

                ths[index].Start();
            }
            for (int index = 0; index < ths.Length; index++)
            {
                ths[index].Join();
            }
            if (Gnd.i.cancelled)
            {
                throw new Cancelled("処理を中止しました。\n途中まで処理が進んでいるかもしれません。");
            }

            Gnd.i.progressMessage.post("");             // 完了
        }
コード例 #17
0
        private void loadFile()
        {
            string redirFile = _wd.makePath();

            Gnd.i.progressMessage.post("入力ファイルをコピーしています...");

            File.Copy(_origFile, _duplFile);

            Gnd.i.progressMessage.post("入力ファイルのフォーマットを調べています...");

            ProcessTools.runOnBatch(
                "ffprobe.exe " + _duplFile + " 2> " + redirFile,
                FFmpegBin.i.getBinDir()
                );

            foreach (string fLine in FileTools.readAllLines(redirFile, Encoding.ASCII))
            {
                string line = fLine.Trim();

                if (line.StartsWith("Stream"))
                {
                    List <string> sInts    = StringTools.tokenize(line, StringTools.DIGIT, true, true);
                    int           mapIndex = int.Parse(sInts[1]);

                    List <string> tokens = StringTools.tokenize(line, " ,", false, true);

                    if (line.Contains("Audio:"))
                    {
                        AudioStream stream = new AudioStream();

                        stream.mapIndex = mapIndex;

                        _audioStreams.Add(stream);
                    }
                    else if (line.Contains("Video:"))
                    {
                        VideoStream stream = new VideoStream();

                        stream.mapIndex = mapIndex;

                        {
                            int index = ArrayTools.indexOf <string>(tokens.ToArray(), "fps", StringTools.comp);

                            if (index == -1)
                            {
                                throw new Exception("映像ストリームの秒間フレーム数を取得出来ませんでした。");
                            }

                            stream.fps = IntTools.toInt(double.Parse(tokens[index - 1]));
                        }

                        {
                            string token = Utils.getTokenDigitFormat(tokens.ToArray(), "9x9");

                            if (token == null)
                            {
                                throw new Exception("映像ストリームの画面サイズを取得出来ませんでした。");
                            }

                            List <string> s_wh = StringTools.tokenize(token, StringTools.DIGIT, true, true);

                            stream.w = int.Parse(s_wh[0]);
                            stream.h = int.Parse(s_wh[1]);
                        }

                        if (IntTools.isRange(stream.fps, 1, IntTools.IMAX) == false)
                        {
                            throw new FailedOperation("映像ストリームの秒間フレーム数を認識出来ません。" + stream.fps);
                        }

                        if (IntTools.isRange(stream.w, 1, IntTools.IMAX) == false)
                        {
                            throw new FailedOperation("映像ストリームの画面の幅を認識出来ません。" + stream.w);
                        }

                        if (IntTools.isRange(stream.h, 1, IntTools.IMAX) == false)
                        {
                            throw new FailedOperation("映像ストリームの画面の高さを認識出来ません。" + stream.h);
                        }

                        _videoStreams.Add(stream);
                    }
                    else
                    {
                        // "Data:" とか
                    }
                }
            }

            if (_audioStreams.Count == 0)
            {
                throw new FailedOperation("音声ストリームがありません。");
            }

            if (_videoStreams.Count == 0)
            {
                throw new FailedOperation("映像ストリームがありません。");
            }

            _targetAudioStream = _audioStreams[0];
            _targetVideoStream = _videoStreams[0];

            // ---- Audio Stream ----

            Gnd.i.progressMessage.post("音声ストリームを取り出しています...");

            ProcessTools.runOnBatch(
                "ffmpeg.exe -i " + _duplFile + " -map 0:" + _targetAudioStream.mapIndex + " -ac 2 " + _wavFile + " 2> " + _wd.makePath("mk_wav_stderr.txt"),
                FFmpegBin.i.getBinDir()
                );

            Gnd.i.progressMessage.post("音声ストリームを展開しています...");

            _wavHz = CTools.wavFileToCsvFile(_wavFile, _wavCsvFile, _wd.makePath("mk_wav-csv_stdout.txt"));

            // 1 <= 音声の長さ < IMAX

            {
                long size = new FileInfo(_wavCsvFile).Length;

                if (size % 12L != 0)
                {
                    throw new Exception("wav-csv data size error");
                }

                long count = size / 12L;

                if (count == 0L)
                {
                    throw new FailedOperation("音声ストリームに最初のサンプリング値がありません。");
                }

                if (IntTools.IMAX <= count)
                {
                    throw new FailedOperation("音声ストリームが長過ぎます。");
                }
            }

            // ---- Video Stream ----

            Gnd.i.progressMessage.post("映像ストリームを展開しています...");

            ProcessTools.runOnBatch(
                "ffmpeg.exe -i " + _duplFile + " -map 0:" + _targetVideoStream.mapIndex + " -r " + _targetVideoStream.fps + " -f image2 -vcodec " + Consts.V_IMG_VCODEC + " " + _imgDir + "\\%%010d" + Consts.V_IMG_EXT + " 2> " + _wd.makePath("mk_img_stderr.txt"),
                FFmpegBin.i.getBinDir()
                );

            // 1 <= 映像の長さ < IMAX

            if (File.Exists(_imgDir + "\\0000000001" + Consts.V_IMG_EXT) == false)
            {
                throw new FailedOperation("映像ストリームに最初のフレームがありません。");
            }

            if (File.Exists(_imgDir + "\\1000000001" + Consts.V_IMG_EXT))
            {
                throw new FailedOperation("映像ストリームが長過ぎます。");
            }

            // ----

            Gnd.i.progressMessage.post("");             // 完了

            ed = new EditData(this);

            // VIDEO_W/H_MIN/MAX
            {
                Image img = ed.v.getImage(0);

                if (img.Width < Consts.VIDEO_W_MIN)
                {
                    throw new FailedOperation("映像の幅が小さ過ぎます。" + img.Width);
                }

                if (Consts.VIDEO_W_MAX < img.Width)
                {
                    throw new FailedOperation("映像の幅が大き過ぎます。" + img.Width);
                }

                if (img.Height < Consts.VIDEO_H_MIN)
                {
                    throw new FailedOperation("映像の高さが小さ過ぎます。" + img.Height);
                }

                if (Consts.VIDEO_H_MAX < img.Height)
                {
                    throw new FailedOperation("映像の高さが大き過ぎます。" + img.Height);
                }
            }

            // AUDIO_HZ_MIN/MAX
            {
                int hz = this._wavHz;

                if (hz < Consts.AUDIO_HZ_MIN)
                {
                    throw new FailedOperation("音声ストリームのサンプリング周波数が小さ過ぎます。" + hz);
                }

                if (Consts.AUDIO_HZ_MAX < hz)
                {
                    throw new FailedOperation("音声ストリームのサンプリング周波数が大き過ぎます。" + hz);
                }
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: stackprobe/Kirara2
        private static void main2(string[] args)
        {
            if (args.Length == 0)
            {
                throw new Exception("no args");
            }

            try
            {
                Gnd.i.logger.writeLine("開始");

                Gnd.i.loadConf();

                {
                    ArgsReader ar = new ArgsReader();

                    Gnd.i.keepDiskFree_MB  = IntTools.toInt(ar.nextArg(), 1);
                    Gnd.i.rFileSizeMax_MB  = IntTools.toInt(ar.nextArg(), 1);
                    Gnd.i.ffmpegBinDir     = FileTools.toFullPath(ar.nextArg());
                    Gnd.i.wavMasterBinDir  = FileTools.toFullPath(ar.nextArg());
                    Gnd.i.rFile            = FileTools.toFullPath(ar.nextArg());
                    Gnd.i.convWavMastering = StringTools.toFlag(ar.nextArg());
                    Gnd.i.wFileNoExt       = FileTools.toFullPath(ar.nextArg());
                    Gnd.i.wFileConvReturn  = FileTools.toFullPath(ar.nextArg());
                }

                Gnd.i.logger.writeLine("keepDiskFree_MB: " + Gnd.i.keepDiskFree_MB);
                Gnd.i.logger.writeLine("rFileSizeMax_MB: " + Gnd.i.rFileSizeMax_MB);
                Gnd.i.logger.writeLine("ffmpegBinDir: " + Gnd.i.ffmpegBinDir);
                Gnd.i.logger.writeLine("wavMasterBinDir: " + Gnd.i.wavMasterBinDir);
                Gnd.i.logger.writeLine("rFile: " + Gnd.i.rFile);
                Gnd.i.logger.writeLine("convWavMastering: " + Gnd.i.convWavMastering);
                Gnd.i.logger.writeLine("wFileNoExt: " + Gnd.i.wFileNoExt);
                Gnd.i.logger.writeLine("wFileConvReturn: " + Gnd.i.wFileConvReturn);

                try
                {
                    Gnd.i.logger.writeLine("コンバート開始");

                    new Conv().perform();

                    Gnd.i.logger.writeLine("コンバート正常終了");

                    Gnd.i.convReturn.successful = true;
                }
                catch (Exception ex)
                {
                    Gnd.i.logger.writeLine("コンバート異常終了:" + ex);

                    Gnd.i.convReturn.errorMessage = ex.Message;
                }

                File.WriteAllLines(Gnd.i.wFileConvReturn, FieldsSerializer.serialize(Gnd.i.convReturn), Encoding.UTF8);

                Gnd.i.logger.writeLine("正常終了");
            }
            catch (Exception e)
            {
                Gnd.i.logger.writeLine("異常終了:" + e);
            }

            // release Gnd.i
            {
                Gnd.i.evCancel.Dispose();
                Gnd.i.evCancel = null;
            }

            FileTools.clearTMP();
        }
コード例 #19
0
ファイル: MkAndPrintWin.cs プロジェクト: stackprobe/SudokuGen
        private void mainTimer_Tick(object sender, EventArgs e)
        {
            if (this.mtEnabled == false || this.mtBusy)
            {
                return;
            }

            this.mtBusy = true;

            try
            {
                if (
                    this._historyData == null &&
                    Gnd.i.mkSudokuProc != null &&
                    Gnd.i.mkSudokuProc.isEnded()
                    )
                {
                    this._historyData = Gnd.i.mkSudokuProc.getResult();
                    this.historyDataCreated();
                }

                if (
                    this._historyData == null &&
                    Gnd.i.mkSudokuProc != null &&
                    Gnd.i.mkSudokuProc.isEnded() == false
                    )
                {
                    double progressRate;

                    lock (Gnd.i.n2Listener.SYNCROOT)
                    {
                        progressRate = Gnd.i.n2Listener.progressRate;
                    }

                    // なんちゃってプログレスバー効果
                    {
                        const long   MC_MAX      = 3000L;                  // 5 min
                        const double MC_MAX_RATE = 0.3;                    // 30 pct

                        long   mc   = Math.Min(mtCount, MC_MAX);
                        double rate = (mc * MC_MAX_RATE) / MC_MAX;

                        progressRate = Math.Max(progressRate, rate);
                    }

                    progressRate  = DoubleTools.toRange(progressRate, 0.0, 1.0);
                    progressRate *= 0.9;
                    progressRate += 0.05;

                    int value = IntTools.toInt(progressRate * IntTools.IMAX);

                    if (pbMk.Value != value)
                    {
                        pbMk.Value = value;
                    }
                }
            }
            finally
            {
                this.mtBusy = false;
                this.mtCount++;
            }
        }
コード例 #20
0
ファイル: SettingDlg.cs プロジェクト: stackprobe/UnrealRemoco
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    if (IntTools.isRange(int.Parse(this.txtPortNo.Text), 1, 65535) == false)
                    {
                        throw null;
                    }
                }
                catch
                {
                    throw new FailedOperation(
                              "ポート番号に問題があります。\n" +
                              "・指定できる値は 1 以上 65535 以下の整数です。"
                              );
                }

                switch (this.cmbCipherMode.SelectedIndex)
                {
                case (int)Consts.CipherMode_e.NOT_ENCRYPT:
                    break;

                case (int)Consts.CipherMode_e.ENCRYPT_BY_KEY:
                {
                    if (_key == null)
                    {
                        throw new FailedOperation("鍵が指定されていません。");
                    }
                }
                break;

                case (int)Consts.CipherMode_e.ENCRYPT_BY_PASSPHRASE:
                {
                    if (this.txtPassphrase.Text == "")
                    {
                        throw new FailedOperation("パスフレーズが指定されていません。");
                    }

                    if (this.txtPassphrase.Text != JString.toJString(this.txtPassphrase.Text, true, false, false, false))
                    {
                        throw new FailedOperation(
                                  "パスフレーズに問題があります。\n" +
                                  "・Shift_JISに変換できない文字は使用できません。\n" +
                                  "・空白は使用できません。"
                                  );
                    }
                }
                break;

                default:
                    throw null;
                }

                if (this.cmbCipherMode.SelectedIndex != (int)Consts.CipherMode_e.NOT_ENCRYPT)
                {
                    try
                    {
                        if (IntTools.isRange(int.Parse(this.txtForwardPortNo.Text), 1, 65535) == false)
                        {
                            throw null;
                        }
                    }
                    catch
                    {
                        throw new FailedOperation(
                                  "中継用ポート番号に問題があります。\n" +
                                  "・指定できる値は 1 以上 65535 以下の整数です。"
                                  );
                    }
                }

                // <-- check

                // save
                {
                    Ground.i.portNo     = int.Parse(this.txtPortNo.Text);
                    Ground.i.key        = null;
                    Ground.i.passphrase = "";

                    switch (this.cmbCipherMode.SelectedIndex)
                    {
                    case (int)Consts.CipherMode_e.NOT_ENCRYPT:
                        break;

                    case (int)Consts.CipherMode_e.ENCRYPT_BY_KEY:
                        Ground.i.key = _key;
                        break;

                    case (int)Consts.CipherMode_e.ENCRYPT_BY_PASSPHRASE:
                        Ground.i.passphrase = this.txtPassphrase.Text;
                        break;

                    default:
                        throw null;
                    }

                    Ground.i.forwardPortNo = IntTools.toInt(this.txtForwardPortNo.Text, 1, 65535, 55901);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                FailedOperation.caught(ex);
            }
        }
コード例 #21
0
        private Bitmap Make字幕(string line)
        {
            Bmp.Dot dotBack = new Bmp.Dot(0, 0, 0, 0);
            Bmp.Dot dotExte = new Bmp.Dot(255, 0, 0, 0);
            Bmp.Dot dotInte = new Bmp.Dot(255, 255, 255, 255);

            Bmp bmp;

            using (Bitmap b = new Bitmap(10000, 400))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.FillRectangle(Brushes.Black, 0f, 0f, (float)b.Width, (float)b.Height);
                    g.DrawString(line, new Font("メイリオ", 200f, FontStyle.Regular), Brushes.White, 50f, 50f);
                }
                bmp = Bmp.create(b);
            }

            bmp.select(dot => dot.r < 128 ? dotBack : dotInte);

            {
                Rect rect = bmp.getRect(dot => dot.IsSame(dotInte));

                Gnd.i.logger.writeLine("rect.l: " + rect.l);
                Gnd.i.logger.writeLine("rect.t: " + rect.t);
                Gnd.i.logger.writeLine("rect.r: " + rect.r);
                Gnd.i.logger.writeLine("rect.b: " + rect.b);

                bmp = bmp.getRectBmp(
                    IntTools.toInt(rect.l),
                    IntTools.toInt(rect.t),
                    IntTools.toInt(rect.w),
                    IntTools.toInt(rect.h)
                    );
            }

            Bmp bmpExte;

            bmpExte = bmp.copy();
            bmpExte.select(dot => dot.IsSame(dotInte) ? dotExte : dotBack);

            using (Bitmap b = new Bitmap(bmp.table.w + 60, bmp.table.h + 60))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.Clear(Color.Transparent);

                    {
                        Bitmap be = bmpExte.getBitmap();

                        for (int c = 0; c < 40; c++)
                        {
                            g.DrawImage(be, 10 + c, 10);
                            g.DrawImage(be, 10 + c, 49);
                            g.DrawImage(be, 10, 10 + c);
                            g.DrawImage(be, 49, 10 + c);
                        }
                    }

                    g.DrawImage(bmp.getBitmap(), 30, 30);
                }
                bmp = Bmp.create(b);
            }

            {
                Rect rect = bmp.getRect(dot => dot.IsSame(dotBack) == false);

                bmp = bmp.getRectBmp(
                    IntTools.toInt(rect.l),
                    IntTools.toInt(rect.t),
                    IntTools.toInt(rect.w),
                    IntTools.toInt(rect.h)
                    );
            }

            bmp = bmp.addMargin(10, 10, 10, 10, dotBack);
            bmp = bmp.expand(
                IntTools.toInt(bmp.table.w / 3.0),
                IntTools.toInt(bmp.table.h / 3.0)
                );

            {
                Rect rect = bmp.getRect(dot => dot.IsSame(dotBack) == false);

                bmp = bmp.getRectBmp(
                    IntTools.toInt(rect.l),
                    IntTools.toInt(rect.t),
                    IntTools.toInt(rect.w),
                    IntTools.toInt(rect.h)
                    );
            }

            {
                int w;
                int h;

                h = IntTools.toInt(Img_H * 0.08);
                w = IntTools.toInt(h * bmp.table.w * 1.0 / bmp.table.h);

                w = Math.Min(w, Img_W);

                bmp = bmp.expand(w, h);
            }

            return(bmp.getBitmap());
        }
コード例 #22
0
ファイル: Client.cs プロジェクト: stackprobe/Kirara2
        private void recvedEvent(string line)
        {
            if (line == "X")
            {
                xRecved = true;
                return;
            }

            // ---- 最大化 ----

            if (line == "M")
            {
                int  playingIndex = getPlayingIndex();
                bool moviePlaying = false;

                if (playingIndex != -1)
                {
                    MediaInfo mi = PlayListWin.self.plSheetGetRow(playingIndex);

                    if (mi.type == Consts.MediaType_e.MOVIE)
                    {
                        moviePlaying    = true;
                        _maximizeSerial = mi.serial;
                    }
                }
                if (moviePlaying)
                {
                    _n2w.sendLine("C");
                    _n2w.sendLine("D");
                }
                _n2w.sendLine("R");
                _n2w.sendLine("EM-2");

                if (moviePlaying)
                {
                    _n2w.sendLine("EM-3");
                }
                else
                {
                    _n2w.sendLine("EM-3.2");
                }

                return;
            }
            if (line.StartsWith("Curr="))
            {
                _seekRate = (double)int.Parse(line.Substring(5)) / IntTools.IMAX;
                return;
            }
            if (line.StartsWith("Rect="))
            {
                List <string> tokens = StringTools.tokenize(line.Substring(5), ",");
                int           c      = 0;

                Gnd.i.screen_l = int.Parse(tokens[c++]);
                Gnd.i.screen_t = int.Parse(tokens[c++]);
                Gnd.i.screen_w = int.Parse(tokens[c++]);
                Gnd.i.screen_h = int.Parse(tokens[c++]);

                // adjust
                {
                    Gnd.i.screen_w = Math.Max(Gnd.i.screen_w, Consts.SCREEN_W_MIN);
                    Gnd.i.screen_h = Math.Max(Gnd.i.screen_h, Consts.SCREEN_H_MIN);
                }
                return;
            }
            if (line == "M-2")
            {
                for (int index = 0; index < Gnd.i.monitors.getCount(); index++)
                {
                    Monitors.Monitor m = Gnd.i.monitors.get(index);

                    if (
                        Gnd.i.screen_l == m.l &&
                        Gnd.i.screen_t == m.t &&
                        Gnd.i.screen_w == m.w &&
                        Gnd.i.screen_h == m.h
                        )
                    {
                        int l = Gnd.i.normScreen_l;
                        int t = Gnd.i.normScreen_t;
                        int w = Gnd.i.normScreen_w;
                        int h = Gnd.i.normScreen_h;

                        // old

                        /*
                         * w = Math.Min(w, Gnd.i.screen_w - 1);
                         * h = Math.Min(h, Gnd.i.screen_h - 1);
                         *
                         * int l = m.l + (m.w - w) / 2;
                         * int t = m.t + (m.h - h) / 2;
                         *
                         * t = Math.Max(m.t + 30, t); // ウィンドウがデカすぎても上部バーが見えるように。
                         */

                        _n2w.sendLine("L" + l);
                        _n2w.sendLine("Y" + t);
                        _n2w.sendLine("W" + w);
                        _n2w.sendLine("H" + h);
                        _n2w.sendLine("M");
                        _n2w.sendLine("r1");

                        // 2回目 -- r1によって位置が正しく設定されないことがあるため。
                        {
                            _n2w.sendLine("L" + l);
                            _n2w.sendLine("Y" + t);
                            _n2w.sendLine("W" + w);
                            _n2w.sendLine("H" + h);
                            _n2w.sendLine("M");
                        }
                        return;
                    }
                }
                Monitors.Monitor currMon = null;

                for (int index = 0; index < Gnd.i.monitors.getCount(); index++)
                {
                    Monitors.Monitor m = Gnd.i.monitors.get(index);

                    if (
                        Gnd.i.screen_l < m.r &&
                        Gnd.i.screen_t < m.b &&
                        m.l < Gnd.i.screen_r &&
                        m.t < Gnd.i.screen_b
                        )
                    {
                        currMon = m;
                        break;
                    }
                }
                if (currMon == null)
                {
                    currMon = Gnd.i.monitors.get(0);
                }

                if (Gnd.i.screen_w != -1)                 // 2bs? -- 未設定ってことは無いと思うけど..
                {
                    Gnd.i.normScreen_l = Gnd.i.screen_l;
                    Gnd.i.normScreen_t = Gnd.i.screen_t;
                    Gnd.i.normScreen_w = Gnd.i.screen_w;
                    Gnd.i.normScreen_h = Gnd.i.screen_h;
                }
                _n2w.sendLine("r0");
                _n2w.sendLine("L" + currMon.l);
                _n2w.sendLine("Y" + currMon.t);
                _n2w.sendLine("W" + currMon.w);
                _n2w.sendLine("H" + currMon.h);
                _n2w.sendLine("M");
                return;
            }
            if (line == "M-3")
            {
                int miIndex = getIndexBySerial(_maximizeSerial);
                _maximizeSerial = -1;

                if (miIndex == -1)
                {
                    return;                     // エラー
                }
                MediaInfo mi = PlayListWin.self.plSheetGetRow(miIndex);

                if (mi.type != Consts.MediaType_e.MOVIE)
                {
                    return;                     // エラー
                }
                int startTime = IntTools.toInt(_seekRate * mi.time);
                startTime = IntTools.toRange(startTime, 0, mi.time - 2000);                 // 2秒の余裕 <- 動画の長さより長いと不安定になる。

                _n2w.sendLine("I" + mi.serial);
                _n2w.sendLine("W" + mi.w);
                _n2w.sendLine("H" + mi.h);
                _n2w.sendLine("T" + startTime);
                _n2w.sendLine("t" + mi.time);
                _n2w.sendLine("P");
                return;
            }
            if (line == "M-3.2")
            {
                _n2w.sendLine("+");
                return;
            }

            // ---- 連続再生 ----

            if (line == "B" || line == "R")
            {
                int playingIndex = getPlayingIndex();

                if (playingIndex != -1)
                {
                    MediaInfo mi = PlayListWin.self.plSheetGetRow(playingIndex);

                    if (mi.type == Consts.MediaType_e.AUDIO ? line == "B" : line == "R")
                    {
                        if (Gnd.i.ignoreBRTimeSec < DateTimeToSec.Now.getSec())
                        {
                            Gnd.i.ignoreBRTimeSec = DateTimeToSec.Now.getSec() + 20L;                             // マージン適当, 20秒以上もBR受信し続けたら、もう事故だろう..
                            _n2w.sendLine("E-IgnBR");

                            doPlayNext(playingIndex);
                        }
                    }
                }
                return;
            }
            if (line == "-IgnBR")
            {
                Gnd.i.ignoreBRTimeSec = -1L;
                return;
            }

            // ---- 再生ボタン ----

            if (line == "S" || line == "S!" || line == "S/")
            {
                int playingIndex = getPlayingIndex();

                if (line == "S/")                 // 強制的に停止する。
                {
                    if (playingIndex == -1)
                    {
                        // 2bs -- 停止
                        {
                            _n2w.sendLine("F");
                            _n2w.sendLine("+");
                        }
                        return;
                    }
                }
                if (line == "S!")                 // 強制的に再生する。
                {
                    playingIndex = -1;
                }

                if (playingIndex != -1)                 // ? 再生中 -> 停止
                {
                    {
                        MediaInfo mi = PlayListWin.self.plSheetGetRow(playingIndex);
                        mi.status = Consts.MediaStatus_e.READY;
                        PlayListWin.self.plSheetSetRow(playingIndex, mi);
                    }

                    _n2w.sendLine("F");
                    _n2w.sendLine("+");
                }
                else                 // ? 停止中 -> 再生
                {
                    int index = getIndexBySerial(Gnd.i.lastPlayedSerial);

                    if (index == -1)
                    {
                        for (index = 0; index < PlayListWin.self.getPlSheet().RowCount; index++)
                        {
                            MediaInfo mi = PlayListWin.self.plSheetGetRow(index);

                            if (mi.status == Consts.MediaStatus_e.READY)
                            {
                                break;
                            }
                        }
                    }
                    doPlay(index);
                }
                return;
            }

            // ---- シークバー操作 ----

            if (line.StartsWith("Seek="))
            {
                int playingIndex = getPlayingIndex();

                if (playingIndex != -1)
                {
                    MediaInfo mi = PlayListWin.self.plSheetGetRow(playingIndex);

                    if (mi.type == Consts.MediaType_e.MOVIE)
                    {
                        double rate      = (double)int.Parse(line.Substring(5)) / IntTools.IMAX;
                        int    startTime = IntTools.toInt(rate * mi.time);

                        _n2w.sendLine("I" + mi.serial);
                        _n2w.sendLine("W" + mi.w);
                        _n2w.sendLine("H" + mi.h);
                        _n2w.sendLine("T" + startTime);
                        _n2w.sendLine("t" + mi.time);
                        _n2w.sendLine("P");
                    }
                }
                return;
            }

            // ---- 情報レスポンス ----

            if (line.StartsWith("Volume="))
            {
                Gnd.i.volume = int.Parse(line.Substring(7));
                return;
            }

            // スクリーンのサイズ Rect= は上の方で、、

            // ----

            if (line.StartsWith("!"))             // エラーの通知
            {
                Gnd.i.logger.writeLine("SCREEN_ERROR: " + line.Substring(1));
                return;
            }
            if (line == "Booting")
            {
                _n2w.sendLine("i" + (Gnd.i.instantMessagesDisabled ? 1 : 0));

                if (Gnd.i.monitors.contains(Gnd.i.screen_l, Gnd.i.screen_t, Gnd.i.screen_w, Gnd.i.screen_h))
                {
                    _n2w.sendLine("r0");
                }

                _n2w.sendLine("L" + Gnd.i.screen_l);
                _n2w.sendLine("Y" + Gnd.i.screen_t);
                _n2w.sendLine("W" + Gnd.i.screen_w);
                _n2w.sendLine("H" + Gnd.i.screen_h);
                _n2w.sendLine("M");

                _n2w.sendLine("v" + Gnd.i.volume);

                refreshDoubleMovie();

                _n2w.sendLine("+");                 // 壁紙表示
                return;
            }
            if (line == "Resized")
            {
                int  playingIndex = getPlayingIndex();
                bool moviePlaying = false;

                if (playingIndex != -1)
                {
                    MediaInfo mi = PlayListWin.self.plSheetGetRow(playingIndex);

                    if (mi.type == Consts.MediaType_e.MOVIE)
                    {
                        moviePlaying    = true;
                        _maximizeSerial = mi.serial;
                    }
                }
                if (moviePlaying)
                {
                    _n2w.sendLine("C");
                    _n2w.sendLine("D");
                }

                // resize screen
                {
                    _n2w.sendLine("L" + Gnd.i.screen_l);
                    _n2w.sendLine("Y" + Gnd.i.screen_t);
                    _n2w.sendLine("W" + Gnd.i.screen_w);
                    _n2w.sendLine("H" + Gnd.i.screen_h);
                    _n2w.sendLine("M");
                }

                if (moviePlaying)
                {
                    _n2w.sendLine("EM-3");
                }
                else
                {
                    _n2w.sendLine("EM-3.2");
                }

                return;
            }
            if (line == "XP")             // 終了
            {
                _n2w.sendLine("V");
                _n2w.sendLine("R");
                _n2w.sendLine("EX");
                return;
            }
        }