Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
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 
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 
Alright Smile | :)

Let's assume an initial background color of RGB 20/50/150.

1) Determine the color component with the smallest value and subtract it from 255. In this case: (Red) 255-20 = 235

2) Determine the color component with the highest value. In this case: (Blue) 150

3) Set the Maximum of the TrackBar to the sum of those values: 235+150 = 385

4) Set the Value (Position) of the TrackBar to the value from Step 2: 150

5) When the slider gets moved, take its Value and subtract the value from Step 2. Add the result of this to the color components of the initial background color (with Min/Max of 0/255 of course) and set it as current background color.

Example 1:
Let's assume the TrackBar got moved to 0. Then we calculate: 0-150 = -150
R: 20 + -150 = -130 ==> 0
G: 50 + -150 = -100 ==> 0
B: 150+ -150 = 0

Example 2:
Let's assume the TrackBar got moved to 200. Then we calculate: 200-150 = 50
R: 20 + 50 = 70
G: 50 + 50 = 100
B: 150+ 50 = 200

Example 3:
Let's assume the TrackBar got moved to 385. Then we calculate: 385-150 = 235
R: 20 + 235 = 255
G: 50 + 235 = 285 ==> 255
B: 150+ 235 = 385 ==> 255

Looks good?

Edit: If you want to achieve that all three color components reach the min/max value "at the same time" so that no value has to be "clipped" (which will probably produce a better result for image brightness adjustment) you would have to apply some slightly more sophisticated math but I think you'll get the basic idea from the above method.
Recursion: see Recursion.


modified 21-Mar-15 20:17pm.

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 
QuestionRe: Issue with outllok addin file generation Pin
Eddy Vluggen20-Mar-15 8:23
professionalEddy Vluggen20-Mar-15 8:23 
QuestionSQLDependency not firing any notification on Hyper V machines Pin
Rakesh Kumar Sah19-Mar-15 18:25
Rakesh Kumar Sah19-Mar-15 18:25 
QuestionExe Pin
Member 1133602719-Mar-15 8:21
Member 1133602719-Mar-15 8:21 

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.