コード例 #1
0
        /*private void Timer_Tick(object sender, EventArgs e)
         * {
         *  bool called = false;
         *  if (DateTime.Now.Second==0 && !called)
         *  {
         *      CallSecondTick(DateTime.Now.Minute);
         *      called = true;
         *  }//ha gyorsabb a tick mint 1 mp akkor többször is meg hívódna mint kell
         *  if (called && DateTime.Now.Second == 10)
         *  {
         *      called = false;
         *  }
         * }*/

        private void CreateMainMenu()
        {
            Log.Message("Menü létrehozva.");
            gm      = null;
            ovm     = null;
            gevm    = null;
            spvm    = null;
            mpvm    = null;
            mmvm    = null;
            players = null;
            players = new List <Gamer>();
            mmvm    = new MainMenuViewModel();
            g.Children.Clear();
            //play gomb
            Button play = new Button();

            play.Margin   = new Thickness(0, -250, 0, 0);
            play.Height   = 50;
            play.Width    = 200;
            play.FontSize = 20;
            play.Content  = "Játék";
            play.Click   += Play_Click;
            //exit gomb
            Button exit = new Button();

            exit.Height   = 50;
            exit.Margin   = new Thickness(0, 100, 0, 0);
            exit.Width    = 200;
            exit.FontSize = 20;
            exit.Content  = "Kilépés";
            exit.Click   += Exit_Click;
            //options
            Button options = new Button();

            options.Height   = 50;
            options.Margin   = new Thickness(0, -10, 0, 0);
            options.Width    = 200;
            options.FontSize = 20;
            options.Content  = "Beállítások";
            options.Click   += Options_Click;
            //gamemode
            Label gml = new Label();

            gml.Height   = 30;
            gml.Width    = 100;
            gml.Content  = "Játékmód";
            gml.Margin   = new Thickness(0, -160, 0, 0);
            gml.FontSize = 15;
            //játékmód
            ComboBox cb = new ComboBox();

            cb.Height      = 30;
            cb.Width       = 200;
            cb.Margin      = new Thickness(0, -100, 0, 0);
            cb.BorderBrush = Brushes.Black;
            cb.FontSize    = 15;
            cb.SetBinding(ComboBox.SelectedItemProperty, new Binding("SelectedGamemode"));
            cb.SetBinding(ComboBox.ItemsSourceProperty, new Binding("GameModeList"));

            g.Children.Add(cb);
            g.Children.Add(gml);
            g.Children.Add(options);
            g.Children.Add(play);
            g.Children.Add(exit);

            DataContext = mmvm;
        }
コード例 #2
0
        private void Single_Click(object sender, RoutedEventArgs e)
        {
            Log.Message("Egyjátékos létrehozva");
            spvm = new SinglePlayerViewModel();
            g.Children.Clear();

            //play btn
            Button play = new Button();

            play.Height   = 50;
            play.Margin   = new Thickness(200, 270, 0, 0);
            play.Width    = 150;
            play.FontSize = 20;
            play.Content  = "Játék";
            play.Click   += Play_Click1;
            //menü btn
            Button menu = new Button();

            menu.Height   = 50;
            menu.Margin   = new Thickness(-200, 270, 0, 0);
            menu.Width    = 150;
            menu.FontSize = 20;
            menu.Content  = "Fő menü";
            menu.Click   += Back_Click;
            //név txt
            Label nam = new Label();

            nam.Foreground = Brushes.White;
            nam.Content    = "Név: ";
            nam.Height     = 40;
            nam.Width      = 50;
            nam.Margin     = new Thickness(-100, -500, 0, 0);
            nam.FontSize   = 20;
            //név box
            TextBox name = new TextBox();

            name.SetBinding(TextBox.TextProperty, "Name");
            name.Height   = 30;
            name.Width    = 200;
            name.Margin   = new Thickness(100, -450, 0, 0);
            name.FontSize = 20;
            //jobb-bal karakter váltás
            Button left  = new Button();
            Button right = new Button();

            left.Content  = "<";
            right.Content = ">";
            left.Margin   = new Thickness(-200, -200, 0, 0);
            right.Margin  = new Thickness(200, -200, 0, 0);
            left.Height   = 200;
            right.Height  = 200;
            left.Width    = 20;
            right.Width   = 20;
            right.Click  += spvm.Right;
            left.Click   += spvm.Left;
            //karakter képe
            Image   im = new Image();
            Binding b  = new Binding("Selected.Alak");

            b.Converter = (IValueConverter)FindResource("StringToImageConverter");
            im.SetBinding(Image.SourceProperty, b);
            im.Width  = 96;
            im.Height = 160;
            im.Margin = new Thickness(0, -200, 0, 0);
            /*statok kiírása*/
            //élet txt
            Label health = new Label();

            health.ContentStringFormat = "Élet: {0}";
            health.SetBinding(Label.ContentProperty, new Binding("Selected.Health"));
            health.Foreground = Brushes.White;
            health.Height     = 30;
            health.Width      = 100;
            health.Margin     = new Thickness(-100, 90, 0, 0);
            //sebesség txt
            Label speed = new Label();

            speed.SetBinding(Label.ContentProperty, new Binding("Selected.Speed"));
            speed.Foreground          = Brushes.White;
            speed.ContentStringFormat = "Sebesség: {0}";
            speed.Height = 30;
            speed.Width  = 100;
            speed.Margin = new Thickness(-100, 140, 0, 0);
            //ugrás magasság txt
            Label jump = new Label();

            jump.SetBinding(Label.ContentProperty, new Binding("Selected.JumpHeight"));
            jump.Foreground          = Brushes.White;
            jump.ContentStringFormat = "Ugrás magasság: {0}";
            jump.Height = 30;
            jump.Width  = 150;
            jump.Margin = new Thickness(-55, 190, 0, 0);

            g.Children.Add(menu);
            g.Children.Add(play);
            g.Children.Add(jump);
            g.Children.Add(speed);
            g.Children.Add(health);
            g.Children.Add(im);
            g.Children.Add(left);
            g.Children.Add(right);
            g.Children.Add(name);
            g.Children.Add(nam);
            DataContext = spvm;
        }