Example #1
0
        static void Main(string[] args)
        {
            // Create app
            MyApplication application = new MyApplication();

            // Create Services
            uint          width         = 1280;
            uint          height        = 720;
            WindowsSystem windowsSystem = CreateWindowSystem();

            application.Container.RegisterInstance(windowsSystem);
            var window = windowsSystem.CreateWindow("AreaLightsDemo", width, height);

            ConfigureGraphicsContext(application, window);

            AudioDevice audioDevice = CreateAudioDevice();

            application.Container.RegisterInstance(audioDevice);

            Stopwatch clockTimer = Stopwatch.StartNew();

            windowsSystem.Run(
                () =>
            {
                application.Initialize();
            },
                () =>
            {
                var gameTime = clockTimer.Elapsed;
                clockTimer.Restart();

                application.UpdateFrame(gameTime);
                application.DrawFrame(gameTime);
            });
        }
Example #2
0
        public override string execute()
        {
            string result = "";

            switch (this.getCommandType())
            {
            case (int)CommandType.ListProcesses:
                List <Process> processList = WindowsSystem.ListProcesses();

                processList.ForEach((process) => {
                    result += String.Format("{0} (hWnd: {1})", process.MainWindowTitle, process.MainWindowHandle) + Environment.NewLine;
                });

                break;

            case (int)CommandType.WindowScreenshot:
                if (this.getParams().Length == 0)
                {
                    throw new MissingCommandParameter();
                }

                List <string> files = WindowsSystem.WindowScreenshot(this.getParams()[0]);

                result += "--------------------------" + Environment.NewLine;
                result += String.Format("Screenshot list of '{0}':", this.getParams()[0]) + Environment.NewLine;

                files.ForEach((file) => {
                    result += "- " + file + Environment.NewLine;
                });

                // Check if needed to send them in email
                if (this.getParams().Length > 1)
                {
                    Mail mail = new Mail(MailService.smtpMail, result, String.Format("Screenshots of '{0}'", this.getParams()[0]));
                    mail.addAttachment(files);
                    MailService.Send(mail);
                    result += String.Format("******* Screenshots emailed to {0}*******{1}", MailService.smtpMail, Environment.NewLine);
                }

                result += "--------------------------" + Environment.NewLine;

                break;

            case (int)CommandType.SendEmail:
                MailService.Send(new Mail(MailService.smtpMail, "Holaaaa"));
                result = "Mail sent to " + MailService.smtpMail;
                break;

            case (int)CommandType.ClearScreenshots:
                WindowsSystem.ClearScreenshotFolder();
                result = "Screenshots folder cleared successfuly";
                break;

            default:
                result = "Invalid command, please try again";
                break;
            }

            return(result);
        }
Example #3
0
    private void Update()
    {
        Vector3    point = new Vector3(camera.pixelWidth / 2, camera.pixelHeight / 2, 0);
        Ray        ray   = camera.ScreenPointToRay(point);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.gameObject.tag == "Button")
            {
                IPushContinous btn = hit.transform.gameObject.GetComponent <IPushContinous>();
                if (btn != null)
                {
                    if (Input.GetMouseButton(0))
                    {
                        btn.PushContin();
                    }
                }
                else
                {
                    IControllButton controllBtn = hit.transform.gameObject.GetComponent <IControllButton>();

                    if (WindowsSystem.Do().GetShortShowDescriptionFlag() == false)
                    {
                        WindowsSystem.Do().EnableDescriptionWindow();
                        WindowsSystem.Do().SetDescription(controllBtn.GetDescription());
                    }
                    if (Input.GetMouseButtonDown(0))
                    {
                        controllBtn.Push();
                    }
                }
            }
            else
            {
                WindowsSystem.Do().DisableDescriptionWindow();
                WindowsSystem.Do().SetDescription(" ");
            }
            IDescripted description = hit.transform.gameObject.GetComponent <IDescripted>();
            if (description != null)
            {
                if (WindowsSystem.Do().GetShortShowDescriptionFlag() == false)
                {
                    WindowsSystem.Do().EnableDescriptionWindow();
                    WindowsSystem.Do().SetDescription(description.GetDescription());
                }
            }
        }
    }
