Example #1
0
        public void SetRamBitmap(RamBitmap ram)
        {
            _ramBitmap = ram;

            if (ram == null)
            {
                return;
            }

            ram.SetBounds(_innerBounds.Width, _innerBounds.Height);

            _draw(true);
        }
Example #2
0
        private void _setBounds(int width, int height)
        {
            // Update width of the entire indicator axis
            // We have n indicators, each one separated by a 1 pixel line
            int indicatorDim = 0;

            foreach (var entry in _indicators)
            {
                indicatorDim += entry.Indicator.Dimension;
            }

            _indicatorAxisWidth = indicatorDim + _indicators.Count * 1;

            // Width and height of the border and axis
            // The border contains the ticks and text, the indicator axis and
            // a 2 pixel line separating the axis from the ram view
            _axisWidth  = _borderWidth + _indicatorAxisWidth + _innerLineWidth;
            _axisHeight = _borderHeight + _indicatorAxisWidth + _innerLineWidth;

            // We scale the plot only in units of major ticks to
            // always keep the axis frame consistent.
            _width  = width - ((width - _axisWidth * 2) % _majorTick);
            _height = height - ((height - _axisHeight * 2) % _majorTick);

            // The inner rectangle into which we will draw the ram
            // excluding the inner frame line
            _innerBounds = new Rectangle(_axisWidth, _axisHeight,
                                         _width - _axisWidth * 2, _height - _axisHeight * 2);

            // The outer rectangle that we take as basis for the tick
            // and text drawing. The rectangle does not include the outer
            // frame line.
            _outerBounds = new Rectangle(_borderWidth, _borderHeight,
                                         _width - _borderWidth * 2, _height - _borderHeight * 2);

            // Now, that we know the dimensions of the inner view, we can
            // update the bounds of the indicators.
            for (int i = 0; i < _indicators.Count; ++i)
            {
                IndicatorEntry e   = _indicators[i];
                int            dim = e.Indicator.Dimension;

                e.Indicator.SetBounds(_innerBounds.Width, _innerBounds.Height);

                e.TopBar = new Rectangle(_innerBounds.Left,
                                         _innerBounds.Top - _innerLineWidth - (dim * (i + 1)) - i,
                                         _innerBounds.Width, dim);

                e.BottomBar = new Rectangle(_innerBounds.Left,
                                            _innerBounds.Bottom + _innerLineWidth + (dim * i) + i,
                                            _innerBounds.Width, dim);

                e.LeftBar = new Rectangle(
                    _innerBounds.Left - _innerLineWidth - (dim * (i + 1)) - i,
                    _innerBounds.Top, dim, _innerBounds.Height);

                e.RightBar = new Rectangle(
                    _innerBounds.Right + _innerLineWidth + (dim * i) + i,
                    _innerBounds.Top, dim, _innerBounds.Height);

                e.Bounds = new Rectangle(e.LeftBar.Left, e.TopBar.Top,
                                         e.RightBar.Right - e.LeftBar.Left,
                                         e.BottomBar.Bottom - e.TopBar.Top);
            }

            if (_ramBitmap != null)
            {
                _ramBitmap.SetBounds(_innerBounds.Width, _innerBounds.Height);
            }

            _setupCanvas(width, height);
        }