コード例 #1
0
        public CanvasTestWindow()
        {
            InitializeComponent();
            UnitListView units  = new UnitListView();
            UnitListView units2 = new UnitListView();

            Canvas.SetLeft(units, 20);
            Canvas.SetTop(units, 20);
            canvas.Children.Add(units);
            Canvas.SetLeft(units2, 700);
            Canvas.SetTop(units2, 20);
            canvas.Children.Add(units2);
            // adding elements
            units.AddUnit(new Spaceship(new Gros_Tas(null, null), null));
        }
コード例 #2
0
        private void DrawUI()
        {
            _scrollPanel.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
            Brush aRGBcolor = new SolidColorBrush(Color.FromArgb(50, 50, 100, 150));

            _bottomLeft = new Grid()
            {
                Height     = 246,
                Width      = 327,
                Background = aRGBcolor,
            };
            _bottomCenter = new Grid()
            {
                Height     = 246,
                Width      = 1195,
                Background = aRGBcolor,
            };
            _bottomRight = new Grid()
            {
                Height     = 246,
                Width      = 400,
                Background = aRGBcolor,
            };
            _unitList = new UnitListView();
            _bottomRight.Children.Add(_unitList);

            Border background = new Border()
            {
                BorderBrush     = Brushes.Black,
                BorderThickness = new Thickness(2)
            };
            Border background2 = new Border()
            {
                BorderBrush     = Brushes.Black,
                BorderThickness = new Thickness(2)
            };
            Border background3 = new Border()
            {
                BorderBrush     = Brushes.Black,
                BorderThickness = new Thickness(2)
            };

            _bottomLeft.Children.Add(background);
            _bottomCenter.Children.Add(background2);
            _bottomRight.Children.Add(background3);

            Rectangle timeZoneContainer = new Rectangle()
            {
                Stroke = Brushes.Black,
                Fill   = Brushes.DarkOrange,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Height = 50,
                Width  = 100,
            };
            Label timer = new Label()
            {
                Content    = "00 : 00",
                Background = Brushes.Transparent,
            };
            Image timePNG = new Image()
            {
                Source = new BitmapImage(_unitsFileLoader.GetUri("time.png")),
                Height = 28,
                Width  = 16,
            };
            Canvas timeZone = new Canvas()
            {
                Margin = new Thickness(20),
            };

            Canvas.SetTop(timeZoneContainer, 0);
            Canvas.SetLeft(timeZoneContainer, 0);
            Canvas.SetZIndex(timeZoneContainer, 0);
            Canvas.SetTop(timePNG, 5);
            Canvas.SetLeft(timePNG, 5);
            Canvas.SetZIndex(timePNG, 1);
            Canvas.SetTop(timer, 5);
            Canvas.SetLeft(timer, 20);
            Canvas.SetZIndex(timer, 1);
            timeZone.Children.Add(timeZoneContainer);
            timeZone.Children.Add(timePNG);
            timeZone.Children.Add(timer);
            _bottomLeft.Children.Add(timeZone);

            _bottomCenter.Children.Add(new GameStatsDisplay(_player));

            ToolBarTray toolBarTray = new ToolBarTray()
            {
                Background = Brushes.Transparent,
            };
            Border toolBarBorder = new Border()
            {
                BorderThickness = new Thickness(0),
            };
            ToolBar toolBar = new ToolBar();

            toolBar.Items.Add(toolBarBorder);
            Menu     menu     = new Menu();
            MenuItem menuItem = new MenuItem()
            {
                Header = "Options",
            };
            MenuItem menuItem1 = new MenuItem()
            {
                Header = "Quit",
            };

            menuItem1.Click += new RoutedEventHandler(BtnClose_Click);
            // build toolbar tray
            menuItem.Items.Add(menuItem1);
            menu.Items.Add(menuItem);
            toolBar.Items.Add(menu);
            toolBarTray.ToolBars.Add(toolBar);
            Canvas.SetZIndex(toolBarTray, 10);
            _uiCanvas.Children.Add(toolBarTray);

            Canvas.SetBottom(_consoleOutput, 10);
            Canvas.SetLeft(_consoleOutput, 50);
            Canvas.SetZIndex(_consoleOutput, 10);
            _bottomCenter.Children.Add(_consoleOutput);

            AddElements(_bottomLeft, _bottomCenter, _bottomRight);
            Binding binding = new Binding("Action");

            binding.Source = _player.Joueur;
            _consoleOutput.SetBinding(Label.ContentProperty, binding);

            _map.DrawMap(_mapCanvas, _hexagonsFileLoader.Uris);
            BuildReserve();
        }