Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // *realmaster42
- // Functions that may help bot development.
- // Incluiding: limit, negative, textBoxHint
- // Limits specified value to the maximum and minimum. If exceeds, equal it to maximum. If below minimum, equal it to minimum.
- public int limit(int value, int max, int minimum = int.MinValue)
- {
- if (value > max)
- return max;
- else if (value < minimum)
- return minimum;
- else
- return value;
- }
- // Creates the negative form of the other color.
- public Color negative(Color clr)
- {
- return Color.FromArgb(255 - clr.R, 255 - clr.G, 255 - clr.B);
- }
- // Creates the negative form of the other color.
- public Color negative(int r = 255, int g = 255, int b = 255)
- {
- return Color.FromArgb(255 - r, 255 - g, 255 - b);
- }
- // Activates "hint" mode for textbox. Basically, the text currently in it becomes a hint.
- public void textBoxHint(TextBox txtBox)
- {
- if (txtBox == null)
- throw new Exception("Attempted creating a hint on a null textbox.");
- Color orig = txtBox.ForeColor;
- Color hint = Color.FromArgb(limit(orig.R + 111, 255), limit(orig.G + 111, 255), limit(orig.B + 111, 255));
- string defTxt = txtBox.Text;
- txtBox.ForeColor = hint;
- txtBox.MouseClick += new MouseEventHandler(delegate
- {
- if (txtBox.Text == defTxt)
- txtBox.Text = "";
- txtBox.ForeColor = orig;
- });
- txtBox.LostFocus += new EventHandler(delegate
- {
- if (string.IsNullOrEmpty(txtBox.Text) || string.IsNullOrWhiteSpace(txtBox.Text) || txtBox.Text == defTxt)
- {
- txtBox.Text = defTxt;
- txtBox.ForeColor = hint;
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement