Image Events

Scripting is not supported by TWC

Event icon The Image control supports the following scripting events. Click next to any event name in the Events pane to see a short description for the selected event.

See Accessing Screen Objects for more information about how to view control objects in script in the Canvas application.

When an event is enabled, the control will be automatically added to script and the Include in script property will be set to True.

Event Description

Click

The Click event is called when the user clicks once on the control with the left mouse button.

Examples

Copy
Click event
Objects.Button1.Click += new EventHandler(this.Button1_Click);
 

Objects.CheckBox1.Click += new EventHandler(this.CheckBox1_Click);

 
Objects.Image1.Click += new EventHandler(this.Image1_Click);


Objects.TextTool1.Click += new EventHandler(this.TextTool1_Click);

Close

The Close event is called when the screen is closed.

Custom Context Menu Action

The Custom Context Menu Action event is called when the custom context menu item is clicked. A Script event ID (configured for each custom context menu item in the Context Menu Items property for the screen or control) is passed in along with other relevant information in the context of the click, for example, facility or point tag, as appropriate.

Example

The following example shows how to use the Custom Context Menu Action event for the CygNet Grid. Substitute Grid1 with your control.

Canvas.Controls.Grid.CustomContextMenuActionEventArgs

When you click on a custom context menu item from a control, Canvas will execute the following function:

  • Grid1_CustomContextMenuAction(object sender, EventArgs args)

CustomContextMenuActionEventArgs.EventActionID indicates the Script event ID defined in the Custom Context Menu Configuration dialog box.

Copy
Custom Context Menu Action event
private void Grid1_CustomContextMenuAction(object sender, EventArgs args)

{
    CustomContextMenuActionEventArgs myargs = (CustomContextMenuActionEventArgs)args;
    MessageBox.Show(myargs.MenuItemText + " " + myargs.EventActionID + " " + myargs.FacilityTag + " " + myargs.PointTag);
}

See Event Argument Type for more information about EventArgs.

Initialize

The Initialize event is called when the screen is created in preview or run mode to allow further initialization of the control.

Loaded

The Loaded event is called when the control is rendered and ready for interaction.

Mouse Enter

The Mouse Enter event is called when the mouse pointer enters (moves over) a control.

Mouse Leave

The Mouse Leave event is called when the mouse pointer leaves (moves out of) a control.

Tooltip Opening

The Tooltip Opening event is called right before the tooltip opens creating a custom tooltip, which can show any desired information, for example, a value from an affiliated point, an unrelated data point, or even a CygNet note. The Tooltip mode (TooltipMode) property must be set to Script. The Tooltip Opening event supports multi-line tooltips.

Example

In the following example, a custom tooltip will be created that will retrieve and display three point values (Choke Position, SDV Valve Position, and Tubing Pressure) for the JOHNSON_WL facility on three separate lines.

Copy
Tooltip Opening example
private void TextTool1_TooltipOpening(object sender, EventArgs args)

    {
        CygNet.Data.Core.DomainSiteService Site = new CygNet.Data.Core.DomainSiteService(5410, "MYSITE", "UIS");
        CygNet.API.Points.RealtimeClient PointsClient = new CygNet.API.Points.RealtimeClient(Site);
        CygNet.Data.Core.PointTag Choke = new CygNet.Data.Core.PointTag("MYSITE.UIS:JOHNSON_WL_POACTCHO");
        CygNet.Data.Core.PointTag SDV = new CygNet.Data.Core.PointTag("MYSITE.UIS:JOHNSON_WL_POACTSDV");
        CygNet.Data.Core.PointTag Tubing = new CygNet.Data.Core.PointTag("MYSITE.UIS:JOHNSON_WL_PRTUBXIN");
        string TipValues = string.Concat("Choke Position: ", PointsClient.GetPointValueRecord(Choke).Value.ToString(), Environment.NewLine,
        "SDV Valve Position: ", PointsClient.GetPointValueRecord(SDV).Value.ToString(), Environment.NewLine,
        "Tubing Pressure: ", PointsClient.GetPointValueRecord(Tubing).Value.ToString());
        Objects.TextTool1.TooltipText = TipValues;
    }

See Event Argument Type for more information about EventArgs.

See Order of Event Execution for information about the order in which events are executed on a screen.