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)); } }
/// <summary> /// Forces the tracker to immedately update its graphics /// </summary> public new void Update() { _renderer.Update(); Invalidate(new Rectangle(0, 0, _renderer.Width, _renderer.Height)); }