Esempio n. 1
0
        public void DrawObject(Layer layer, DrawObject item)
        {
            Point[] cPoints = item.ConvertPoints(layer);
            bool    bDraw   = Boundary.BoundFix(ref cPoints[0], ref cPoints[1], new Rectangle4(layer.LayerRectangleWithoutAxisY));

            if (bDraw)
            {
                IntPtr cOldPen = __cGDI.SelectPen(item.Pens[0]);
                __cGDI.DrawLine(cPoints[0].X, cPoints[0].Y, cPoints[1].X, cPoints[1].Y);
                __cGDI.RemoveObject(__cGDI.SelectPen(cOldPen));
            }
        }
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
        private void DrawTradeInfo(ITrade trade, AxisX axisX, ChartProperty property, IntPtr font, Rectangle4 layerRect, int top)
        {
            ITradeOrder cEntry  = trade.EntryOrder;
            Point       cPoint1 = new Point(axisX.ConvertBarNumberToWidth(cEntry.BarNumber).CenterPoint, top + this.AxisY.ConvertValueToHeight(cEntry.Price));

            __cGDI.DrawString("▸", property.TradeSymbolColor, cPoint1.X - 7, cPoint1.Y - 7);
            DrawTradeName(cEntry.Name, font, property.ForeColor, cPoint1, true);

            ITradeOrder cExit = trade.ExitOrder;

            if (cExit != null)
            {
                Point cPoint2 = new Point(axisX.ConvertBarNumberToWidth(cExit.BarNumber).CenterPoint, top + this.AxisY.ConvertValueToHeight(cExit.Price));
                __cGDI.DrawString("◂", property.TradeSymbolColor, cPoint2.X + 1, cPoint2.Y - 7);
                DrawTradeName(cExit.Name, font, property.ForeColor, cPoint2, false);

                if (Boundary.BoundFix(ref cPoint1, ref cPoint2, layerRect))
                {
                    __cGDI.DrawLine(cPoint1.X, cPoint1.Y, cPoint2.X, cPoint2.Y);
                }
            }
        }