Example #1
0
        private async void SaveAction(object obj)
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
                var saved = await PerubahanService.AddItemAsync(Model);

                if (saved)
                {
                    Helpers.ShowMessage("Permohonan Perubahan Berhasil Dikirim");
                    ResetCommand.Execute(null);
                }
            }
            catch (Exception ex)
            {
                Helpers.ShowMessageError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #2
0
        private async void SaveAction(object obj)
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
                var saved = await PemasanganService.AddItemAsync(Model);

                if (saved)
                {
                    Helpers.ShowMessage("Permohonan Pemasangan Berhasil Dikirim");
                    ResetCommand.Execute(null);
                    var app = await Helpers.GetMainPageAsync();

                    if (app != null)
                    {
                        app.SetCurrenttarget("Pemasangan");
                    }
                }
            }
            catch (Exception ex)
            {
                Helpers.ShowMessageError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #3
0
        public override void Run(string[] args)
        {
            options = new CmdParserOptionSet()
            {
                { "h|help", "Display this help information. To see online help, use: git help <command>", v => OfflineHelp() },
                { "mixed", "Resets the index but not the working tree (i", v => cmd.Mixed = true },
                { "soft", "Does not touch the index file nor the working tree at all, but requires them to be in a good order", v => cmd.Soft = true },
                { "hard", "Matches the working tree and index to that of the tree being switched to", v => cmd.Hard = true },
                { "merge", "Resets the index to match the tree recorded by the named commit, and updates the files that are different between the named commit and the current commit in the working tree", v => cmd.Merge = true },
                { "p|patch", "Interactively select hunks in the difference between the index and <commit> (defaults to HEAD)", v => cmd.Patch = true },
                { "q", "Be quiet, only report errors", v => cmd.Q = true },
            };

            try
            {
                List <String> arguments = ParseOptions(args);
                if (arguments.Count > 0)
                {
                    cmd.Arguments = arguments;
                    cmd.Execute();
                }
                else
                {
                    OfflineHelp();
                }
            }
            catch (Exception e)
            {
                cmd.OutputStream.WriteLine(e.Message);
            }
        }
Example #4
0
        public void CallsReset()
        {
            var viewModel = Mock.Of <IViewModel>();
            var command   = new ResetCommand(viewModel);

            command.Execute(null);

            Mock.Get(viewModel).Verify(x => x.Reset());
        }
        public void AccountPasswordReset_Execute_ReturnsSuccessMessage()
        {
            var command = new ResetCommand(_console, LoggerMock.GetLogger <ResetCommand>().Object, _accountService.Object, _consoleReader.Object)
            {
                User = "******"
            };

            var resultMessage = command.Execute();

            Assert.Equal("Password for user [email protected] has been reset", resultMessage);
        }
Example #6
0
            public void CallsReplReset()
            {
                // arrange
                var repl = new Mock <IRepl>();

                var cmd = new ResetCommand();

                // act
                cmd.Execute(repl.Object, null);

                // assert
                repl.Verify(x => x.Reset(), Times.Once);
            }
Example #7
0
            public void CallsReplReset()
            {
                // arrange
                var executor = new Mock <IScriptExecutor>();

                var cmd = new ResetCommand();

                // act
                cmd.Execute(executor.Object, null);

                // assert
                executor.Verify(x => x.Reset(), Times.Once);
            }
        private void StartKinect(KinectSensor newSensor)
        {
            try
            {
                newSensor.ColorStream.Enable(DefaultColorImageFormat);
                newSensor.DepthStream.Enable(DefaultDepthImageFormat);
                try
                {
                    // This will throw on non Kinect For Windows devices.
                    newSensor.DepthStream.Range = DepthRange.Near;
                    newSensor.SkeletonStream.EnableTrackingInNearRange = true;
                }
                catch (InvalidOperationException)
                {
                    newSensor.DepthStream.Range = DepthRange.Default;
                    newSensor.SkeletonStream.EnableTrackingInNearRange = false;
                }

                newSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;

                var smoothParams = new TransformSmoothParameters()
                {
                    Smoothing          = 0.8f,
                    Correction         = 0.2f,
                    Prediction         = 0.5f,
                    JitterRadius       = 0.10f,
                    MaxDeviationRadius = 0.04f
                };

                newSensor.SkeletonStream.Enable(smoothParams);
                newSensor.AllFramesReady += KinectSensorOnAllFramesReady;

                _elevationAngle = newSensor.ElevationAngle;
                RaisePropertyChanged(ElevationAnglePropertyName);

                this.KinectSensor = newSensor;

                this.rawFrameCount = 0;

                //TODO cleanup old voice command
                _voiceCommand = new VoiceCommand(newSensor);
                _voiceCommand.IsListeningChanged += (s, e) =>
                {
                    this.IsListening = _voiceCommand.IsListening;
                    if (this.IsListening)
                    {
                        VoiceHeard = "Listening...";
                    }
                };
                _voiceCommand.FusionPause += (s, e) =>
                {
                    if (FusionManager.IsIntegrationPaused)
                    {
                        FusionManager.IsIntegrationPaused    = false;
                        FusionManager.RotationRateInDegrees  = 0;
                        FusionManager.CurrentRotationDegrees = 0;
                    }
                    else
                    {
                        FusionManager.IsIntegrationPaused   = true;
                        FusionManager.RotationRateInDegrees = 3;
                    }
                    VoiceHeard = "Heard: Fusion Pause";
                };
                _voiceCommand.FusionReset += (s, e) =>
                {
                    ResetCommand.Execute(null);
                    if (FusionManager != null)
                    {
                        FusionManager.IsIntegrationPaused   = false;
                        FusionManager.RotationRateInDegrees = 0;

                        FusionManager.CurrentRotationDegrees = 0;
                    }
                    VoiceHeard = "Heard: Fusion Reset";
                };
                _voiceCommand.FusionStart += (s, e) =>
                {
                    ResetCommand.Execute(null);
                    if (FusionManager != null)
                    {
                        FusionManager.IsIntegrationPaused   = false;
                        FusionManager.RotationRateInDegrees = 0;

                        FusionManager.CurrentRotationDegrees = 0;
                    }
                    VoiceHeard = "Heard: Fusion Start";
                };


                if (FusionManager != null)
                {
                    FusionManager.Dispose();
                    FusionManager = null;
                }

                FusionManager = new FusionManager(KinectSensor);
            }
            catch (InvalidOperationException)
            {
                // This exception can be thrown when we are trying to
                // enable streams on a device that has gone away.  This
                // can occur, say, in app shutdown scenarios when the sensor
                // goes away between the time it changed status and the
                // time we get the sensor changed notification.
                //
                // Behavior here is to just eat the exception and assume
                // another notification will come along if a sensor
                // comes back.
            }
        }
        public EntityCollectionFilterControl()
        {
            InitializeComponent();

            string constraintsFile = Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "Data",
                                                  "Properties.json");

            if (!File.Exists(constraintsFile))
            {
                return;
            }

            JsonSerializer serializer = new JsonSerializer();

            using (StreamReader sr = new StreamReader(constraintsFile))
            {
                using (JsonTextReader reader = new JsonTextReader(sr))
                {
                    PropertyEntry[] constraints = serializer.Deserialize <PropertyEntry[]>(reader);

                    foreach (PropertyEntry constraint in constraints)
                    {
                        Constraints.AddSorted(constraint);
                    }
                }
            }

            if (File.Exists(_propertiesFileCustom))
            {
                LoadCustomProperties();
            }

            if (File.Exists(Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory,
                                         "EntityViewer.json")))
            {
                try
                {
                    serializer = new JsonSerializer();

                    using (JsonTextReader jtr = new JsonTextReader(new StreamReader(
                                                                       Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "EntityViewer.json"))))
                    {
                        EntityCollectionFilter[] entries = serializer.Deserialize <EntityCollectionFilter[]>(jtr);

                        if (entries != null && entries.Length > 0)
                        {
                            ResetCommand?.Execute(null);
                            Items.Clear();

                            foreach (EntityCollectionFilter entry in entries)
                            {
                                PropertyEntry constraint =
                                    Constraints.FirstOrDefault(c => c.Name == entry.Constraint.Name);

                                if (constraint != null)
                                {
                                    Items.Add(new EntityCollectionFilter
                                    {
                                        Constraint = constraint, Operator = entry.Operator, Value = entry.Value
                                    });
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, Strings.Error);
                }
            }
            else
            {
                Items.Add(new EntityCollectionFilter {
                    Constraint = Constraints.FirstOrDefault()
                });
            }
        }
 public void OnDialogOpen()
 {
     ResetCommand.Execute(null);
 }
Example #11
0
        public void Update(GameTime gameTime)
        {
            if (health <= 0)
            {
                direction = Dir.Dead;
            }

            if (Blocks.Blocks.inwater(position, length, width))
            {
                speed = 50;
            }
            else
            {
                speed = 200;
            }
            stateMachine.Update(gameTime);
            direction = stateMachine.getDirection();
            anim      = facing[direction];
            if (stateMachine.ifIsMoving() || stateMachine.ifIsSwording())
            {
                anim.Update(gameTime);
            }
            else
            {
                anim.setFrame(1);
            }
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (healthTimer > 0)
            {
                healthTimer -= dt;
                ColorTimer  -= dt;
            }
            if (ColorTimer > 0)
            {
                ColorTimer -= dt;
            }
            if (stateMachine.ifIsMoving())
            {
                Vector2 tempPos = position;
                tempPos.X = position.X + 20;
                tempPos.Y = position.Y + 10;
                switch (direction)
                {
                case Dir.Right:
                    tempPos.X += speed * dt;
                    if (!Blocks.Blocks.didCollide(tempPos, length, width))
                    {
                        position.X += speed * dt;
                    }

                    break;

                case Dir.Left:
                    tempPos.X -= speed * dt;
                    if (!Blocks.Blocks.didCollide(tempPos, length, width))
                    {
                        position.X -= speed * dt;
                    }

                    break;

                case Dir.Up:
                    tempPos.Y -= speed * dt;
                    if (!Blocks.Blocks.didCollide(tempPos, length, width))
                    {
                        position.Y -= speed * dt;
                    }

                    break;

                case Dir.Down:
                    tempPos.Y += speed * dt;
                    if (!Blocks.Blocks.didCollide(tempPos, length, width))
                    {
                        position.Y += speed * dt;
                    }

                    break;

                default:
                    break;
                }
            }



            KeyboardState kState = Keyboard.GetState();

            if (kState.IsKeyDown(Keys.D1) && previous.IsKeyUp(Keys.D1))
            {
                BombProj.bomb.Add(new BombProj(position));
            }
            if (kState.IsKeyDown(Keys.D2) && previous.IsKeyUp(Keys.D2))
            {
                if (direction == Dir.Down)
                {
                    ArrowProj.arrowDown.Add(new ArrowProj(position, direction));
                }
                if (direction == Dir.Up)
                {
                    ArrowProj.arrowUp.Add(new ArrowProj(position, direction));
                }
                if (direction == Dir.Left)
                {
                    ArrowProj.arrowLeft.Add(new ArrowProj(position, direction));
                }
                if (direction == Dir.Right)
                {
                    ArrowProj.arrowRight.Add(new ArrowProj(position, direction));
                }
            }
            if (kState.IsKeyDown(Keys.D3) && previous.IsKeyUp(Keys.D3))
            {
                BoomerangProj.boomerang.Add(new BoomerangProj(position, direction));
            }

            if (kState.IsKeyDown(Keys.F) && previous.IsKeyUp(Keys.F))
            {
                camMoveUp.Execute();
            }
            if (kState.IsKeyDown(Keys.V) && previous.IsKeyUp(Keys.V))
            {
                camMoveDown.Execute();
            }
            if (kState.IsKeyDown(Keys.C) && previous.IsKeyUp(Keys.C))
            {
                camMoveLeft.Execute();
            }
            if (kState.IsKeyDown(Keys.B) && previous.IsKeyUp(Keys.B))
            {
                camMoveRight.Execute();
            }
            previous = kState;
            if (kState.IsKeyDown(Keys.Q))
            {
                exit.Execute();
            }
            if (kState.IsKeyDown(Keys.R))
            {
                reset.Execute();
            }
            if (kState.IsKeyDown(Keys.P))
            {
                MediaPlayer.Pause();
            }
            if (kState.IsKeyDown(Keys.O))
            {
                MediaPlayer.Resume();
            }
        }