Example #4
0
    private void Start()
    {
        winSystem = GetComponent <WindowsSystem>();

        descriptionWindow = new DescriptionWindow(descriptionObj);
        helpWindow        = new HelpWindow(helpObj);
        helloWindow       = new HelloWindow(helloObj);
        chooseModeWindow  = new ChooseModeWindow(chooseModeObj);
        parametrsWindow   = new ParametrsWindow(parametrsWindowObj, velocityText, heightText, psiText);

        heliMovement = GetComponent <SimulateHeliMovement>();
        heliMovement.RegisterObserver(this);

        DisableDescriptionWindow();
        DisableHelpWindow();
        DisableChooseModeWindow();
        EnableHelloWindow();
        DisableParametrsWindow();
    }
Example #5
0
 public override void On()
 {
     if (ControllPanel().Do().GetRadiostation().GetType() == typeof(UKV2Radiostation))
     {
         if (isOn == false)
         {
             WindowsSystem.Do().ShowShortDecription("Подавитель шумов УКВ-2 радиостанции включен");
             isOn = true;
         }
         else if (isOn)
         {
             WindowsSystem.Do().ShowShortDecription("Подавитель шумов УКВ-2 радиостанции выключен");
             isOn = false;
         }
     }
     else
     {
         WindowsSystem.Do().ShowShortDecription("Подавитель шумов не включен.Радиостанция работает в другом режиме");
     }
     PlayAnimation();
 }
Example #6
0
        public static void Run(ConfigApp config)
        {
            so = new WindowsSystem();

            List <string> listaCores = new List <string>();

            listaCores.AddRange(config.ListOfColors);
            if (listaCores.Contains(config.ForegroundColor))
            {
                Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), NormalizeColorString(config.ForegroundColor));
            }

            so.UserName = Environment.UserName;
            if (Environment.Is64BitOperatingSystem)
            {
                so.OSType = "OS_Arch: 64-Bit";
            }
            else
            {
                so.OSType = "OS_Arch 32-Bit";
            }
            so.Hd             = HardDiskInfo.getHd();
            so.Host           = "Host: " + Environment.MachineName;
            so.RamMaximum     = HardwareInfo.getTotalRam();
            so.RamConsumed    = HardwareInfo.getUsageRam();
            so.Resolution     = ResolutionInfo.getResolution();
            so.SystemNome     = OSInfo.GetName();
            so.CPUInfo        = HardwareInfo.getCPU();
            so.GPUInfo        = HardwareInfo.getGPU();
            so.PCManufacturer = OSInfo.GetManufacturer();
            so.Build          = OSInfo.GetBuild();
            so.Uptime         = "Uptime: " + OSInfo.GetUptime();

            Console.Write(so);
            ConsoleWorker.WriteAll(so.ArrayTheProprierties());
            Console.ForegroundColor = ConsoleColor.White;
        }
Example #7
0
 public override void ShowCurrentMode()
 {
     WindowsSystem.Do().ShowShortDecription("Режим нижней ручки сдвоенного поворотного переключателя установлен в: " + SecondControllPanel.Do().GetListenMode().GetDescription());
 }
