Exemple #1
0
        public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode, DrawerSettings drawerSettings, Func <Form> formFactory)
        {
            FormDrawer    drawer        = CreateDrawer(videoMode, drawerSettings);
            DrawerControl drawerControl = null;
            var           localsync     = new ManualResetEventSlim();
            var           t             = new Thread(() =>
            {
                var form      = formFactory();
                drawerControl = new DrawerControl(drawer)
                {
                    Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom
                };
                form.Controls.Add(drawerControl);
                form.Shown += (o, e) => localsync.Set();
                Application.Run(form);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            localsync.Wait();
            if (drawer != null)
            {
                drawer.WaitForInitialization();
            }
            return(drawerControl);
        }
Exemple #2
0
        public KroRForm(IWorld world)
        {
            this.world=world;
            ClientSize = new System.Drawing.Size(800, 600);

            var font=new Font("Arial", 18);

            clocks=new Label();
            clocks.Size=new Size(100,50);
            clocks.Location=new Point(ClientSize.Width-clocks.Width,0);
            clocks.Font=font;
            clocks.BackColor=Color.White;
            Controls.Add(clocks);

            scores = new Label();
            scores.BackColor = Color.White;
            scores.Font = font;
            scores.Size = new Size(ClientSize.Width-clocks.Width, clocks.Height);
            scores.BringToFront();
            Controls.Add(scores);
            
            var engine = world.Engine as KroREngine;
            var control = new DrawerControl(new DirectXFormDrawer(engine.DrawerFactory.GetDirectXScene(), new DrawerSettings
            {
                ViewMode = ViewModes.FirstPerson,
                BodyCameraLocation = world.Configuration.Settings.ObserverCameraLocation,
                Robot = engine.Root
            }));



            control.Size = new Size(ClientSize.Width,ClientSize.Height-scores.Height);
            control.Location = new Point(0, scores.Height);
            Controls.Add(control);


            world.Scores.ScoresChanged += () => { Invoke(new Action(UpdateScores)); };
            world.Clocks.Ticked += () => { Invoke(new Action(UpdateClocks)); };
            world.Exit += () => worldExited = true;

            UpdateScores();
            thread= new Thread(()=>world.RunActively(1)) { IsBackground = true };
            thread.Start();

           

        }
Exemple #3
0
		public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode, DrawerSettings drawerSettings, Func<Form> formFactory)
		{
			FormDrawer drawer = CreateDrawer(videoMode, drawerSettings);
			DrawerControl drawerControl = null;
			var localsync = new ManualResetEventSlim();
			var t = new Thread(() =>
				{
					var form = formFactory();
					drawerControl = new DrawerControl(drawer)
						{
							Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom
						};
					form.Controls.Add(drawerControl);
					form.Shown += (o, e) => localsync.Set();
					Application.Run(form);
				});
			t.SetApartmentState(ApartmentState.STA);
			t.Start();
			localsync.Wait();
			if (drawer!=null)
				drawer.WaitForInitialization();
			return drawerControl;
		}