/// <summary> /// ウィンドウにトラックバーを作成し、作成したトラックバーを返す /// </summary> /// <param name="name">トラックバーの名前</param> /// <param name="value">スライダの初期位置</param> /// <param name="count">スライダの最大値.最小値は常に 0.</param> /// <param name="onChange">スライダの位置が変更されるたびに呼び出されるデリゲート</param> /// <returns></returns> #else /// <summary> /// Creates the trackbar and attaches it to this window /// </summary> /// <param name="name">Name of created trackbar. </param> /// <param name="value">The position of the slider</param> /// <param name="count">Maximal position of the slider. Minimal position is always 0. </param> /// <param name="onChange">the function to be called every time the slider changes the position. This function should be prototyped as void Foo(int);</param> /// <returns></returns> #endif public TrackbarWithLabel CreateTrackbar(string name, int value, int count, CvTrackbarCallback onChange) { var t = new TrackbarWithLabel(name, value, count, 0); t.Dock = DockStyle.Top; t.Trackbar.ValueChanged += (o, e) => { int pos = ((TrackBar)o).Value; onChange(pos); }; SetClientSize(new System.Drawing.Size(ClientSize.Width, ClientSize.Height + t.Height)); _panelTrackbar.Height += t.Height; _panelTrackbar.Controls.Add(t); return(t); }
/// <summary> /// ウィンドウにトラックバーを作成し、作成したトラックバーを返す /// </summary> /// <param name="name">トラックバーの名前</param> /// <param name="value">スライダの初期位置</param> /// <param name="count">スライダの最大値.最小値は常に 0.</param> /// <param name="onChange">スライダの位置が変更されるたびに呼び出されるデリゲート</param> /// <returns></returns> #else /// <summary> /// Creates the trackbar and attaches it to this window /// </summary> /// <param name="name">Name of created trackbar. </param> /// <param name="value">The position of the slider</param> /// <param name="count">Maximal position of the slider. Minimal position is always 0. </param> /// <param name="onChange">the function to be called every time the slider changes the position. This function should be prototyped as void Foo(int);</param> /// <returns></returns> #endif public TrackbarWithLabel CreateTrackbar(string name, int value, int count, CvTrackbarCallback onChange) { var t = new TrackbarWithLabel(name, value, count, 0); t.Dock = DockStyle.Top; t.Trackbar.ValueChanged += (o, e) => { int pos = ((TrackBar)o).Value; onChange(pos); }; SetClientSize(new CvSize(ClientSize.Width, ClientSize.Height + t.Height)); _panelTrackbar.Height += t.Height; _panelTrackbar.Controls.Add(t); return t; }