Пример #1
0
        private void InitializeTracker()
        {
            bool isEmpty     = _layout == null;
            bool willBeEmpty = false;

            if (_layoutFile == null || _layoutName == null)
            {
                willBeEmpty = true;
            }
            else
            {
                TrackerLayout l;
                if (!_layoutFile.layouts.TryGetValue(_layoutName, out l))
                {
                    willBeEmpty = true;
                }
            }

            if (!isEmpty && willBeEmpty)
            {
                UninitializeTracker();
            }
            else if (!willBeEmpty)
            {
                // ACTUALLY INITIALIZE
                FreeLayoutResources();

                _layout = _layoutFile.layouts[_layoutName];
                if (cachedViews.ContainsKey(_layoutName))
                {
                    _renderer = cachedViews[_layoutName];
                    _renderer.Update(); // Todo: determine if cached views should update in realtime, or if not, they should at least to allow redundant invalidations
                }
                else
                {
                    _renderer = new LayoutRenderer(_layoutFile, _layoutName);
                    if (CacheViews && !cachedViews.ContainsKey(_layoutName))
                    {
                        cachedViews.Add(_layoutName, _renderer);
                    }
                }
                foreach (var placement in _layout.maps)
                {
                    var       mmap   = _layoutFile.GetEffectiveMetrics(placement);
                    Rectangle bounds = new Rectangle(
                        mmap.x,
                        mmap.y,
                        mmap.cellWidth * mmap.gridWidth,
                        mmap.cellHeight * mmap.gridHeight
                        );
                    mapBounds.Add(Tuple.Create(mmap, bounds));
                }

                SetupPicker();
                Invalidate(new Rectangle(0, 0, _renderer.Width, _renderer.Height));
            }
        }
Пример #2
0
        private void TryLoadContents()
        {
            bool willBeLoaded = _layoutFile != null && _layoutName != null && _markerSetPlacement != null && _mapPlacement != null;

            if (_wasLoaded && !willBeLoaded)
            {
                this._tileSource = null;
                this.Invalidate();
            }

            if (willBeLoaded)
            {
                var metrics = _layoutFile.GetEffectiveMetrics(_mapPlacement);

                this._tileSource = _layoutFile.Meta.GetImage(_markerSetPlacement.source);
                this._tileWidth  = metrics.cellWidth;  //MapPlacement.cellWidth;
                this._tileHeight = metrics.cellHeight; //MapPlacement.cellHeight;
                this._tileCount  = _tileSource.Width / _tileWidth;
                this.Invalidate();
            }

            _wasLoaded = willBeLoaded;
        }