Autor Beitrag
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 04.07.11 07:11 
Hallo Leute,

weiß jemand wo ich mir solche TrackBar Steuerelementerunterladen kann: www8.pic-upload.de/0....11/3w2tg8eiaseo.jpg
oder muss ich so etwas selber schreiben, wenn ja, wie geht so etwas ?

Liebe Grüße BleachRukia
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mo 04.07.11 09:12 
Hallo,

bei User-Controls würde ich immer zuerst bei codeproject.com nachschauen.
Ich habe folgende TrackBar (Slider)-Controls gefunden:
www.codeproject.com/...cctrl/gTrackBar.aspx
www.codeproject.com/...ion/ColorSlider.aspx
(und da dort der Source-Code dabei ist, kannst du ja dann einen LinearGradientBrush o.ä als Path zum Zeichnen verwenden.)

Und weitere Controls findest du über die Suche dort: www.codeproject.com/search.aspx (und dabei "Articles" ankreuzen und am besten "C#" zusätzlich zum Suchbegriff eingeben)
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 05.07.11 20:39 
Hallo,

deine Antwort war wirklich hilfreich, habe zum Thema LinearGradientBrush folgendes im Netz gefunden:

ausblenden C#-Quelltext
1:
2:
3:
4:
            LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(new Rectangle(00this.panel1.Width, this.panel1.Height), Color.Red, Color.Green, LinearGradientMode.Horizontal);
            Graphics Graphics = Graphics.FromHwnd(this.panel1.Handle);
            Graphics.FillRectangle(LinearGradientBrush, new Rectangle(00this.panel1.Width, this.panel1.Height));
            Graphics.Dispose();


Mit dieser Lösung kann ich aber nur einen Farbverlauf mit 2 Farben Maximal machen aber ich wollte ja einen Farbverlauf mit allen Farben machen, so wie es auf dem Bild ist, kennt da jemand eine Lösung ?

Liebe Grüße BleachRukia
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Di 05.07.11 22:51 
Hallo,

mit dieser Klasse kannst du dir eine Farbe basierend auf Farbton (Hue), Helligkeit (Brightness) und Sättigung (Saturation) erstellen. Die lezten beiden kannst du auf einem konstanten Wert lassen, IMHO dürfte das 1 sein. Dann musst du nur noch in einer Schleife für jede Spalte der TrackBar eine senkrechte Linie in der bestimmten Farbe zeichnen.

Grüße,
Yogu
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 06.07.11 10:05 
Hallo BleachRukia,

BleachRukia hat folgendes geschrieben:
Mit dieser Lösung kann ich aber nur einen Farbverlauf mit 2 Farben Maximal machen

Du kannst aber mehrere LinearGradientBrush-Path Objekte nebeneinander zeichnen, z.B. rot->grün, grün->blau, blau->rot.

Und schau dir dazu auch mal die Farbleiste-Zeichnung bei HSL-Farbraum an.
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 10:32 
Hallo TH69,

so etwas habe ich mir auch schon überlegt aber gut das du es erwähnst hast, da war ich wenigstens schon mal auf dem richtigen Weg gewesen :D

Liebe Grüße BleachRukia
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 11:17 
Hallo,

habe ein riesen Problem, das einfach nur unlogisch für mich ist, mit dieser Schleife male ich einen Farbverlauf:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
        int Position;
        Color Color01;
        Color Color02;
        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 2; i++)
            {
                switch (i)
                {
                    case 0:
                        Color01 = Color.Red;
                        Color02 = Color.Yellow;
                        break;
                    case 1:
                        Color01 = Color.Yellow;
                        Color02 = Color.Green;
                        break;

                }

                LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(new Rectangle(Position, 060this.panel1.Height), Color01, Color02, LinearGradientMode.Horizontal);
                Graphics Graphics = Graphics.FromHwnd(this.panel1.Handle);
                Graphics.FillRectangle(LinearGradientBrush, new Rectangle(Position, 060this.panel1.Height));
                Graphics.Dispose();
                Position += 60;
            }
        }


