public void pictureDepth_Paint(Object sender, PaintEventArgs e) { // 背景を描画 int width = pictureDepth.Width; int height = pictureDepth.Height; System.Drawing.Graphics g = e.Graphics; g.FillRectangle(System.Drawing.Brushes.LightGray, 0, 0, width, height); // 選択中のハンドルを取得 VibratoHandle handle = mSelected; if (handle == null) { return; } // 描画の準備 LineGraphDrawer d = getDrawerDepth(); d.clear(); d.setGraphics(g); drawVibratoCurve( handle.getDepthBP(), handle.getStartDepth(), d, width, height); }
public void textDepth_TextChanged(Object sender, EventArgs e) { if (mSelected == null) { return; } int old = mSelected.getStartDepth(); int value = old; string s = textDepth.Text; try { value = int.Parse(s); } catch (Exception ex) { value = old; } if (value < 0) { value = 0; } if (127 < value) { value = 127; } mSelected.setStartDepth(value); string nstr = value + ""; if (s != nstr) { textDepth.Text = nstr; textDepth.SelectionStart = textDepth.Text.Length; } repaintPictures(); }
public void listPresets_SelectedIndexChanged(Object sender, EventArgs e) { // インデックスを取得 int index = listPresets.SelectedIndex; #if DEBUG sout.println("FormVibratoPreset#listPresets_SelectedIndexChanged; index=" + index); #endif // 範囲外ならbailout if ((index < 0) || (mHandles.Count <= index)) { #if DEBUG sout.println("FormVibratoPreset#listPresets_SelectedIndexChanged; bail-out, mSelected -> null; index=" + index); #endif mSelected = null; return; } // イベントハンドラを一時的に取り除く textDepth.TextChanged -= new EventHandler(textDepth_TextChanged); textRate.TextChanged -= new EventHandler(textRate_TextChanged); textName.TextChanged -= new EventHandler(textName_TextChanged); // テクストボックスに値を反映 mSelected = mHandles[index]; textDepth.Text = mSelected.getStartDepth() + ""; textRate.Text = mSelected.getStartRate() + ""; textName.Text = mSelected.getCaption(); // イベントハンドラを再登録 textDepth.TextChanged += new EventHandler(textDepth_TextChanged); textRate.TextChanged += new EventHandler(textRate_TextChanged); textName.TextChanged += new EventHandler(textName_TextChanged); // 再描画 repaintPictures(); }
public void pictureResulting_Paint(Object sender, PaintEventArgs e) { // 背景を描画 int raw_width = pictureResulting.Width; int raw_height = pictureResulting.Height; System.Drawing.Graphics g = e.Graphics; g.FillRectangle(System.Drawing.Brushes.LightGray, 0, 0, raw_width, raw_height); // 選択中のハンドルを取得 VibratoHandle handle = mSelected; if (handle == null) { return; } // 描画の準備 LineGraphDrawer d = getDrawerResulting(); d.setGraphics(g); // ビブラートのピッチベンドを取得するイテレータを取得 int width = raw_width; int vib_length = 960; int tempo = 500000; double vib_seconds = tempo * 1e-6 / 480.0 * vib_length; // 480クロックは0.5秒 VsqFileEx vsq = new VsqFileEx("Miku", 1, 4, 4, tempo); VibratoBPList list_rate = handle.getRateBP(); VibratoBPList list_depth = handle.getDepthBP(); int start_rate = handle.getStartRate(); int start_depth = handle.getStartDepth(); if (list_rate == null) { list_rate = new VibratoBPList(new float[] { 0.0f }, new int[] { start_rate }); } if (list_depth == null) { list_depth = new VibratoBPList(new float[] { 0.0f }, new int[] { start_depth }); } // 解像度 float resol = (float)(vib_seconds / width); if (resol <= 0.0f) { return; } VibratoPointIteratorBySec itr = new VibratoPointIteratorBySec( vsq, list_rate, start_rate, list_depth, start_depth, 0, vib_length, resol); // 描画 int height = raw_height - MARGIN * 2; d.clear(); //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; int x = 0; int lastx = 0; int lasty = -10; int tx = 0, ty = 0; for (; itr.hasNext(); x++) { double pitch = itr.next().getY(); int y = height - (int)((pitch + 1.25) / 2.5 * height) + MARGIN - 1; int dx = x - lastx; // xは単調増加 int dy = Math.Abs(y - lasty); tx = x; ty = y; //if ( dx > MIN_DELTA || dy > MIN_DELTA ) { d.append(x, y); lastx = x; lasty = y; //} } d.append(tx, ty); d.flush(); }