Irgend so etwas vielleicht???
Public Class frmCMYK
Dim WithEvents cyan As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = 10, .Height = 20, .Width = 300, .TickStyle = TickStyle.None}
Dim WithEvents magenta As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = cyan.Top + 40, .Height = 20, .Width = 300, .TickStyle = _
TickStyle.None}
Dim WithEvents yellow As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = magenta.Top + 40, .Height = 20, .Width = 300, .TickStyle = _
TickStyle.None}
Dim WithEvents key As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = yellow.Top + 40, .Height = 20, .Width = 300, .TickStyle = _
TickStyle.None}
Dim WithEvents pb As New PictureBox _
With {.Parent = Me, .Top = key.Top + 40, .Width = 300, .Height = 200}
Dim WithEvents cyan2 As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = 10, .Height = 20, .Width = 300, .TickStyle = TickStyle.None, _
.Left = 320}
Dim WithEvents magenta2 As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = cyan.Top + 40, .Height = 20, .Width = 300, .TickStyle = _
TickStyle.None, _
.Left = 320}
Dim WithEvents yellow2 As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = magenta.Top + 40, .Height = 20, .Width = 300, .TickStyle = _
TickStyle.None, _
.Left = 320}
Dim WithEvents key2 As New TrackBar With _
{.Parent = Me, .Minimum = 0, .Maximum = 100, _
.Top = yellow.Top + 40, .Height = 20, .Width = 300, .TickStyle = _
TickStyle.None, _
.Left = 320}
Dim WithEvents pb2 As New PictureBox _
With {.Parent = Me, .Top = key.Top + 40, .Width = 300, .Height = 200, _
.Left = 320}
Dim lblMix As New Label With _
{.Parent = Me, .Top = pb.top + pb.height + 10, .Width = 120, _
.Text = "Mixfaktor Farbe1 (%):"}
Dim WithEvents txtMix As New TextBox With _
{.Parent = Me, .Top = pb.top + pb.height + 10, .Width = 100, .Left = _
130}
Dim WithEvents pbMix As New PictureBox With _
{.Parent = Me, .Top = txtMix.top + txtMix.height + 10, _
.Width = 600, .Height = 200}
Private Sub frmCMYK_Load(sender As System.Object, _
e As System.EventArgs) Handles MyBase.Load
Me.Width = 660
Me.Height = 700
End Sub
Private Sub cyan_ValueChanged(sender As Object, e As System.EventArgs) _
Handles cyan.ValueChanged, magenta.ValueChanged, _
yellow.ValueChanged, key.ValueChanged, _
cyan2.ValueChanged, magenta2.ValueChanged, _
yellow2.ValueChanged, key2.ValueChanged
pb.Invalidate()
pb2.Invalidate()
pbmix.invalidate()
End Sub
Private Sub pb_Paint(sender As Object, _
e As System.Windows.Forms.PaintEventArgs) Handles pb.Paint, pb2.Paint
Dim pb As PictureBox = DirectCast(sender, PictureBox)
Dim r, g, b As Byte
If pb.Left = 0 Then
CMYK2RGB(cyan.Value / 100, magenta.Value / 100, _
yellow.Value / 100, key.Value / 100, _
r, g, b)
e.Graphics.Clear(Color.FromArgb(r, g, b))
Else
CMYK2RGB(cyan2.Value / 100, magenta2.Value / 100, _
yellow2.Value / 100, key2.Value / 100, _
r, g, b)
e.Graphics.Clear(Color.FromArgb(r, g, b))
End If
End Sub
Private Sub pbMix_Paint(sender As Object, _
e As System.Windows.Forms.PaintEventArgs) Handles pbMix.Paint
Dim mix As Double
If Not Double.TryParse(txtMix.Text, mix) OrElse (mix < 0 Or mix > _
100) Then
e.Graphics.Clear(Me.BackColor)
Else
Dim r, g, b As Byte
Dim c As Double = _
(mix * cyan.Value) / 10000 + (1 - mix / 100) * cyan2.Value / 100
Dim m As Double = _
(mix * magenta.Value) / 10000 + (1 - mix / 100) * magenta2.Value / _
100
Dim y As Double = _
(mix * yellow.Value) / 10000 + (1 - mix / 100) * yellow2.Value / 100
Dim k As Double = _
(mix * key.Value) / 10000 + (1 - mix / 100) * key2.Value / 100
CMYK2RGB(c, m, y, k, r, g, b)
e.Graphics.Clear(Color.FromArgb(r, g, b))
End If
End Sub
Private Sub txtMix_KeyDown(sender As Object, _
e As System.Windows.Forms.KeyEventArgs) Handles txtMix.KeyDown
If e.KeyCode = Keys.Return Then pbMix.Invalidate()
End Sub
End Class |