示例#1
0
        /// <summary>
        /// Advances the algorithm and updates the current step property.
        /// </summary>
        public void AdvanceAlgorithm()
        {
            if (!timerStarted)
            {
                timerStarted = true;
                Timer.initTimer(1000, OnTimerElapsed, true);
                Timer.startTimer();
            }

            if (CurrentPosition.Equals(Algorithm.FirstStep))
            {
                if (CurrentPosition.NextStep.RythmStyle == RythmStyle.Shockable)
                {
                    History.AddItem("Rytme vurderet - Stødbar");
                }
                else
                {
                    History.AddItem("Rytme vurderet - Ikke-Stødbar");
                }
            }
            else
            {
                History.AddItem(CurrentPosition.Name);
            }

            Algorithm.AdvanceOneStep();
            CurrentPosition = Algorithm.CurrentStep;
        }
示例#2
0
        public void LoadDir(string dir, bool saveInHistory)
        {
            //loading files into second column
            FileSystem.LoadDirectory(dir);
            dirChanged = true;

            //loading files into first column
            lbContent1.ItemsSource = null;//clear items
            if (!FileSystem.IsRootPath(FileSystem.CurrentPlace.FullName))
            {
                fileSystem1.LoadDirectory(PathExt.GetDirectoryName(FileSystem.CurrentPlace.FullName, FileSystem.IsWindowsFileSystem));
                lbContent1.ItemsSource = fileSystem1.Items;
            }

            //save in history
            if (saveInHistory)
            {
                HistoryGlobal.AddItem(FileSystem.CurrentPlace);
                history.AddItem(FileSystem.CurrentPlace, false);
            }
        }
示例#3
0
        public void LoadDir(string dir, bool saveInHistory)
        {
            FileSystem.LoadDirectory(dir);
            dirChanged = true;

            //save in history
            if (saveInHistory)
            {
                HistoryGlobal.AddItem(FileSystem.CurrentPlace);
                History.AddItem(FileSystem.CurrentPlace, false);
            }
        }
示例#4
0
        public void ChangeFileSystem(FileSystem.FileSystemBase fileSystem)
        {
            FileSystem = fileSystem;

            //set up binding
            Binding bind = new Binding("Items");

            bind.Source = FileSystem;
            lbContent.SetBinding(ListBox.ItemsSourceProperty, bind);

            //save in history
            HistoryGlobal.AddItem(FileSystem.CurrentPlace);
            History.AddItem(FileSystem.CurrentPlace, false);

            dirChanged = true;
            SetFocusOnContent();
            OnPropertyChanged("FileSystem");
        }
示例#5
0
        public void LoadDirectory(string dir, bool moveUp = false, bool saveInHistory = true)
        {
            fileSystemWatcher.EnableRaisingEvents = false;
            var lastPlace = FileSystem.CurrentPlace;

            FileSystem.LoadDirectory(dir);
            Items          = FileSystem.Items.OrderByDescending(x => x.IsMoveUp || x.IsDirectory).ToArray();
            DirectoryName  = FileSystem.DirectoryName;
            FullPath       = FileSystem.FullPath;
            IsFavoritePath = PathsManager.Favorites.Contains(FileSystem.CurrentPlace);
            SelectedItem   = moveUp ? Items.First(x => x.FullName == lastPlace.FullName) : GetItemToSelect();

            if (FileSystem.IsWindowsFileSystem)
            {
                fileSystemWatcher.Path = dir;
                fileSystemWatcher.EnableRaisingEvents = true;
            }

            if (saveInHistory)
            {
                HistoryGlobal.AddItem(FileSystem.CurrentPlace);
                History.AddItem(FileSystem.CurrentPlace, false);
            }
        }
