Advertisement
Roland-2

GControlsPack(Gscrollbar AddOps2)

Jan 14th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.36 KB | None | 0 0
  1.  Dim _mMaxReturnValue As Integer = 100
  2.     Dim _mReturnValue As Double
  3.     Dim _mValue2 As Integer = 0
  4.     Dim _maverage As Integer
  5.     Dim _mMax As Integer = 100
  6.     Dim _mMin As Integer = 0
  7.     Dim _mValue As Integer = 0
  8.  
  9. #Region "Value Properties"
  10.  
  11.  
  12.     Public Property MaxReturnValue() As Integer
  13.         Get
  14.             Return _mMaxReturnValue
  15.         End Get
  16.         Set(ByVal xvalue As Integer)
  17.             _mMaxReturnValue = xvalue
  18.             Me.Invalidate()
  19.         End Set
  20.     End Property
  21.  
  22.     Public Function ReturnValue() As Integer
  23.  
  24.         Return _mReturnValue
  25.  
  26.     End Function
  27.  
  28.     Public Property Maximum() As Integer
  29.         Get
  30.             Return _mMax
  31.         End Get
  32.         Set(ByVal xvalue As Integer)
  33.             _mMax = xvalue
  34.             If _mMax < Minimum Then Minimum = _mMax
  35.             If _mMax < Value Then Value = _mMax
  36.             Dim bull1 As Integer = Valuebulletl + 22 ' bullet=Left from Arrow spacing
  37.             Dim bull2 As Integer = Valuebulletr + ClientRectangle.Width * 0.3 + 1 'Bullet=Right Size 30 %
  38.             Dim zdiff As Integer = bull2 - bull1
  39.  
  40.             _mMax = Me.Width - zdiff - 40 - Me.Height ' height increase width bullet
  41.             Me.Invalidate()
  42.         End Set
  43.     End Property
  44.  
  45.     Public Function averages2() As Integer
  46.  
  47.         Return _maverage
  48.  
  49.     End Function
  50.  
  51.     Public Property Minimum() As Integer
  52.         Get
  53.             Return _mMin
  54.         End Get
  55.         Set(ByVal xvalue As Integer)
  56.             _mMin = xvalue
  57.             If _mMin > Maximum Then Maximum = _mMin
  58.             If _mMin > Value Then Value = _mMin
  59.             _mMin = 0
  60.             Me.Invalidate()
  61.         End Set
  62.     End Property
  63.  
  64.     <Category("Values"), Description("The control's value"),
  65.  DefaultValue(0)>
  66.     Public Property Value() As Integer
  67.         Get
  68.             Return _mValue
  69.         End Get
  70.  
  71.         Set(ByVal xvalue As Integer)
  72.             _mValue = xvalue
  73.             If _mValue < Minimum Then _mValue = Minimum
  74.             If _mValue > Maximum Then _mValue = Maximum
  75.  
  76.             Dim z As Double = (Maximum) / 100
  77.             _maverage = CInt(Value / z)
  78.  
  79.             If _maverage < 1 Then
  80.                 _mReturnValue = 0
  81.             Else
  82.                 _mReturnValue = _mMaxReturnValue * (_maverage / 100)
  83.             End If
  84.  
  85.             xvalue = _mValue
  86.             RaiseEvent ValueChanged()
  87.             Me.Invalidate()
  88.  
  89.         End Set
  90.     End Property
  91.  
  92.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  93.         MyBase.OnResize(e)
  94.         'Resizing refreshes the graphics
  95.         Dim bull1 As Object = Me.Valuebulletl + 22
  96.  
  97.  
  98.         Dim bull2 As Object = Me.Valuebulletr + Me.Width * 0.3
  99.         Dim zdiff As Integer = bull2 - bull1 'width of bullet
  100.  
  101.  
  102.         Me.Maximum = Me.Width - zdiff - 40 - Me.Height
  103.  
  104.         Me.Invalidate()
  105.     End Sub
  106.  
  107.  
  108.  
  109.  
  110. Form1
  111.  Private Sub GScrollBar1_ValueChanged() Handles GScrollBar1.ValueChanged
  112.  
  113.         Me.Pnlright.Width = CInt((Me.Width) * (100 - GScrollBar1.averages2) * (0.01)) - 13
  114.  
  115.         TextBox1.Text = GScrollBar1.averages2
  116.         TextBox2.Text = GScrollBar1.ReturnValue
  117.         TextBox3.Text = GScrollBar1.Value
  118.         TextBox1.Refresh()
  119.         TextBox2.Refresh()
  120.         TextBox3.Refresh()
  121.         ListBox1.Refresh()
  122.         ListBox2.Refresh()
  123.         GScrollBar1.Refresh()
  124.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement