Пример #1
0
 protected void DrawHandle(Graphics canvas, KeyPoint kp, uint index, float size, Color color, Color bordercolor)
 {
     DrawHandle(canvas, kp.Time, kp.GetValue(index), size, color, bordercolor);
 }
Пример #2
0
        // ctrl+左键为在指定折线上添加一个细分,alt+左键为删除当前操作手柄对应的时间点,左键点击操作手柄为选择操作手柄,可以上下移动被选中的手柄
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Focus();
            m_X = e.X;
            m_Y = e.Y;
            if (e.Button == MouseButtons.Left)
            {
                float size = 6.0f * m_GridScale;
                //如果按下ctrl键则视为在所选位置增加节点
                if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                {
                    if (m_Stream == null)
                    {
                        return;
                    }
                    PointF pt = ScreenToWorld(e.X, e.Y);
                    m_Stream.AddKeyPoint(pt.X);
                    Invalidate();
                }
                if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt)
                {
                    if (m_Stream == null)
                    {
                        return;
                    }
                    //否则检测是否选中了操作器
                    for (int j = 0; j < m_Stream.GetStreamCount(); ++j)
                    {
                        if (!m_Stream.GetStreamEnable(j))
                        {
                            continue;
                        }
                        List <KeyPoint> list = m_Stream.GetStream();
                        for (int k = list.Count - 1; k >= 0; --k)
                        {
                            RectangleF rect = new RectangleF(list[k].Time - size, list[k].GetValue((uint)j) - size, size * 2, size * 2);
                            PointF     pt   = ScreenToWorld(e.X, e.Y);
                            if (rect.Contains(pt))
                            {
                                if (list.Count <= 2)
                                {
                                    m_CurrentKeyPoint      = list[k];
                                    m_CurrentStreamIndex   = j;
                                    m_CurrentKeyPointIndex = k;
                                    Invalidate();
                                    base.OnMouseDown(e);
                                    return;
                                }
                                m_Stream.RemoveKeyPoint(k);
                                Invalidate();
                                m_CurrentKeyPoint = null;
                                base.OnMouseDown(e);
                                return;
                            }
                        }
                    }
                    m_CurrentKeyPoint = null;
                    Invalidate();
                }
                else
                {
                    if (m_Stream == null)
                    {
                        return;
                    }
                    //否则检测是否选中了操作器
                    for (int j = 0; j < m_Stream.GetStreamCount(); ++j)
                    {
                        if (!m_Stream.GetStreamEnable(j))
                        {
                            continue;
                        }
                        List <KeyPoint> list = m_Stream.GetStream();
                        for (int k = list.Count - 1; k >= 0; --k)
                        {
                            RectangleF rect = new RectangleF(list[k].Time - size, list[k].GetValue((uint)j) - size, size * 2, size * 2);
                            PointF     pt   = ScreenToWorld(e.X, e.Y);
                            if (rect.Contains(pt))
                            {
                                m_CurrentKeyPoint      = list[k];
                                m_CurrentStreamIndex   = j;
                                m_CurrentKeyPointIndex = k;
                                Invalidate();
                                base.OnMouseDown(e);
                                return;
                            }
                        }
                    }
                    m_CurrentKeyPoint = null;
                    Invalidate();
                }
            }

            base.OnMouseDown(e);
        }
Пример #3
0
 protected void DrawLine(Graphics canvas, Pen pen, KeyPoint st, KeyPoint ed, uint index)
 {
     {
         DrawLine(canvas, pen, st.Time, st.GetValue(index), ed.Time, ed.GetValue(index));
     }
 }