示例#6
0
        /// <summary>
        /// TimerElapsed event handler.
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Arguments</param>
        private void OnTimerElapsed(object sender, EventArgs e)
        {
            // Update Total Time
            TotalTime = TimeSpan.FromSeconds(DateTime.Now.Subtract(Algorithm.StartTime.Value).TotalSeconds);

            // Update Step Time
            if (CurrentPosition.GetType().Equals(typeof(AssessmentStep)))
            {
                Algorithm.StepTime = TimeSpan.FromMinutes(2);
                StepTime           = Algorithm.StepTime;
            }
            else if (CurrentPosition.Name == "HLR 2 Minutter" || CurrentPosition.Name == "Fortsæt HLR" ||
                     CurrentPosition.Description == "Fortsæt HLR")
            {
                if (Algorithm.StepTime.TotalSeconds > 0)
                {
                    Algorithm.StepTime = Algorithm.StepTime.Subtract(TimeSpan.FromSeconds(1));
                    StepTime           = Algorithm.StepTime;

                    if (StepTime.TotalSeconds < 21)
                    {
                        CrossVibrate.Current.Vibration(TimeSpan.FromSeconds(0.25));

                        if (Mode == InteractionMode.Sound)
                        {
                            // Play Sound
                            DependencyService.Get <IAudio>().PlayMp3File(2);
                        }
                    }
                }
            }

            // Update Cycles
            Cycles = Algorithm.Cycles;

            // Update Drug Queue
            ObservableCollection <DrugShot> list = new ObservableCollection <DrugShot>();

            foreach (DrugShot shot in DoseQueue)
            {
                if (Cycles == 0 && CurrentPosition.NextStep.RythmStyle == RythmStyle.NonShockable &&
                    shot.Drug.DrugType == DrugType.Adrenalin && shot.TimeRemaining.TotalMinutes > TimeSpan.FromMinutes(2).TotalMinutes)
                {
                    shot.TimeRemaining = TimeSpan.FromMinutes(2);
                }

                if (shot.TimeRemaining.TotalSeconds > 0)
                {
                    shot.TimeRemaining = shot.TimeRemaining.Subtract(TimeSpan.FromSeconds(1));
                }

                if (shot.Injected)
                {
                    shot.ShotAddressed();
                    History.AddItem(shot.DrugDoseString);
                    Algorithm.RemoveDrugsFromQueue(DoseQueue);
                }

                list.Add(shot);
            }

            DoseQueue.Clear();

            foreach (var item in list)
            {
                DoseQueue.Add(item);

                // Notify when we change from 'prep' drug to 'give' drug
                if (item.TimeRemaining.TotalSeconds == 120)
                {
                    CrossVibrate.Current.Vibration(TimeSpan.FromSeconds(0.25));

                    if (Mode == InteractionMode.Sound)
                    {
                        // Play Sound
                        DependencyService.Get <IAudio>().PlayMp3File(1);
                    }
                }

                // Notify constantly when drug timer is nearly done
                if (item.TimeRemaining.TotalSeconds < 16)
                {
                    CrossVibrate.Current.Vibration(TimeSpan.FromSeconds(0.25));

                    if (Mode == InteractionMode.Sound)
                    {
                        // Play Sound
                        DependencyService.Get <IAudio>().PlayMp3File(2);
                    }
                }
            }
        }
示例#7
0
        public override void Update(GameTime gameTime)
        {
            MouseState mstate = Mouse.GetState();

            if (selectedPlayerBtn != null)
            {
                string debug = " mode: ";
                selectedPlayerBtn.Update(gameTime, debug);
            }

            if (selectedUnitsBtn != null)
            {
                string debugTwo = "Nearest GridPoint: " + camera.GetNearestGrid32(camera.GetMapCords(), 32);
                selectedUnitsBtn.Update(gameTime, debugTwo);
            }

            if (pointer != null)
            {
                pointer.Position = camera.GetNearestGrid32(camera.GetMapCords(), 32);
                pointer.Update(gameTime, "A");
            }

            if (undoBtn != null)
            {
                undoBtn.Update(gameTime, "");

                if (!undoIsHeld && undoBtn.Clicked && mstate.LeftButton == ButtonState.Pressed)
                {
                    undoIsHeld = true;
                }

                if (undoIsHeld)
                {
                    if (mstate.LeftButton == ButtonState.Released)
                    {
                        history.Undo();
                        undoIsHeld = false;
                    }
                }
            }

            if (redoBtn != null)
            {
                redoBtn.Update(gameTime, "");

                if (!redoIsHeld && redoBtn.Clicked && mstate.LeftButton == ButtonState.Pressed)
                {
                    redoIsHeld = true;
                }

                if (redoIsHeld)
                {
                    if (mstate.LeftButton == ButtonState.Released)
                    {
                        history.Redo();
                        redoIsHeld = false;
                    }
                }
            }

            if (saveBtn != null)
            {
                saveBtn.Update(gameTime, "");

                if (!saveIsHeld && saveBtn.Clicked && mstate.LeftButton == ButtonState.Pressed)
                {
                    saveIsHeld = true;
                }

                if (saveIsHeld)
                {
                    if (mstate.LeftButton == ButtonState.Released)
                    {
                        history.Save("a");
                        saveIsHeld = false;
                    }
                }
            }

            if (loadBtn != null)
            {
                loadBtn.Update(gameTime, "");

                if (!loadIsHeld && loadBtn.Clicked && mstate.LeftButton == ButtonState.Pressed)
                {
                    loadIsHeld = true;
                }

                if (loadIsHeld)
                {
                    if (mstate.LeftButton == ButtonState.Released)
                    {
                        history.Load("a");
                        loadIsHeld = false;
                    }
                }
            }

            if (peopleModeBtn != null)
            {
                if (peopleModeBtn.Clicked && Mouse.GetState().LeftButton == ButtonState.Released)
                {
                    buildingModeActive = false;
                    peopleModeActive   = !peopleModeActive;
                }
                peopleModeBtn.Update(gameTime, "");
            }

            if (buildingModeBtn != null)
            {
                if (buildingModeBtn.Clicked && Mouse.GetState().LeftButton == ButtonState.Released)
                {
                    peopleModeActive   = false;
                    buildingModeActive = !buildingModeActive;
                }
                buildingModeBtn.Update(gameTime, "");
            }

            if (peopleModeActive)
            {
                foreach (var aiUnit in unitController.AiUnits)
                {
                    aiUnit.Selected = false;
                }

                camera.SelectionSwitch = false;

                mousePosition = camera.GetNearestGrid32(camera.GetMapCords(), 32);

                bool uiCollision = false;

                foreach (var peopleBtn in peopleBtns)
                {
                    if (peopleBtn.GetArea().Contains(mstate.Position))
                    {
                        uiCollision = true;
                        break;
                    }

                    if (undoBtn.GetArea().Contains(mstate.Position))
                    {
                        uiCollision = true;
                        break;
                    }

                    if (redoBtn.GetArea().Contains(mstate.Position))
                    {
                        uiCollision = true;
                        break;
                    }

                    if (saveBtn.GetArea().Contains(mstate.Position))
                    {
                        uiCollision = true;
                        break;
                    }

                    if (loadBtn.GetArea().Contains(mstate.Position))
                    {
                        uiCollision = true;
                        break;
                    }
                }

                foreach (var peopleBtn in peopleBtns)
                {
                    if (peopleBtn.Clicked && !buttonHeld)
                    {
                        currentPeopleBtn = peopleBtn;
                        buttonHeld       = true;
                    }
                    else
                    {
                        buttonHeld = false;
                    }

                    if (buttonHeld)
                    {
                        mousePosition = camera.GetNearestGrid32(camera.GetMapCords(), 32);
                    }

                    if (currentPeopleBtn != null && mstate.RightButton == ButtonState.Pressed)
                    {
                        currentPeopleBtn = null;
                    }

                    peopleBtn.Update(gameTime, "");

                    if (!uiCollision && currentPeopleBtn != null && mstate.LeftButton == ButtonState.Pressed)
                    {
                        if (unitController.AiUnits.Count == 0)
                        {
                            unitController.AddPerson(mousePosition, "worker");
                        }
                        else
                        {
                            if (!unitController.AiUnitPositions.Contains(mousePosition))
                            {
                                unitController.AddPerson(mousePosition, "worker");
                            }
                        }
                    }
                }
            }
            else
            {
                camera.SelectionSwitch = true;
                currentPeopleBtn       = null;
            }

            if (buildingModeActive)
            {
                foreach (var aiUnit in unitController.AiUnits)
                {
                    aiUnit.Selected = false;
                }

                camera.SelectionSwitch = false;

                mousePosition = camera.GetNearestGrid32(camera.GetMapCords(), 32);

                if (demoBtn != null)
                {
                    demoBtn.Update(gameTime, "");

                    if (!demoisHeld && demoBtn.Clicked && mstate.LeftButton == ButtonState.Pressed)
                    {
                        demoModeActive = !demoModeActive;
                        demoisHeld     = true;
                    }

                    if (demoisHeld)
                    {
                        if (mstate.LeftButton == ButtonState.Released)
                        {
                            demoisHeld = false;
                        }
                    }
                }

                bool uiCollision = false;

                if (buildingModeBtn.GetArea().Contains(mstate.Position))
                {
                    uiCollision = true;
                }
                else
                {
                    foreach (var buildingBtn in buildingsBtns)
                    {
                        if (buildingBtn.GetArea().Contains(mstate.Position))
                        {
                            uiCollision = true;
                            break;
                        }

                        if (undoBtn.GetArea().Contains(mstate.Position))
                        {
                            uiCollision = true;
                            break;
                        }

                        if (redoBtn.GetArea().Contains(mstate.Position))
                        {
                            uiCollision = true;
                            break;
                        }

                        if (saveBtn.GetArea().Contains(mstate.Position))
                        {
                            uiCollision = true;
                            break;
                        }

                        if (loadBtn.GetArea().Contains(mstate.Position))
                        {
                            uiCollision = true;
                            break;
                        }
                    }
                }

                foreach (var buildingBtn in buildingsBtns)
                {
                    if (buildingBtn.Clicked && !buttonHeld)
                    {
                        currentBuildingBtn = buildingBtn;
                        buttonHeld         = true;
                    }
                    else
                    {
                        buttonHeld = false;
                    }

                    if (buttonHeld)
                    {
                        mousePosition = camera.GetNearestGrid32(camera.GetMapCords(), 32);
                    }

                    if (currentBuildingBtn != null && mstate.RightButton == ButtonState.Pressed)
                    {
                        currentBuildingBtn = null;
                    }

                    if (demoModeActive)
                    {
                        currentBuildingBtn = null;

                        if (unitController.CollisionPositions.Contains(mousePosition) && mstate.LeftButton == ButtonState.Pressed)
                        {
                            unitController.RemoveStructure(mousePosition);
                        }
                    }

                    buildingBtn.Update(gameTime, buildingBtn.Text);

                    if (!uiCollision && currentBuildingBtn != null && mstate.LeftButton == ButtonState.Pressed)
                    {
                        if (unitController.Structures.Count == 0 && !demoModeActive)
                        {
                            unitController.AddStructure(mousePosition, currentBuildingBtn.Text);
                            history.AddItem(currentBuildingBtn.Text, mousePosition);
                        }
                        else
                        {
                            bool collision = false;
                            if (unitController.CollisionPositions.Contains(mousePosition) || unitController.FlooringPositions.Contains(mousePosition))
                            {
                                collision = true;
                            }

                            if (collision == false && !demoModeActive)
                            {
                                unitController.AddStructure(mousePosition, currentBuildingBtn.Text);
                                history.AddItem(currentBuildingBtn.Text, mousePosition);
                            }
                        }
                    }
                }
            }
            else
            {
                camera.SelectionSwitch = true;
                currentBuildingBtn     = null;
            }

            foreach (var aiUnit in unitController.AiUnits)
            {
                if (aiUnit.Selected)
                {
                    aiUnit.UnitSelectedBtn      = new Button(aiUnit.Position, content.Load <Texture2D>("selected32"), content.Load <SpriteFont>("Ariel"));
                    aiUnit.UnitSelectedBtn.Text = aiUnit.Position.ToString();
                    aiUnit.UnitSelectedBtn.Update(gameTime, aiUnit.UnitSelectedBtn.Text);
                }
                else
                {
                    aiUnit.UnitSelectedBtn = null;
                }
            }
        }