Esempio n. 1
0
        private void Settings_button_Click(object sender, EventArgs e)
        {
            SettingsForm SettingsForm         = new SettingsForm();
            DialogResult SettingsDialogResult = new DialogResult();

            SettingsDialogResult = SettingsForm.ShowDialog(this);

            if (SettingsDialogResult == DialogResult.OK) // ok - other settings where changed.
            {
                if (Properties.Settings.Default.AutoSaving)
                {
                    AutoSaveTimer.Start();
                }
                else
                {
                    AutoSaveTimer.Stop();
                }
            }
            if (SettingsDialogResult == DialogResult.Yes) // yes - authentification values where changed.
            {
                // reconnect to server.
                if (BuisinessLogicClass.Connect() == 2)
                {
                    Properties.Settings.Default.Connection = true;
                    OldCommits();
                    BuisinessLogicClass.Update();
                    Search_others_button.Enabled = true;
                }
            }
        }
Esempio n. 2
0
 public WidgetViewModel()
 {
     if (!AutoSaveTimer.IsEnabled)
     {
         AutoSaveTimer.Start();
     }
 }
Esempio n. 3
0
 public NoteViewModel()
 {
     if (!AutoSaveTimer.IsEnabled)
     {
         AutoSaveTimer.Start();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Activates auto-saving to a certain location with a specified delay
 /// </summary>
 /// <param name="path">The target path</param>
 /// <param name="milliseconds">The delay in milliseconds</param>
 public void SetAutoSave(string name, int milliseconds)
 {
     if (AutoSaveTimer != null)
     {
         AutoSaveTimer.Dispose();
     }
     AutoSaveTimer = new Timer(
         (o) =>
     {
         if (Interlocked.CompareExchange(ref TimerIsExecuting, 1, 0) == 0)
         {
             try
             {
                 if (IsDirty)
                 {
                     try
                     {
                         SaveSettings(name);
                         IsDirty = false;
                     }
                     catch (Exception ex)
                     {
                         Debug.WriteLine(ex.ToString());
                     }
                 }
             }
             finally
             {
                 TimerIsExecuting = 0;
             }
         }
     }, null,
         TimeSpan.FromMilliseconds(0),
         TimeSpan.FromMilliseconds(milliseconds));
 }
Esempio n. 5
0
        private void Commit_button_Click(object sender, EventArgs e)
        {
            CurrentIssueTimer.Stop();
            CurrentIssueTimerTicking = false;
            AutoSaveTimer.Stop();
            SaveTimeTicked(NewTicksAfterAutoSave);

            if (NewIssueSelectionAvailability)
            {
                BuisinessLogicClass.SuperIssueId = Convert.ToInt32(Issue_list_GridView.SelectedRows[0].Cells[0].Value);
            }
            else
            {
                BuisinessLogicClass.SuperIssueId = CurrentIssueId;
            }

            CommitForm CommitWindow = new CommitForm();

            if (CommitWindow.ShowDialog() == DialogResult.OK)
            {
                Timer_label.Text        = "00:00:00";
                Start_timer_button.Text = "Start";
                NewTicksAfterAutoSave   = 0;
                TimerTicks = 0;
                NewIssueSelectionAvailability = true;
                Commit_button.Enabled         = false;
                ModifyGridViewData();
            }
            else
            {
                CurrentIssueTimer.Start();
                CurrentIssueTimerTicking = true;
                AutoSaveTimer.Start();
            }
        }
Esempio n. 6
0
        public bool CloseCurrentProject()
        {
            if (ProjectManager.IsProjectOpen)
            {
                AutoSaveTimer.Stop();

                if (ProjectManager.IsModified || ProjectManager.IsNewProject)
                {
                    var messageText = ProjectManager.IsNewProject ?
                                      Messages.Message_SaveNewProject :
                                      Messages.Message_SaveChanges;

                    var result = MessageBox.Show(messageText, Messages.Caption_SaveBeforeClose, MessageBoxButtons.YesNoCancel);

                    if (result == DialogResult.Yes)
                    {
                        SaveProject(CurrentProject);
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        AutoSaveTimer.Start();
                        return(false);
                    }
                }

                ProjectManager.CloseCurrentProject();
            }

            return(true);
        }
Esempio n. 7
0
 private void ExitApplication()
 {
     CurrentIssueTimer.Stop();
     CurrentIssueTimerTicking = false;
     AutoSaveTimer.Stop();
     SaveTimeTicked(NewTicksAfterAutoSave);
     BuisinessLogicClass.CleanUpIssuesFile(); // move all time to comments and empty time in main file.
     notifyIcon.Visible = false;
 }
Esempio n. 8
0
 protected override void OnStart()
 {
     base.OnStart();
     defaultSiteId = BL.ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId;
     AllowArchive  = false;
     AutoSaveTimer.Start();
     BindData();
     txtSupplierCodeFrom.DataBindings.Add(new Binding("EditValue", aorFilters, "SupplierCodeFrom", true, DataSourceUpdateMode.OnPropertyChanged));
     txtSupplierCodeTo.DataBindings.Add(new Binding("EditValue", aorFilters, "SupplierCodeTo", true, DataSourceUpdateMode.OnPropertyChanged));
 }
Esempio n. 9
0
File: MainForm.cs Progetto: uffu/brg
        public MainForm()
        {
            InitializeComponent();
            ucGroups.setWordsPanel(ucWords.getWordsPanel());

            LoadData();

            AutoSaveTimer.Interval = 2 * 60 * 1000;
            AutoSaveTimer.Tick    += AutoSaveTimer_Tick;
            AutoSaveTimer.Start();
        }
Esempio n. 10
0
 /// <summary>
 /// This is called when the plugin is shut down. This happens only once.
 /// </summary>
 protected override void Shutdown()
 {
     try
     {
         //Destroy the view.
         MVWireupHelper.WireupEnd(this);
         AllQuestRedrawTimer.Stop();
         AutoSaveTimer.Stop();
         SaveState();
     }
     catch (Exception ex) { Util.LogError(ex); }
 }
Esempio n. 11
0
        private void LoadPartProject(PartProject project)
        {
            if (!CloseCurrentProject())
            {
                return;
            }

            ProjectManager.SetCurrentProject(project);
            if (project != null)
            {
                AutoSaveTimer.Start();
            }
        }
Esempio n. 12
0
        private void Start_timer_button_Click(object sender, EventArgs e)
        {
            if (NewIssueSelectionAvailability)
            {
                CurrentIssueId = Convert.ToInt32(Convert.ToString(Issue_list_GridView
                                                                  .Rows[Issue_list_GridView.SelectedRows[0].Index].Cells[0].Value));
                BuisinessLogicClass.SuperIssueId = CurrentIssueId;
                CurrentIssueName = Convert.ToString(Issue_list_GridView
                                                    .Rows[Issue_list_GridView.SelectedRows[0].Index].Cells[1].Value);
                if (CurrentIssueName.Length > 50)
                {
                    Text = "RC: " + CurrentIssueName.Substring(0, 50);
                }
                else
                {
                    Text = "RC: " + CurrentIssueName;
                }

                Issue_list_GridView.BackgroundColor = Color.WhiteSmoke;
                for (int i = 0; i < 5; i++)
                {
                    Issue_list_GridView.Rows[CurrentIssueDataGridRowId].Cells[i].Style.BackColor = Color.DarkGray;
                }
            }

            if (Start_timer_button.Text == "Start")
            {
                NewIssueSelectionAvailability = true;
            }
            if (CurrentIssueTimerTicking)
            {
                CurrentIssueTimer.Stop();
                CurrentIssueTimerTicking = false;
                AutoSaveTimer.Stop();
                Start_timer_button.Text = "Continue";
            }
            else
            {
                CurrentIssueTimer.Start();
                CurrentIssueTimerTicking = true;
                AutoSaveTimer.Start();
                Start_timer_button.Text       = "Pause";
                Commit_button.Enabled         = true;
                NewIssueSelectionAvailability = false;
            }
        }
Esempio n. 13
0
        public bool CloseCurrentProject()
        {
            if (ProjectManager.IsProjectOpen)
            {
                AutoSaveTimer.Stop();

                if (ProjectManager.IsModified || ProjectManager.IsNewProject)
                {
                    var messageText = ProjectManager.IsNewProject ?
                                      Messages.Message_SaveNewProject :
                                      Messages.Message_SaveChanges;

                    var result = MessageBox.Show(messageText, Messages.Caption_SaveBeforeClose, MessageBoxButtons.YesNoCancel);

                    if (result == DialogResult.Yes)
                    {
                        SaveProject(CurrentProject);
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        AutoSaveTimer.Start();
                        return(false);
                    }
                }

                string workingDirPath = CurrentProject?.ProjectWorkingDir;

                if (!string.IsNullOrEmpty(workingDirPath) && Directory.Exists(workingDirPath))
                {
                    Task.Factory.StartNew(() => FileHelper.DeleteFileOrFolder(workingDirPath, true, true));
                }

                SettingsManager.Current.LastOpenProject = null;
                SettingsManager.SaveSettings();

                ProjectManager.CloseCurrentProject();
            }

            return(true);
        }
Esempio n. 14
0
        private SaveTapOperator()
        {
            for (int i = 0; i < TapOperatorMoments.Length; i++) // initialiserer objekter i listen TapOperatorMoments
            {
                TapOperatorMoments[i] = new TapOperatorMoment();
            }

            for (int i = 0; i < FluidWeightControls.Length; i++) // initialiserer objekter i listen FluidWeightControls
            {
                FluidWeightControls[i] = new FluidWeightControl(this);
            }

            GenerateObjectsToBeSaved();
            _saveToDbMethod   = PostSaveMethod;
            SaveCommand       = new RelayCommand(SaveCommandPush);
            AutoSaveTimer     = new AutoSaveTimer(this);
            LiquidTankCommand = new RelayCommand <object>(LiquidTankCommandMethod);
            ProItem           = new ProcessingItems();
            ShowMsg           = new ShowMsg();
            CalculateAverageWeight();
            CurrentFinishedItem = new FinishedItems();
        }
Esempio n. 15
0
        private bool LoadPartProject(PartProject project, string tempPath = null)
        {
            if (!CloseCurrentProject())
            {
                return(false);
            }

            ViewportPanel.ForceRender();
            ProjectManager.SetCurrentProject(project, tempPath);

            if (project != null)
            {
                if (!ProjectManager.IsNewProject && string.IsNullOrEmpty(tempPath))
                {
                    RebuildRecentFilesMenu();
                    SettingsManager.AddRecentProject(ProjectManager.GetCurrentProjectInfo(), true);
                }

                AutoSaveTimer.Start();
            }

            return(project != null);
        }
Esempio n. 16
0
        private void SaveCommandPush()
        {
            // Stopper timer
            AutoSaveTimer.StopTimer();

            //Run saveDelegate
            if (SAveToDbMethod("button"))
            {
                //Return saveDelegate to startMethod
                _saveToDbMethod = PostSaveMethod;

                //Nulstil objeckt af TapOperator
                GenerateObjectsToBeSaved();

                // Slet indtastninger i momenter
                foreach (TapOperatorMoment moment in TapOperatorMoments)
                {
                    moment.Moment = "";
                }

                // Sletter indtastninger vægtkontrol
                foreach (FluidWeightControl weight in FluidWeightControls)
                {
                    weight.Weight = "";
                }

                // Fjerner kryds i checkbokse
                IsCheckedHeuftLid      = false;
                IsCheckedFillHeight    = false;
                IsCheckedProductTasted = false;
                IsCheckedSugarTest     = false;
                IsCheckedDropTest      = false;

                // Sletter kommentar
                Comment = "";
            }
        }
Esempio n. 17
0
 void Stop_Click(object sender, MVControlEventArgs e)
 {
     AllQuestRedrawTimer.Stop();
     AutoSaveTimer.Stop();
 }
Esempio n. 18
0
        public override void Update(DwarfTime gameTime)
        {
            // If this playstate is not supposed to be running, just exit.
            if (!IsActiveState || IsShuttingDown)
            {
                return;
            }

            if (QuitOnNextUpdate)
            {
                QuitGame();
                IsShuttingDown   = true;
                QuitOnNextUpdate = false;
                return;
            }

            Debugger.SetConsoleCommandContext(World);
            InfoTray.ClearTopMessage();

            // Hide tutorial while menu is up
            if (PausePanel == null || PausePanel.Hidden)
            {
                World.TutorialManager.ShowTutorial();
            }
            else
            {
                World.TutorialManager.HideTutorial();
            }

#if !DEBUG
            try
            {
#endif
            if (IsMouseOverGui)
            {
                ShowInfo(InfoTray.TopEntry, "MOUSE OVER GUI");
            }
            else
            {
                BottomToolBar.RefreshVisibleTray();
            }

            #region Handle keyboard input

            DwarfGame.GumInput.FireActions(Gui, (@event, args) =>
            {
                if (DwarfGame.IsConsoleVisible)
                {
                    return;
                }

                // Mouse down but not handled by GUI? Collapse menu.
                if (@event == DwarfCorp.Gui.InputEvents.MouseClick)
                {
                    GodMenu.CollapseTrays();

                    if (ContextMenu != null)
                    {
                        ContextMenu.Close();
                        ContextMenu = null;
                    }

                    // double click logic.
                    if (args.MouseButton == 0)
                    {
                        var now = (float)gameTime.TotalRealTime.TotalSeconds;
                        if (now - timeOnLastClick < doubleClickThreshold)
                        {
                            World.Renderer.Camera.ZoomTo(World.Renderer.CursorLightPos);
                            World.Renderer.Camera.ZoomTo(World.Renderer.CursorLightPos);
                        }
                        timeOnLastClick = now;
                    }

                    if (args.MouseButton == 1) // Right mouse click.
                    {
                        var bodiesClicked = World.ComponentManager.FindRootBodiesInsideScreenRectangle(
                            new Rectangle(args.X, args.Y, 1, 1), World.Renderer.Camera);

                        if (bodiesClicked.Count > 0)
                        {
                            var contextBody       = bodiesClicked[0];
                            var availableCommands = ContextCommands.Where(c => c.CanBeAppliedTo(contextBody, World));

                            if (availableCommands.Count() > 0)
                            {
                                // Show context menu.
                                ContextMenu = Gui.ConstructWidget(new ContextMenu
                                {
                                    Commands = availableCommands.ToList(),
                                    Body     = contextBody,
                                    World    = World
                                });

                                Gui.ShowDialog(ContextMenu);
                                args.Handled = true;
                            }
                        }
                    }
                }

                else if (@event == InputEvents.KeyUp)
                {
                    // Camera position hotkeys
                    if (args.KeyValue >= '0' && args.KeyValue <= '9' && (args.Control || args.Shift))
                    {
                        var savedPositionSlot = args.KeyValue - '0';

                        if (args.Control)
                        {
                            if (World.Renderer.PersistentSettings.SavedCameraPositions.ContainsKey(savedPositionSlot))
                            {
                                var saved = World.Renderer.PersistentSettings.SavedCameraPositions[savedPositionSlot];
                                World.Renderer.Camera.Target     = saved.Target;
                                World.Renderer.Camera.ViewMatrix = saved.ViewMatrix;
                                World.Renderer.Camera.Position   = saved.Position;
                                World.Renderer.SetMaxViewingLevel(saved.SliceLevel);
                            }
                        }
                        else if (args.Shift)
                        {
                            World.Renderer.PersistentSettings.SavedCameraPositions[savedPositionSlot] = new CameraPositiionSnapshot
                            {
                                Position   = World.Renderer.Camera.Position,
                                Target     = World.Renderer.Camera.Target,
                                ViewMatrix = World.Renderer.Camera.ViewMatrix,
                                SliceLevel = World.Renderer.PersistentSettings.MaxViewingLevel
                            };
                        }
                    }
                    // Main Toolbar Hotkeys
                    else if (FlatToolTray.Tray.Hotkeys.Contains((Keys)args.KeyValue))
                    {
                        if (PausePanel == null || PausePanel.Hidden)
                        {
                            (BottomToolBar.Children.First(w => w.Hidden == false) as FlatToolTray.Tray).Hotkey((Keys)args.KeyValue);
                        }
                    }
                    else if ((Keys)args.KeyValue == Keys.Escape)
                    {
                        BrushTray.Select(0);
                        CameraTray.Select(0);

                        if (World.TutorialManager.HasCurrentTutorial())
                        {
                            World.TutorialManager.DismissCurrentTutorial();
                        }
                        else if (TogglePanels.Any(p => p.Hidden == false))
                        {
                            HideTogglePanels();
                        }
                        else if (MainMenu.Hidden && PausePanel == null)
                        {
                            (BottomToolBar.Children.First(w => w.Hidden == false) as FlatToolTray.Tray).Hotkey(FlatToolTray.Tray.Hotkeys[0]);
                        }
                        else if (CurrentToolMode != "SelectUnits" && PausePanel == null)
                        {
                            ChangeTool("SelectUnits");
                        }
                        else if (PausePanel != null)
                        {
                            PausePanel.Close();
                        }
                        else
                        {
                            OpenPauseMenu();
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SelectAllDwarves && (PausePanel == null || PausePanel.Hidden))
                    {
                        World.PersistentData.SelectedMinions.AddRange(World.PlayerFaction.Minions);
                        World.Tutorial("dwarf selected");
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SelectNextEmployee && (PausePanel == null || PausePanel.Hidden))
                    {
                        if (World.PlayerFaction.Minions.Count > 0)
                        {
                            if (World.PersistentData.SelectedMinions.Count == 0)
                            {
                                World.PersistentData.SelectedMinions.Clear();
                                World.PersistentData.SelectedMinions.Add(World.PlayerFaction.Minions[0]);
                            }
                            else
                            {
                                var index = World.PlayerFaction.Minions.IndexOf(World.PersistentData.SelectedMinions[0]);
                                index    += 1;
                                if (index >= World.PlayerFaction.Minions.Count)
                                {
                                    index = 0;
                                }
                                World.PersistentData.SelectedMinions.Clear();
                                World.PersistentData.SelectedMinions.Add(World.PlayerFaction.Minions[index]);
                            }

                            World.Tutorial("dwarf selected");
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SelectPreviousEmployee && (PausePanel == null || PausePanel.Hidden))
                    {
                        if (World.PlayerFaction.Minions.Count > 0)
                        {
                            if (World.PersistentData.SelectedMinions.Count == 0)
                            {
                                World.PersistentData.SelectedMinions.Clear();
                                World.PersistentData.SelectedMinions.Add(World.PlayerFaction.Minions[0]);
                            }
                            else
                            {
                                var index = World.PlayerFaction.Minions.IndexOf(World.PersistentData.SelectedMinions[0]);
                                index    -= 1;
                                if (index < 0)
                                {
                                    index = World.PlayerFaction.Minions.Count - 1;
                                }
                                World.PersistentData.SelectedMinions.Clear();
                                World.PersistentData.SelectedMinions.Add(World.PlayerFaction.Minions[index]);
                            }
                            World.Tutorial("dwarf selected");
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Pause)
                    {
                        if (PausePanel == null || PausePanel.Hidden)
                        {
                            World.Paused = !World.Paused;
                            if (World.Paused)
                            {
                                GameSpeedControls.Pause();
                            }
                            else
                            {
                                GameSpeedControls.Resume();
                            }
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.TimeForward)
                    {
                        if (PausePanel == null || PausePanel.Hidden)
                        {
                            GameSpeedControls.CurrentSpeed += 1;
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.TimeBackward)
                    {
                        if (PausePanel == null || PausePanel.Hidden)
                        {
                            GameSpeedControls.CurrentSpeed -= 1;
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.ToggleGUI)
                    {
                        Gui.RootItem.Hidden = !Gui.RootItem.Hidden;
                        Gui.RootItem.Invalidate();
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Map && (PausePanel == null || PausePanel.Hidden))
                    {
                        Gui.SafeCall(MinimapIcon.OnClick, MinimapIcon, new InputEventArgs());
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Employees && (PausePanel == null || PausePanel.Hidden))
                    {
                        Gui.SafeCall(EmployeesIcon.OnClick, EmployeesIcon, new InputEventArgs());
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Tasks && (PausePanel == null || PausePanel.Hidden))
                    {
                        Gui.SafeCall(TasksIcon.OnClick, TasksIcon, new InputEventArgs());
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Zones && (PausePanel == null || PausePanel.Hidden))
                    {
                        Gui.SafeCall(ZonesIcon.OnClick, ZonesIcon, new InputEventArgs());
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Marks && (PausePanel == null || PausePanel.Hidden))
                    {
                        Gui.SafeCall(MarksIcon.OnClick, MarksIcon, new InputEventArgs());
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Xray)
                    {
                        Xray.CheckState = !Xray.CheckState;
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.GodMode)
                    {
                        if (PausePanel == null || PausePanel.Hidden)
                        {
                            if (!GodMenu.Hidden)
                            {
                                ChangeTool("SelectUnits");
                            }
                            GodMenu.Hidden = !GodMenu.Hidden;
                            GodMenu.Invalidate();
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SliceUp)
                    {
                        sliceUpheld  = false;
                        args.Handled = true;
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SliceDown)
                    {
                        sliceDownheld = false;
                        args.Handled  = true;
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SliceSelected)
                    {
                        if (args.Control)
                        {
                            World.Renderer.SetMaxViewingLevel(rememberedViewValue);
                            args.Handled = true;
                        }
                        else if (VoxSelector.VoxelUnderMouse.IsValid)
                        {
                            World.Tutorial("unslice");
                            World.Renderer.SetMaxViewingLevel(VoxSelector.VoxelUnderMouse.Coordinate.Y + 1);
                            Drawer3D.DrawBox(VoxSelector.VoxelUnderMouse.GetBoundingBox(), Color.White, 0.15f, true);
                            args.Handled = true;
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.Unslice)
                    {
                        rememberedViewValue = World.Renderer.PersistentSettings.MaxViewingLevel;
                        World.Renderer.SetMaxViewingLevel(World.WorldSizeInVoxels.Y);
                        args.Handled = true;
                    }
                }
                else if (@event == DwarfCorp.Gui.InputEvents.KeyDown)
                {
                    if ((Keys)args.KeyValue == ControlSettings.Mappings.SliceUp)
                    {
                        if (!sliceUpheld)
                        {
                            sliceUpheld = true;
                            World.Tutorial("unslice");
                            sliceUpTimer.Reset(0.5f);
                            World.Renderer.SetMaxViewingLevel(World.Renderer.PersistentSettings.MaxViewingLevel + 1);
                            args.Handled = true;
                        }
                    }
                    else if ((Keys)args.KeyValue == ControlSettings.Mappings.SliceDown)
                    {
                        if (!sliceDownheld)
                        {
                            World.Tutorial("unslice");
                            sliceDownheld = true;
                            sliceDownTimer.Reset(0.5f);
                            World.Renderer.SetMaxViewingLevel(World.Renderer.PersistentSettings.MaxViewingLevel - 1);
                            args.Handled = true;
                        }
                    }
                }
            });

            #endregion

            // Close the bottom menu if the only icon is the return icon.
            if (BottomToolBar.Children.First(w => w.Hidden == false).Children.Count(c => c.Hidden == false) == 1)
            {
                (BottomToolBar.Children.First(w => w.Hidden == false) as FlatToolTray.Tray).Hotkey(FlatToolTray.Tray.Hotkeys[0]);
            }

            #region Handle slice hotkeys being held down

            if (sliceDownheld)
            {
                sliceDownTimer.Update(gameTime);
                if (sliceDownTimer.HasTriggered)
                {
                    World.Renderer.SetMaxViewingLevel(World.Renderer.PersistentSettings.MaxViewingLevel - 1);
                    sliceDownTimer.Reset(sliceDownTimer.TargetTimeSeconds * 0.6f);
                }
            }
            else if (sliceUpheld)
            {
                sliceUpTimer.Update(gameTime);
                if (sliceUpTimer.HasTriggered)
                {
                    World.Renderer.SetMaxViewingLevel(World.Renderer.PersistentSettings.MaxViewingLevel + 1);
                    sliceUpTimer.Reset(sliceUpTimer.TargetTimeSeconds * 0.6f);
                }
            }

            #endregion

            World.Update(gameTime);

            #region Vox and Body selectors
            if (!IsMouseOverGui)
            {
                if (KeyManager.RotationEnabled(World.Renderer.Camera))
                {
                    SetMouse(null);
                }
                VoxSelector.Update();
                BodySelector.Update();
            }
            #endregion

            World.Renderer.Update(gameTime);
            Input.Update();
            CurrentTool.Update(Game, gameTime);



            UpdateGui(gameTime);

            AutoSaveTimer.Update(gameTime);

            if (GameSettings.Current.AutoSave && AutoSaveTimer.HasTriggered)
            {
                AutoSave();
            }

            #region select employee

            World.PersistentData.SelectedMinions.RemoveAll(minion => minion.IsDead);
            if (World.PersistentData.SelectedMinions.Count == 1)
            {
                // Lol this is evil just trying to reduce the update rate for speed
                if (MathFunctions.RandEvent(0.1f))
                {
                    SelectedEmployeeInfo.Employee = World.PersistentData.SelectedMinions[0];
                }
            }
            else
            {
                bool update = MathFunctions.RandEvent(0.1f);
                if ((SelectedEmployeeInfo.Employee == null || SelectedEmployeeInfo.Employee.IsDead || !SelectedEmployeeInfo.Employee.Active) &&
                    World.PlayerFaction.Minions.Count > 0)
                {
                    SelectedEmployeeInfo.Employee = World.PlayerFaction.Minions[0];
                }
                else if (update)
                {
                    SelectedEmployeeInfo.Employee = SelectedEmployeeInfo.Employee;
                }
            }
            #endregion

            #region Console
            if (DwarfGame.IsConsoleVisible)
            {
                World.DisplaySpeciesCountsInMetrics();
                // Todo: Employee AI debug display

                var scheduleDisplay = DwarfGame.GetConsoleTile("FORECAST");
                scheduleDisplay.TextSize = 1;
                scheduleDisplay.Lines.Clear();
                scheduleDisplay.Lines.Add(String.Format("Diff:{0:+00;-00;+00} Forecast:{1:+00;-00;+00}", World.EventScheduler.CurrentDifficulty, World.EventScheduler.ForecastDifficulty(World.Time.CurrentDate)));
                foreach (var scheduledEvent in World.EventScheduler.Forecast)
                {
                    scheduleDisplay.Lines.Add(String.Format("{2:+00;-00;+00} {1} {0}", scheduledEvent.Event.Name, (scheduledEvent.Date - World.Time.CurrentDate).ToString(@"hh\:mm"), scheduledEvent.Event.Difficulty));
                }
                scheduleDisplay.Invalidate();
            }
            #endregion

#if !DEBUG
        }

        catch (Exception e)
        {
            Program.CaptureException(e);
            if (Program.ShowErrorDialog(e.Message))
            {
                throw new HandledException(e);
            }
        }
#endif
        }