Moving fullscreen projects between multiple monitors

Here is a screen that will show the display configuration and allow you to move the project to a display of your choice. Click on the desired window and it'll prompt you to move the project there.


screenMove.vwin (14.4 KB)

Here is an updated window



Move Screen.vwin (14.4 KB)

2 Likes

Cool!

very cool ! how does it work? how to we import the vwin? I have a similar need for this functionality.

Amazing !!! :thumb_left:

Thanks Kyle; nice work!

Tailfire: The .vwin file is an Ignition Vision client popup window with some slick scripting in it. You import the .vwin by right clicking the Windows folder in the Designer’s project browser and selecting import:
[attachment=0]Fullscreen capture 2014.01.05 145114.bmp.jpg[/attachment]
After import, you’ll see a new “Move To Screen” window in your project tree. To use it:
1 - Add a button to one of your windows that opens the “Move To Screen” window.
2 - Pressing that button will then bring up the screen showing your monitors as shown in Kyle’s screenshot above.
3 - Touching/clicking the box corresponding to the screen your client is NOT currently on will move the client to that screen. (Touch/clicking the screen your client IS currently on closes the Move To Screen popup.)

1 Like

Dead links above. Here is an exported window:

Move To Screen.proj (16.1 KB)

3 Likes

This is awesome!

8 years later, but very nice! Nice to see how it’s done as well :slight_smile:

1 Like

That saved my day. Tanks a lot!

Hi all, after 13 years this topic is still usefull :smiley:

I want to share a solution I had to apply to avoid an exception generated by this code, after moving the project:

from java.awt import MouseInfo, Point
from system.gui import getParentWindow

# return the distance of cursor from window:
# negative if from leftmost / uppper edge
# positive if from rightmost / lower edge 	
def getDistanceFromWindow(window):
	p = MouseInfo.getPointerInfo().getLocation()
	c = window.getLocationOnScreen() # <<< this generate the exception
    # component must be showing on the screen to determine its location
	x = p.x - c.x
	if x > 0:
		x -= window.width
		if x < 0:
			x = 0

	y = p.y - c.y
	if y > 0:
		y -= window.height
		if y < 0:
			y = 0
	return Point(x , y)

After reading this post on Stack Overflow I chaged the code of the Paintable Canvas component for the mouseClicked event this way:

from java.awt import Rectangle, GraphicsDevice, GraphicsEnvironment
from javax.swing import SwingUtilities, JFrame

screens = event.source.parent.screens

screenClickX = event.x/float(event.source.width)*event.source.gWidth
screenClickY = event.y/float(event.source.height)*event.source.gHeight


for i in range(screens.rowCount):
	name = screens.getValueAt(i,'screen')
	x = screens.getValueAt(i,'x')
	y = screens.getValueAt(i,'y')
	width = screens.getValueAt(i,'width')
	height = screens.getValueAt(i,'height')

	if Rectangle(x,y,width,height).contains(screenClickX,screenClickY):
		if event.source.currentWindow == name:
			system.gui.closeParentWindow(event)
#		elif system.gui.confirm("Do you want to move this project to "+name+"?"):
		else:

			frame = SwingUtilities.getAncestorOfClass(JFrame, event.source)
			ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
			gd = ge.getScreenDevices()[i]		
			newFrame = JFrame(gd.getDefaultConfiguration())	
			def doLater(canvas=event.source,frame=frame,x=x,y=y,width=width,height=height, newFrame = newFrame, state= JFrame.MAXIMIZED_BOTH):
				frame.setLocationRelativeTo(newFrame)
				newFrame.dispose()
				frame.setExtendedState(state)
				
			system.gui.closeParentWindow(event)
			system.util.invokeLater(doLater)

And the problem is solved :grin:

3 Likes