Click here to Skip to main content
15,884,629 members
Home / Discussions / C#
   

C#

 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053222-Mar-15 23:46
Member 1071053222-Mar-15 23:46 
GeneralRe: data from file Word in DataGridView Pin
OriginalGriff23-Mar-15 0:10
mveOriginalGriff23-Mar-15 0:10 
AnswerRe: data from file Word in DataGridView Pin
manchanx21-Mar-15 5:27
professionalmanchanx21-Mar-15 5:27 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 6:37
Member 1071053221-Mar-15 6:37 
GeneralRe: data from file Word in DataGridView Pin
manchanx21-Mar-15 6:46
professionalmanchanx21-Mar-15 6:46 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 6:49
Member 1071053221-Mar-15 6:49 
GeneralRe: data from file Word in DataGridView Pin
manchanx21-Mar-15 6:50
professionalmanchanx21-Mar-15 6:50 
QuestionC# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317320-Mar-15 23:12
Member 1154317320-Mar-15 23:12 
I have a trackbar control that is adjusting the brightness of the background color of a form. Eventually, I'll modify it to adjust an image's brightness. If you look at how the brightness slider works in the colorDialog Control, as you move up and down, the value changes from white to black, but in the middle, the hue of the original color is never lost. The problem with my code is that once I reach the high end of brightness (white), or the low end (black), I lose the hue, and the trackbar becomes an adjustment of grayscale brightness, instead of an adjustment of the original color's brightness. So, I need to know how to change my code to adjust the brightness while preserving the hue.

C#
int valueOne = 0, valueTwo = 0, valueNew = 0;
bool count = true;

private void Form1_BackColorChanged(object sender, EventArgs e)
     {
    // set inital trackbar position, do this only once, when user sets a new BG color
    if (count == true)
    trackBar1.Value = (this.BackColor.R + this.BackColor.G + this.BackColor.B) / 3;
    count = false;

    // Get initial trackbar position value
    valueOne = trackBar1.Value;
 }

private void trackBar1_Scroll(object sender, EventArgs e)
 {
     int bgRed = 0, bgGreen = 0, bgBlue = 0;

     // get amount of change in trackbar value
     valueTwo = trackBar1.Value;
     valueNew = valueTwo - valueOne;

     // apply change amount to original color value
     bgRed = this.BackColor.R + valueNew;
     bgGreen = this.BackColor.G + valueNew;
     bgBlue = this.BackColor.B + valueNew;

     // dont allow > 255
     if (bgRed > 255)
         bgRed = 255;
     if (bgGreen > 255)
         bgGreen = 255;
     if (bgBlue > 255)
         bgBlue = 255;

     // dont allow < 0
     if (bgRed < 0)
         bgRed = 0;
     if (bgGreen < 0)
         bgGreen = 0;
     if (bgBlue < 0)
         bgBlue = 0;

     // apply new settings to form
     this.BackColor = Color.FromArgb(255, bgRed, bgGreen, bgBlue);
 }


Thank you
AnswerRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
manchanx21-Mar-15 4:18
professionalmanchanx21-Mar-15 4:18 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317321-Mar-15 11:16
Member 1154317321-Mar-15 11:16 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
manchanx21-Mar-15 14:00
professionalmanchanx21-Mar-15 14:00 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317322-Mar-15 11:01
Member 1154317322-Mar-15 11:01 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
manchanx22-Mar-15 11:04
professionalmanchanx22-Mar-15 11:04 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317325-Mar-15 11:02
Member 1154317325-Mar-15 11:02 
QuestionTic Tac Toe - Multiplayer Pin
Googooli8620-Mar-15 9:42
Googooli8620-Mar-15 9:42 
AnswerRe: Tic Tac Toe - Multiplayer Pin
Gerry Schmitz20-Mar-15 13:14
mveGerry Schmitz20-Mar-15 13:14 
QuestionCan some one help me how to download 2 PDF files in WEB API. Here is the code, Only one file returning and next file not returning where as my Query showing 2 results Pin
Ramalingeswar Akkireddy20-Mar-15 5:05
Ramalingeswar Akkireddy20-Mar-15 5:05 
AnswerRe: Can some one help me how to download 2 PDF files in WEB API. Here is the code, Only one file returning and next file not returning where as my Query showing 2 results Pin
Richard Deeming20-Mar-15 8:18
mveRichard Deeming20-Mar-15 8:18 
AnswerRe: Can some one help me how to download 2 PDF files in WEB API. Here is the code, Only one file returning and next file not returning where as my Query showing 2 results Pin
F-ES Sitecore21-Mar-15 2:23
professionalF-ES Sitecore21-Mar-15 2:23 
QuestionHow to manage timeexeption with GET and POST requests in C# Pin
KimToredo19-Mar-15 23:31
KimToredo19-Mar-15 23:31 
AnswerRe: How to manage timeexeption with GET and POST requests in C# Pin
Afzaal Ahmad Zeeshan20-Mar-15 1:17
professionalAfzaal Ahmad Zeeshan20-Mar-15 1:17 
GeneralRe: How to manage timeexeption with GET and POST requests in C# Pin
KimToredo20-Mar-15 13:59
KimToredo20-Mar-15 13:59 
Question[EDIT] Implmenting Tree Node MouseDoubleClick Event Properly Pin
Django_Untaken19-Mar-15 21:39
Django_Untaken19-Mar-15 21:39 
AnswerRe: [EDIT] Implmenting Tree Node MouseDoubleClick Event Properly Pin
Eddy Vluggen20-Mar-15 1:26
professionalEddy Vluggen20-Mar-15 1:26 
QuestionIssue with outllok addin file generation Pin
sma123#19-Mar-15 20:57
sma123#19-Mar-15 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.