Example #1
0
        private static UIElement GetNotificationContent(string text, Drawing drawingGroup)
        {
            var panel = new StackPanel
            {
                Orientation = Orientation.Vertical
            };

            var textBlock = new TextBlock
            {
                Text   = text,
                Margin = new Thickness(0, 0, 0, 5)
            };

            panel.Children.Add(textBlock);

            var gridCellControl = new GridCellControl
            {
                Background          = new SolidColorBrush(ColorParser.ParseHexColor("#fcfbfa")),
                GridLineBrush       = new SolidColorBrush(ColorParser.ParseHexColor("#dcdcdc")),
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Child = new Image
                {
                    Source  = new DrawingImage(drawingGroup),
                    Stretch = Stretch.Uniform
                }
            };

            var binding = new Binding
            {
                Path           = new PropertyPath("ActualWidth"),
                RelativeSource = RelativeSource.Self
            };

            gridCellControl.SetBinding(FrameworkElement.HeightProperty, binding);
            panel.Children.Add(gridCellControl);

            return(panel);
        }
Example #2
0
        private void UpdateGrid()
        {
            _gridCells = new GridCellControl[_grid.Size.Width,_grid.Size.Height];

            for(var i = 0; i < _grid.Size.Width; i++)
            {
                for(var j = 0; j < _grid.Size.Height; j++)
                {
                    if (_grid.Weight[i, j] <= 128) continue;

                    // create local instances of i and js so the anon GridClicked function won't misbehave
                    var li = i;
                    var lj = j;

                    var gridCell = new GridCellControl { Bounds = new UniRectangle(i*50, j*50, 50, 50) };
                    gridCell.GridClicked += () => GridCellSelected.Invoke(li, lj);
                    _gridCells[i, j] = gridCell;
                    _gui.Screen.Desktop.Children.Add(gridCell);
                    gridCell.GridClicked += () => { ((BattleScene) Scene).ExecuteAimAbility(li, lj); };
                }
            }
        }