Public Class Corner_Rectangle Private Shared buttonOffset As Integer Private Shared cornerRectangleCounter As Integer = 0 ' --- Create textboxes when user clicks the rectangle corner recess button --- Public Shared Sub SquareButtton(sender As Object, e As EventArgs) Individual.Panel_Recesses.Controls("Button_Angle_Corner").Enabled = False Individual.Panel_Recesses.Controls("Button_Angle_Side").Enabled = False Individual.Panel_Recesses.Controls("Button_Square_Corner").Enabled = False Individual.Panel_Recesses.Controls("Button_Square_Side").Enabled = False Individual.Panel_Recesses.Controls("Button_Square_Middle").Enabled = False Dim buttonX As Integer = Individual.Panel_Recesses.Controls("Button_Square_Corner").Location.X + Individual.Panel_Recesses.Controls("Button_Square_Corner").Width Dim buttonY As Integer = Individual.Panel_Recesses.Controls("Button_Square_Corner").Location.Y Individual.Create_TextBox_Recesses("Y_TextBox", "", buttonX + 60, buttonY + 10, 60) AddHandler Individual.Panel_Recesses.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed AddHandler Individual.Panel_Recesses.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress Individual.Create_Label_Recesses("Y_Label", "Width", buttonX + 18, buttonY + 13) Individual.Create_TextBox_Recesses("X_TextBox", "", buttonX + 60, buttonY + 40, 60) AddHandler Individual.Panel_Recesses.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed AddHandler Individual.Panel_Recesses.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress Individual.Create_Label_Recesses("X_Label", "Length", buttonX + 10, buttonY + 43) buttonOffset = 130 Individual.Panel_Recesses.Controls("Button_Square_Side").Left = Individual.Panel_Recesses.Controls("Button_Square_Side").Left + buttonOffset Individual.Panel_Recesses.Controls("Button_Square_Middle").Left = Individual.Panel_Recesses.Controls("Button_Square_Middle").Left + buttonOffset Individual.Panel_Recesses.Controls("Button_Radius").Left = Individual.Panel_Recesses.Controls("Button_Radius").Left + buttonOffset Individual.Button_Square_Corner.FlatStyle = FlatStyle.Flat Individual.Button_Square_Corner.FlatAppearance.BorderColor = Color.Red End Sub ' --- Check the key pressed by the user --- Private Shared Sub FunctionText_KeyPress(sender As Object, e As KeyPressEventArgs) User_Input.Check_IfNumber(e) End Sub ' --- Adds clickable buttons for all corners if conditions are met --- Private Shared Sub FunctionTextCorner_Changed(sender As TextBox, e As EventArgs) Dim value1, value2 As Integer Try value1 = CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text) value2 = CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text) Catch ex As Exception value1 = 0 value2 = 0 End Try If value1 > 0 AndAlso value2 > 0 Then If Individual.Panel_Grating.Controls.Count = 2 Then For i = 0 To Data.gratingPoints.Rows.Count - 1 If Data.gratingPoints.Rows(i)("RECESS OK") Then Dim pointButton As New Button With { .Width = 30, .Height = 30, .Left = Data.gratingPoints.Rows(i)("GUI X") - 30 / 2, .Top = Data.gratingPoints.Rows(i)("GUI Y") - 30 / 2, .Name = Data.gratingPoints.Rows(i)("NAME") & "_Button", .Text = "" } pointButton.BackColor = Color.FromArgb(50, Color.Red) pointButton.FlatStyle = FlatStyle.Flat pointButton.FlatAppearance.BorderSize = 0 pointButton.FlatAppearance.MouseOverBackColor = Color.Red pointButton.FlatAppearance.MouseDownBackColor = Color.DarkRed Dim gp As New Drawing2D.GraphicsPath gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30))) pointButton.Region = New Region(gp) Individual.Panel_Grating.Controls.Add(pointButton) AddHandler pointButton.Click, AddressOf PointButton_Click End If Next End If ElseIf Individual.Panel_Grating.Controls.Count > 2 Then For i = 0 To Data.gratingPoints.Rows.Count - 1 If Data.gratingPoints.Rows(i)("RECESS OK") Then Dim buttonName As String = Data.gratingPoints.Rows(i)("NAME") & "_Button" RemoveHandler Individual.Panel_Grating.Controls(buttonName).Click, AddressOf PointButton_Click Individual.Panel_Grating.Controls.RemoveByKey(Data.gratingPoints.Rows(i)("NAME") & "_Button") End If Next End If End Sub ' --- When a corner function button is pressed --- Private Shared Sub PointButton_Click(sender As Button, e As EventArgs) 'Determine which point is being pressed Dim pointPressed As String = sender.Name.Replace("_Button", "").Trim() Dim index As Integer For Each DR As DataRow In Data.gratingPoints.Rows If DR("NAME") = pointPressed Then index = Data.gratingPoints.Rows.IndexOf(DR) Exit For End If Next ' Remove point buttons For i = 0 To Data.gratingPoints.Rows.Count - 1 If Data.gratingPoints.Rows(i)("RECESS OK") Then Dim buttonName As String = Data.gratingPoints.Rows(i)("NAME") & "_Button" RemoveHandler Individual.Panel_Grating.Controls(buttonName).Click, AddressOf PointButton_Click Individual.Panel_Grating.Controls.RemoveByKey(Data.gratingPoints.Rows(i)("NAME") & "_Button") End If Next cornerRectangleCounter += 1 'Retrive the points coords Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X") Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y") Dim pX As Decimal = Data.gratingPoints.Rows(index)("X") Dim pY As Decimal = Data.gratingPoints.Rows(index)("Y") Dim dXGUI As Integer = CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text / Data.scaleDiff) Dim dYGUI As Integer = CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text / Data.scaleDiff) Dim dX As Decimal = Individual.Panel_Recesses.Controls("X_TextBox").Text / 1000 Dim dY As Decimal = Individual.Panel_Recesses.Controls("Y_TextBox").Text / 1000 Data.recessData.Rows.Add() For i = 2 To Data.pointsMeasurements.Count - 1 Dim mesName As String = Data.pointsMeasurements.Keys(i) If mesName.Split("_")(0) <> "SS1" AndAlso mesName.Split("_")(0) <> "SS" AndAlso mesName.Split("_")(0) <> "MS" AndAlso mesName.Split("_")(0) <> "MS1" Then If index + 1 = Data.pointsMeasurements(mesName)(0) Then If Draw_Grating.measureLabels(mesName)(3) = 1 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("X_TextBox").Text Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2 ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("Y_TextBox").Text Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2 ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("X_TextBox").Text Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2 Else Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("Y_TextBox").Text Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2 End If ElseIf index + 1 = Data.pointsMeasurements(mesName)(1) Then If Draw_Grating.measureLabels(mesName)(3) = 1 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("Y_TextBox").Text Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2 ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("X_TextBox").Text Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2 ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("Y_TextBox").Text Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2 Else Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("X_TextBox").Text Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2 End If End If ElseIf mesName.Split("_")(0) = "SS1" AndAlso index + 2 = Data.pointsMeasurements(mesName)(1) Then If Draw_Grating.measureLabels(mesName)(3) = 1 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("X_TextBox").Text Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2 Draw_Grating.sideSquareMesLine(mesName)(0) = Draw_Grating.sideSquareMesLine(mesName)(0) + dXGUI ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("Y_TextBox").Text Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2 Draw_Grating.sideSquareMesLine(mesName)(1) = Draw_Grating.sideSquareMesLine(mesName)(1) + dYGUI ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("X_TextBox").Text Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2 Draw_Grating.sideSquareMesLine(mesName)(0) = Draw_Grating.sideSquareMesLine(mesName)(0) - dXGUI Else Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - Individual.Panel_Recesses.Controls("Y_TextBox").Text Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2 Draw_Grating.sideSquareMesLine(mesName)(1) = Draw_Grating.sideSquareMesLine(mesName)(1) - dYGUI End If End If Next Dim mesNum As Integer = Data.pointsMeasurements.Count - 1 For i = 2 To Data.pointsMeasurements.Count - 1 Dim mesName As String = Data.pointsMeasurements.Keys(i) If index + 1 < Data.pointsMeasurements(mesName)(0) Then If mesName.Split("_")(0) <> "MS" AndAlso mesName.Split("_")(0) <> "MS1" Then Data.pointsMeasurements(mesName)(0) = Data.pointsMeasurements(mesName)(0) + 2 Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 2 ElseIf mesName.Split("_")(0) = "MS1" Then Data.pointsMeasurements(mesName)(0) = Data.pointsMeasurements(mesName)(0) + 2 End If ElseIf index + 1 = Data.pointsMeasurements(mesName)(0) OrElse index + 1 = Data.pointsMeasurements(mesName)(1) Then If mesName.Split("_")(0) <> "MS" AndAlso mesName.Split("_")(0) <> "MS1" Then Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 2 ElseIf mesName.Split("_")(0) = "MS1" AndAlso index + 1 = Data.pointsMeasurements(mesName)(0) AndAlso Data.pointsMeasurements(mesName)(2) = 3 Then Data.pointsMeasurements(mesName)(0) = Data.pointsMeasurements(mesName)(0) + 2 End If End If Next Dim pointQuadrant As Integer = Get_PointQuadrant(pXGUI, pYGUI) Dim pointRow1 As DataRow = Data.gratingPoints.NewRow Dim pointRow2 As DataRow = Data.gratingPoints.NewRow Dim pointRow3 As DataRow = Data.gratingPoints.NewRow pointRow1("NAME") = "CR" & cornerRectangleCounter & "_" & 1 pointRow1("QUADRANT") = pointQuadrant pointRow1("RECESS OK") = False ' Can be True (implemented in GUI but not for SW) pointRow2("NAME") = "CR" & cornerRectangleCounter & "_" & 2 pointRow2("QUADRANT") = pointQuadrant pointRow2("RECESS OK") = False pointRow3("NAME") = "CR" & cornerRectangleCounter & "_" & 3 pointRow3("QUADRANT") = pointQuadrant pointRow3("RECESS OK") = False ' Can be True (implemented in GUI but not for SW) If pointQuadrant = 1 Then ' Add the new points pointRow1("X") = pX pointRow1("Y") = pY - dY pointRow1("GUI X") = pXGUI pointRow1("GUI Y") = pYGUI + dYGUI pointRow2("X") = pX + dX pointRow2("Y") = pY - dY pointRow2("GUI X") = pXGUI + dXGUI pointRow2("GUI Y") = pYGUI + dYGUI pointRow3("X") = pX + dX pointRow3("Y") = pY pointRow3("GUI X") = pXGUI + dXGUI pointRow3("GUI Y") = pYGUI ' Update outer measuements (SW) Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 2 Data.pointsMeasurements("Wmes")(0) = Data.pointsMeasurements("Wmes")(0) + 2 Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 2 ' Add recess measuements (SW) Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 1}) Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 4}) ' Add recess measurments (GUI) Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8, pYGUI + dYGUI + 3, 1}) Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3, pYGUI + dYGUI / 2 - 4, 1}) ' Recess Data Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE" Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 1 Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text) Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text) ElseIf pointQuadrant = 2 Then ' Add the new points pointRow1("X") = pX - dX pointRow1("Y") = pY pointRow1("GUI X") = pXGUI - dXGUI pointRow1("GUI Y") = pYGUI pointRow2("X") = pX - dX pointRow2("Y") = pY - dY pointRow2("GUI X") = pXGUI - dXGUI pointRow2("GUI Y") = pYGUI + dYGUI pointRow3("X") = pX pointRow3("Y") = pY - dY pointRow3("GUI X") = pXGUI pointRow3("GUI Y") = pYGUI + dYGUI ' Update outer measuements (SW) Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 2 Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 2 ' Add recess measuements (SW) Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 2}) Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 1}) ' Add recess measurments (GUI) Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3, pYGUI + dYGUI / 2 - 4, 2}) Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8, pYGUI + dYGUI + 3, 2}) ' Recess Data Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE" Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 2 Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text) Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text) ElseIf pointQuadrant = 3 Then ' Add the new points pointRow1("X") = pX pointRow1("Y") = pY + dY pointRow1("GUI X") = pXGUI pointRow1("GUI Y") = pYGUI - dYGUI pointRow2("X") = pX - dX pointRow2("Y") = pY + dY pointRow2("GUI X") = pXGUI - dXGUI pointRow2("GUI Y") = pYGUI - dYGUI pointRow3("X") = pX - dX pointRow3("Y") = pY pointRow3("GUI X") = pXGUI - dXGUI pointRow3("GUI Y") = pYGUI ' Update outer measuements (SW) Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 2 ' Add recess measuements (SW) Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 3}) Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 2}) ' Add recess measurments (GUI) Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8, pYGUI - dYGUI - 12 - 3, 3}) Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3, pYGUI - dYGUI / 2 - 4, 3}) ' Recess Data Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE" Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 3 Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text) Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text) Else ' Add the new points pointRow1("X") = pX + dX pointRow1("Y") = pY pointRow1("GUI X") = pXGUI + dXGUI pointRow1("GUI Y") = pYGUI pointRow2("X") = pX + dX pointRow2("Y") = pY + dY pointRow2("GUI X") = pXGUI + dXGUI pointRow2("GUI Y") = pYGUI - dYGUI pointRow3("X") = pX pointRow3("Y") = pY + dY pointRow3("GUI X") = pXGUI pointRow3("GUI Y") = pYGUI - dYGUI ' Add recess measuements (SW) Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 4}) Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 3}) ' Add recess measurments (GUI) Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3, pYGUI - dYGUI / 2 - 4, 4}) Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8, pYGUI - dYGUI - 12 - 3, 4}) ' Recess Data Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE" Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 4 Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(Individual.Panel_Recesses.Controls("Y_TextBox").Text) Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(Individual.Panel_Recesses.Controls("X_TextBox").Text) End If Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1) Data.gratingPoints.Rows.InsertAt(pointRow2, index + 2) Data.gratingPoints.Rows.InsertAt(pointRow3, index + 3) Data.gratingPoints.Rows.RemoveAt(index) 'Redraw grating Individual.Panel_Grating.Refresh() RemoveHandler Individual.Panel_Recesses.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed RemoveHandler Individual.Panel_Recesses.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress Individual.Panel_Recesses.Controls.RemoveByKey("X_TextBox") RemoveHandler Individual.Panel_Recesses.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed RemoveHandler Individual.Panel_Recesses.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress Individual.Panel_Recesses.Controls.RemoveByKey("Y_TextBox") Individual.Panel_Recesses.Controls.RemoveByKey("X_Label") Individual.Panel_Recesses.Controls.RemoveByKey("Y_Label") Individual.Panel_Recesses.Controls("Button_Square_Side").Left = Individual.Panel_Recesses.Controls("Button_Square_Side").Left - buttonOffset Individual.Panel_Recesses.Controls("Button_Square_Middle").Left = Individual.Panel_Recesses.Controls("Button_Square_Middle").Left - buttonOffset Individual.Panel_Recesses.Controls("Button_Radius").Left = Individual.Panel_Recesses.Controls("Button_Radius").Left - buttonOffset Individual.Panel_Recesses.Controls("Button_Angle_Corner").Enabled = True Individual.Panel_Recesses.Controls("Button_Angle_Side").Enabled = True Individual.Panel_Recesses.Controls("Button_Square_Corner").Enabled = True Individual.Panel_Recesses.Controls("Button_Square_Side").Enabled = True Individual.Panel_Recesses.Controls("Button_Square_Middle").Enabled = True Individual.Button_Square_Corner.FlatAppearance.BorderColor = Color.Black End Sub ' --- Determines the clicked points quadrant --- Private Shared Function Get_PointQuadrant(pXGUI As Integer, pYGUI As Integer) Dim quadrant As Integer If pXGUI < Data.guiPanelMidX Then If pYGUI > Data.guiPanelMidY Then quadrant = 4 Else quadrant = 1 End If Else If pYGUI > Data.guiPanelMidY Then quadrant = 3 Else quadrant = 2 End If End If Return quadrant End Function End Class