Differenze tra le versioni di "Creare uno pseudo-slider con uno o più cursori posti fra un valore minimo e uno massimo variabili"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "E' possibile creare uno pseudo-slider avente uno o più cursori, indicatori di valori, che potranno essere spostati nell'ambito di due valori, uno minimo e uno massimo, variab...") |
(Nessuna differenza)
|
Versione delle 05:00, 27 giu 2024
E' possibile creare uno pseudo-slider avente uno o più cursori, indicatori di valori, che potranno essere spostati nell'ambito di due valori, uno minimo e uno massimo, variabili e determinabili dall'utente.
Creare uno pseudo-slider avente un cursore indicatore posto fra un valore minimo e un valore massimo variabili arbitrariamente
Vediamo un possibile esempio:
Private DrawingArea1 As DrawingArea Private bt1 As Button Private bt2 As Button Public Sub Form_Open() With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1" .X = 20 .Y = 20 .W = 310 .H = 20 .Border = Border.Solid End With With bt1 = New Button(DrawingArea1) As "BT" If Not Even(DrawingArea1.W * 0.03) Then .W = (DrawingArea1.W * 0.03) + 1 .H = DrawingArea1.H .X = 0 .Y = 0 .Text = String.Chr(&2193) End With With bt2 = New Button(DrawingArea1) As "BT" .W = bt1.W .H = DrawingArea1.H .X = DrawingArea1.W - .W .Y = 0 .Text = String.Chr(&2193) End With Me.Title = "Min = 0" & " Max = " & CStr(bt2.X) End Public Sub DrawingArea1_Draw() With Paint .Brush = Paint.Color(Color.Orange) .Rectangle(bt1.X + bt1.W, 0, (DrawingArea1.W - bt1.X) - (DrawingArea1.W - bt2.X), DrawingArea1.H) .Fill .End End With End Public Sub BT_MouseMove() With Last .X = .X + Mouse.X - Mouse.StartX .Y = .Y + Mouse.Y - Mouse.StartY End With If Last.Y <> 0 Then Last.Y = 0 Select Case Last.Id Case bt1.Id If bt1.X < 0 Then bt1.X = 0 If bt1.X > bt2.X - bt1.W Then bt1.X = bt2.X - bt1.W Case bt2.Id If bt2.X < (bt1.X + bt1.W) Then bt2.X = bt1.X + bt1.W If bt2.X > DrawingArea1.W - bt2.W Then bt2.X = DrawingArea1.W - bt2.W End Select DrawingArea1.Refresh ' I valori assunti dai due indicatori mobili durante il loro spostamento sono mostrati nel titolo della finestra del "Form": Me.Title = "Min = " & CStr(bt1.X) & " Max =" & CStr(bt2.X) End
Creare uno pseudo-slider avente due cursori indicatori posti fra un valore minimo e un valore massimo variabili arbitrariamente
Vediamo un possibile esempio:
Private DrawingArea1 As DrawingArea Private bt1 As Button Private bt2 As Button Private bt3 As Button Public Sub Form_Open() With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1" .X = 20 .Y = 20 .W = 310 .H = 20 .Border = Border.Solid End With With bt1 = New Button(DrawingArea1) As "BT" If Not Even(DrawingArea1.W * 0.03) Then .W = (DrawingArea1.W * 0.03) + 1 .H = DrawingArea1.H .X = 0 .Y = 0 .Text = String.Chr(&2193) End With With bt2 = New Button(DrawingArea1) As "BT" .W = bt1.W .H = DrawingArea1.H .X = DrawingArea1.W - (DrawingArea1.W / 2) .Y = 0 .Text = String.Chr(&2193) End With With bt3 = New Button(DrawingArea1) As "BT" .W = bt1.W .H = DrawingArea1.H .X = DrawingArea1.W - .W .Y = 0 .Text = String.Chr(&2193) End With Me.Title = "Min = " & CStr(bt1.X) & " Med =" & CStr(bt2.X) & " Max =" & CStr(bt3.X) End Public Sub DrawingArea1_Draw() With Paint .Brush = Paint.Color(Color.Green) .Rectangle(bt1.X + bt1.W, 0, (DrawingArea1.W - bt1.X) - (DrawingArea1.W - bt2.X), DrawingArea1.H) .Fill .Brush = Paint.Color(Color.Orange) .Rectangle(bt2.X + bt2.W, 0, (DrawingArea1.W - bt2.X) - (DrawingArea1.W - bt3.X), DrawingArea1.H) .Fill .End End With End Public Sub BT_MouseMove() With Last .X = .X + Mouse.X - Mouse.StartX .Y = .Y + Mouse.Y - Mouse.StartY End With If Last.Y <> 0 Then Last.Y = 0 Select Case Last.Id Case bt1.Id If bt1.X < 0 Then bt1.X = 0 If bt1.X > bt2.X - bt1.W Then bt1.X = bt2.X - bt1.W Case bt2.Id If bt2.X < (bt1.X + bt1.W) Then bt2.X = bt1.X + bt1.W If (bt2.X + bt2.W) > bt3.X Then bt2.X = bt3.X - bt2.W Case bt3.Id If bt3.X < (bt2.X + bt2.W) Then bt3.X = bt2.X + bt2.W If (bt3.X + bt3.W) > DrawingArea1.W Then bt3.X = DrawingArea1.W - bt3.W End Select DrawingArea1.Refresh ' I valori assunti dai tre indicatori mobili durante il loro spostamento sono mostrati nel titolo della finestra del "Form": Me.Title = "Min = " & CStr(bt1.X) & " Med =" & CStr(bt2.X) & " Max =" & CStr(bt3.X) End
Creare uno pseudo-slider avente tre cursori indicatori posti fra un valore minimo e un valore massimo variabili arbitrariamente
Vediamo un possibile esempio:
Private DrawingArea1 As DrawingArea Private bt1 As Button Private bt2 As Button Private bt3 As Button Private bt4 As Button Public Sub Form_Open() With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1" .X = 20 .Y = 20 .W = 310 .H = 20 .Border = Border.Solid End With With bt1 = New Button(DrawingArea1) As "BT" If Not Even(DrawingArea1.W * 0.03) Then .W = (DrawingArea1.W * 0.03) + 1 .H = DrawingArea1.H .X = 0 .Y = 0 .Text = String.Chr(&2193) End With With bt2 = New Button(DrawingArea1) As "BT" .W = bt1.W .H = DrawingArea1.H .X = DrawingArea1.W - (DrawingArea1.W * 0.6) .Y = 0 .Text = String.Chr(&2193) End With With bt3 = New Button(DrawingArea1) As "BT" .W = bt1.W .H = DrawingArea1.H .X = DrawingArea1.W - (DrawingArea1.W * 0.3) .Y = 0 .Text = String.Chr(&2193) End With With bt4 = New Button(DrawingArea1) As "BT" .W = bt1.W .H = DrawingArea1.H .X = DrawingArea1.W - .W .Y = 0 .Text = String.Chr(&2193) End With Me.Title = "Min = " & CStr(bt1.X) & " Med1 =" & CStr(bt2.X) & " Med2 =" & CStr(bt3.X) & " Max =" & CStr(bt4.X) End Public Sub DrawingArea1_Draw() With Paint .Brush = Paint.Color(Color.Green) .Rectangle(bt1.X + bt1.W, 0, (DrawingArea1.W - bt1.X) - (DrawingArea1.W - bt2.X), DrawingArea1.H) .Fill .Brush = Paint.Color(Color.Yellow) .Rectangle(bt2.X + bt2.W, 0, (DrawingArea1.W - bt2.X) - (DrawingArea1.W - bt3.X), DrawingArea1.H) .Fill .Brush = Paint.Color(Color.Red) .Rectangle(bt3.X + bt3.W, 0, (DrawingArea1.W - bt3.X) - (DrawingArea1.W - bt4.X), DrawingArea1.H) .Fill .End End With End Public Sub BT_MouseMove() With Last .X = .X + Mouse.X - Mouse.StartX .Y = .Y + Mouse.Y - Mouse.StartY End With If Last.Y <> 0 Then Last.Y = 0 Select Case Last.Id Case bt1.Id If bt1.X < 0 Then bt1.X = 0 If bt1.X > bt2.X - bt1.W Then bt1.X = bt2.X - bt1.W Case bt2.Id If bt2.X < (bt1.X + bt1.W) Then bt2.X = bt1.X + bt1.W If (bt2.X + bt2.W) > bt3.X Then bt2.X = bt3.X - bt2.W Case bt3.Id If bt3.X < (bt2.X + bt2.W) Then bt3.X = bt2.X + bt2.W If (bt3.X + bt3.W) > bt4.X Then bt3.X = bt4.X - bt3.W Print "bt3" Case bt4.Id If bt4.X < (bt3.X + bt3.W) Then bt4.X = bt3.X + bt3.W If (bt4.X + bt4.W) > DrawingArea1.W Then bt4.X = DrawingArea1.W - bt4.W End Select DrawingArea1.Refresh ' I valori assunti dai tre indicatori mobili durante il loro spostamento sono mostrati nel titolo della finestra del "Form": Me.Title = "Min = " & CStr(bt1.X) & " Med1 =" & CStr(bt2.X) & " Med2 =" & CStr(bt3.X) & " Max =" & CStr(bt4.X) End