public static void TableGoTo(DataGridView table, int row) { row = MoreMath.Clamp(row, 0, table.RowCount - 1); if (row >= 0 && row < table.RowCount) { table.FirstDisplayedScrollingRowIndex = row; } }
public static Color InterpolateColor(Color c1, Color c2, double amount) { amount = MoreMath.Clamp(amount, 0, 1); byte r = (byte)((c1.R * (1 - amount)) + c2.R * amount); byte g = (byte)((c1.G * (1 - amount)) + c2.G * amount); byte b = (byte)((c1.B * (1 - amount)) + c2.B * amount); return(Color.FromArgb(r, g, b)); }
public static Color GetColor(ObjectDataModel obj) { int?numRngUsages = GetNumRngUsages(obj); if (!numRngUsages.HasValue) { return(ObjectSlotsConfig.VacantSlotColor); } int index = MoreMath.Clamp(numRngUsages.Value, 0, ObjectSlotsConfig.RngUsageColors.Count - 1); return(ObjectSlotsConfig.RngUsageColors[index]); }
public static void SetTrackBarValueCapped(TrackBar trackBar, double value) { int newValue = (int)MoreMath.Clamp(value, trackBar.Minimum, trackBar.Maximum); trackBar.Value = newValue; }