private void DrawClusterPriceBarBg(/*double price, int amount*/ CCluster clusterData, double y, DateTime dtInterval, double actualWidthClusterGrid)
        {
            GenClusterBrushPen(clusterData, dtInterval);

            //calculate width of cluster bar
            long dealsAmountFullBar = CUtilConv.GetIntVolume(Math.Max(_dealsAmountFullBar, 1), _decimalVolume);//zero devide protect

            _volumeRectWidth = (((double)clusterData.AmountTotal) / ((double)dealsAmountFullBar)) * actualWidthClusterGrid;
            //draw cluster bar with proportional width
            //DrawRectangle(_brushCluster, _penCluster, new Rect(0.0, y, _volumeRectWidth, (double)_stirngHeight));
            _drwCntxtClustersBg.DrawRectangle(_brushCluster, _penCluster, new Rect(0.0, y, _volumeRectWidth, (double)_stirngHeight));


            //   FormattedText(text, _cultureInfoDefault, FlowDirection.LeftToRight, _typeFaceDefault, _fontSizeScaled, brush);

            //2018-02-21
            string stAmount = CTerminalUtil.GetAmount(clusterData.AmountTotal, _decimalVolume);



            //print cluster amount
            //DrawText(_FrmTxtCurrClustAmount, new Point(0.0, y));
            //KAA 2017-03-01 changed to Glyph
            //2018-05-01 changed to fontsizeScaled
            GlyphRun gr = _glyphGenBg.GetGlyph(0, y + _fontSizeScaled,
                                               _fontSizeScaled,
                                               " " + /*clusterData.AmountTotal.ToString()*/ stAmount);

            _drwCntxtClustersBg.DrawGlyphRun(_brushFontBg, gr);
        }
        private void DrawClusterDateBg(CCluster cluster, double actualCanvasWidth)
        {
            //double actualWidthClusterGrid = GridCanvasControlClusters.ColumnDefinitions[1].ActualWidth;

            GenClusterTotalBrushBg(cluster.AmountBuy, cluster.AmountSell);

            double offsetBottom = 12;//27.0;
            double y            = _actualHeight - _stirngHeight - offsetBottom;

            //Draw rectangle with summary of period on bottom of screen
            //DrawRectangle(_brushClusterTotal, _penClusterTotal, new Rect(0.0, y, actualCanvasWidth, (double)_stirngHeight));
            _drwCntxtClustersBg.DrawRectangle(_brushClusterTotalBg, _penClusterTotalBg,
                                              new Rect(0.0, y, actualCanvasWidth, (double)_stirngHeight));
            //2018-07-10
            string stAmountTotal = CTerminalUtil.GetAmount(cluster.AmountTotal, _decimalVolume);

            _FrmTxtCurrClustAmount = GetFormattedTextBg(" " + stAmountTotal);

            _drwCntxtClustersBg.DrawText(_FrmTxtCurrClustAmount, new Point(0.0, y));
        }
 private void UpdateBrushes()
 {
     CTerminalUtil.UpdateBrush(_colorFontBg, ref _brushFontBg);
 }
        public void ThreadDrawClusters()
        {
            try
            {
                _drwVisClustersBg = new DrawingVisual();


                _glyphGenBg          = new CGlyphGenerator();
                _rendererClusterBg   = new CRendererBackground(this, _drwVisClustersBg, _guiDispatcher);
                _culterInfoBg        = new CultureInfo("en-US");
                _fontFamilyDefaultBg = new FontFamily("Verdana");
                _typeFaceDefaultBg   = new Typeface(_fontFamilyDefaultBg, FontStyles.Normal, _fontWeightDefault, new FontStretch());

                _evDrawClusters = new AutoResetEvent(true);
            }
            catch (Exception e)
            {
                Error("ThreadDrawClusters.Create", e);
            }



            _brushFontBg = new SolidColorBrush(Colors.White);

            WaitImagesInit();//2018-06-09

            _lstImageSegmentsBg.Add(Image_0);
            _lstImageSegmentsBg.Add(Image_1);
            _lstImageSegmentsBg.Add(Image_2);
            _lstImageSegmentsBg.Add(Image_3);
            _lstImageSegmentsBg.Add(Image_4);
            _lstImageSegmentsBg.Add(Image_5);
            _lstImageSegmentsBg.Add(Image_6);
            _lstImageSegmentsBg.Add(Image_7);
            _lstImageSegmentsBg.Add(Image_8);
            _lstImageSegmentsBg.Add(Image_9);

            //This is specieal pause which sets time to allow other contols
            //load. Without this pause prices will draw a very long time - about 20 seconds
            System.Threading.Thread.Sleep(15000);

            while (true)
            {
                try
                {
                    _evDrawClusters.WaitOne(500);
                    _isNeedFullRedraw = true;


                    if (_disablePaintClusters)
                    {
                        Thread.Sleep(100);
                        continue;
                    }


                    _guiDispatcher.Invoke(new Action(() =>
                    {
                        DisableRecalcClusters = true;


                        _actualHeight     = ActualHeight;
                        _isNeedFullRedraw = true;

                        CTerminalUtil.UpdateLocalColors(FontColor, ref _colorFontBg);



                        UpdateTimesAxe();
                    }
                                                     ));


                    UpdateBrushes();

                    DrawClustersBg();



                    _guiDispatcher.Invoke(new Action(() => DisableRecalcClusters = false));



                    //Thread.Sleep(500);
                }
                catch (Exception e)
                {
                    Error("ThreadDrawClusters(", e);
                    Thread.Sleep(100);
                }
                finally
                {
                    _guiDispatcher.Invoke(new Action(() =>
                    {
                        DisableRecalcClusters = false;
                    }));
                }
            }
        }