public static int getNumOfProcessor() { int ret = 1; try { ret = int.Parse(Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS")); ret = IntTools.toRange(ret, 1, 128); // HACK } catch { } return(ret); }
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); }
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; } }
public void eachTimerTick() { try { for (; ;) { ObjectList ol = (ObjectList)_frtwv.recv(0); if (ol == null) { break; } byte[] recvData = (byte[])ol[0]; string recvLine = StringTools.ENCODING_SJIS.GetString(recvData); List <string> prms = StringTools.tokenize(recvLine, " "); int c = 0; string command = prms[c++]; // 受信コマンド処理 > if (command == "SENDER-IDLING") { _frtwv.send(Utils.toOL( "SEND-TO-CLIENT", Utils.getScreenImage(monitorIndex, quality), "" )); } else if (command == "MONITOR-INDEX") { monitorIndex = int.Parse(prms[c++]); monitorIndex = IntTools.toRange(monitorIndex, 0, IntTools.IMAX); monitorIndex %= Ground.i.monitorCenter.getCount(); MonitorCenter.Monitor monitor = Ground.i.monitorCenter.get(monitorIndex); _frtwv.send(Utils.toOL( "MOUSE_LTRB " + monitor.l + " " + monitor.t + " " + monitor.r + " " + monitor.b )); } else if (command == "QUALITY") { quality = int.Parse(prms[c++]); quality = IntTools.toRange(quality, 0, 101); } else if (command == "DISCONNECTED") { if (Ground.i.disconnectAndShiftKeysUp) { _frtwv.send(Utils.toOL("SHIFT-KEYS-UP")); } } else if (command == "SET-CLIP-BOARD-TEXT") { byte[] bText = StringTools.decodeBase64(prms[c++]); string text = JString.toJString(bText, true, true, true, true); Clipboard.SetText(text); } else if (command == "GET-CLIP-BOARD-TEXT") { string text = Clipboard.GetText(); if (string.IsNullOrEmpty(text)) { text = "(クリップボードにテキストはありません[S])"; } if (Consts.CLIPBOARD_TEXT_LEN_MAX < text.Length) { text = "(クリップボードのテキストは長すぎます[S])"; } _frtwv.send(Utils.toOL( "SEND-TO-CLIENT", "", text )); } else { Utils.WriteLog("不明なコマンド:" + command); } // < 受信コマンド処理 } } catch (Exception e) { Utils.WriteLog("Service each-timer error: " + e); GC.Collect(); } }