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)); } }
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(); }
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 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; } } }
public void btnRight_MouseDown(Object sender, MouseEventArgs e) { mOverviewBtnDowned = PortUtil.getCurrentTime(); mOverviewStartToDrawClockInitialValue = mOverviewStartToDrawClock; if (mOverviewUpdateThread != null) { try { while (mOverviewUpdateThread.IsAlive) { System.Windows.Forms.Application.DoEvents(); } } catch (Exception ex) { serr.println("FormMain#btnRight_MouseDown; ex=" + ex); Logger.write(typeof(FormMain) + ".btnRight_MouseDown; ex=" + ex + "\n"); } mOverviewUpdateThread = null; } mOverviewDirection = 1; mOverviewUpdateThread = new Thread(new ThreadStart(this.updateOverview)); mOverviewUpdateThread.Start(); }
/// <summary> /// このWAVE描画コンテキストが保持しているWAVEデータを、ゲートタイム基準でグラフィクスに描画します。 /// </summary> /// <param name="g">描画に使用するグラフィクスオブジェクト</param> /// <param name="pen">描画に使用するペン</param> /// <param name="rect">描画範囲</param> /// <param name="clock_start">描画開始位置のゲートタイム</param> /// <param name="clock_end">描画終了位置のゲートタイム</param> /// <param name="tempo_table">ゲートタイムから秒数を調べる際使用するテンポ・テーブル</param> /// <param name="pixel_per_clock">ゲートタイムあたりの秒数</param> /// <param name="scale_y">Y軸方向の描画スケール。デフォルトは1.0</param> /// <param name="auto_maximize">自動で最大化するかどうか</param> private void drawCore( Graphics2D g, Color pen, Rectangle rect, int clock_start, int clock_end, TempoVector tempo_table, float pixel_per_clock, float scale_y, bool auto_maximize) { if (mWave.Length == 0) { return; } #if DEBUG double startedTime = PortUtil.getCurrentTime(); #endif mDrawer.setGraphics(g); mDrawer.clear(); double secStart = tempo_table.getSecFromClock(clock_start); double secEnd = tempo_table.getSecFromClock(clock_end); int sStart0 = (int)(secStart * mSampleRate) - 1; int sEnd0 = (int)(secEnd * mSampleRate) + 1; int count = tempo_table.Count; int sStart = 0; double cStart = 0.0; float order_y = 1.0f; if (auto_maximize) { order_y = rect.height / 2.0f / 127.0f * mMaxAmplitude / mActualMaxAmplitude; } else { order_y = rect.height / 127.0f * scale_y * mMaxAmplitude; } int ox = rect.x; int oy = rect.height / 2; int last = mWave[0]; int lastx = ox; int lastYMax = oy - (int)(last * order_y); int lastYMin = lastYMax; int lasty = lastYMin; int lasty2 = lastYMin; bool skipped = false; mDrawer.append(ox, lasty); int xmax = rect.x + rect.width; int lastTempo = 500000; for (int i = 0; i <= count; i++) { double time = 0.0; int tempo = 500000; int cEnd = 0; if (i < count) { TempoTableEntry entry = tempo_table[i]; time = entry.Time; tempo = entry.Tempo; cEnd = entry.Clock; } else { time = tempo_table.getSecFromClock(clock_end); tempo = tempo_table[i - 1].Tempo; cEnd = clock_end; } int sEnd = (int)(time * mSampleRate); // sStartサンプルからsThisEndサンプルまでを描画する(必要なら!) if (sEnd < sStart0) { sStart = sEnd; cStart = cEnd; lastTempo = tempo; continue; } if (sEnd0 < sStart) { break; } // int xoffset = (int)(cStart * pixel_per_clock) - AppManager.mMainWindowController.getStartToDrawX() + AppManager.keyOffset; double sec_per_clock = lastTempo * 1e-6 / 480.0; lastTempo = tempo; double pixel_per_sample = 1.0 / mSampleRate / sec_per_clock * pixel_per_clock; int j0 = sStart; if (j0 < 0) { j0 = 0; } int j1 = sEnd; if (mWave.Length < j1) { j1 = mWave.Length; } // 第j0サンプルのデータを画面に描画したときのx座標がいくらになるか? int draftStartX = xoffset + (int)((j0 - sStart) * pixel_per_sample); if (draftStartX < rect.x) { j0 = (int)((rect.x - xoffset) / pixel_per_sample) + sStart; } // 第j1サンプルのデータを画面に描画した時のx座標がいくらになるか? int draftEndX = xoffset + (int)((j1 - sStart) * pixel_per_sample); if (rect.x + rect.width < draftEndX) { j1 = (int)((rect.x + rect.width - xoffset) / pixel_per_sample) + sStart; } bool breakRequired = false; for (int j = j0; j < j1; j++) { int v = mWave[j]; if (v == last) { skipped = true; continue; } int x = xoffset + (int)((j - sStart) * pixel_per_sample); if (xmax < x) { breakRequired = true; break; } if (x < rect.x) { continue; } int y = oy - (int)(v * order_y); if (lastx == x) { lastYMax = Math.Max(lastYMax, y); lastYMin = Math.Min(lastYMin, y); continue; } if (skipped) { mDrawer.append(x - 1, lasty); lastx = x - 1; } if (lastYMax == lastYMin) { mDrawer.append(x, y); } else { if (lasty2 != lastYMin) { mDrawer.append(lastx, lastYMin); } mDrawer.append(lastx, lastYMax); if (lastYMax != lasty) { mDrawer.append(lastx, lasty); } mDrawer.append(x, y); } lasty2 = lasty; lastx = x; lastYMin = y; lastYMax = y; lasty = y; last = v; skipped = false; } sStart = sEnd; cStart = cEnd; if (breakRequired) { break; } } mDrawer.append(rect.x + rect.width, lasty); mDrawer.flush(); }
public void timer_Tick(Object sender, EventArgs e) { try { double now = PortUtil.getCurrentTime(); double dt_ms = (now - m_last_event_processed) * 1000.0; //JoystickState state = m_game_ctrl.CurrentJoystickState; int len = winmmhelp.JoyGetNumButtons(0); byte[] buttons = new byte[len]; int pov0; winmmhelp.JoyGetStatus(0, out buttons, out pov0); //int[] pov = state.GetPointOfView(); //int pov0 = pov[0]; bool btn_x = (buttons[AppManager.editorConfig.GameControlerCross] > 0x00); bool btn_o = (buttons[AppManager.editorConfig.GameControlerCircle] > 0x00); bool btn_tr = (buttons[AppManager.editorConfig.GameControlerTriangle] > 0x00); bool btn_re = (buttons[AppManager.editorConfig.GameControlerRectangle] > 0x00); bool pov_r = pov0 == 9000; //(4500 <= pov0 && pov0 <= 13500); bool pov_l = pov0 == 27000; //(22500 <= pov[0] && pov[0] <= 31500); bool pov_u = pov0 == 0; //(31500 <= pov[0] || (0 <= pov[0] && pov[0] <= 4500)); bool pov_d = pov0 == 18000; //(13500 <= pov[0] && pov[0] <= 22500); bool L1 = (buttons[AppManager.editorConfig.GameControlL1] > 0x00); bool R1 = (buttons[AppManager.editorConfig.GameControlR1] > 0x00); bool L2 = (buttons[AppManager.editorConfig.GameControlL2] > 0x00); bool R2 = (buttons[AppManager.editorConfig.GameControlR2] > 0x00); bool SELECT = (buttons[AppManager.editorConfig.GameControlSelect] > 0x00); if (dt_ms > AppManager.editorConfig.GameControlerMinimumEventInterval) { if (btnStart.Focused) { if (btn_o) { timer.Stop(); btnStart_Click(this, new EventArgs()); m_last_event_processed = now; } else if (pov_r) { btnCancel.Focus(); m_last_event_processed = now; } else if (pov_d) { numSpeed.Focus(); m_last_event_processed = now; } } else if (btnCancel.Focused) { if (btn_o) { timer.Stop(); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; Close(); } else if (pov_l) { btnStart.Focus(); m_last_event_processed = now; } else if (pov_d || pov_r) { numSpeed.Focus(); m_last_event_processed = now; } } else if (numSpeed.Focused) { if (R1) { if (numSpeed.Value + numSpeed.Increment <= numSpeed.Maximum) { numSpeed.Value = numSpeed.Value + numSpeed.Increment; m_last_event_processed = now; } } else if (L1) { if (numSpeed.Value - numSpeed.Increment >= numSpeed.Minimum) { numSpeed.Value = numSpeed.Value - numSpeed.Increment; m_last_event_processed = now; } } else if (pov_l) { btnCancel.Focus(); m_last_event_processed = now; } else if (pov_u) { btnStart.Focus(); m_last_event_processed = now; } } } } catch (Exception ex) { } }