Mit jeder Position und Breite wird mir der Farbverlauf richtig gemalt, nur nicht mit der Zahl 60 :shock: , bekomme dann immer mit Color02 einen kleinen Farbbalken als Schnitt im Farbverlauf, weiß jemand wieso ?

Liebe Grüße BleachRukia
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 13:13 
Hallo,

ein besseres Beispiel für den Fehler ist dieser Code hier: (Die Breite von Panel ist 360)

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
        int Position;
        Color Color01, Color02;
        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 6; i++)
            {
                switch (i)
                {
                    case 0:
                        Color01 = Color.Red;
                        Color02 = Color.Yellow;
                        break;
                    case 1:
                        Color01 = Color.Yellow;
                        Color02 = Color.Green;
                        break;
                    case 2:
                        Color01 = Color.Green;
                        Color02 = Color.Cyan;
                        break;
                    case 3:
                        Color01 = Color.Cyan;
                        Color02 = Color.Blue;
                        break;
                    case 4:
                        Color01 = Color.Blue;
                        Color02 = Color.Magenta;
                        break;
                    case 5:
                        Color01 = Color.Magenta;
                        Color02 = Color.Red;
                        break;
                }

                LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(new Rectangle(Position, 0this.panel1.Width / 6this.panel1.Height), Color01, Color02, LinearGradientMode.Horizontal);
                Graphics Graphics = Graphics.FromHwnd(this.panel1.Handle);
                Graphics.FillRectangle(LinearGradientBrush, new Rectangle(Position, 0this.panel1.Width / 6this.panel1.Height));
                Graphics.Dispose();
                Position += this.panel1.Width / 6;
            }
        }


Liebe Grüße BleachRukia
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 06.07.11 13:17 
Hallo,

ich habe den Farbverlauf bei mir selber getestet und kann den selben Effekt nachvollziehen, d.h Striche im Bild. Dies scheint nicht nur bei 60 sondern auch bei anderen Schrittweiten zu passieren (ich habe dafür extra auf die Form gezeichnet, so daß ich diese in der Größe verändern kann und sich die Schrittweite (step) daran anpaßt):
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
private void MainForm_Paint(object sender, PaintEventArgs e)
{
  int position = 0;
  int step = this.ClientSize.Width / 6;
  Color color01 = new Color();
  Color color02 = new Color();
  for (int i = 0; i < 6; i++)
  {
    switch (i)
    {
      case 0:
        color01 = Color.Red;
        color02 = Color.Yellow;
        break;
      case 1:
        color01 = Color.Yellow;
        color02 = Color.Lime;
        break;
      case 2:
        color01 = Color.Lime;
        color02 = Color.Cyan;
        break;
      case 3:
        color01 = Color.Cyan;
        color02 = Color.Blue;
        break;
      case 4:
        color01 = Color.Blue;
        color02 = Color.Magenta;
        break;
      case 5:
        color01 = Color.Magenta;
        color02 = Color.Red;
        break;
    }

    Rectangle rect = new Rectangle(position, 0, step, this.ClientSize.Height+1);
    using(LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, color01, color02, LinearGradientMode.Horizontal))
      e.Graphics.FillRectangle(linearGradientBrush, rect);
    position += step;
  }
}

Es scheint wohl eine interne Rechenungenauigkeit beim LinearGradientBrush vorzuliegen.
Evtl bringt es ja was, auf Fließkommazahlen umzusteigen...

Edit: ja, ein bißchen besser wird es bei 'float':
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
float position = 0;
float step = this.ClientSize.Width / 6.0f;

//...

RectangleF rect = new RectangleF(position, 0, step, this.ClientSize.Height+1);

aber bei einigen wenigen Schrittweiten bleiben trotzdem ein paar Striche übrig :gruebel:
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von Th69 am Mi 06.07.11 14:00, insgesamt 4-mal bearbeitet
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 13:24 
Hallo,

wie hast den du das jetzt hinbekommen das keine Schnittstellen angezeigt werden, habe deinen Code ausprobiert, aber bekomme wieder den selben Fehler !?

