Click here to Skip to main content
15,886,199 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Change file extention association and apply changes? Pin
Member 21389208-Mar-09 21:32
Member 21389208-Mar-09 21:32 
GeneralRe: Change file extention association and apply changes? Pin
Dave Kreskowiak9-Mar-09 2:15
mveDave Kreskowiak9-Mar-09 2:15 
Questionlink for merger module for CR Pin
hrishiS6-Mar-09 2:32
hrishiS6-Mar-09 2:32 
AnswerRe: link for merger module for CR Pin
Dave Kreskowiak6-Mar-09 4:17
mveDave Kreskowiak6-Mar-09 4:17 
QuestionCrystal Reports Parameter problem Pin
Jay Royall6-Mar-09 1:44
Jay Royall6-Mar-09 1:44 
QuestionUsercontrol focus Pin
JR2126-Mar-09 0:54
JR2126-Mar-09 0:54 
AnswerRe: Usercontrol focus Pin
Eddy Vluggen6-Mar-09 1:15
professionalEddy Vluggen6-Mar-09 1:15 
GeneralRe: Usercontrol focus Pin
JR2129-Mar-09 4:28
JR2129-Mar-09 4:28 
Thanks for the help
Here is the result
Public Class DiagonalDoubleTextBox
#Region "Declare"
  Enum eDirection
    LeftUp2rightDown
    RightUp2LeftDown
  End Enum
  Dim _Direction As eDirection = eDirection.RightUp2LeftDown
  Dim _clrDiaLine As Color = Color.Red
  Dim _text() As String = {"U", "A"}
  Dim _activeCell As Integer = 1
  Dim _BackColor1 As Color = Color.White
  Dim _Forecolor1 As Color = Color.Black
  Dim _ForeColor0 As Color = Color.White
  Dim bm00, bm10, bm01, bm11 As Bitmap
#End Region
#Region "Propertys"
  Property BackColor1() As Color
    Get
      Return _BackColor1
    End Get
    Set(ByVal value As Color)
      _BackColor1 = value
      MyBase.Invalidate()
    End Set
  End Property
  Property ForeColor0() As Color
    Get
      Return _ForeColor0
    End Get
    Set(ByVal value As Color)
      _ForeColor0 = value
      MyBase.Invalidate()
    End Set
  End Property
  Property ForeColor1() As Color
    Get
      Return _Forecolor1
    End Get
    Set(ByVal value As Color)
      _Forecolor1 = value
      MyBase.Invalidate()
    End Set
  End Property
  Property Direction() As eDirection
    Get
      Return _Direction
    End Get
    Set(ByVal value As eDirection)
      _Direction = value
      MyBase.Invalidate()
    End Set
  End Property
  Property ColorDiagonalLine() As Color
    Get
      Return _clrDiaLine
    End Get
    Set(ByVal value As Color)
      _clrDiaLine = value
      MyBase.Invalidate()
    End Set
  End Property
  Property Tekst(ByVal Index As Integer) As String
    Get
      Return _text(Index)
    End Get
    Set(ByVal value As String)
      If value.Length > 1 Then value = value.Remove(2, value.Length - 1)
      _text(Index) = value
      MyBase.Invalidate()
    End Set
  End Property
#End Region
#Region "Handles"
  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Static b As Boolean
    b = Not b
    Select Case _activeCell
      Case 0
        Select Case b = True AndAlso Me.Focused
          Case True
            Me.BackgroundImage = bm01
          Case False
            Me.BackgroundImage = bm00
        End Select
      Case 1
        Select Case b AndAlso Me.Focused
          Case True
            Me.BackgroundImage = bm11
          Case False
            Me.BackgroundImage = bm10
        End Select
    End Select
  End Sub
  Sub New()
    ' This call is required by the Windows Form Designer.
    InitializeComponent()
    Me.Size = New Size(30, 30)
    Me.BackColor = Color.Black
    Me.BorderStyle = Windows.Forms.BorderStyle.Fixed3D
    ' Add any initialization after the InitializeComponent() call.
  End Sub
