本文整理汇总了TypeScript中electron.screen.getPrimaryDisplay方法的典型用法代码示例。如果您正苦于以下问题:TypeScript screen.getPrimaryDisplay方法的具体用法?TypeScript screen.getPrimaryDisplay怎么用?TypeScript screen.getPrimaryDisplay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.screen
的用法示例。
在下文中一共展示了screen.getPrimaryDisplay方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createWindow
function createWindow() {
const size = screen.getPrimaryDisplay().workAreaSize;
const args = process.argv.slice(1);
window = new BrowserWindow({
backgroundColor: '#ffffff',
icon: `${__dirname}/ux/favicon.ico`,
width: size.width,
height: size.height
});
if(args.some(val => val == '--serve')) {
require('electron-reload')(__dirname, {
electron: require(`${__dirname}/../node_modules/electron`)
});
window.loadURL(`http://localhost:4200/`);
}
else {
window.loadURL(`file://${__dirname}/ux/index.html`);
}
window.on('closed', function() {
window = null;
});
}
示例2: function
var resetToDefaults = function(windowState) {
var bounds = screen.getPrimaryDisplay().bounds;
return Object.assign({}, defaultSize, {
x: (bounds.width - defaultSize.width) / 2,
y: (bounds.height - defaultSize.height) / 2
});
};
示例3: createWindow
function createWindow() {
const size = screen.getPrimaryDisplay().workAreaSize;
// Create the browser window.
win = new BrowserWindow({
x: 0,
y: 0,
width: size.width,
height: size.height
});
// and load the index.html of the app.
win.loadURL(url.format({
protocol: 'file:',
pathname: path.join(__dirname, '/index.html'),
slashes: true
}));
if (serve) {
win.webContents.openDevTools();
}
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store window
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
});
}
示例4: BrowserWindow
app.on('ready', () => {
var size = screen.getPrimaryDisplay().workAreaSize;
mainWindow = new BrowserWindow({ width: size.width, height: size.height });
});
示例5: getMainWindow
function getMainWindow(): Electron.BrowserWindow {
const workAreaSize = screen.getPrimaryDisplay().workAreaSize;
if (!browserWindow) {
let options: Electron.BrowserWindowOptions = {
webPreferences: {
experimentalFeatures: true,
experimentalCanvasFeatures: true,
},
titleBarStyle: "hidden",
resizable: true,
minWidth: 500,
minHeight: 300,
width: workAreaSize.width,
height: workAreaSize.height,
show: false,
};
browserWindow = new BrowserWindow(options);
browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
menu.setMenu(app, browserWindow);
browserWindow.on("closed", (): void => browserWindow = undefined)
.on("focus", (): void => app.dock && app.dock.setBadge(""));
browserWindow.webContents.on("did-finish-load", () => {
browserWindow.show();
browserWindow.focus();
});
}
return browserWindow;
}
示例6: windowBounds
function windowBounds(): Electron.Rectangle {
try {
return JSON.parse(readFileSync(windowBoundsFilePath).toString());
} catch (error) {
const workAreaSize = screen.getPrimaryDisplay().workAreaSize;
return {
width: workAreaSize.width,
height: workAreaSize.height,
x: 0,
y: 0,
};
}
}
示例7: BrowserWindow
ipcMain.on(MainAction.OPEN, (event: Electron.IpcMainEvent, roomId: string) => {
if(receiverWindow) return;
const size = Electron.screen.getPrimaryDisplay().size;
receiverWindow = new BrowserWindow({
x: 0,
y: 0,
width: size.width,
height: size.height,
frame: false,
show: true,
fullscreen : true,
transparent: true,
resizable: false,
alwaysOnTop: true,
skipTaskbar: true
});
receiverWindow.on('closed', function() {
receiverWindow = null;
});
receiverWindow.setIgnoreMouseEvents(true);
receiverWindow.maximize();
receiverWindow.setAlwaysOnTop(true);
receiverWindow.loadURL(`file://${__dirname}/views/receive.html?roomid=${roomId}`);
});
示例8:
socket.on('screen-getPrimaryDisplay', () => {
var display = screen.getPrimaryDisplay();
socket.emit('screen-getPrimaryDisplayCompleted', display);
});
示例9: createWindow
function createWindow(config: Config, icon_path: string) {
const display_size = screen.getPrimaryDisplay().workAreaSize as DisplaySize;
function getConfigLength(key: 'width'|'height'): number {
const len = config[key];
const default_len = default_config[key] as number;
switch (typeof len) {
case 'string': {
if (len === 'max') {
return display_size[key];
}
return default_len;
}
case 'number': {
return len as number;
}
default: {
return default_len;
}
}
}
const config_width = getConfigLength('width');
const config_height = getConfigLength('height');
const win_state = windowState({
defaultWidth: config_width,
defaultHeight: config_height,
});
let options: Electron.BrowserWindowConstructorOptions;
if (config.restore_window_state) {
options = {
x: win_state.x,
y: win_state.y,
width: win_state.width,
height: win_state.height,
};
} else {
options = {
width: config_width,
height: config_height,
};
}
options.icon = icon_path;
options.autoHideMenuBar = config.hide_menu_bar;
options.show = false;
if (config.hide_title_bar) {
options.titleBarStyle = 'hiddenInset';
}
const win = new BrowserWindow(options);
win.once('ready-to-show', () => {
win.show();
});
if (config.restore_window_state) {
if (win_state.isFullScreen) {
win.setFullScreen(true);
} else if (win_state.isMaximized) {
win.maximize();
}
win_state.manage(win);
}
return win;
}