Пример #1
0
        private void ProccessObjects(IEnumerable <ITextObject> textObjects, ChartProperty property, bool useROP)
        {
            //將 TextObject 物件按照 DataStream 分類
            foreach (TextObject cTextObject in textObjects)
            {
                Queue <TextObject> cQueue = null;
                if (!__cObjects.TryGetValue(cTextObject.DataStream, out cQueue))
                {
                    cQueue = new Queue <TextObject>(128);
                    __cObjects.Add(cTextObject.DataStream, cQueue);
                }
                cQueue.Enqueue(cTextObject);
            }

            //將分類好的 TextObject 顯示在 Chart 上
            foreach (int iDataStream in __cObjects.Keys)
            {
                ChartSetting cChartSetting = property.ChartSettings[iDataStream - 1];
                if (cChartSetting.IsSubChart)
                {
                    Layer     cLayer     = __cLayers[cChartSetting.LayerIndex];
                    Rectangle cLayerRect = cLayer.LayerRectangleWithoutAxisY;

                    __cGDI.SaveDC();
                    __cGDI.ClipRectangle(cLayerRect);

                    Queue <TextObject> cQueue = __cObjects[iDataStream];
                    while (cQueue.Count > 0)
                    {
                        DrawTextObject(cLayer, cQueue.Dequeue(), property, useROP);
                    }
                    __cGDI.RestoreDC();
                }
            }
        }
Пример #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();
            }
        }
Пример #3
0
        public override bool DrawPlot(Layer layer, ChartProperty property, bool onlyUpdateLastBar)
        {
            AxisX      cAxisX     = layer.AxisX;
            Rectangle  cRectY     = this.AxisY.AxisRectangle;
            Rectangle4 cLayerRect = new Rectangle4(layer.LayerRectangleWithoutAxisY);

            __cGDI.SaveDC();
            __cGDI.ClipRectangle(layer.LayerRectangleWithoutAxisY);

            int    iOldMode  = __cGDI.SelectTransparent();
            IntPtr iOldFont  = __cGDI.SelectFont(__cSymbolFont);
            IntPtr iOldPen   = __cGDI.SelectPen(new PowerLanguage.PenStyle(property.TradeLineColor, 1, (int)__uPattern));
            IntPtr iNameFont = __cLegendFont.ToHfont();

            if (onlyUpdateLastBar)
            {
                if (__cPrevTrade != null)
                {
                    DrawTradeInfo(__cPrevTrade, cAxisX, property, iNameFont, cLayerRect, cRectY.Top);
                }
            }
            else
            {
                this.RefreshAxisY(property);

                int iStartIndex          = cAxisX.BarNumber;
                int iEndIndex            = iStartIndex + cAxisX.BarCount - 1;
                HashSet <ITrade> cTrades = __cTrades.GetTradeObjects(iStartIndex, iEndIndex);
                foreach (ITrade cTrade in cTrades)
                {
                    DrawTradeInfo(cTrade, cAxisX, property, iNameFont, cLayerRect, cRectY.Top);
                    __cPrevTrade = cTrade;
                }
            }

            __cGDI.RemoveObject(iNameFont);
            __cGDI.RemoveObject(__cGDI.SelectPen(iOldPen));
            __cGDI.RemoveObject(__cGDI.SelectFont(iOldFont));

            if (layer.Drawable)
            {
                this.DrawLegend(layer.LegendIndex, property);
            }
            __cGDI.ClearTransparent(iOldMode);
            __cGDI.RestoreDC();
            return(true);
        }