#End Region
#Region "Protected Sub"
  Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
    _text(Math.Abs(Not -_activeCell)) = e.KeyChar
    MyBase.OnKeyPress(e)
  End Sub
  Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
    Me.Width = Me.Height
    MyBase.OnResize(e)
  End Sub
  Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
    If e.KeyCode = Keys.PageDown Or e.KeyCode = Keys.PageUp Then
      _activeCell = Math.Abs(Not -_activeCell)
    End If
    MyBase.OnKeyDown(e)
  End Sub
  Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
    If e.Button = Windows.Forms.MouseButtons.Left Then
      Dim b As Bitmap = Me.BackgroundImage
      Dim c As Color = b.GetPixel(e.X, e.Y)
      If c.A = BackColor.A AndAlso c.B = BackColor.B AndAlso c.R = BackColor.R AndAlso c.G = BackColor.G Then
        _activeCell = 1
        Me.BackgroundImage = bm10
      Else
        _activeCell = 0
        Me.BackgroundImage = bm00
      End If
      MyBase.OnMouseDown(e)
    End If
    Me.Focus()
  End Sub

  Protected Overrides Sub OnMarginChanged(ByVal e As System.EventArgs)
    MyBase.Refresh()
    MyBase.OnMarginChanged(e)
  End Sub

  Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    bm00 = sMakePictures(0, 0)
    bm01 = sMakePictures(0, 1)
    bm10 = sMakePictures(1, 0)
    bm11 = sMakePictures(1, 1)
    MyBase.OnPaint(e)
  End Sub
#End Region
#Region "Functions"
  Function sMakePictures(ByVal nCel As Integer, ByVal nBlinkOn As Integer) As Bitmap
    Dim i As New Bitmap(Me.Width, Me.Height)
    Dim g As Graphics = Graphics.FromImage(i)
    If _Direction = eDirection.LeftUp2rightDown Then
      Dim p() As Point = {New Point(0, 0), New Point(Me.Width - 2, 0), New Point(Me.Width - 2, Me.Height - 2)}
      g.FillPolygon(New SolidBrush(_BackColor1), p)
      p(1) = New Point(0, Me.Height - 2)
      g.FillPolygon(New SolidBrush(Me.BackColor), p)
    Else
      Dim p() As Point = {New Point(0, 0), New Point(Me.Width - 2, 0), New Point(0, Me.Height - 2)}
      g.FillPolygon(New SolidBrush(_BackColor1), p)
      p(0) = New Point(Me.Width - 2, Me.Height - 2)
      g.FillPolygon(New SolidBrush(Me.BackColor), p)
    End If

    Dim s As String = _text(_activeCell)
    Dim SF As SizeF = g.MeasureString(s, Me.Font)
    Dim r0 As Rectangle
    Dim r1 As Rectangle
    Select Case _activeCell
      Case 1
        If _Direction = eDirection.RightUp2LeftDown Then
          r1.X = Me.Width - SF.Width - Me.Margin.Right
          r1.Y = Me.Height - SF.Height - Me.Margin.Bottom
        Else
          r1.Y = Me.Width - SF.Height - Me.Margin.Right
          r1.X = Me.Margin.Top
        End If
      Case 0
        If _Direction = eDirection.RightUp2LeftDown Then
          r0.Y = Me.Margin.Top
          r0.X = Me.Margin.Left
        Else
          r0.Y = Me.Margin.Top
          r0.X = Me.Width - Me.Margin.Right - SF.Width
        End If
    End Select
    r0.Width = SF.Width
    r0.Height = SF.Height
    r1.Width = SF.Width
    r1.Height = SF.Height

    If _Direction = eDirection.RightUp2LeftDown Then
      g.DrawLine(New Pen(_clrDiaLine), Me.Width - 1, 0, 0, Me.Height - 1)
      g.DrawString(_text(1), Me.Font, New SolidBrush(_Forecolor1), Me.Margin.Left, Me.Margin.Top)
      g.DrawString(_text(0), Me.Font, New SolidBrush(_ForeColor0), Me.Width - g.MeasureString(_text(1), Me.Font).Width - Me.Margin.Right, Me.Height - g.MeasureString(_text(1), Me.Font).Height - Me.Margin.Bottom)
    Else
      g.DrawLine(New Pen(_clrDiaLine), 0, 0, Me.Width - 1, Me.Height - 1)
      g.DrawString(_text(0), Me.Font, New SolidBrush(_ForeColor0), Me.Margin.Left, Me.Height - g.MeasureString(_text(0), Me.Font).Height - Me.Margin.Bottom)
      g.DrawString(_text(1), Me.Font, New SolidBrush(_Forecolor1), Me.Width - g.MeasureString(_text(1), Me.Font).Width - Me.Margin.Right, Me.Margin.Top)
    End If

    If nCel = 0 Then
      g.DrawRectangle(New Pen(_clrDiaLine), r0)
      If nBlinkOn = 1 Then g.FillRectangle(New SolidBrush(_clrDiaLine), r0)
    Else
      g.DrawRectangle(New Pen(_clrDiaLine), r1)
      If nBlinkOn = 1 Then g.FillRectangle(New SolidBrush(_clrDiaLine), r1)
    End If

    Return i
  End Function
