Vwa.Shape.addOverlay Method

Última modificación: sábado, 06 de agosto de 2011

Hace referencia a: apps for SharePoint | SharePoint Server 2013

Crea una superposición visual basada en el contenido especificado y en la posición especificada.

var value = Shape.addOverlay(string overlayID, string content, Vwa.HorizontalAlignment horizontalPosition, Vwa.VerticalAlignment verticalPosition, integer overlayWidth, integer overlayHeight)

Parámetros

overlayID Una cadena que representa el identificador (ID) de la superposición. Debe ser único entre todos los identificadores de superposición.

content Una cadena que especifica el contenido HTML de la superposición, si el modo de presentación es Vwa.DisplayMode.rastero el contenido XAML de la superposición, si el modo de presentación es Vwa.DisplayMode.silverlight.

horizontalPosition Una constante Vwa.HorizontalAlignment que especifica la posición horizontal del centro de la superposición, en relación con el cuadro delimitador de la forma.

verticalPosition Una constante Vwa.VerticalAlignment que especifica la posición vertical del centro de la superposición, en relación con el cuadro delimitador de la forma.

overlayWidth Un entero positivo que especifica el ancho de la superposición, en píxeles.

overlayHeight Un entero positivo que especifica el alto de la superposición, en píxeles.

Valor devuelto

Object Devuelve el objeto subyacente que representa la superposición.

Comentarios

Las formas pueden tener superposiciones de uno o más. La infraestructura de elementos Web es responsable de zoom y la panorámica se superpone con el dibujo original.

El objeto subyacente que representa la superposición es un elemento <div> HTML si el modo de presentación actual es Vwa.DisplayMode.raster o un elemento XAML de <Canvas> si el modo de presentación actual es Vwa.DisplayMode.silverlight. Para determinar qué actual es modo de presentación, puede utilizar el método Vwa.VwaControl.getDisplayMode .

Para obtener más información acerca de cómo agregar un elemento Web de Visio Web Access a una página de elementos web de SharePoint, consulte Customizing Visio Web Drawings in the Visio Web Access Web Part.

Ejemplo

En el ejemplo siguiente se agrega un controlador para el evento Vwa.shapeselectionchanged que crea una etiqueta HTML o una cubierta transparente de XAML en la forma seleccionada, según el modo de presentación.

<script type="text/javascript">

// Hook into the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Define global variables.
var vwaControl;
var vwaPage;
var vwaShapes;
var currentlyAnnotatedShape;  

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
        vwaControl= new Vwa.VwaControl(getVWAWebPartID());
        vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    }
    catch(err){
        alert(err);
    }
}

// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID() {
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

// Capture references to the global variables and register a handler for shapeselectionchanged event.
function onDiagramComplete() {
    try{
        vwaPage = vwaControl.getActivePage();
        vwaShapes = vwaPage.getShapes(); 
        vwaControl.addHandler("shapeselectionchanged", onShapeSelectionChanged);
    }
    catch(err){
        alert(err);
    }
}

function onShapeSelectionChanged(source, args){
    try{
        // Ignore the shapeselectionchanged event raised when the selection is cleared.
        if (args != null && args != Sys.EventArgs.Empty){

            // Get the value of the display mode for the Visio Web Access Web Part.
            var displayMode = vwaControl.getDisplayMode();

            // Remove any existing overlay from the diagram.
            removeAnnotation();
            currentlyAnnotatedShape = vwaShapes.getItemById(args);

            // Test to see what the current display mode is.
            if (displayMode == 1) {
                
                // The display mode is Silverlight; add a XAML overlay.
                currentlyAnnotatedShape.addOverlay(
                    "Overlay", 
                    "<Rectangle Height=\"" + currentlyAnnotatedShape.getBounds().height + "\"" + 
                    " Width=\"" + currentlyAnnotatedShape.getBounds().width + "\"" + 
                    " Stroke=\"Black\" StrokeThickness=\"1\" Fill=\"#88FF0000\"" + 
                    " RadiusX=\"0.0\" RadiusY=\"0.0\"\/>",
                    1, 
                    1,
                    currentlyAnnotatedShape.getBounds().width,
                    currentlyAnnotatedShape.getBounds().height);
            }
            else {
                
                // The display mode is raster format; add an HTML overlay.
                currentlyAnnotatedShape.addOverlay(
                    "Overlay", 
                    "<div id=\"HTMLDiv\" style=\"width: 100%; height:" + 
                    "100%;background-color:#FF0000;z-order:32;" + 
                    "filter:alpha(opacity=30);\"><\/div>", 
                    1, 
                    1,
                    currentlyAnnotatedShape.getBounds().width,
                    currentlyAnnotatedShape.getBounds().height);
            }
            
            // Re-center the drawing on the selected shape.
            vwaPage.centerViewOnShape(currentlyAnnotatedShape.getId());
        }
    }
    catch(err){
        alert(err);
    }
}

// Remove any existing overlay.
function removeAnnotation() {
    if (typeof(currentlyAnnotatedShape)!="undefined") {
            currentlyAnnotatedShape.removeOverlay("Overlay");
    } 
}
</script>

Vea también

Referencia

Vwa.Shape Class

Vwa.Shape Class Methods