Orc
Join Date: Mar 2012
Posts: 45
|
|
Hello all. I'm not sure if any of you recall seeing my post about this time last year, but I did develop a standalone log-reading map viewer using VB.Net and GDI+. Includes a mode where it's on top of EQ, with adjustable opacity, and ignores all input so it doesn't interfere with EQ. Etc. Here's a link to that thread: http://www.project1999.com/forums/sh...d.php?t=126067
I did some work on the app today to improve responsiveness when zooming and moving the map with the mouse. Ignore the download links in the previous post, here's the most recent archive, including source and classic/kunark maps:
https://www.dropbox.com/s/mun2exoktf...eqmap.rar?dl=0
Here's a full copy/paste of the(ugly) VB.Net code. The calls you see to getasynckeystate are for the hotkeys that toggle opacity/topmost mode, not a keylogger:
Code:
Imports EQMap.User32Wrappers
Public Class Form1
Private _InitialStyle As Integer
Dim opaque As Boolean = True
Dim pX As Integer
Dim pY As Integer
Dim pZ As Integer
Dim pXtwo As Integer
Dim pYtwo As Integer
Dim r As Integer
Dim g As Integer
Dim b As Integer
Dim zoom As Double = 22.2
Dim offset As Integer
Dim offsety As Integer
Dim logfile As String
Dim MouseUpx As Integer
Dim MouseUpy As Integer
Dim zonelong As String
Dim rely As Integer
Dim relx As Integer
Dim mousedown As Boolean = False
Dim playery As Double
Dim playerx As Double
Dim zoneshort As String
Dim zones As New Dictionary(Of String, String)
Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
Private Sub Form1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub SetFormToTransparent()
SetWindowLong(Me.Handle, GWL.ExStyle, _
_InitialStyle Or WS_EX.Layered Or WS_EX.Transparent)
SetLayeredWindowAttributes(Me.Handle, 0, _
255 * (TrackBar3.Value / 100), LWA.Alpha)
End Sub
Private Sub SetFormToOpaque()
' Turn off the Transparent Extended Style.
SetWindowLong(Me.Handle, GWL.ExStyle, _
_InitialStyle Or WS_EX.Layered)
' Set the Alpha back to 100% opaque.
SetLayeredWindowAttributes(Me.Handle, _
0, 255, LWA.Alpha)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Grab the Extended Style information
' for this window and store it.
_InitialStyle = GetWindowLong(Me.Handle, GWL.ExStyle)
' Set this window to Transparent
' (to the mouse that is!)
'SetFormToTransparent()
' Just for giggles, set this window
' to stay on top of all others so we
' can see what's happening.
ComboBox2.Text = 1
zoom = TrackBar2.Value + 0.2
Try
For Each n In TextBox5.Text.Split("|")
zoneshort = n.Split(",")(0)
zonelong = n.Split(",")(1)
Try
Dim fileExists As Boolean
fileExists = My.Computer.FileSystem.FileExists(Application.StartupPath() & "\maps\" & zoneshort & ".txt")
If fileExists = True Then
ComboBox1.Items.Add(zonelong.Replace(vbNewLine, ""))
addz(zonelong.Replace(vbNewLine, ""), zoneshort)
End If
Catch ex As Exception
End Try
Next
Catch ex As Exception
End Try
ComboBox1.Sorted = True
End Sub
Function addz(ByVal shortz As String, ByVal longz As String)
zones.Add(shortz, longz)
End Function
Sub drawmap()
Using redBrush As New SolidBrush(Color.Tan), _
formGraphics As Graphics = PictureBox1.CreateGraphics()
formGraphics.FillRectangle(redBrush, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height))
End Using
For Each line In TextBox1.Text.Split(vbNewLine)
Try
If line.Substring(0, 2).IndexOf("L") <> -1 Then
r = line.Split(",")(6)
g = line.Split(",")(7)
b = line.Split(",")(8)
pY = line.Split(",")(1)
pX = line.Split(",")(0).Replace("L ", "")
pXtwo = line.Split(",")(3)
pYtwo = line.Split(",")(4)
pXtwo = pXtwo / zoom
pYtwo = pYtwo / zoom
pX = pX / zoom
pY = pY / zoom
If pY < 0 Then
pY = Math.Abs(pY)
pY = 300 - pY
Else
pY = 300 + pY
End If
If pYtwo < 0 Then
pYtwo = Math.Abs(pYtwo)
pYtwo = 300 - pYtwo
Else
pYtwo = 300 + pYtwo
End If
If pX > 0 Then
pX = pX + 300
Else
pX = 300 - Math.Abs(pX)
End If
If pXtwo > 0 Then
pXtwo = pXtwo + 300
Else
pXtwo = 300 - Math.Abs(pXtwo)
End If
Using redBrush As New Pen(Color.FromArgb(r, g, b)), _
formGraphics As Graphics = PictureBox1.CreateGraphics()
formGraphics.DrawLine(redBrush, New System.Drawing.Point(pX + offset, pY + offsety), New System.Drawing.Point(pXtwo + offset, pYtwo + offsety))
End Using
ElseIf line.Substring(0, 2).IndexOf("P") <> -1 Then
Dim label As String = line.Split(",")(7)
pY = line.Split(",")(1)
pX = line.Split(",")(0).Replace("P ", "")
pX = pX / zoom
pY = pY / zoom
If pY < 0 Then
pY = Math.Abs(pY)
pY = 300 - pY
Else
pY = 300 + pY
End If
If pX > 0 Then
pX = pX + 300
Else
pX = 300 - Math.Abs(pX)
End If
'MsgBox(pX & "," & pY & ":" & pXtwo & "," & pYtwo)
Dim drawFont As New Font("Arial", 10)
Using blueb As New SolidBrush(Color.Black), _
formGraphics As Graphics = PictureBox1.CreateGraphics()
If CheckBox2.Checked = True Then
If CheckBox1.Checked = True Then
If label.ToUpper.Contains(txtFilter.Text.ToUpper) Then
formGraphics.DrawString(label, drawFont, blueb, New System.Drawing.Point(pX + offset, pY + offsety))
End If
Else
formGraphics.DrawString(label, drawFont, blueb, New System.Drawing.Point(pX + offset, pY + offsety))
End If
End If
End Using
End If
Catch ex As Exception
End Try
Next
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
TrackBar2.Focus()
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs)
zoom = TrackBar2.Value + 0.2
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub OpenMapToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
drawmap()
drawpoint2()
Drawpoint()
End Sub
Sub Drawpoint()
If TextBox3.Text.Length > 1 Then
Dim friendx As Double = TextBox3.Text * -1
Dim friendy As Double = TextBox4.Text * -1
friendx = friendx / zoom
friendy = friendy / zoom
If friendy < 0 Then
friendy = Math.Abs(friendy)
friendy = 300 - friendy
Else
friendy = 300 + friendy
End If
If friendx > 0 Then
friendx = friendx + 300
Else
friendx = 300 - Math.Abs(friendx)
End If
Using redBrush As New SolidBrush(Color.Blue), _
formGraphics1 As Graphics = PictureBox1.CreateGraphics()
formGraphics1.FillRectangle(redBrush, New Rectangle(friendx + offset, friendy + offsety, TextBox8.Text, TextBox8.Text))
End Using
End If
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
TextBox1.Text = fileContents
Threading.Thread.Sleep(500)
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If CheckBox3.Checked = True Then
drawmap()
Drawpoint()
drawpoint2()
End If
Try
Timer3.Interval = ComboBox2.Text * 1000
Catch ex As Exception
End Try
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim fileContents As String
Try
fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath() & "\maps\" & zones(ComboBox1.Text) & ".txt")
TextBox1.Text = fileContents
drawmap()
Drawpoint()
drawpoint2()
Catch ex As Exception
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
drawmap()
Drawpoint()
drawpoint2()
End Sub
Sub drawpoint2()
If TextBox6.Text.Length > 1 Then
Dim friendx As Double = TextBox7.Text * -1
Dim friendy As Double = TextBox6.Text * -1
friendx = friendx / zoom
friendy = friendy / zoom
If friendy < 0 Then
friendy = Math.Abs(friendy)
friendy = 300 - friendy
Else
friendy = 300 + friendy
End If
If friendx > 0 Then
friendx = friendx + 300
Else
friendx = 300 - Math.Abs(friendx)
End If
Using redBrush As New SolidBrush(Color.Green), _
formGraphics1 As Graphics = PictureBox1.CreateGraphics()
formGraphics1.FillRectangle(redBrush, New Rectangle(friendx + offset, friendy + offsety, TextBox2.Text, TextBox2.Text))
End Using
End If
End Sub
Private Sub txtFilter_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFilter.TextChanged
If CheckBox1.Checked = True Then
drawmap()
Drawpoint()
drawpoint2()
End If
End Sub
Function openmap(ByVal map As String)
Dim fileContents As String
Try
fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath() & "\maps\" & map & ".txt")
TextBox1.Text = fileContents
drawmap()
Drawpoint()
drawpoint2()
Catch ex As Exception
End Try
End Function
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
relx = e.X
rely = e.Y
mousedown = True
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If mousedown = True Then
Dim oldoff As Integer = offset
Dim oldoffy As Integer = offsety
offset = offset + (e.X - relx)
offsety = offsety + (e.Y - rely)
MouseUpx = offset
MouseUpy = offsety
drawmap()
Drawpoint()
drawpoint2()
offset = oldoff
offsety = oldoffy
Exit Sub
Else
If relx <> 0 Then
offset = offset + (e.X - relx)
offsety = offsety + (e.Y - rely)
MouseUpx = offset
MouseUpy = offsety
drawmap()
Drawpoint()
drawpoint2()
End If
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
relx = 0
rely = 0
offset = MouseUpx
offsety = MouseUpy
drawmap()
Drawpoint()
drawpoint2()
mousedown = False
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
offset = 300 - playerx
offsety = 300 - playery
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
offset = 0
offsety = 0
zoom = 22.2
TrackBar2.Value = 20
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If CheckBox4.Checked = True Then
Dim fileContents2 As String
Dim loc As String
Dim locs As New ArrayList
fileContents2 = My.Computer.FileSystem.ReadAllText(logfile)
For Each n In fileContents2.Split(vbNewLine)
If n.Contains("Your Location") Then
loc = n.Substring(n.IndexOf("Your Lo") + 17, n.Length - 17 - n.IndexOf("Your Lo"))
If locs.Contains(loc) = False Then
locs.Add(loc)
End If
End If
Next
If locs.Count <> 0 Then
If TextBox3.Text <> locs(locs.Count - 1).Split(",")(1) Then
TextBox4.Text = locs(locs.Count - 1).Split(",")(0)
TextBox3.Text = locs(locs.Count - 1).Split(",")(1)
drawmap()
Drawpoint()
drawpoint2()
End If
End If
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Button4_Click_1(sender As Object, e As EventArgs)
MsgBox("Please navigate to your /logs directory and choose a " & vbNewLine & "log so that I can read its location")
OpenFileDialog2.ShowDialog()
End Sub
Private Sub OpenFileDialog2_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk
logfile = OpenFileDialog2.FileName
CheckBox4.Enabled = True
End Sub
Private Sub keyhot_Tick(sender As Object, e As EventArgs) Handles keyhot.Tick
If GetKeyPress(Keys.Pause) Then
Me.WindowState = FormWindowState.Normal
If opaque = True Then
SetFormToTransparent()
opaque = False
Me.TopMost = True
drawmap()
drawpoint2()
Drawpoint()
Else
SetFormToOpaque()
opaque = True
Me.TopMost = False
drawmap()
drawpoint2()
Drawpoint()
End If
ElseIf GetKeyPress(Keys.Scroll) Then
opaque = True
SetFormToOpaque()
Me.TopMost = False
Me.WindowState = FormWindowState.Minimized
drawmap()
drawpoint2()
Drawpoint()
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
zoom = TrackBar2.Value + 0.2
drawmap()
Drawpoint()
drawpoint2()
End Sub
Private Sub Button4_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
OpenFileDialog2.ShowDialog()
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
drawmap()
Drawpoint()
drawpoint2()
End Sub
End Class
|