void UpdateOverlays()

in Kiosk/Controls/Overlays/Primitives/OverlayControl.xaml.cs [193:259]


        void UpdateOverlays()
        {
            //validate
            var overlayInfo = OverlayInfo;
            var defaultSize = DefaultOverlaySize;
            if (_mainGrid == null)
            {
                return;
            }
            if (overlayInfo == null || (overlayInfo.OverlaySize == null && defaultSize == null))
            {
                _mainGrid.Visibility = Visibility.Collapsed;
                return;
            }

            //show the grid
            _mainGrid.Visibility = Visibility.Visible;

            //set grid widths
            var size = overlayInfo.OverlaySize ?? defaultSize.GetValueOrDefault();
            var width = overlayInfo.Rect.Left;
            _mainGrid.ColumnDefinitions[0].Width = new GridLength(width, GridUnitType.Star);
            width = overlayInfo.Rect.Width / 2;
            _mainGrid.ColumnDefinitions[1].Width = new GridLength(width, GridUnitType.Star);
            _mainGrid.ColumnDefinitions[2].Width = new GridLength(width, GridUnitType.Star);
            width = size.Width - overlayInfo.Rect.Right;
            width = width < 0 ? 0 : width;
            _mainGrid.ColumnDefinitions[3].Width = new GridLength(width, GridUnitType.Star);
            //set grid heights
            var height = overlayInfo.Rect.Top;
            _mainGrid.RowDefinitions[0].Height = new GridLength(height, GridUnitType.Star);
            height = overlayInfo.Rect.Height / 2;
            _mainGrid.RowDefinitions[1].Height = new GridLength(height, GridUnitType.Star);
            _mainGrid.RowDefinitions[2].Height = new GridLength(height, GridUnitType.Star);
            height = size.Height - overlayInfo.Rect.Bottom;
            height = height < 0 ? 0 : height;
            _mainGrid.RowDefinitions[3].Height = new GridLength(height, GridUnitType.Star);

            //set data source of labels
            var labels = Labels;
            if (labels != null)
            {
                for (int i = 0; i < labels.Count; i++)
                {
                    var label = labels[i];
                    if (overlayInfo.Labels != null && overlayInfo.Labels.Count > i)
                    {
                        label.DataContext = overlayInfo.Labels[i];
                        label.OverlayInfo = overlayInfo;
                    }
                    else
                    {
                        label.DataContext = null;
                    }
                }
            }

            //place labels on grid - if havn't
            if (labels != null && !_hasAddedLabels)
            {
                _hasAddedLabels = true;
                foreach (var label in labels)
                {
                    _mainGrid.Children.Add(label);
                }
            }
        }