Liebe Grüße BleachRukia
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 06.07.11 13:32 
Hallo,

bei 59 und 60 kriege ich auch weiterhin die Striche, aber bei 58 bzw. 61 nicht.
Teste das mal bei dir aus.
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 13:34 
Hallo,

das weiß ich auch aber die Farben sollen ja mit der Breite des Controls übereinstimmen.

Liebe Grüße BleachRukia

ps. Wenn das so weitergeht werde ich mir ein Bild von einem Farbverlauf herunterladen und als Backgroundimage setzen lol
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 06.07.11 13:54 
Habe gerade mal im Internet recherchiert:
www.dotnetmonster.co...earGradientBrush-bug
stackoverflow.com/qu...-artifact-workaround
objectmix.com/dotnet...argradientbrush.html
www.mycsharp.de/wbb2...ad.php?postid=282727

scheint also ein bekanntes Problem zu sein :)

Mittels
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, color01, color02, LinearGradientMode.Horizontal))
{
  linearGradientBrush.WrapMode = WrapMode.TileFlipX;
  e.Graphics.FillRectangle(linearGradientBrush, rect);
}

läßt sich das aber lösen und der Effekt taucht dann nicht mehr auf...

P.S. Habe gerade gemerkt, daß ich bei Grün die falsche Farbe genommen habe, anstatt Color.Green muß man Color.Lime verwenden (habe es oben korrigiert) - nun paßt es auch mit dem Wikipedia-Farbverlauf überein...
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 17:32 
Hallo,

tausend dank, jetzt funktioniert es richtig :D

Mit diesem Code hier kann ich unabhängig von der Größe, in jedes Control meinen Farbverlauf malen: www8.pic-upload.de/0....11/owu39xt549z4.jpg

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
        int Position;
        Color Color01, Color02;
        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 6; i++)
            {
                switch (i)
                {
                    case 0:
                        Color01 = Color.Red;
                        Color02 = Color.Yellow;
                        break;
                    case 1:
                        Color01 = Color.Yellow;
                        Color02 = Color.Green;
                        break;
                    case 2:
                        Color01 = Color.Green;
                        Color02 = Color.Cyan;
                        break;
                    case 3:
                        Color01 = Color.Cyan;
                        Color02 = Color.Blue;
                        break;
                    case 4:
                        Color01 = Color.Blue;
                        Color02 = Color.Magenta;
                        break;
                    case 5:
                        Color01 = Color.Magenta;
                        Color02 = Color.Red;
                        break;
                }

                LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(new Rectangle(Position, 0this.panel1.Width / 6this.panel1.Height), Color01, Color02, LinearGradientMode.Horizontal);
                LinearGradientBrush.WrapMode = WrapMode.TileFlipX;
                Graphics Graphics = Graphics.FromHwnd(this.panel1.Handle);
                Graphics.FillRectangle(LinearGradientBrush, new Rectangle(Position, 0this.panel1.Width / 6this.panel1.Height));
                Graphics.Dispose();
                Position += this.panel1.Width / 6;
            }
        }


Jetzt habe ich aber folgendes Problem, wie ihr auf dem Bild sicher sehen könnt, schaut die Linie an dem der Slider entlang fährt auf beiden Seiten
etwas heraus(Combo aus Panel und TrackBar), dies muss so sein das der Slider genau mit dem Pfeil an die erste oder letzte Position zeigt, nur leider stört mich das sehr das es an beiden Seiten herausschaut, die Sliders in den Links von TH69 haben mir jetzt auch nicht wirklich zugesagt, was ich aber komisch finde ist, die Sliders von Photoshop habe ich schon in ganz vielen Programmen gesehen, machen die die alle selber oder laden die sich die Slider irgendwo herunter, wenn nicht wie kann ich solche Slider selber machen die dann genauso ausehen ?

Liebe Grüße BleachRukia
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 06.07.11 17:56 
Hallo,
meinst du wie bei www.photoshopessenti...aturation-slider.gif ?
Dort ist es ja auch ein Control, d.h. es wird in der Sliderleiste gezeichnet (und nicht wie bei dir zwei Controls übereinander).

