private void SetFoVNumeric(decimal fov) { ClampEx.Clamp(ref fov, FoVNumeric.Minimum, FoVNumeric.Maximum); if (FoVNumeric.InvokeRequired) { FoVNumeric.BeginInvoke((MethodInvoker) delegate() { FoVNumeric.Value = fov; }); } else { FoVNumeric.Value = fov; } }
private void UpdateProcessBox() { try { var selectedIndex = GamePIDBox.SelectedIndex; GamePIDBox.BeginUpdate(); for (int i = 0; i < GamePIDBox.Items.Count; i++) { var memory = GamePIDBox.GetMemoryFromIndex(i); if (!memory?.IsRunning() ?? false) { GamePIDBox.Items.Remove(GamePIDBox.Items[i]); } } var allProcs = Pool.GetList <Process>(); try { GetAllGameProcessesNoAlloc(ref allProcs); for (int i = 0; i < allProcs.Count; i++) { var proc = allProcs[i]; if (proc?.Id == 0) { continue; } var hasPid = false; for (int j = 0; j < GamePIDBox.Items.Count; j++) { if (GamePIDBox?.GetMemoryFromIndex(j) != null) { hasPid = true; break; } } if (!hasPid) { GamePIDBox.AddProcessMemory(new Memory(proc.Id)); } } } finally { Pool.FreeList(ref allProcs); } GamePIDBox.Visible = GamePIDBox.Items.Count > 0; if (GamePIDBox.SelectedItem == null && GamePIDBox.Items.Count > 0) { GamePIDBox.SelectedIndex = ClampEx.Clamp(selectedIndex - 1, 0, GamePIDBox.Items.Count); } GamePIDBox.EndUpdate(); } catch (Exception ex) { Log.WriteLine("An error happened while trying to get running Call of Duty/UO processes:" + Environment.NewLine + ex.ToString()); MessageBox.Show("An error happend while trying to get running Call of Duty/UO processes: " + ex.Message + Environment.NewLine + "Please refer to the log for more info.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }