示例#1
0
        private void CounterEnter(object sender, MouseEventArgs e)
        {
            OnCounterHover = true;
            Engine.Map.SetOnTop(this);
            UnitGrid.Children.Clear();
            if (Tile.HasBattle)
            {
                Battle     battle    = Tile.Battles[0];
                StackPanel hor_panel = new StackPanel
                {
                    Orientation         = Orientation.Horizontal,
                    Background          = ColorHandler.ColorFromARGB(100, 100, 100, 100),
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                hor_panel.MouseLeave += Leave;
                UnitGrid.Children.Add(hor_panel);

                StackPanel attacker_panel = CreatePanel(battle.Attackers);
                hor_panel.Children.Add(attacker_panel);

                Image img = new Image();
                img.Source = Images.IconQuestionmark;
                img.Width  = 20;
                hor_panel.Children.Add(img);

                StackPanel defender_panel = CreatePanel(battle.Defenders);
                hor_panel.Children.Add(defender_panel);

                int    counter_width = 50;
                double left_shift    = counter_width + img.Width + counter_width;
                left_shift      -= 100;
                left_shift      /= 2;
                hor_panel.Margin = new Thickness(-left_shift, 0, 0, 0);
            }
            else
            {
                StackPanel panel = new StackPanel();
                panel.Background          = Brushes.Gray;
                panel.VerticalAlignment   = VerticalAlignment.Center;
                panel.HorizontalAlignment = HorizontalAlignment.Center;
                panel.MouseLeave         += Leave;
                UnitGrid.Children.Add(panel);

                //- Units
                double height_count = 0;
                for (int i = 0; i < Tile.Units.Count; i++)
                {
                    Border border = CreateUnit(Tile.Units[i]);
                    border.Margin = new Thickness(4);
                    height_count += border.Height + 8;
                    panel.Children.Add(border);
                }
                if (height_count > 100)
                {
                    double height = height_count - 100;
                    height         /= 2;
                    UnitGrid.Margin = new Thickness(0, -height, 0, 0);
                }
            }
        }