@@ -43,6 +43,7 @@ public partial class MainWindow : Window, INotifyPropertyChanged
43
43
// colors
44
44
PixelColor currentColor ;
45
45
PixelColor [ ] palette ;
46
+
46
47
int currentColorIndex = 0 ;
47
48
byte opacity = 255 ;
48
49
@@ -176,8 +177,8 @@ void Start()
176
177
palette = LoadPalette ( "pack://application:,,,/Resources/Palettes/aap-64-1x.png" , paletteBitmap , paletteResolutionX , paletteResolutionY ) ;
177
178
currentColorIndex = 5 ;
178
179
currentColor = palette [ currentColorIndex ] ;
179
- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
180
- UpdateCurrentHue ( currentColor ) ;
180
+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
181
+ ResetCurrentBrightnessPreview ( currentColor ) ;
181
182
}
182
183
183
184
@@ -318,11 +319,11 @@ void PickPalette(MouseEventArgs e)
318
319
currentColorIndex = y * paletteResolutionX + x + 1 ; // +1 for fix index magic number..
319
320
currentColor = palette [ currentColorIndex ] ;
320
321
321
- UpdateCurrentHue ( currentColor ) ;
322
+ ResetCurrentBrightnessPreview ( currentColor ) ;
322
323
}
323
324
324
325
LinearGradientBrush myBrush ;
325
- void UpdateCurrentHue ( PixelColor c )
326
+ void ResetCurrentBrightnessPreview ( PixelColor c )
326
327
{
327
328
hueLocation = 0.5 ;
328
329
@@ -357,8 +358,9 @@ void UpdateCurrentHue(PixelColor c)
357
358
358
359
rectCurrentHue . Fill = myBrush ;
359
360
360
- //myBrush.GradientStops
361
-
361
+ // move hueline
362
+ int offset = ( int ) ( hueLocation * 253 ) ;
363
+ lineCurrentHueLine . Margin = new Thickness ( offset , 0 , offset , 0 ) ;
362
364
}
363
365
364
366
// https://stackoverflow.com/a/39450207/5452781
@@ -424,7 +426,8 @@ unsafe PixelColor GetPixelColor(int x, int y, WriteableBitmap source)
424
426
void PaletteLeftButtonDown ( object sender , MouseButtonEventArgs e )
425
427
{
426
428
PickPalette ( e ) ;
427
- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
429
+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
430
+ ResetCurrentBrightnessPreview ( currentColor ) ;
428
431
}
429
432
430
433
void DrawingRightButtonDown ( object sender , MouseButtonEventArgs e )
@@ -440,8 +443,8 @@ void DrawingMiddleButtonDown(object sender, MouseButtonEventArgs e)
440
443
int y = ( int ) ( e . GetPosition ( drawingImage ) . Y / canvasScaleX ) ;
441
444
442
445
currentColor = GetPixel ( x , y ) ;
443
- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
444
- UpdateCurrentHue ( currentColor ) ;
446
+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
447
+ ResetCurrentBrightnessPreview ( currentColor ) ;
445
448
}
446
449
}
447
450
@@ -526,7 +529,7 @@ void DrawingAreaMouseMoved(object sender, MouseEventArgs e)
526
529
else if ( e . MiddleButton == MouseButtonState . Pressed )
527
530
{
528
531
currentColor = GetPixel ( x , y ) ;
529
- UpdateCurrentHue ( currentColor ) ;
532
+ ResetCurrentBrightnessPreview ( currentColor ) ;
530
533
}
531
534
532
535
ShowMousePos ( x , y ) ;
@@ -586,7 +589,12 @@ void DrawingMouseWheel(object sender, MouseWheelEventArgs e)
586
589
cc . Blue = c . B ;
587
590
cc . Alpha = 255 ;
588
591
currentColor = cc ;
589
- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
592
+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
593
+ //ResetCurrentBrightnessPreview(currentColor);
594
+
595
+ // move hueline
596
+ int offset = ( int ) ( hueLocation * 253 ) ;
597
+ lineCurrentHueLine . Margin = new Thickness ( offset , 0 , offset , 0 ) ;
590
598
}
591
599
592
600
private void OnClearButton ( object sender , RoutedEventArgs e )
@@ -999,7 +1007,7 @@ private void OnLevelSaturationMouseDown(object sender, MouseButtonEventArgs e)
999
1007
c2 . Blue = c1 . B ;
1000
1008
currentColor = c2 ;
1001
1009
rectCurrentColor . Fill = new SolidColorBrush ( Color . FromArgb ( c2 . Alpha , c2 . Red , c2 . Green , c2 . Blue ) ) ;
1002
- UpdateCurrentHue ( currentColor ) ;
1010
+ ResetCurrentBrightnessPreview ( currentColor ) ;
1003
1011
}
1004
1012
} // class
1005
1013
0 commit comments