本文整理汇总了TypeScript中electron.screen类的典型用法代码示例。如果您正苦于以下问题:TypeScript screen类的具体用法?TypeScript screen怎么用?TypeScript screen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了screen类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: BrowserWindow
app.on('ready', () => {
let cursorPos = screen.getCursorScreenPoint()
let workAreaSize = screen.getDisplayNearestPoint(cursorPos).workAreaSize
app.setName('Ansel')
mainWindow = new BrowserWindow({
width: 1356,
height: 768,
title: 'Ansel',
titleBarStyle: 'hiddenInset',
backgroundColor: '#37474f', // @blue-grey-800
webPreferences: {
experimentalFeatures: true,
blinkFeatures: 'CSSGridLayout'
}
})
if (workAreaSize.width <= 1366 && workAreaSize.height <= 768)
mainWindow.maximize()
mainWindow.loadURL('file://' + __dirname + '/../../static/index.html')
mainWindow.setTitle('Ansel')
initBackgroundService(mainWindow)
initForegroundClient(mainWindow)
//let usb = new Usb()
//
//usb.scan((err, drives) => {
// mainWindow.webContents.send('scanned-devices', drives)
//})
//
//usb.watch((err, action, drive) => {
// if (action === 'add')
// mainWindow.webContents.send('add-device', drive)
// else
// mainWindow.webContents.send('remove-device', drive)
//})
if (fs.existsSync(config.settings)) {
initLibrary(mainWindow)
} else {
initDb()
ipcMain.on('settings-created', () => initLibrary(mainWindow))
}
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
})
开发者ID:m0g,项目名称:ansel,代码行数:54,代码来源:entry.ts
示例2: async
watcher.on(actions.preferencesLoaded, async (store, action) => {
const hidden = action.payload.openAsHidden;
if (!hidden) {
store.dispatch(actions.focusWindow({ window: "root" }));
}
screen.on("display-added", () => ensureMainWindowInsideDisplay(store));
screen.on("display-removed", () => ensureMainWindowInsideDisplay(store));
screen.on("display-metrics-changed", () =>
ensureMainWindowInsideDisplay(store)
);
});
开发者ID:HorrerGames,项目名称:itch,代码行数:12,代码来源:main-window.ts
示例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;
});
}
开发者ID:meltedspark,项目名称:electron-angular2-native,代码行数:30,代码来源:main.electron.ts
示例4: 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;
});
}
开发者ID:MikeCook9994,项目名称:TwitchPlaysTinder,代码行数:25,代码来源:main.ts
示例5: function
app.on('ready', function() {
// Create the browser window.
let displays = electron.screen.getAllDisplays()
let d = displays.find((display) => {
return { width: display.bounds.width, height: display.bounds.height }
})
let minScreenWidth = 650;
let minScreenHeight = 450;
mainWindow = new BrowserWindow({
width: Math.max(minScreenWidth, ~~(d.bounds.width * 0.75)),
height: Math.max(minScreenHeight, ~~(d.bounds.height * 0.75)),
minWidth: minScreenWidth,
minHeight: minScreenHeight,
title: 'Leto'
})
mainWindow.loadURL(`file://${ path.join(__dirname, '../www/index_electron.html')}`)
// Open the DevTools.
mainWindow.webContents.openDevTools({mode:'undocked'});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
开发者ID:HelixOne,项目名称:leto,代码行数:30,代码来源:electron.ts
示例6: 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
});
};
开发者ID:chauey,项目名称:ngrev,代码行数:7,代码来源:window.ts
示例7: 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;
}
开发者ID:F2Ealexis,项目名称:black-screen,代码行数:33,代码来源:Main.ts
示例8: function
var windowIsOffScreen = function(windowBounds: Electron.Rectangle): boolean {
const nearestDisplay = Electron.screen.getDisplayMatching(windowBounds).workArea;
return (
windowBounds.x > (nearestDisplay.x + nearestDisplay.width) ||
(windowBounds.x + windowBounds.width) < nearestDisplay.x ||
windowBounds.y > (nearestDisplay.y + nearestDisplay.height) ||
(windowBounds.y + windowBounds.height) < nearestDisplay.y
);
}
开发者ID:sarthakfx,项目名称:BotFramework-Emulator,代码行数:9,代码来源:main.ts
示例9: getSettings
mainWindow.on('restore', () => {
if (windowIsOffScreen(mainWindow.getBounds())) {
const bounds = mainWindow.getBounds();
let display = Electron.screen.getAllDisplays().find(display => display.id === getSettings().windowState.displayId);
display = display || Electron.screen.getDisplayMatching(bounds);
mainWindow.setPosition(display.workArea.x, display.workArea.y);
dispatch<WindowStateAction>({
type: 'Window_RememberBounds',
state: {
displayId: display.id,
width: bounds.width,
height: bounds.height,
left: display.workArea.x,
top: display.workArea.y
}
});
}
});
开发者ID:sarthakfx,项目名称:BotFramework-Emulator,代码行数:18,代码来源:main.ts
示例10: enableHiresResources
function enableHiresResources(): void {
const scaleFactor = Math.max(
...electronScreen.getAllDisplays().map(display => display.scaleFactor)
);
if (scaleFactor === 1) {
return;
}
const filter = {urls: [`*://*.${domain}/`]};
session.defaultSession!.webRequest.onBeforeSendHeaders(
filter,
(details: OnSendHeadersDetails, callback: (response: BeforeSendHeadersResponse) => void) => {
let cookie = (details.requestHeaders as any).Cookie;
if (cookie && details.method === 'GET') {
if (/(; )?dpr=\d/.test(cookie)) {
cookie = cookie.replace(/dpr=\d/, `dpr=${scaleFactor}`);
} else {
cookie = `${cookie}; dpr=${scaleFactor}`;
}
(details.requestHeaders as any).Cookie = cookie;
}
callback({
cancel: false,
requestHeaders: details.requestHeaders
});
}
);
}
开发者ID:kusamakura,项目名称:caprine,代码行数:33,代码来源:index.ts
注:本文中的electron.screen类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论