P.S. Noch als Zusatz:
Zeichne immer im Paint-Ereignis (so wie mein Code von oben), niemals von außen durch z.B. einen ButtonClick und die Verwendung von Graphics.FromHwnd oder CreateGraphics.
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.07.11 19:03 
user profile iconTh69 hat folgendes geschrieben Zum zitierten Posting springen:
Hallo,
meinst du wie bei www.photoshopessenti...aturation-slider.gif ?
Dort ist es ja auch ein Control, d.h. es wird in der Sliderleiste gezeichnet (und nicht wie bei dir zwei Controls übereinander).


Hallo,

genau das meine ich, genau nach so etwas habe ich gesucht, weißt du wie ich so etwas in mein Programm reinbekomme ?

Liebe Grüße BleachRukia

PS. Vielen dank mit dem Tipp, nur im Paint Event Zeichnen :D
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.07.11 15:39 
Hallo Leute,

in den letzten Tagen habe ich mich intensive mit dem Tehma Color Sliders beschäftigt und Projekte wie dieses gefunden: www.avengersutd.com/...-windows-forms-in-c/

Habe jetzt meinen eigenen ColorSlider mit diesem Code geschrieben:

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int Position;
        Color Color01, Color02;
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 0; i < 6; i++)
            {
                switch (i)
                {
                    case 0:
                        Color01 = Color.Red;
                        Color02 = Color.Yellow;
                        break;
                    case 1:
                        Color01 = Color.Yellow;
                        Color02 = Color.Green;
                        break;
                    case 2:
                        Color01 = Color.Green;
                        Color02 = Color.Cyan;
                        break;
                    case 3:
                        Color01 = Color.Cyan;
                        Color02 = Color.Blue;
                        break;
                    case 4:
                        Color01 = Color.Blue;
                        Color02 = Color.Magenta;
                        break;
                    case 5:
                        Color01 = Color.Magenta;
                        Color02 = Color.Red;
                        break;
                }

                Rectangle Rectangle = new Rectangle(Position, 0this.panel1.Width / 6this.panel1.Height);
                LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(Rectangle, Color01, Color02, LinearGradientMode.Horizontal);
                LinearGradientBrush.WrapMode = WrapMode.TileFlipX;
                e.Graphics.FillRectangle(LinearGradientBrush, Rectangle);
                Position += this.panel1.Width / 6;
            }
        }

        int MouseX;
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Point[] Triangle = { new Point(this.panel1.Location.X - 6 + MouseX, this.panel1.Location.Y + this.panel1.Height + 10), 
                                 new Point(this.panel1.Location.X + 6 + MouseX, this.panel1.Location.Y + this.panel1.Height + 10), 
                                 new Point(this.panel1.Location.X + MouseX, this.panel1.Location.Y + this.panel1.Height) };
            e.Graphics.FillPolygon(new SolidBrush(Color.DarkGray), Triangle);
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (e.Y >= this.panel1.Location.Y + this.panel1.Height && e.Y <= this.panel1.Location.Y + this.panel1.Height + 10)
                {
                    if (e.X >= this.panel1.Location.X && e.X <= this.panel1.Location.X + this.panel1.Width)
                    {
                        MouseX = e.X - this.panel1.Location.X;
                    }
                    else if (e.X <= this.panel1.Location.X)
                    {
                        MouseX = 0;
                    }
                    else if (e.X >= this.panel1.Location.X + this.panel1.Width)
                    {
                        MouseX = 200;
                    }

                    this.Refresh();
                    this.Text = MouseX.ToString();
                }
            }
        }
    }
}


Mit diesem Code kann ich den Vrogang wunderbar darstellen nur mit 2 Einschränkungen/Probleme.

Das 1. wäre, wenn ich das Dreieck bewege, dann muss neu gezeichnet werden, das funktioniert auch gut beim Dreieck nur leider löscht das Programm dann den Farbverlauf, kennt Jemand eine alternative/Lösung zu Refresh zum neu zeichnen ?

