@@ -610,12 +610,7 @@ void WindowMouseWheel(object sender, MouseWheelEventArgs e)
610
610
if ( hueIndicatorLocation > 1 ) hueIndicatorLocation = 1 ;
611
611
612
612
var c = GetColorByOffset ( currentBrightnessBrushGradient . GradientStops , hueIndicatorLocation ) ;
613
- var cc = new PixelColor ( ) ;
614
- cc . Red = c . R ;
615
- cc . Green = c . G ;
616
- cc . Blue = c . B ;
617
- cc . Alpha = 255 ;
618
- currentColor = cc ;
613
+ currentColor = new PixelColor ( c . R , c . G , c . B , 255 ) ;
619
614
SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
620
615
//ResetCurrentBrightnessPreview(currentColor);
621
616
@@ -693,34 +688,24 @@ private void OnModeSelectionChanged(object sender, SelectionChangedEventArgs e)
693
688
// if key is pressed down globally
694
689
void OnKeyDown ( object sender , KeyEventArgs e )
695
690
{
696
- // TODO: add tool shortcut keys
697
691
switch ( e . Key )
698
692
{
699
- case Key . I : // TEST global color picker
700
- CustomPoint cursor ;
701
- GetCursorPos ( out cursor ) ;
702
- var c1 = Win32GetScreenPixel ( ( int ) cursor . X , ( int ) cursor . Y ) ;
703
- var c2 = new PixelColor ( ) ;
704
- c2 . Alpha = c1 . A ;
705
- c2 . Red = c1 . R ;
706
- c2 . Green = c1 . G ;
707
- c2 . Blue = c1 . B ;
708
- currentColor = c2 ;
709
- rectCurrentColor . Fill = new SolidColorBrush ( Color . FromArgb ( c2 . Alpha , c2 . Red , c2 . Green , c2 . Blue ) ) ;
710
- // Console.WriteLine(cursor.X + "," + cursor.Y + " = " + c1);
693
+ case Key . D : // reset to default colors (current, secondary)
694
+ currentColor = new PixelColor ( 255 , 255 , 255 , 255 ) ; // white
695
+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
696
+ rectSecondaryColor . Fill = new PixelColor ( 0 , 0 , 0 , 255 ) . AsSolidColorBrush ( ) ;
697
+ break ;
698
+ case Key . I : // global color picker
699
+ currentColor = Win32GetScreenPixelColor ( ) ;
700
+ rectCurrentColor . Fill = currentColor . AsSolidColorBrush ( ) ;
711
701
break ;
712
702
case Key . X : // swap current/secondary colors
713
703
var tempcolor = rectCurrentColor . Fill ;
714
704
rectCurrentColor . Fill = rectSecondaryColor . Fill ;
715
705
rectSecondaryColor . Fill = tempcolor ;
716
706
// TODO move to converter
717
- var c = new PixelColor ( ) ;
718
707
var t = ( ( SolidColorBrush ) rectCurrentColor . Fill ) . Color ;
719
- c . Red = t . R ;
720
- c . Green = t . G ;
721
- c . Blue = t . B ;
722
- c . Alpha = t . A ;
723
- currentColor = c ;
708
+ currentColor = new PixelColor ( t . R , t . G , t . B , t . A ) ;
724
709
break ;
725
710
case Key . B : // brush
726
711
CurrentTool = ToolMode . Draw ;
@@ -899,13 +884,8 @@ void OnPasteImageFromClipboard()
899
884
for ( int y = 0 ; y < canvasResolutionY ; y ++ )
900
885
{
901
886
var cc = GetPixelColor ( x , y , target ) ;
902
- Console . WriteLine ( ) ;
903
- var ccc = new PixelColor ( ) ;
904
- ccc . Red = cc . Red ;
905
- ccc . Green = cc . Green ;
906
- ccc . Blue = cc . Blue ;
907
- ccc . Alpha = 255 ;
908
- SetPixel ( canvasBitmap , x , y , ( int ) ccc . ColorBGRA ) ;
887
+ cc . Alpha = 255 ;
888
+ SetPixel ( canvasBitmap , x , y , ( int ) cc . ColorBGRA ) ;
909
889
}
910
890
}
911
891
}
@@ -1186,13 +1166,9 @@ private void rectHueBar_MouseDown(object sender, MouseButtonEventArgs e)
1186
1166
1187
1167
private void OnGetTransparentColorButton ( object sender , MouseButtonEventArgs e )
1188
1168
{
1189
- var c = new PixelColor ( ) ;
1190
- c . Red = 255 ;
1191
- c . Green = 255 ;
1192
- c . Blue = 255 ;
1193
- c . Alpha = 0 ;
1169
+ var c = new PixelColor ( 255 , 255 , 255 , 0 ) ;
1194
1170
currentColor = c ;
1195
- rectCurrentColor . Fill = new SolidColorBrush ( Color . FromArgb ( c . Alpha , c . Red , c . Green , c . Blue ) ) ;
1171
+ rectCurrentColor . Fill = c . AsSolidColorBrush ( ) ;
1196
1172
ResetCurrentBrightnessPreview ( currentColor ) ;
1197
1173
}
1198
1174
@@ -1216,16 +1192,8 @@ private void OnLevelSaturationMouseMoved(object sender, MouseEventArgs e)
1216
1192
1217
1193
private void OnLevelSaturationMouseDown ( object sender , MouseButtonEventArgs e )
1218
1194
{
1219
- CustomPoint cursor ;
1220
- GetCursorPos ( out cursor ) ;
1221
- var c1 = Win32GetScreenPixel ( ( int ) cursor . X , ( int ) cursor . Y ) ;
1222
- var c2 = new PixelColor ( ) ;
1223
- c2 . Alpha = c1 . A ;
1224
- c2 . Red = c1 . R ;
1225
- c2 . Green = c1 . G ;
1226
- c2 . Blue = c1 . B ;
1227
- currentColor = c2 ;
1228
- rectCurrentColor . Fill = new SolidColorBrush ( Color . FromArgb ( c2 . Alpha , c2 . Red , c2 . Green , c2 . Blue ) ) ;
1195
+ currentColor = Win32GetScreenPixelColor ( ) ;
1196
+ rectCurrentColor . Fill = currentColor . AsSolidColorBrush ( ) ;
1229
1197
ResetCurrentBrightnessPreview ( currentColor ) ;
1230
1198
}
1231
1199
0 commit comments