Esempio n. 1
0
        public void Action(ChartParameter parameter)
        {
            InputDeviceStatus cStatus = parameter.Status;

            if (cStatus.Event == EInputDeviceEvent.MouseWheel)
            {
                MouseEventArgs e      = cStatus.GetCurrentMouseArgs();
                ZChart         cChart = parameter.Chart;
                AxisX          cAxisX = cChart.AxisX;

                int iCount = cAxisX.BarCount;
                if (e.Delta < 0)
                {
                    iCount += ZOOM_SCALE_UNIT;
                }
                else
                {
                    iCount -= ZOOM_SCALE_UNIT;
                }

                cAxisX.BarCount = iCount;
                if (cAxisX.Refresh)
                {
                    cChart.Refresh();
                }
            }
        }
Esempio n. 2
0
        public void Action(ChartParameter parameter)
        {
            ZChart            cChart  = parameter.Chart;
            InputDeviceStatus cStatus = parameter.Status;
            MouseEventArgs    e       = cStatus.GetCurrentMouseArgs();

            if (cStatus.Event == EInputDeviceEvent.MouseUp)
            {
                if (__cStart == Point.Empty)
                {
                    List <Layer> cLayers = cChart.Layers;
                    int          iCount  = cLayers.Count;
                    for (int i = 0; i < iCount; i++)
                    {
                        Layer cLayer = cLayers[i];
                        if (cLayer.IsLayerScope(e.X, e.Y))
                        {
                            __cLayer = cLayer;
                            break;
                        }
                    }

                    __cStart = e.Location;
                }
                else
                {
                    Point cEnd = e.Location;
                    Boundary.BoundFix(ref __cStart, ref cEnd, new Rectangle4(__cLayer.LayerRectangleWithoutAxisY));

                    //保存至使用者繪製容器內
                    parameter.Behavior.DrawContainer.AddDrawObject(__sName, __cLayer, new Point[] { __cStart, cEnd }, new PowerLanguage.PenStyle[] { parameter.CustomPen });

                    __cStart = Point.Empty;
                    parameter.CustomPainter = null;                      //繪圖完畢需要設定為 null

                    __cGDI.ClearRops(__cLineInfos, null, false);
                    cChart.Refresh();
                }
            }
            else if (__cStart != Point.Empty && cStatus.Event == EInputDeviceEvent.MouseMove)
            {
                __cGDI.SaveDC();
                __cGDI.ClipRectangle(__cLayer.LayerRectangleWithoutAxisY);
                __cGDI.ClearRops(__cLineInfos, null, !parameter.Updated);

                ChartProperty cProperty = cChart.ChartProperty;
                IntPtr        cPen      = Gdi.CreatePen(new PowerLanguage.PenStyle(cProperty.DrawAideLineColor, 1));
                __cLineInfos.Add(__cGDI.DrawRopLine(cPen, __cStart.X, __cStart.Y, e.X, e.Y));

                __cGDI.RestoreDC();
            }
        }
Esempio n. 3
0
        public void Action(ChartParameter parameter)
        {
            InputDeviceStatus cStatus = parameter.Status;

            if (cStatus.IsDrag && cStatus.Event == EInputDeviceEvent.MouseMove)
            {
                MouseEventArgs e = cStatus.GetCurrentMouseArgs();
                if (e.Button == MouseButtons.Left)
                {
                    ZChart cChart  = parameter.Chart;
                    AxisX  cAxisX  = cChart.AxisX;
                    double dUnit   = cAxisX.AxisRectangle.Width / (double)cAxisX.BarCount;
                    int    iOffset = (int)((__iMouseX - e.X) / dUnit);

                    cAxisX.BarNumber = __iInitBarNumber + iOffset;
                    if (cAxisX.Refresh)
                    {
                        cChart.Refresh();
                    }
                }
            }
            else if (!cStatus.IsDrag && cStatus.Event == EInputDeviceEvent.MouseDown)
            {
                MouseEventArgs e = cStatus.GetCurrentMouseArgs();
                if (e.Button == MouseButtons.Left)
                {
                    parameter.IsAction       = true;
                    parameter.Context.Cursor = Cursors.SizeWE;
                    __iMouseX        = cStatus.GetCurrentMouseArgs().X;
                    __iInitBarNumber = parameter.Chart.AxisX.BarNumber;
                }
            }
            else if (cStatus.Event == EInputDeviceEvent.MouseUp)
            {
                parameter.IsAction       = false;
                parameter.Context.Cursor = Cursors.Default;
            }
        }
Esempio n. 4
0
        public void Action(ChartParameter parameter)
        {
            InputDeviceStatus cStatus = parameter.Status;

            if (cStatus.Event == EInputDeviceEvent.MouseMove)
            {
                MouseEventArgs e = cStatus.GetCurrentMouseArgs();
                if (cStatus.IsDrag && e.Button == MouseButtons.Left)
                {
                    int          iOffset = e.Y - __iMouseY;
                    ZChart       cChart  = parameter.Chart;
                    List <Layer> cLayers = cChart.Layers;
                    Layer        cLayer  = cLayers[__iLayerIndex];

                    //如果 Layers 只有一個就不需要計算鄰近的 Layer 的相對高度
                    if (cLayers.Count > 1)
                    {
                        double dScale = (__dLayerHeight + iOffset) / cChart.ChartRectangle.Height;
                        cLayers[__iLayerIndex + 1].HeightScale += cLayer.HeightScale - dScale;
                        cLayer.HeightScale = dScale;

                        cChart.Resize();
                        cChart.Refresh();
                    }
                }
                else
                {
                    ZChart       cChart  = parameter.Chart;
                    List <Layer> cLayers = cChart.Layers;
                    int          iCount  = cLayers.Count - 1;
                    for (int i = 0; i < iCount; i++)
                    {
                        Layer cLayer = cLayers[i];
                        if (cLayer.IsLayerScope(e.X, e.Y))
                        {
                            Rectangle cRect      = cLayer.LayerRectangle;
                            int       iMaxBottom = cRect.Y + cRect.Height;
                            int       iMinBottom = iMaxBottom - 5;
                            if (e.Y >= iMinBottom && e.Y <= iMaxBottom)
                            {
                                __bResize                = true;
                                __iLayerIndex            = i;
                                __dLayerHeight           = cRect.Height;
                                parameter.Context.Cursor = Cursors.SizeNS;
                                return;
                            }
                        }
                    }

                    __bResize = false;
                    parameter.Context.Cursor = Cursors.Default;
                }
            }
            else if (__bResize && !cStatus.IsDrag && cStatus.Event == EInputDeviceEvent.MouseDown)
            {
                parameter.IsAction = true;
                __iMouseY          = cStatus.GetCurrentMouseArgs().Y;
            }
            else if (cStatus.Event == EInputDeviceEvent.MouseUp)
            {
                __bResize                = false;
                parameter.IsAction       = false;
                parameter.Context.Cursor = Cursors.Default;
            }
        }