RectangleHotSpot.GetCoordinates Método
Definição
Retorna uma cadeia de caracteres que representa as coordenadas x e y do canto superior esquerdo de um objeto RectangleHotSpot e as coordenadas x e y de seu canto inferior direito.Returns a string that represents the x -and y-coordinates of a RectangleHotSpot object's top left corner and the x- and y-coordinates of its bottom right corner.
public:
override System::String ^ GetCoordinates();
public override string GetCoordinates ();
override this.GetCoordinates : unit -> string
Public Overrides Function GetCoordinates () As String
Retornos
Uma cadeia de caracteres que representa as coordenadas x e y do canto superior esquerdo de um objeto RectangleHotSpot e as coordenadas x e y de seu canto inferior direito.A string that represents the x- and y-coordinates of a RectangleHotSpot object's top left corner and the x- and y-coordinates of its bottom right corner.
Exemplos
O exemplo de código a seguir demonstra como criar declarativamente um ImageMap controle que contém dois RectangleHotSpot objetos.The following code example demonstrates how to declaratively create an ImageMap control that contains two RectangleHotSpot objects. A ImageMap.HotSpotMode propriedade é definida como HotSpotMode.PostBack , o que faz com que a página seja reposta ao servidor sempre que um usuário clicar em uma das regiões de ponto de acesso.The ImageMap.HotSpotMode property is set to HotSpotMode.PostBack, which causes the page to post back to the server each time a user clicks one of the hot spot regions. Cada vez que o usuário clica em um dos RectangleHotSpot objetos, o GetCoordinates método é chamado e as coordenadas do ponto de acesso selecionado são exibidas para o usuário.Each time the user clicks one of the RectangleHotSpot objects, the GetCoordinates method is called and the coordinates of the selected hot spot are displayed to the user. Para que este exemplo funcione corretamente, você deve fornecer sua própria imagem para a ImageUrl propriedade e atualizar o caminho para a imagem de forma adequada para que o aplicativo possa localizá-la.For this example to work correctly, you must supply your own image for the ImageUrl property and update the path to the image appropriately so that the application can locate it.
<%@ page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void VoteMap_Clicked(object sender, ImageMapEventArgs e)
{
string coordinates;
// When a user clicks the "Yes" hot spot,
// display the hot spot's coordinates.
if (e.PostBackValue == "Yes")
{
coordinates = Vote.HotSpots[0].GetCoordinates();
Message1.Text = "The hot spot's coordinates are " + coordinates;
}
// When a user clicks the "No" hot spot,
// display the hot spot's coordinates.
else if (e.PostBackValue == "No")
{
coordinates = Vote.HotSpots[1].GetCoordinates();
Message1.Text = "The hot spot's coordinates are " + coordinates;
}
else
Message1.Text = "You did not click a valid hot spot region.";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>RectangleHotSpot.GetCoordinates Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>RectangleHotSpot.GetCoordinates Example</h3>
<!-- Change or remove the width and height attributes as
appropriate for your image. -->
<asp:imagemap id="Vote"
imageurl="Images/VoteImage.jpg"
alternatetext="Voting choices"
hotspotmode="PostBack"
width="400"
height="200"
onclick="VoteMap_Clicked"
runat="Server">
<asp:RectangleHotSpot
top="0"
left="0"
bottom="200"
right="200"
postbackvalue="Yes"
alternatetext="Vote yes">
</asp:RectangleHotSpot>
<asp:RectangleHotSpot
top="0"
left="201"
bottom="200"
right="400"
postbackvalue="No"
alternatetext="Vote no">
</asp:RectangleHotSpot>
</asp:imagemap>
<br />
<asp:label id="Message1"
runat="Server">
</asp:label>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub VoteMap_Clicked(ByVal sender As Object, ByVal e As ImageMapEventArgs)
Dim coordinates As String
' When a user clicks the "Yes" hot spot,
' display the hot spot's coordinates.
If (e.PostBackValue = "Yes") Then
coordinates = Vote.HotSpots(0).GetCoordinates()
Message1.Text = "The hot spot's coordinates are " & coordinates
' When a user clicks the "No" hot spot,
' display the hot spot's coordinates.
ElseIf (e.PostBackValue = "No") Then
coordinates = Vote.HotSpots(1).GetCoordinates()
Message1.Text = "The hot spot's coordinates are " & coordinates
Else
Message1.Text = "You did not click in a valid hot spot region."
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>RectangleHotSpot.GetCoordinates Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>RectangleHotSpot.GetCoordinates Example</h3>
<!-- Change or remove the width and height attributes as
appropriate for your image. -->
<asp:imagemap id="Vote"
imageurl="Images/VoteImage.jpg"
alternatetext="Voting choices"
hotspotmode="PostBack"
width="400"
height="200"
onclick="VoteMap_Clicked"
runat="Server">
<asp:RectangleHotSpot
top="0"
left="0"
bottom="200"
right="200"
postbackvalue="Yes"
alternatetext="Vote yes">
</asp:RectangleHotSpot>
<asp:RectangleHotSpot
top="0"
left="201"
bottom="200"
right="400"
postbackvalue="No"
alternatetext="Vote no">
</asp:RectangleHotSpot>
</asp:imagemap>
<br /><br />
<asp:label id="Message1"
runat="Server">
</asp:label>
</form>
</body>
</html>
Comentários
Esse método retorna uma cadeia de caracteres que representa as coordenadas do RectangleHotSpot canto superior esquerdo de um objeto e as coordenadas de seu canto inferior direito.This method returns a string that represents the coordinates of a RectangleHotSpot object's top left corner and the coordinates of its bottom right corner. Esse método usa os valores atribuídos às Left Propriedades e Top para retornar as coordenadas para o canto superior esquerdo.This method uses the values assigned to the Left and Top properties to return the coordinates for the top left corner. Ele usa os valores atribuídos às Right Propriedades e Bottom para retornar as coordenadas do canto inferior direito.It uses the values assigned to the Right and Bottom properties to return the coordinates for the bottom right corner.
O GetCoordinates método é usado internamente pelo ASP.net para obter o texto a ser usado para as coordenadas de um RectangleHotSpot quando ele é renderizado.The GetCoordinates method is used internally by ASP.NET to get the text to use for the coordinates of a RectangleHotSpot when it is rendered. A cadeia de caracteres retornada é específica para o navegador e a linguagem de marcação.The string that is returned is specific to the browser and markup language.