Public Class Form1
Class Tooltip
Private _Area As Rectangle
Public Property Area() As Rectangle
Get
Return _Area
End Get
Set(ByVal value As Rectangle)
_Area = value
End Set
End Property
Public Sub Draw(ByVal G As Graphics)
Dim WAdjust, HAdjust As Byte
WAdjust = IIf(Me.Area.Width Mod 2 = 0, 0, 1)
HAdjust = IIf(Me.Area.Height Mod 2 = 0, 1, 0)
Me.Area = New Rectangle(Me.Area.X, Me.Area.Y, Me.Area.Width + WAdjust, Me.Area.Height + HAdjust)
'Sfondo
G.FillRectangle(New SolidBrush(Color.FromArgb(200, 22, 32, 59)), _
New Rectangle(Area.X + 4, Area.Y + 5, Area.Width - 6, Area.Height - 10))
'Angoli superiori
G.DrawImage(My.Resources.Tooltip, Me.Area.X - 1, Me.Area.Y, New Rectangle(64, 0, 12, 16), GraphicsUnit.Pixel)
G.DrawImage(My.Resources.Tooltip, Me.Area.X - 1 + Me.Area.Width - 12, Me.Area.Y, New Rectangle(84, 0, 12, 16), GraphicsUnit.Pixel)
'Lato superiore
For X As Int16 = Me.Area.X + 15 To Me.Area.X - 1 + Me.Area.Width - 13 Step 2
G.DrawImage(My.Resources.Tooltip, X, Me.Area.Y, New Rectangle(83, 0, 1, 16), GraphicsUnit.Pixel)
Next
'Angoli inferiori
G.DrawImage(My.Resources.Tooltip, Me.Area.X - 1, Me.Area.Y + Me.Area.Height - 20, New Rectangle(96, 0, 12, 16), GraphicsUnit.Pixel)
G.DrawImage(My.Resources.Tooltip, Me.Area.X - 1 + Me.Area.Width - 12, Me.Area.Y + Me.Area.Height - 20, New Rectangle(116, 0, 12, 16), GraphicsUnit.Pixel)
'Lato inferiore
For X As Int16 = Me.Area.X + 15 To Me.Area.X - 1 + Me.Area.Width - 13 Step 2
G.DrawImage(My.Resources.Tooltip, X, Me.Area.Y + Me.Area.Height - 20, New Rectangle(115, 0, 1, 16), GraphicsUnit.Pixel)
Next
'Lato destro
For Y As Int16 = Me.Area.Y + 21 To Me.Area.Y + Me.Area.Height - 21 Step 2
G.DrawImage(My.Resources.Tooltip, Me.Area.X - 1, Y, New Rectangle(64, 14, 7, 1), GraphicsUnit.Pixel)
Next
'Lasto sinistro
For Y As Int16 = Me.Area.Y + 21 To Me.Area.Y + Me.Area.Height - 21 Step 2
G.DrawImage(My.Resources.Tooltip, Me.Area.X - 1 + Me.Area.Width - 5, Y, New RectangleF(57.2, 2, 7, 1), GraphicsUnit.Pixel)
Next
End Sub
Sub New(ByVal X As Int32, ByVal Y As Int32, ByVal Width As Int32, ByVal Height As Int32)
Me.Area = New Rectangle(X, Y, Width, Height)
End Sub
Sub New()
End Sub
End Class
Private QualityColors() As Color = _
{Color.FromArgb(255, 192, 192, 192), _
Color.FromArgb(255, 255, 255, 255), _
Color.FromArgb(255, 34, 239, 30), _
Color.FromArgb(255, 0, 112, 221), _
Color.FromArgb(255, 153, 50, 225), _
Color.FromArgb(255, 253, 124, 0), _
Color.FromArgb(255, 229, 204, 128)}
Private ItemNameFont As New Font("Friz Quadrata TT", 12, FontStyle.Regular)
Private ItemInfoFont As New Font("Friz Quadrata TT", 9, FontStyle.Regular)
Private TooltipIcon As Image
Private Sub AddTooltipLine(ByVal G As Graphics, ByVal Line As String, ByVal Font As Font, ByVal Color As Color, ByVal Position As Point, ByRef MaxWidth As Int32, ByRef Y As Int32)
Dim Size As SizeF = G.MeasureString(Line, Font, 220)
If Size.Width > MaxWidth Then
MaxWidth = Size.Width
End If
If MaxWidth < 190 Then
G.DrawString(Line, Font, New SolidBrush(Color), Position.X, Position.Y)
Y += 16
Else
Size = G.MeasureString(Line, Font, New SizeF(220, 400))
G.DrawString(Line, Font, New SolidBrush(Color), New RectangleF(Position.X, Position.Y, 220, 400))
If Size.Width > MaxWidth Then
MaxWidth = Size.Width - 5
End If
Y += Size.Height
End If
End Sub
Private Sub DrawEverything(ByVal G As Graphics, ByVal BackgroundImage As Image, ByVal BGSize As Size)
Static T As New Tooltip(30, 60, 204, 60)
Static MinY As Int16 = 68
Static MinX As Int16 = 37
Dim Y As Int16 = 86
Dim MaxWidth As Int16 = 60
If chbTooltipManual.Checked Then
T.Area = New Rectangle(30, 60, nudWidth.Value, nudHeight.Value)
End If
G.Clear(Color.White)
If BackgroundImage IsNot Nothing Then
G.DrawImage(BackgroundImage, 0, 0, BGSize.Width, BGSize.Height)
End If
T.Draw(G)
G.TextContrast = 3
G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
If TooltipIcon IsNot Nothing Then
G.DrawImage(TooltipIcon, 30, 17, 40, 40)
End If
'ITEM ------------------------------------------------------------------------
If tabMain.SelectedIndex = 0 Then
Dim Size As SizeF = G.MeasureString(txtItemName.Text, ItemNameFont, 220)
G.DrawString(txtItemName.Text, ItemNameFont, New SolidBrush(QualityColors(cmbQuality.SelectedIndex)), MinX, MinY)
If Size.Width > MaxWidth Then
MaxWidth = Size.Width
End If
G.TextContrast = 2
If cmbBind.SelectedIndex > 0 Then
AddTooltipLine(G, cmbBind.SelectedItem, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
If chbUnique.Checked Then
AddTooltipLine(G, "Unique", ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
Dim ArmorSkillY As Int16 = 0
If tabItemType.SelectedIndex = 0 Then
ArmorSkillY = Y
AddTooltipLine(G, cmbArmorSlot.SelectedItem, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
If nudArmor.Value > 0 Then
AddTooltipLine(G, nudArmor.Value & " Armor", ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
End If
Dim WeaponSkillY, WeaponSpeedY As Int16
If tabItemType.SelectedIndex = 1 Then
WeaponSkillY = Y
AddTooltipLine(G, cmbWeaponSlot.SelectedItem, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
WeaponSpeedY = Y
AddTooltipLine(G, String.Format("{0} - {1} Damage", nudMinDamage.Value, nudMaxDamage.Value), ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
AddTooltipLine(G, String.Format("({0:N1} damage per second)", ((nudMinDamage.Value + nudMaxDamage.Value) / 2) / nudSpeed.Value).Replace(",", "."), ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
For Each Row As DataGridViewRow In dgvStats.Rows
Try
Dim StatValue As Int32 = Row.Cells(0).Value
Dim StatType As String = Row.Cells(1).Value
If StatValue <> 0 And (Not String.IsNullOrEmpty(StatType)) Then
AddTooltipLine(G, IIf(StatValue > 0, "+", "") & StatValue & " " & StatType, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
Catch ex As Exception
End Try
Next
If tabItemType.SelectedIndex <= 1 Then
If nudDurability.Value > 0 Then
AddTooltipLine(G, String.Format("Durability {0}/{0}", nudDurability.Value), ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
If Not String.IsNullOrEmpty(txtRequires.Text) Then
AddTooltipLine(G, "Requires " & txtRequires.Text, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
If lstClasses.CheckedItems.Count > 0 Then
Dim Text As String = "Classes: "
For I As Int16 = 0 To lstClasses.CheckedItems.Count - 1
Text &= lstClasses.Items(lstClasses.CheckedIndices(I))
If I < lstClasses.CheckedIndices.Count - 1 Then
Text &= ", "
End If
Next
AddTooltipLine(G, Text, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
End If
For Each Row As DataGridViewRow In dgvEffects.Rows
Try
Dim EffectType As String = Row.Cells(0).Value
Dim Effect As String = Row.Cells(1).Value
Dim Text As String = EffectType & " " & Effect
If (Not String.IsNullOrEmpty(EffectType)) And (Not String.IsNullOrEmpty(Effect)) Then
AddTooltipLine(G, Text, ItemInfoFont, QualityColors(2), New Point(MinX, Y), MaxWidth, Y)
End If
Catch ex As Exception
End Try
Next
If tabItemType.SelectedIndex = 2 Then
If nudCharges.Value > 0 Then
AddTooltipLine(G, nudCharges.Value & " Charges", ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
End If
If Not String.IsNullOrEmpty(txtYellowText.Text) Then
AddTooltipLine(G, """" & txtYellowText.Text & """", ItemInfoFont, Color.FromArgb(255, 238, 196, 1), New Point(MinX, Y), MaxWidth, Y)
End If
If chbTooltipManual.Checked = False Then
If (Y > T.Area.Y + T.Area.Height - 6) Or (T.Area.Y + T.Area.Height - Y > 10) Or _
(T.Area.Width - 19 < MaxWidth - 1 Or T.Area.Width - 19 > MaxWidth + 1) Then
T.Area = New Rectangle(T.Area.X, T.Area.Y, MaxWidth + 19, Y - 60 + 6)
DrawEverything(G, BackgroundImage, BGSize)
End If
End If
If tabItemType.SelectedIndex = 0 Then
If cmbArmorSkill.SelectedIndex > 0 Then
Dim ArmorSkillSize As SizeF = G.MeasureString(cmbArmorSkill.SelectedItem, ItemInfoFont)
AddTooltipLine(G, cmbArmorSkill.SelectedItem, ItemInfoFont, Color.White, New Point(MinX + MaxWidth - ArmorSkillSize.Width - 3, ArmorSkillY), 0, 0)
End If
End If
If tabItemType.SelectedIndex = 1 Then
If cmbWeaponSkill.SelectedIndex > 0 Then
Dim WeaponSkillSize As SizeF = G.MeasureString(cmbWeaponSkill.SelectedItem, ItemInfoFont)
AddTooltipLine(G, cmbWeaponSkill.SelectedItem, ItemInfoFont, Color.White, New Point(MinX + MaxWidth - WeaponSkillSize.Width + 7, WeaponSkillY), 0, 0)
End If
Dim Text As String = String.Format("Speed {0:N2}", nudSpeed.Value).Replace(",", ".")
Dim WeaponSpeedSize As SizeF = G.MeasureString(Text, ItemInfoFont)
AddTooltipLine(G, Text, ItemInfoFont, Color.White, New Point(MinX + MaxWidth - WeaponSpeedSize.Width + 7, WeaponSpeedY), 0, 0)
End If
End If
'SPELL -------------------------------------------------------------------------------------
If tabMain.SelectedIndex = 1 Then
Dim Size As SizeF = G.MeasureString(txtItemName.Text, ItemNameFont, 220)
Dim RankY As Int16 = MinY
G.DrawString(txtSpellName.Text, ItemNameFont, New SolidBrush(Color.White), MinX, MinY)
If Size.Width > MaxWidth Then
MaxWidth = Size.Width
End If
G.TextContrast = 2
Dim RangeY, CooldownY As Int16
If chbCastable.Checked Then
If nudSpellCost.Value > 0 Then
RangeY = Y
AddTooltipLine(G, nudSpellCost.Value & " " & txtSpellCost.Text, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
Else
If nudRange.Value > 0 Then
AddTooltipLine(G, nudRange.Value & " yd", ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
End If
If Not String.IsNullOrEmpty(txtCastTime.Text) Then
CooldownY = Y
AddTooltipLine(G, txtCastTime.Text, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
Else
If nudCooldown.Value > 0 Then
Dim Unit As String = "sec"
Select Case cmbCooldown.SelectedIndex
Case 0
Unit = "sec"
Case 1
Unit = "min"
Case 2
Unit = "hr"
Case 3
Unit = "days"
End Select
AddTooltipLine(G, nudCooldown.Value & " " & Unit & " cooldown", ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
End If
End If
If Not String.IsNullOrEmpty(txtReagents.Text) Then
AddTooltipLine(G, "Reagents: " & txtReagents.Text, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
If cmbWeaponReq.SelectedIndex > 0 Then
AddTooltipLine(G, "Requires " & cmbWeaponReq.SelectedItem, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
If cmbStanceReq.SelectedIndex > 0 Then
AddTooltipLine(G, "Requires " & cmbStanceReq.SelectedItem, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
If Not String.IsNullOrEmpty(txtOtherReq.Text) Then
AddTooltipLine(G, "Requires " & txtOtherReq.Text, ItemInfoFont, Color.White, New Point(MinX, Y), MaxWidth, Y)
End If
G.TextContrast = 0
AddTooltipLine(G, txtDescription.Text, ItemInfoFont, Color.FromArgb(255, 238, 196, 1), New Point(MinX, Y), MaxWidth, Y)
G.TextContrast = 2
If chbTooltipManual.Checked = False Then
If (Y > T.Area.Y + T.Area.Height - 6) Or (T.Area.Y + T.Area.Height - Y > 10) Or _
(T.Area.Width - 19 < MaxWidth - 1 Or T.Area.Width - 19 > MaxWidth + 1) Then
T.Area = New Rectangle(T.Area.X, T.Area.Y, MaxWidth + 19, Y - 60 + 6)
DrawEverything(G, BackgroundImage, BGSize)
End If
End If
If rtbRank.Checked Then
Dim Text As String = "Rank " & nudRank.Value
Dim RankSize As SizeF = G.MeasureString(Text, ItemNameFont)
AddTooltipLine(G, Text, ItemNameFont, QualityColors(0), New Point(MinX + MaxWidth - RankSize.Width + 7, RankY), 0, 0)
ElseIf rtbRacial.Checked Then
Dim RacialSize As SizeF = G.MeasureString("Racial", ItemNameFont)
AddTooltipLine(G, "Racial", ItemNameFont, QualityColors(0), New Point(MinX + MaxWidth - RacialSize.Width + 7, RankY), 0, 0)
End If
If nudRange.Value > 0 And RangeY > 0 Then
Dim Text As String = nudRange.Value & " yd"
Dim RangeSize As SizeF = G.MeasureString(Text, ItemInfoFont)
AddTooltipLine(G, Text, ItemInfoFont, Color.White, New Point(MinX + MaxWidth - RangeSize.Width + 3, RangeY), 0, 0)
End If
If nudCooldown.Value > 0 And CooldownY > 0 Then
Dim Unit As String = "sec"
Select Case cmbCooldown.SelectedIndex
Case 0
Unit = "sec"
Case 1
Unit = "min"
Case 2
Unit = "hr"
Case 3
Unit = "days"
End Select
Dim Text As String = nudCooldown.Value & " " & Unit & " cooldown"
Dim CooldownSize As SizeF = G.MeasureString(Text, ItemInfoFont)
AddTooltipLine(G, Text, ItemInfoFont, Color.White, New Point(MinX + MaxWidth - CooldownSize.Width + 3, CooldownY), 0, 0)
End If
End If
End Sub
Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtItemName.TextChanged, txtRequires.TextChanged, nudSpeed.ValueChanged, nudMaxDamage.ValueChanged, nudDurability.ValueChanged, nudArmor.ValueChanged, cmbWeaponSlot.SelectedIndexChanged, cmbWeaponSkill.SelectedIndexChanged, cmbQuality.SelectedIndexChanged, cmbBind.SelectedIndexChanged, cmbArmorSlot.SelectedIndexChanged, cmbArmorSkill.SelectedIndexChanged, chbUnique.CheckedChanged, txtYellowText.TextChanged, nudWidth.ValueChanged, nudHeight.ValueChanged, nudCharges.ValueChanged, txtSpellName.TextChanged, txtSpellCost.TextChanged, txtReagents.TextChanged, txtOtherReq.TextChanged, txtDescription.TextChanged, txtCastTime.TextChanged, rtbRacial.CheckedChanged, nudSpellCost.ValueChanged, nudRank.ValueChanged, nudRange.ValueChanged, nudCooldown.ValueChanged, cmbWeaponReq.SelectedIndexChanged, cmbStanceReq.SelectedIndexChanged, cmbCooldown.SelectedIndexChanged, chbCastable.TextChanged
imgPreview.Refresh()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtItemName.Text = "Item Name"
cmbQuality.SelectedIndex = 1
cmbBind.SelectedIndex = 0
cmbArmorSlot.SelectedIndex = 0
cmbArmorSkill.SelectedIndex = 0
cmbWeaponSlot.SelectedIndex = 0
cmbWeaponSkill.SelectedIndex = 0
End Sub
Private Sub dgvStats_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
If e.ColumnIndex = 1 Then
Dim Cell As DataGridViewCell = dgvStats.Rows(e.RowIndex).Cells(e.ColumnIndex)
If Cell.Value = "Custom..." Then
Dim NewStat As String = InputBox("Insert the new custom stat's name:")
If Not String.IsNullOrEmpty(NewStat) Then
DirectCast(dgvStats.Columns(1), DataGridViewComboBoxColumn).Items.Add(NewStat)
End If
End If
End If
imgPreview.Refresh()
End Sub
Private Sub imgPreview_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles imgPreview.Paint
DrawEverything(e.Graphics, imgPreview.Image, imgPreview.Size)
End Sub
Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
AddHandler dgvStats.CellValueChanged, AddressOf dgvStats_CellValueChanged
End Sub
Private Sub tabItemType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabItemType.SelectedIndexChanged
grpEquippable.Enabled = (tabItemType.SelectedIndex <= 1)
imgPreview.Refresh()
End Sub
Private Sub nudMinDamage_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudMinDamage.ValueChanged
nudMaxDamage.Minimum = nudMinDamage.Value + 1
End Sub
Private Sub btnBrowseIcon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowseIcon.Click
Dim Open As New OpenFileDialog
Open.Filter = "Immagini|*.jpg;*.bmp;*.png;*.gif;*.tga;*.wmf"
If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
TooltipIcon = Image.FromFile(Open.FileName)
End If
End Sub
Private Sub cmbBackground_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBackground.SelectedIndexChanged
imgPreview.Image = My.Resources.ResourceManager.GetObject(cmbBackground.SelectedItem)
End Sub
Private Sub btnSaveImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveImage.Click
Dim Save As New SaveFileDialog
Save.Filter = "PNG|*.png|JPEG|*.jpg|Bitamp|*.bmp|GIF|*.gif"
If Save.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim Buffer As New Bitmap(imgPreview.Image, imgPreview.Width, imgPreview.Height)
Dim BufferGraphics As Graphics = Graphics.FromImage(Buffer)
DrawEverything(BufferGraphics, IIf(chbIncludeBg.Checked, imgPreview.Image, Nothing), imgPreview.Size)
Buffer.Save(Save.FileName)
BufferGraphics.Dispose()
End If
End Sub
Private Sub chbTooltipManual_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbTooltipManual.CheckedChanged
grpManualTooltip.Enabled = chbTooltipManual.Checked
imgPreview.Refresh()
End Sub
Private Sub lstClasses_ItemCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles lstClasses.ItemCheck
imgPreview.Refresh()
End Sub
Private Sub dgvEffects_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvEffects.CellValueChanged
imgPreview.Refresh()
End Sub
Private Sub rtbRank_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtbRank.CheckedChanged
nudRank.Enabled = rtbRank.Checked
End Sub
Private Sub chbCastable_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbCastable.CheckedChanged
grpCastable.Enabled = chbCastable.Checked
End Sub
End Class