Das 2. wäre, das das Ergeniss des Dreiecks immer der Min/Max Wert der Breite des Panels ist, aber ich wollte es so machen das es immer unabhängig von der Breite des Panels von 0 bis 360 geht.

Liebe Grüße BleachRukia
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.07.11 18:13 
Hallo,

habe das Problem mit der Farbe halb gelöst, der Positions Wert musste einfach bei jedem Paint Event wieder auf 0 gesetzt werden, nur leider flackert das Panel jetzt bei jedem Paint Event :(

Liebe Grüße BleachRukia
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.07.11 20:36 
Hallo Leute,

habe das Problem mit dem flackern gelöst, anstatt immer wieder alles neu zu zeichnen, rufe ich mit diesem Code hier:

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int Position;
        Color Color01, Color02;
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 0; i < 6; i++)
            {
                switch (i)
                {
                    case 0:
                        Color01 = Color.Red;
                        Color02 = Color.Yellow;
                        break;
                    case 1:
                        Color01 = Color.Yellow;
                        Color02 = Color.Green;
                        break;
                    case 2:
                        Color01 = Color.Green;
                        Color02 = Color.Cyan;
                        break;
                    case 3:
                        Color01 = Color.Cyan;
                        Color02 = Color.Blue;
                        break;
                    case 4:
                        Color01 = Color.Blue;
                        Color02 = Color.Magenta;
                        break;
                    case 5:
                        Color01 = Color.Magenta;
                        Color02 = Color.Red;
                        break;
                }

                Rectangle Rectangle = new Rectangle(Position, 0this.panel1.Width / 6this.panel1.Height);
                LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(Rectangle, Color01, Color02, LinearGradientMode.Horizontal);
                LinearGradientBrush.WrapMode = WrapMode.TileFlipX;
                e.Graphics.FillRectangle(LinearGradientBrush, Rectangle);
                Position += this.panel1.Width / 6;
            }
        }

        int MouseX;
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Point[] Triangle = { new Point(this.panel1.Location.X - 6 + MouseX, this.panel1.Location.Y + this.panel1.Height + 10), 
                                 new Point(this.panel1.Location.X + 6 + MouseX, this.panel1.Location.Y + this.panel1.Height + 10), 
                                 new Point(this.panel1.Location.X + MouseX, this.panel1.Location.Y + this.panel1.Height) };
            e.Graphics.Clear(Color.FromArgb(454545));
            e.Graphics.FillPolygon(new SolidBrush(Color.Gray), Triangle);
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (e.Y >= this.panel1.Location.Y + this.panel1.Height && e.Y <= this.panel1.Location.Y + this.panel1.Height + 10)
                {
                    if (e.X >= this.panel1.Location.X && e.X <= this.panel1.Location.X + this.panel1.Width)
                    {
                        MouseX = e.X - this.panel1.Location.X;
                    }
                    else if (e.X <= this.panel1.Location.X)
                    {
                        MouseX = 0;
                    }
                    else if (e.X >= this.panel1.Location.X + this.panel1.Width)
                    {
                        MouseX = 200;
                    }

                    this.Invalidate();
                    this.Text = MouseX.ToString() + " - " + "ColorSlider";
                }
            }
        }
    }
}


immer nur das Paint Event der Form auf :D

Liebe Grüße BleachRukia
BleachRukia
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 10.07.11 18:51 
Hallo Leute,

habe es endlich hinbekommen meine eigenen ColorSlider zu machen :D: www7.pic-upload.de/1....11/4f18aebi9bnh.jpg

Jetzt fehlt nur noch eine Sache, dann ist es perfekt, wenn ich im Hue Bereich eine Farbe auswähle möchte ich das die Farbstärke und auch der HelligkeitsSlider automatisch ihren Farbverlauf anpassen, wenn ich z.b. im Hue Bereich den FarbWert 58 habe, wie kann ich dann den Wert wieder in einen RGB Wert konvertieren, sodass ich dann wieder mit dem Farbverlauf Color.FromARGB(konvertierter Hue Wert zu RGB) zeichnen kann ?

Liebe Grüße BleachRukia