#End Region
End Class


I'm not complete finish but this gives an idee
GeneralRe: Usercontrol focus Pin
Eddy Vluggen9-Mar-09 6:07
professionalEddy Vluggen9-Mar-09 6:07 
GeneralRe: Usercontrol focus Pin
JR2129-Mar-09 21:16
JR2129-Mar-09 21:16 
GeneralRe: Usercontrol focus Pin
Eddy Vluggen9-Mar-09 23:21
professionalEddy Vluggen9-Mar-09 23:21 
Questionapllication.startpath Pin
hrishiS6-Mar-09 0:08
hrishiS6-Mar-09 0:08 
AnswerRe: apllication.startpath Pin
Ashfield6-Mar-09 1:24
Ashfield6-Mar-09 1:24 
GeneralRe: apllication.startpath Pin
hrishiS6-Mar-09 1:39
hrishiS6-Mar-09 1:39 
GeneralRe: apllication.startpath Pin
Dave Kreskowiak6-Mar-09 3:57
mveDave Kreskowiak6-Mar-09 3:57 
QuestionHTML Email Behind Proxy Pin
Rajeev Dhiman5-Mar-09 23:43
Rajeev Dhiman5-Mar-09 23:43 
AnswerRe: HTML Email Behind Proxy Pin
Dave Kreskowiak6-Mar-09 3:56
mveDave Kreskowiak6-Mar-09 3:56 
GeneralMessage Removed Pin
6-Mar-09 6:44
Rajeev Dhiman6-Mar-09 6:44 
GeneralRe: HTML Email Behind Proxy Pin
Dave Kreskowiak6-Mar-09 7:12
mveDave Kreskowiak6-Mar-09 7:12 
Questionto make user interface good looking in vb.net Pin
vinmaac5-Mar-09 20:37
vinmaac5-Mar-09 20:37 
AnswerRe: to make user interface good looking in vb.net Pin
ABitSmart5-Mar-09 22:09
ABitSmart5-Mar-09 22:09 
Questionhow to plot a point on a shape file Pin
Preeti19795-Mar-09 19:42
Preeti19795-Mar-09 19:42 
AnswerRe: how to plot a point on a shape file Pin
Rupesh Kumar Swami5-Mar-09 19:51
Rupesh Kumar Swami5-Mar-09 19:51 
AnswerRe: how to plot a point on a shape file Pin
Dave Kreskowiak6-Mar-09 3:53
mveDave Kreskowiak6-Mar-09 3:53 
Questioncall dll Pin
JAYRAJ GIRI5-Mar-09 19:21
JAYRAJ GIRI5-Mar-09 19:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.