forked from willosof/artnet2atem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
97 lines (71 loc) · 2.36 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
const electron = require('electron');
const ipcMain = require('electron').ipcMain;
var _ = require('lodash');
var app = electron.app;
var path = require('path');
var BrowserWindow = electron.BrowserWindow;
var externalWindow;
/*
app.commandLine.appendSwitch('remote-debugging-port', '8315');
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1');
*/
var mainWindow = null;
var options = {
"debug": true,
"version": "1.0.0",
"views_dir": "views",
"root_view": "index.html",
"external_view": "external.html"
};
options = _.extend({
// ADDITIONAL CUSTOM SETTINGS
}, options);
// ############################################################################################
// ############################################################################################
// Quit when all windows are closed.
app.on('window-all-closed', function() {
if(process.platform !== 'darwins') { app.quit(); }
});
ipcMain.on('minimize', function (event, args) {
if (mainWindow) {
mainWindow.minimize();
}
});
ipcMain.on('quit', function (event, args) {
app.quit();
});
ipcMain.on('screen', function(event, args) {
var electronScreen = electron.screen;
var displays = electronScreen.getAllDisplays();
if (args.command == 'close') {
if (externalWindow) {
externalWindow.close();
externalWindow = undefined;
}
}
else if (args.command == 'open') {
externalWindow = new BrowserWindow({
x: displays[args.display].bounds.x + 50,
y: displays[args.display].bounds.y + 50
});
externalWindow.loadURL(path.join('file://', __dirname, options.views_dir, options.external_view));
externalWindow.on('closed', function () { externalWindow = undefined; });
}
event.sender.send('screenresult', 'ok');
});
app.on('ready', function() {
mainWindow = new BrowserWindow( {
width: 800,
height: 600,
title: "artnet2atem",
frame: false,
minWidth: 768,
minHeight: 460
});
mainWindow.loadURL(path.join('file://', __dirname, options.views_dir, options.root_view));
//if(1||options.debug) { mainWindow.openDevTools(); }
mainWindow.on('closed', function() { mainWindow = null; });
});
// ############################################################################################
// ############################################################################################