@@ -43,6 +43,7 @@ public partial class MainWindow : Window, INotifyPropertyChanged
4343 // colors
4444 PixelColor currentColor ;
4545 PixelColor [ ] palette ;
46+
4647 int currentColorIndex = 0 ;
4748 byte opacity = 255 ;
4849
@@ -176,8 +177,8 @@ void Start()
176177 palette = LoadPalette ( "pack://application:,,,/Resources/Palettes/aap-64-1x.png" , paletteBitmap , paletteResolutionX , paletteResolutionY ) ;
177178 currentColorIndex = 5 ;
178179 currentColor = palette [ currentColorIndex ] ;
179- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
180- UpdateCurrentHue ( currentColor ) ;
180+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
181+ ResetCurrentBrightnessPreview ( currentColor ) ;
181182 }
182183
183184
@@ -318,11 +319,11 @@ void PickPalette(MouseEventArgs e)
318319 currentColorIndex = y * paletteResolutionX + x + 1 ; // +1 for fix index magic number..
319320 currentColor = palette [ currentColorIndex ] ;
320321
321- UpdateCurrentHue ( currentColor ) ;
322+ ResetCurrentBrightnessPreview ( currentColor ) ;
322323 }
323324
324325 LinearGradientBrush myBrush ;
325- void UpdateCurrentHue ( PixelColor c )
326+ void ResetCurrentBrightnessPreview ( PixelColor c )
326327 {
327328 hueLocation = 0.5 ;
328329
@@ -357,8 +358,9 @@ void UpdateCurrentHue(PixelColor c)
357358
358359 rectCurrentHue . Fill = myBrush ;
359360
360- //myBrush.GradientStops
361-
361+ // move hueline
362+ int offset = ( int ) ( hueLocation * 253 ) ;
363+ lineCurrentHueLine . Margin = new Thickness ( offset , 0 , offset , 0 ) ;
362364 }
363365
364366 // https://stackoverflow.com/a/39450207/5452781
@@ -424,7 +426,8 @@ unsafe PixelColor GetPixelColor(int x, int y, WriteableBitmap source)
424426 void PaletteLeftButtonDown ( object sender , MouseButtonEventArgs e )
425427 {
426428 PickPalette ( e ) ;
427- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
429+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
430+ ResetCurrentBrightnessPreview ( currentColor ) ;
428431 }
429432
430433 void DrawingRightButtonDown ( object sender , MouseButtonEventArgs e )
@@ -440,8 +443,8 @@ void DrawingMiddleButtonDown(object sender, MouseButtonEventArgs e)
440443 int y = ( int ) ( e . GetPosition ( drawingImage ) . Y / canvasScaleX ) ;
441444
442445 currentColor = GetPixel ( x , y ) ;
443- SetRectangleFillColor ( rectCurrentColor , currentColor ) ;
444- UpdateCurrentHue ( currentColor ) ;
446+ SetCurrentColorPreviewBox ( rectCurrentColor , currentColor ) ;
447+ ResetCurrentBrightnessPreview ( currentColor ) ;
445448 }
446449 }
447450
@@ -526,7 +529,7 @@ void DrawingAreaMouseMoved(object sender, MouseEventArgs e)
526529 else if ( e . MiddleButton == MouseButtonState . Pressed )
527530 {
528531 currentColor = GetPixel ( x , y ) ;
529- UpdateCurrentHue ( currentColor ) ;
532+ ResetCurrentBrightnessPreview ( currentColor ) ;
530533 }
531534
532535 ShowMousePos ( x , y ) ;
@@ -586,7 +589,12 @@ void DrawingMouseWheel(object sender, MouseWheelEventArgs e)
586589 cc . Blue = c . B ;
587590 cc . Alpha = 255 ;
588591 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 ) ;
590598 }
591599
592600 private void OnClearButton ( object sender , RoutedEventArgs e )
@@ -999,7 +1007,7 @@ private void OnLevelSaturationMouseDown(object sender, MouseButtonEventArgs e)
9991007 c2 . Blue = c1 . B ;
10001008 currentColor = c2 ;
10011009 rectCurrentColor . Fill = new SolidColorBrush ( Color . FromArgb ( c2 . Alpha , c2 . Red , c2 . Green , c2 . Blue ) ) ;
1002- UpdateCurrentHue ( currentColor ) ;
1010+ ResetCurrentBrightnessPreview ( currentColor ) ;
10031011 }
10041012 } // class
10051013
0 commit comments