Example #8
0
 public override void On()
 {
     WindowsSystem.Do().ShowShortDecription("Радиостанция переключена в режим УКВ-2");
     ControllPanel().Do().SetRadiostation(new UKV2Radiostation());
     PlayAnimation();
 }
        public override void Start()
        {
            UI  ui      = Context.GetSubsystem <UI>();
            var uiStyle = Context.Cache.GetResource <XMLFile>("UI/DefaultStyle.xml");

            ui.Root.SetDefaultStyle(uiStyle);

            ui.Cursor = new Cursor(Context);
            ui.Cursor.SetDefaultStyle(uiStyle);

            var text = new Text(Context);

            text.SetText("test");
            ui.Root.AddChild(text);

            // Viewport
            _scene      = new Scene(Context);
            _scene.Name = "_scene";
            //_scene.LoadFile("Test/Scenes/ThreeScene.xml");
            _scene.CreateComponent <PhysicsWorld>();
            _scene.CreateComponent <Octree>();
            var zone = _scene.CreateComponent <Zone>();

            zone.SetBoundingBox(new BoundingBox(-30, 3200));
            zone.FogStart = 200f;
            zone.FogEnd   = 300f;
            var _c = new Color(43 / 255f, 43 / 255f, 43 / 255f, 0.7f);

            //zone.AmbientColor = _c;
            zone.FogColor = _c;

            _light = _scene.CreateChild("DirectionalLight");
            _light.SetWorldPosition(new Vector3(0, 10, -10));
            _light.SetDirection(new Vector3(-2, -2, 1));
            var light = _light.CreateComponent <Light>();

            light.Color         = Color.White;
            light.CastShadows   = true;
            light.ShadowCascade = new CascadeParameters(50, 0, 0, 0, 0.9f);
            //_light.Brightness = 1;
            light.SetLightMode(LightMode.LmRealtime);
            light.LightType = LightType.LightDirectional;

            #region Character

            /*
             * var character = _scene.CreateChild("character");
             * _body = character.CreateComponent<RigidBody>();
             * _body.CollisionLayer = 1u;
             * _body.SetKinematic(true);
             * _body.SetTrigger(true);
             * _body.SetAngularFactor(Vector3.Zero);
             * _body.CollisionEventMode = CollisionEventMode.CollisionAlways;
             *
             * _shape = character.CreateComponent<CollisionShape>();
             * _shape.SetCapsule(0.7f, 1.8f, new Vector3(0.0f, 0.9f, 0.0f));
             *
             * _characterController = character.CreateComponent<KinematicCharacterController>();
             */
            #endregion

            _cameraRoot          = _scene.CreateChild("Camera Pivot", CreateMode.Replicated);
            _cameraRoot.Position = new Vector3(0, 0, 0);
            _camera          = _cameraRoot.CreateChild("Main Camera", CreateMode.Replicated);
            _camera.Position = StartPositionCamera;
            //_camera.LookAt(new Vector3(6, 0, 6), Vector3.Up);
            _viewport                 = new Viewport(Context);
            _viewport.Scene           = _scene;
            _viewport.Camera          = (Camera)_camera.GetOrCreateComponent((StringHash)typeof(Camera).Name);
            _viewport.Camera.FarClip  = 350f;
            _viewport.Camera.Fov      = 45f;
            _viewport.Camera.NearClip = 0.01f;

            Context.Renderer.SetViewport(0, _viewport);

            #region WindowsSystem
            stateSystem = new StateMachineSystem();
            windows     = new WindowsSystem(this);
            #endregion

            #region Mouse
            Context.Input.SetMouseVisible(true);
            Context.Input.SetMouseGrabbed(false);
            Context.Input.SetMouseMode(MouseMode.MmFree);
            Context.Input.SetMousePosition(new IntVector2(Context.Graphics.Width / 2, Context.Graphics.Height / 2));
            //Context.Input.SetMouseMode(MouseMode.MmRelative, false);
            #endregion

            _debugHud      = Context.Engine.CreateDebugHud();
            _debugHud.Mode = DebugHudMode.DebughudShowAll;

            windows.SetCamera(_camera, _viewport.Camera);


            #region InitMap
            LogInfo("Dirs:");
            foreach (string d in Context.Cache.ResourceDirs)
            {
                LogInfo(string.Format("Dir: {0}", d));
            }

            var _platforms = new Platforms(EnumPlatform.PC);
            _ufs = new UniversalFileSystem(_platforms, this);

            //_material = Context.Cache.GetResource<Material>("n_sector/materials/m_blocks.xml", true);
            //_material.Name = "blocks";

            int blockID = 7;
            LogInfo($"blockID:{blockID}, value:{blockID % 16}");
            //CreateStaticModelBlock(_model, vertexData, indexData, _material, blockID, new BoundingBox(-0.5f, 0.5f));
            //var sb = Dump(_scene); LogInfo(sb.ToString());
            #endregion

            _debugRenderer = _scene.CreateComponent <DebugRenderer>();

            stateSystem.onSpaceKeyChangeState += OnChangeSpaceKeyState;

            level = new Level("level1", 10, 10);

            gridNode     = _scene.CreateChild("grid");
            gridMaterial = GetCache().GetResource <Material>("UI/Materials/Grid.xml");
            //gridMaterial.FillMode = FillMode.FillWireframe;

            int[] id =
            {
                0, 1, 2,
                3, 4, 5
            };

            float[] vd =
            {
                //front
                0.0f,  0.0f,  0.0f, 0.0f, 0.0f, 1.0f,  0, 10,      //0
                0.0f,  0.0f, 10.0f, 0.0f, 0.0f, 1.0f,  0, 0,       //1
                10.0f, 0.0f, 10.0f, 0.0f, 0.0f, 1.0f, 10, 0,       //2

                10.0f, 0.0f, 10.0f, 0.0f, 0.0f, 1.0f, 10, 0,       //2
                10.0f, 0.0f,  0.0f, 0.0f, 0.0f, 1.0f, 10, 10,      //3
                0.0f,  0.0f,  0.0f, 0.0f, 0.0f, 1.0f,  0, 10,      //0
            };

            var model       = CreateModel(vd, id, new BoundingBox(0, 10));
            var staticModel = CreateStaticModel(gridNode, model, gridMaterial);


            #region Update
            SubscribeToEvent(E.Update, args =>
            {
                var timestep = args[E.Update.TimeStep].Float;
                Debug.Assert(this != null);

                int xx = (int)_camera.Position.X / 16;
                int yy = (int)_camera.Position.Z / 16;

                if (Context.Input.GetKeyDown(Key.KeyEscape))
                {
                    Context.Engine.Exit();
                }

                //ShowGrid();
                ShowMenu();

                if (isShowing)
                {
                    if (ImGui.Begin("Urho3D.NET"))
                    {
                        ImGui.TextColored(Color.White,
                                          $"chunk:{xx}_{yy}\n" +
                                          $"pos:{_camera.Position.X},{_camera.Position.Y},{_camera.Position.Z}\n" +
                                          $"rotXYZ:{_camera.Rotation.EulerAngles.X},{_camera.Rotation.EulerAngles.Y},{_camera.Rotation.EulerAngles.Z}\n" +
                                          $"pos:{ui.CursorPosition.X},{ui.CursorPosition.Y}\n" +
                                          $"Frame time: {timestep}, \n");
                        if (ImGui.Button("Exit"))
                        {
                            Context.Engine.Exit();
                        }
                    }
                    ImGui.End();
                }

                var isMoving = false;
                if (Context.Input.GetMouseButtonDown(MouseButton.MousebRight))
                {
                    if (!isMoving)
                    {
                        Context.Input.SetMouseVisible(false);
                        Context.Input.SetMouseGrabbed(true);
                        Context.Input.SetMouseMode(MouseMode.MmRelative, true);
                        angleX = _camera.Rotation.EulerAngles.X;
                        angleY = _camera.Rotation.EulerAngles.Y;
                    }
                    isMoving = true;
                }

                if (isMoving)
                {
                    var scaleSpeed     = 20f;
                    var mouseSensivity = 20f;

                    Vector3 moveDirection = Vector3.Zero;
                    float moveX           = 0;
                    float moveY           = 0;

                    if (Context.Input.GetKeyDown(Key.KeyW))
                    {
                        moveY = 1;
                    }

                    if (Context.Input.GetKeyDown(Key.KeyS))
                    {
                        moveY = -1;
                    }

                    if (Context.Input.GetKeyDown(Key.KeyA))
                    {
                        moveX = -1;
                    }

                    if (Context.Input.GetKeyDown(Key.KeyD))
                    {
                        moveX = 1;
                    }

                    moveDirection =
                        moveX * scaleSpeed * _camera.Right * timestep +
                        moveY * scaleSpeed * _camera.Direction * timestep;
                    _camera.Position += moveDirection;

                    IntVector2 vec = Context.Input.MouseMove;
                    if (timestep > 0.01f)
                    {
                        timestep = 0.01f;
                    }
                    angleY          += vec.X * mouseSensivity * timestep;
                    angleX          += vec.Y * mouseSensivity * timestep;
                    _camera.Rotation = new Quaternion(new Vector3(angleX, angleY, 0));
                    /**/
                }
                else
                {
                    if (Context.Input.IsMouseGrabbed())
                    {
                        Context.Input.SetMouseGrabbed(false);
                        Context.Input.SetMouseVisible(true);
                        Context.Input.SetMouseMode(MouseMode.MmFree);
                    }
                }

                windows.InputUpdate(timestep);
            });
            #endregion
        }

        private void OnChangeSpaceKeyState(bool value)
        {
            if (value)
            {
                isShowing = !isShowing;
            }
        }

        private void ShowMenu()
        {
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Open", "Ctrl+O")) /* Do stuff */ } {
                    if (ImGui.MenuItem("Save", "Ctrl+S"))   /* Do stuff */
                    {
                    }
                    if (ImGui.MenuItem("Close", "Ctrl+W"))
                    {
                        isShowing = false;
                    }
                    ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Create"))
            {
                if (ImGui.MenuItem("Terrain", "Ctrl+T"))
                {
                    //
                }
                ImGui.EndMenu();
            }
            ImGui.EndMenuBar();
        }
    }
Example #10
0
 public override void ShowCurrentMode()
 {
     WindowsSystem.Do().ShowShortDecription("Значение нижней ручки сдвоенного поворотного переключателя установлено в: " + SecondControllPanel.Do().GetSpuValue());
 }
Example #11
0
 public override void On()
 {
     base.On();
     WindowsSystem.Do().EnableChooseModeWindow();
 }
Example #12
0
 public override void Off()
 {
     base.Off();
     WindowsSystem.Do().DisableChooseModeWindow();
 }