/// <summary> /// パレットツールを実行します /// </summary> /// <param name="id">実行するパレットツールのID</param> /// <param name="track">編集対象のトラック番号</param> /// <param name="vsq_event_intrenal_ids">編集対象のInternalIDのリスト</param> /// <param name="button">パレットツールが押し下げられた時のマウスボタンの種類</param> /// <returns>パレットツールによって編集が加えられた場合true。そうでなければfalse(パレットツールがエラーを起こした場合も含む)。</returns> public static boolean invokePaletteTool( String id, int track, int[] vsq_event_intrenal_ids, MouseButtons button ) { if ( loadedTools.containsKey( id ) ) { VsqFileEx vsq = AppManager.getVsqFile(); VsqTrack item = (VsqTrack)vsq.Track.get( track ).clone(); Object objPal = loadedTools.get( id ); if ( objPal == null ) { return false; } if ( !(objPal is IPaletteTool) ) { return false; } IPaletteTool pal = (IPaletteTool)objPal; boolean edited = false; try { edited = pal.edit( item, vsq_event_intrenal_ids, button ); } catch ( Exception ex ) { AppManager.showMessageBox( PortUtil.formatMessage( _( "Palette tool '{0}' reported an error.\nPlease copy the exception text and report it to developper." ), id ), "Error", cadencii.windows.forms.Utility.MSGBOX_DEFAULT_OPTION, cadencii.windows.forms.Utility.MSGBOX_ERROR_MESSAGE ); serr.println( typeof( PaletteToolServer ) + ".invokePaletteTool; ex=" + ex ); edited = false; } if ( edited ) { CadenciiCommand run = VsqFileEx.generateCommandTrackReplace( track, item, vsq.AttachedCurves.get( track - 1 ) ); AppManager.editHistory.register( vsq.executeCommand( run ) ); } return edited; } else { return false; } }
public override void paintTo(Graphics2D graphics, int x, int y, int width, int height) { // 現在の描画時のストローク、色を保存しておく Stroke old_stroke = graphics.getStroke(); Color old_color = graphics.getColor(); // 描画用のストロークが初期化してなかったら初期化 if (mStroke == null) { mStroke = new BasicStroke(); } // 枠と背景を描画 paintBackground(graphics, mStroke, x, y, width, height, Color.black, PortUtil.Pink); // デバイス名を書く PortUtil.drawStringEx( (Graphics)graphics, "Amplifier", AppManager.baseFont10, new Rectangle(x, y, width, height), PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); // 描画時のストローク、色を元に戻す graphics.setStroke(old_stroke); graphics.setColor(old_color); }
public void btnFlip_Click(Object sender, EventArgs e) { m_credit_mode = !m_credit_mode; if (m_credit_mode) { try { btnFlip.Text = PortUtil.formatMessage(_("About {0}"), m_app_name); } catch (Exception ex) { btnFlip.Text = "About " + m_app_name; } m_scroll_started = PortUtil.getCurrentTime(); m_last_speed = 0f; m_last_t = 0f; m_shift = 0f; pictVstLogo.Visible = false; lblVstLogo.Visible = false; chkTwitterID.Visible = true; timer.Start(); } else { timer.Stop(); btnFlip.Text = _("Credit"); pictVstLogo.Visible = true; lblVstLogo.Visible = true; chkTwitterID.Visible = false; } this.Refresh(); }
/// <summary> /// クリップボードに貼り付けられたアイテムを取得します. /// </summary> /// <returns>クリップボードに貼り付けられたアイテムを格納したClipboardEntryのインスタンス</returns> public ClipboardEntry getCopiedItems() { ClipboardEntry ce = null; #if CLIPBOARD_AS_TEXT String clip = PortUtil.getClipboardText(); if (clip != null && str.startsWith(clip, CLIP_PREFIX)) { int index1 = clip.IndexOf(":"); int index2 = clip.IndexOf(":", index1 + 1); String typename = str.sub(clip, index1 + 1, index2 - index1 - 1); #if DEBUG sout.println("ClipboardModel#getCopiedItems; typename=" + typename); #endif if (typename.Equals(typeof(ClipboardEntry).FullName)) { try { ce = (ClipboardEntry)getDeserializedObjectFromText(clip); } catch (Exception ex) { Logger.write(typeof(ClipboardModel) + ".getCopiedItems; ex=" + ex + "\n"); } } } #else IDataObject dobj = Clipboard.GetDataObject(); if (dobj != null) { Object obj = dobj.GetData(typeof(ClipboardEntry)); if (obj != null && obj is ClipboardEntry) { ce = (ClipboardEntry)obj; } } #endif if (ce == null) { ce = new ClipboardEntry(); } if (ce.beziers == null) { ce.beziers = new SortedDictionary <CurveType, List <BezierChain> >(); } if (ce.events == null) { ce.events = new List <VsqEvent>(); } if (ce.points == null) { ce.points = new SortedDictionary <CurveType, VsqBPList>(); } if (ce.tempo == null) { ce.tempo = new List <TempoTableEntry>(); } if (ce.timesig == null) { ce.timesig = new List <TimeSigTableEntry>(); } return(ce); }
public static void write(string s) { if (!is_enabled) { return; } if (log == null) { if (path == null || (path != null && path.Equals(""))) { path = PortUtil.createTempFile(); //path = "C:\\log.txt"; } try { log = new StreamWriter(path); log.AutoFlush = true; } catch (Exception ex) { serr.println("Logger#write; ex=" + ex); } } if (log == null) { return; } try { log.Write(s); } catch (Exception ex) { serr.println("Logger#write; ex=" + ex); } }
/// <summary> /// このユニットを指定した位置に描画します。 /// </summary> /// <param name="graphics">描画に使用するグラフィクス</param> /// <param name="x">描画する位置のx座標</param> /// <param name="y">描画する位置のy座標</param> /// <returns>描画された装置図に外接する四角形のサイズ</returns> public virtual void paintTo(Graphics2D graphics, int x, int y, int width, int height) { // 現在の描画時のストローク、色を保存しておく Stroke old_stroke = graphics.getStroke(); Color old_color = graphics.getColor(); // 描画用のストロークが初期化してなかったら初期化 if (mStroke == null) { mStroke = new BasicStroke(); } if (mFont == null) { mFont = new Font("Arial", Font.PLAIN, 10); } // 枠と背景を描画 paintBackground(graphics, mStroke, x, y, width, height, Color.black, PortUtil.Pink); // デバイス名を書く string typename = this.GetType().Name; PortUtil.drawStringEx( (Graphics)graphics, typename, mFont, new Rectangle(x, y, width, height), PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); // 描画時のストローク、色を元に戻す graphics.setStroke(old_stroke); graphics.setColor(old_color); }
public void removeEventRange(int[] ids) { List <int> v_ids = new List <int>(PortUtil.convertIntArray(ids)); List <int> index = new List <int>(); int count = mEvents.Count; for (int i = 0; i < count; i++) { if (v_ids.Contains(mEvents[i].original.InternalID)) { index.Add(i); if (index.Count == ids.Length) { break; } } } count = index.Count; for (int i = count - 1; i >= 0; i--) { mEvents.RemoveAt(i); } #if ENABLE_PROPERTY AppManager.propertyPanel.updateValue(AppManager.getSelected()); #endif checkSelectedItemExistence(); }
private void handleMouseDown(BezierPickedSide side) { this.ui.setOpacity(m_min_opacity); m_last_mouse_global_location = PortUtil.getMousePosition(); PointD pd = m_point.getPosition(side); Point loc_on_trackselector = new Point( AppManager.xCoordFromClocks((int)pd.getX()), m_parent.yCoordFromValue((int)pd.getY())); Point loc_topleft = m_parent.getLocationOnScreen(); mScreenMouseDownLocation = new Point( loc_topleft.x + loc_on_trackselector.x, loc_topleft.y + loc_on_trackselector.y); PortUtil.setMousePosition(mScreenMouseDownLocation); MouseEventArgs event_arg = new MouseEventArgs( MouseButtons.Left, 0, loc_on_trackselector.x, loc_on_trackselector.y, 0); m_parent.TrackSelector_MouseDown(this, event_arg); m_picked_side = side; m_btn_datapoint_downed = true; }
public void buttonsMouseMove() { if (m_btn_datapoint_downed) { Point loc_on_screen = PortUtil.getMousePosition(); if (loc_on_screen.x == mScreenMouseDownLocation.x && loc_on_screen.y == mScreenMouseDownLocation.y) { // マウスが動いていないようならbailout return; } Point loc_trackselector = m_parent.getLocationOnScreen(); Point loc_on_trackselector = new Point(loc_on_screen.x - loc_trackselector.x, loc_on_screen.y - loc_trackselector.y); MouseEventArgs event_arg = new MouseEventArgs(MouseButtons.Left, 0, loc_on_trackselector.x, loc_on_trackselector.y, 0); BezierPoint ret = m_parent.HandleMouseMoveForBezierMove(event_arg, m_picked_side); this.ui.setDataPointClockText(((int)ret.getBase().getX()) + ""); this.ui.setDataPointValueText(((int)ret.getBase().getY()) + ""); this.ui.setLeftClockText(((int)ret.getControlLeft().getX()) + ""); this.ui.setLeftValueText(((int)ret.getControlLeft().getY()) + ""); this.ui.setRightClockText(((int)ret.getControlRight().getX()) + ""); this.ui.setRightValueText(((int)ret.getControlRight().getY()) + ""); m_parent.doInvalidate(); } }
public void updateOverview() { bool д = true; #if DEBUG int count = 0; #endif for (; д;) { #if DEBUG count++; sout.println("FormMain#updateOverview; count=" + count); #endif Thread.Sleep(100); int key_width = AppManager.keyWidth; double dt = PortUtil.getCurrentTime() - mOverviewBtnDowned; int draft = (int)(mOverviewStartToDrawClockInitialValue + mOverviewDirection * dt * OVERVIEW_SCROLL_SPEED / mOverviewPixelPerClock); int clock = getOverviewClockFromXCoord(this.Width - key_width, draft); if (AppManager.getVsqFile().TotalClocks < clock) { draft = AppManager.getVsqFile().TotalClocks - (int)((this.Width - key_width) / mOverviewPixelPerClock); } if (draft < 0) { draft = 0; } mOverviewStartToDrawClock = draft; if (this == null || (this != null && this.IsDisposed)) { break; } this.Invoke(new EventHandler(invalidatePictOverview)); } }
/// <summary> /// 「メジャー.マイナー.メンテナンス」の記法に基づく文字列をパースし,新しいインスタンスを作成します /// </summary> /// <param name="str"></param> public VersionString(string s) { mRawString = s; string[] spl = PortUtil.splitString(s, '.'); if (spl.Length >= 1) { try { major = int.Parse(spl[0]); } catch (Exception ex) { } } if (spl.Length >= 2) { try { minor = int.Parse(spl[1]); } catch (Exception ex) { } } if (spl.Length >= 3) { try { build = int.Parse(spl[2]); } catch (Exception ex) { } } }
/*public static UtauFreq FromWav( String file ) { * throw new NotImplementedException(); * return null; * }*/ /// <summary> /// *.frqファイルからのコンストラクタ /// </summary> /// <param name="file"></param> public static UtauFreq FromFrq(string file) { UtauFreq ret = new UtauFreq(); FileStream fs = null; try { fs = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] buf0 = new byte[8]; fs.Read(buf0, 0, 8); char[] ch8 = new char[8]; for (int i = 0; i < 8; i++) { ch8[i] = (char)buf0[i]; } ret.Header = new string(ch8); fs.Read(buf0, 0, 4); ret.SampleInterval = PortUtil.make_int32_le(buf0); fs.Read(buf0, 0, 8); ret.AverageFrequency = PortUtil.make_double_le(buf0); for (int i = 0; i < 4; i++) { int len2 = fs.Read(buf0, 0, 4); int i1 = PortUtil.make_int32_le(buf0); } fs.Read(buf0, 0, 4); ret.NumPoints = PortUtil.make_int32_le(buf0); ret.Frequency = new double[ret.NumPoints]; ret.Volume = new double[ret.NumPoints]; byte[] buf = new byte[16]; int len = fs.Read(buf, 0, 16); int index = 0; while (len > 0) { double d1 = PortUtil.make_double_le(buf); for (int i = 0; i < 4; i++) { buf[i] = buf[i + 4]; } double d2 = PortUtil.make_double_le(buf); ret.Frequency[index] = d1; ret.Volume[index] = d2; len = fs.Read(buf, 0, 16); index++; } } catch (Exception ex) { } finally { if (fs != null) { try { fs.Close(); } catch (Exception ex2) { } } } return(ret); }
/// <summary> /// スクリプトを読み込み、コンパイルします。 /// </summary> public static void reload() { // 拡張子がcs, txtのファイルを列挙 String dir = Utility.getScriptPath(); Vector <String> files = new Vector <String>(); files.addAll(Arrays.asList(PortUtil.listFiles(dir, ".txt"))); files.addAll(Arrays.asList(PortUtil.listFiles(dir, ".cs"))); // 既存のスクリプトに無いまたは新しいやつはロード。 Vector <String> added = new Vector <String>(); //追加または更新が行われたスクリプトのID foreach (String file in files) { String id = PortUtil.getFileName(file); double time = PortUtil.getFileLastModified(file); added.add(id); boolean loadthis = true; if (scripts.containsKey(id)) { double otime = scripts.get(id).fileTimestamp; if (time <= otime) { // 前回コンパイルした時点でのスクリプトファイルよりも更新日が同じか古い。 loadthis = false; } } // ロードする処理 if (!loadthis) { continue; } ScriptInvoker si = (new PluginLoader()).loadScript(file); scripts.put(id, si); } // 削除されたスクリプトがあれば登録を解除する boolean changed = true; while (changed) { changed = false; for (Iterator <String> itr = scripts.keySet().iterator(); itr.hasNext();) { String id = itr.next(); if (!added.contains(id)) { scripts.remove(id); changed = true; break; } } } }
/// <summary> /// このスプラッシュウィンドウに,MouseDownイベントを通知します /// </summary> /// <param name="screen_x"></param> /// <param name="screen_y"></param> public void handleMouseDown(Object sender, MouseEventArgs arg) { mouseDowned = true; Point screen = PortUtil.getMousePosition(); var point = this.PointToClient(new System.Drawing.Point(screen.x, screen.y)); Point p = new Point(point.X, point.Y); mouseDownedLocation = p; }
/// <summary> /// スクリプトを読み込み、コンパイルします。 /// </summary> public static void reload() { // 拡張子がcs, txtのファイルを列挙 string dir = Utility.getScriptPath(); List <string> files = new List <string>(); files.AddRange(new List <string>(PortUtil.listFiles(dir, ".txt"))); files.AddRange(new List <string>(PortUtil.listFiles(dir, ".cs"))); // 既存のスクリプトに無いまたは新しいやつはロード。 List <string> added = new List <string>(); //追加または更新が行われたスクリプトのID foreach (string file in files) { string id = PortUtil.getFileName(file); double time = PortUtil.getFileLastModified(file); added.Add(id); bool loadthis = true; if (scripts.ContainsKey(id)) { double otime = scripts[id].fileTimestamp; if (time <= otime) { // 前回コンパイルした時点でのスクリプトファイルよりも更新日が同じか古い。 loadthis = false; } } // ロードする処理 if (!loadthis) { continue; } ScriptInvoker si = (new PluginLoader()).loadScript(file); scripts[id] = si; } // 削除されたスクリプトがあれば登録を解除する bool changed = true; while (changed) { changed = false; foreach (var id in scripts.Keys) { if (!added.Contains(id)) { scripts.Remove(id); changed = true; break; } } } }
/// <summary> /// スクリプトのファイル名から、そのスクリプトの設定ファイルの名前を決定します。 /// </summary> /// <param name="script_file"></param> /// <returns></returns> public static String configFileNameFromScriptFileName(String script_file) { String dir = Path.Combine(Utility.getApplicationDataPath(), "script"); if (!Directory.Exists(dir)) { PortUtil.createDirectory(dir); } return(Path.Combine(dir, PortUtil.getFileNameWithoutExtension(script_file) + ".config")); }
/// <summary> /// このスプラッシュウィンドウに,MouseMoveイベントを通知します /// </summary> public void handleMouseMove(Object sender, MouseEventArgs arg) { if (!mouseDowned) { return; } Point screen = PortUtil.getMousePosition(); var p = new System.Drawing.Point(screen.x - mouseDownedLocation.x, screen.y - mouseDownedLocation.y); this.Location = p; }
private void paintCor(Graphics g1) { Graphics2D g = (Graphics2D)g1; g.clipRect(0, 0, this.Width, m_height); g.setColor(Color.white); g.fillRect(0, 0, this.Width, this.Height); //g.clearRect( 0, 0, getWidth(), getHeight() ); if (m_credit_mode) { float times = (float)(PortUtil.getCurrentTime() - m_scroll_started) - 3f; float speed = (float)((2.0 - math.erfc(times * 0.8)) / 2.0) * m_speed; float dt = times - m_last_t; m_shift += (speed + m_last_speed) * dt / 2f; m_last_t = times; m_last_speed = speed; Image image = m_show_twitter_id ? m_scroll_with_id : m_scroll; if (image != null) { float dx = (this.Width - image.getWidth(null)) * 0.5f; g.drawImage(image, (int)dx, (int)(90f - m_shift), null); if (90f - m_shift + image.getHeight(null) < 0) { m_shift = -m_height * 1.5f; } } int grad_height = 60; Rectangle top = new Rectangle(0, 0, this.Width, grad_height); Rectangle bottom = new Rectangle(0, m_height - grad_height, this.Width, grad_height); g.clipRect(0, m_height - grad_height + 1, this.Width, grad_height - 1); g.setClip(null); } else { g.setFont(new Font("Century Gorhic", java.awt.Font.BOLD, FONT_SIZE * 2)); g.setColor(m_app_name_color); g.drawString(m_app_name, 20, 60); g.setFont(new Font("Arial", 0, FONT_SIZE)); string[] spl = PortUtil.splitString(m_version, '\n'); int y = 100; int delta = (int)(FONT_SIZE * 1.1); if (delta == FONT_SIZE) { delta++; } for (int i = 0; i < spl.Length; i++) { g.drawString((i == 0 ? "version" : "") + spl[i], 25, y); y += delta; } } }
public void bgWork_DoWork(Object sender, DoWorkEventArgs e) { #if DEBUG sout.println("FormGenerateKeySound#bgWork_DoWork"); #endif PrepareStartArgument arg = (PrepareStartArgument)e.Argument; string singer = arg.singer; double amp = arg.amplitude; string dir = arg.directory; bool replace = arg.replace; // 音源を準備 if (!Directory.Exists(dir)) { PortUtil.createDirectory(dir); } for (int i = 0; i < 127; i++) { string path = Path.Combine(dir, i + ".wav"); sout.println("writing \"" + path + "\" ..."); if (replace || (!replace && !File.Exists(path))) { try { GenerateSinglePhone(i, singer, path, amp); if (File.Exists(path)) { try { Wave wv = new Wave(path); wv.trimSilence(); wv.monoralize(); wv.write(path); } catch (Exception ex0) { serr.println("FormGenerateKeySound#bgWork_DoWork; ex0=" + ex0); Logger.write(typeof(FormGenerateKeySound) + ".bgWork_DoWork; ex=" + ex0 + "\n"); } } } catch (Exception ex) { Logger.write(typeof(FormGenerateKeySound) + ".bgWork_DoWork; ex=" + ex + "\n"); serr.println("FormGenerateKeySound#bgWork_DoWork; ex=" + ex); } } sout.println(" done"); if (m_cancel_required) { m_cancel_required = false; break; } bgWork.ReportProgress((int)(i / 127.0 * 100.0), null); } m_cancel_required = false; }
/// <summary> /// クリップボードにオブジェクトを貼り付けるためのユーティリティ. /// </summary> /// <param name="events"></param> /// <param name="tempo"></param> /// <param name="timesig"></param> /// <param name="curve"></param> /// <param name="bezier"></param> /// <param name="copy_started_clock"></param> private void setClipboard( List <VsqEvent> events, List <TempoTableEntry> tempo, List <TimeSigTableEntry> timesig, SortedDictionary <CurveType, VsqBPList> curve, SortedDictionary <CurveType, List <BezierChain> > bezier, int copy_started_clock) { ClipboardEntry ce = new ClipboardEntry(); ce.events = events; ce.tempo = tempo; ce.timesig = timesig; ce.points = curve; ce.beziers = bezier; ce.copyStartedClock = copy_started_clock; #if CLIPBOARD_AS_TEXT String clip = ""; try { clip = getSerializedText(ce); #if DEBUG sout.println("ClipboardModel#setClipboard; clip=" + clip); #endif } catch (Exception ex) { serr.println("ClipboardModel#setClipboard; ex=" + ex); Logger.write(typeof(ClipboardModel) + ".setClipboard; ex=" + ex + "\n"); return; } PortUtil.setClipboardText(clip); #else // CLIPBOARD_AS_TEXT #if DEBUG // ClipboardEntryがシリアライズ可能かどうかを試すため, // この部分のコードは残しておくこと System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = null; System.IO.MemoryStream ms = null; try { bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); ms = new System.IO.MemoryStream(); bf.Serialize(ms, ce); } catch (Exception ex) { sout.println("ClipboardModel#setClipboard; ex=" + ex); } #endif // DEBUG Clipboard.SetDataObject(ce, false); #endif // CLIPBOARD_AS_TEXT }
/// <summary> /// ダイアログによる設定結果を取得します /// </summary> /// <returns></returns> public List <VibratoHandle> getResult() { // iconIDを整える if (mHandles == null) { mHandles = new List <VibratoHandle>(); } int size = mHandles.Count; for (int i = 0; i < size; i++) { mHandles[i].IconID = "$0404" + PortUtil.toHexString(i + 1, 4); } return(mHandles); }
public static Image createIconImage(string path_image, string singer_name) { #if DEBUG sout.println("IconParader#createIconImage; path_image=" + path_image); #endif Image ret = null; if (System.IO.File.Exists(path_image)) { System.IO.FileStream fs = null; try { fs = new System.IO.FileStream(path_image, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.Drawing.Image img = System.Drawing.Image.FromStream(fs); ret = new Image(); ret.image = img; } catch (Exception ex) { serr.println("IconParader#createIconImage; ex=" + ex); } finally { if (fs != null) { try { fs.Close(); } catch (Exception ex2) { serr.println("IconParader#createIconImage; ex2=" + ex2); } } } } if (ret == null) { // 画像ファイルが無かったか,読み込みに失敗した場合 // 歌手名が描かれた画像をセットする Image bmp = new Image(); bmp.image = new System.Drawing.Bitmap(ICON_WIDTH, ICON_HEIGHT, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics2D g = new Graphics2D(System.Drawing.Graphics.FromImage(bmp.image)); g.clearRect(0, 0, ICON_WIDTH, ICON_HEIGHT); Font font = new Font(System.Windows.Forms.SystemInformation.MenuFont); PortUtil.drawStringEx( (Graphics)g, singer_name, font, new Rectangle(1, 1, ICON_WIDTH - 2, ICON_HEIGHT - 2), PortUtil.STRING_ALIGN_NEAR, PortUtil.STRING_ALIGN_NEAR); ret = bmp; } return(ret); }
public void buttonsMouseUp() { m_btn_datapoint_downed = false; this.ui.setOpacity(1.0); Point loc_on_screen = PortUtil.getMousePosition(); Point loc_trackselector = m_parent.getLocationOnScreen(); Point loc_on_trackselector = new Point(loc_on_screen.x - loc_trackselector.x, loc_on_screen.y - loc_trackselector.y); MouseEventArgs event_arg = new MouseEventArgs(MouseButtons.Left, 0, loc_on_trackselector.x, loc_on_trackselector.y, 0); m_parent.TrackSelector_MouseUp(this, event_arg); PortUtil.setMousePosition(m_last_mouse_global_location); m_parent.doInvalidate(); }
/// <summary> /// 指定した名前のバンドルの,Wineのインストールディレクトリを取得します /// </summary> private string getBuiltinWineTop(string bundle_name) { string appstart = PortUtil.getApplicationStartupPath(); // Wine.bundleの場所は../Wine.bundleまたは./Wine.bundleのどちらか // まず../Wine.bundleがあるかどうかチェック string parent = PortUtil.getDirectoryName(appstart); string ret = Path.Combine(parent, bundle_name); if (!Directory.Exists(ret)) { // ../Wine.bundleが無い場合 ret = Path.Combine(appstart, bundle_name); } ret = Path.Combine(ret, "Contents"); ret = Path.Combine(ret, "SharedSupport"); return(ret); }
public void receivePaintSignal(Graphics g) { int key_width = AppManager.keyWidth; int width = key_width - 1; int height = mUi.getHeight() - 1; // 背景を塗る g.setColor(PortUtil.DarkGray); g.fillRect(0, 0, width, height); // AutoMaximizeのチェックボックスを描く g.setColor(mWaveViewButtonAutoMaximizeMouseDowned ? PortUtil.Gray : PortUtil.LightGray); g.fillRect(SPACE, SPACE, 16, 16); g.setColor(PortUtil.Gray); g.drawRect(SPACE, SPACE, 16, 16); if (mWaveViewAutoMaximize) { g.setColor(PortUtil.Gray); g.fillRect(SPACE + 3, SPACE + 3, 11, 11); } g.setColor(Color.black); g.setFont(AppManager.baseFont8); g.drawString( "Auto Maximize", SPACE + 16 + SPACE, SPACE + AppManager.baseFont8Height / 2 - AppManager.baseFont8OffsetHeight + 1); // ズーム用ボタンを描く int zoom_button_y = SPACE + 16 + SPACE; int zoom_button_height = height - SPACE - zoom_button_y; Rectangle rc = getButtonBoundsWaveViewZoom(); if (!mWaveViewAutoMaximize) { g.setColor(mWaveViewButtonZoomMouseDowned ? PortUtil.Gray : PortUtil.LightGray); g.fillRect(rc.x, rc.y, rc.width, rc.height); } g.setColor(PortUtil.Gray); g.drawRect(rc.x, rc.y, rc.width, rc.height); g.setColor(mWaveViewAutoMaximize ? PortUtil.Gray : Color.black); rc.y = rc.y + 1; PortUtil.drawStringEx( g, (mWaveViewButtonZoomMouseDowned ? "↑Move Mouse↓" : "Zoom"), AppManager.baseFont9, rc, PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); }
/// <summary> /// 指定したIDが示すスクリプトの、表示上の名称を取得します。 /// </summary> /// <param name="id"></param> /// <returns></returns> public static String getDisplayName(String id) { if (scripts.containsKey(id)) { ScriptInvoker invoker = scripts.get(id); if (invoker.getDisplayNameDelegate != null) { String ret = ""; try { ret = invoker.getDisplayNameDelegate(); } catch (Exception ex) { serr.println("ScriptServer#getDisplayName; ex=" + ex); ret = PortUtil.getFileNameWithoutExtension(id); } return(ret); } } return(PortUtil.getFileNameWithoutExtension(id)); }
public void testXmlSerialization() { XmlSerializer xs = new XmlSerializer(typeof(WaveUnitConfig)); WaveUnitConfig item = new WaveUnitConfig(); item.putElement("a", "A"); string actualPath = PortUtil.createTempFile(); using (FileStream fs = new FileStream(actualPath, FileMode.Create, FileAccess.Write)){ xs.serialize(fs, item); } Console.WriteLine(File.ReadAllText(actualPath)); byte[] actual = File.ReadAllBytes(actualPath); byte[] expected = File.ReadAllBytes("./expected/WaveUnitConfig.xml"); Assert.AreEqual(expected, actual); File.Delete(actualPath); }
public void loadTest() { PluginLoader.cleanupUnusedAssemblyCache(); var files = from file in PortUtil.listFiles("./fixture/script", "") where file.EndsWith(".cs") | file.EndsWith(".txt") select file; foreach (var file in files) { var loader = new PluginLoader(); ScriptInvoker invoker = null; Assert.DoesNotThrow(() => { invoker = loader.loadScript(file); }); Assert.IsNotNull(invoker); Console.Error.WriteLine(file + "\n" + invoker.ErrorMessage); Assert.IsNotNull(invoker.scriptDelegate); } }
public void invalidateUi() { double now = PortUtil.getCurrentTime(); if (now - lastDrawn > 0.04) { if (childWnd != IntPtr.Zero) { bool ret = false; try { ret = win32.InvalidateRect(childWnd, IntPtr.Zero, false); } catch (Exception ex) { serr.println("FormPluginUi#invalidateUi; ex=" + ex); ret = false; } lastDrawn = now; } } }
/// <summary> /// 使用されていないアセンブリのキャッシュを削除します /// </summary> public static void cleanupUnusedAssemblyCache() { String dir = Utility.getCachedAssemblyPath(); String[] files = PortUtil.listFiles(dir, ".dll"); foreach (String file in files) { String name = PortUtil.getFileName(file); String full = Path.Combine(dir, name); if (!usedAssemblyChache.Contains(full)) { try { PortUtil.deleteFile(full); } catch (Exception ex) { serr.println("Utility#cleanupUnusedAssemblyCache; ex=" + ex); Logger.write(typeof(Utility) + ".cleanupUnusedAssemblyCache; ex=" + ex + "\n"); } } } }