本文整理汇总了TypeScript中electron.BrowserWindow.setFullScreen方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserWindow.setFullScreen方法的具体用法?TypeScript BrowserWindow.setFullScreen怎么用?TypeScript BrowserWindow.setFullScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.BrowserWindow
的用法示例。
在下文中一共展示了BrowserWindow.setFullScreen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _setBounds
private _setBounds(): void {
if (this._state.isFullScreen) {
this._window.setFullScreen(true)
} else if (this._state.isMaximized) {
this._window.maximize()
} else {
this._window.setBounds(this._state.bounds!)
}
}
示例2:
main.on('close', event => {
if (!isQuitting) {
event.preventDefault();
logger.log('Closing window...');
if (main.isFullScreen()) {
logger.log('Fullscreen detected, leaving full screen before hiding...');
main.once('leave-full-screen', () => main.hide());
main.setFullScreen(false);
} else {
main.hide();
}
}
systemMenu.unregisterShortcuts();
});
示例3: 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;
}
示例4:
click: (item: object, focusedWindow: BrowserWindow) => {
if (focusedWindow) {
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
}
}
示例5: open_window
function open_window(access: AccessToken) {
'use strict';
log.debug('Starting to open window');
const win_state = windowState({
defaultWidth: 600,
defaultHeight: 800,
});
const index_html = 'file://' + join(__dirname, '..', 'index.html');
const icon_path = join(__dirname, '..', 'images', 'icon.png');
win = new BrowserWindow({
x: win_state.x,
y: win_state.y,
width: win_state.width,
height: win_state.height,
titleBarStyle: 'hidden-inset',
autoHideMenuBar: true,
icon: icon_path,
});
win.once('closed', () => { win = null; });
if (win_state.isFullScreen) {
win.setFullScreen(true);
} else if (win_state.isMaximized) {
win.maximize();
}
win_state.manage(win);
if (access.token && access.token_secret) {
win.webContents.on('dom-ready', () => {
log.debug('dom-ready: Ready to connect to Twitter API');
const twitter = new Twitter();
twitter.prepareClient({
consumer_key,
consumer_secret,
access_token: access.token,
access_token_secret: access.token_secret,
});
twitter.sender = new IpcSender(win.webContents);
if (should_use_dummy_data) {
twitter
.sendDummyAccount()
.then(() => twitter.sendDummyStream())
.catch(e => log.error('Unexpected error on dummy stream:', e));
return;
}
twitter
.sendAuthenticatedAccount()
.catch(err => {
if (!err || (err instanceof Error) || err[0].code !== 32) {
log.error('Unexpected error on verifying account:', err);
return;
}
log.debug('Retry authentication flow');
return authenticate(consumer_key, consumer_secret)
.then((a: AccessToken) => {
if (!a.token || !a.token_secret) {
log.error('Invalid access tokens:', a);
return;
}
twitter.prepareClient({
consumer_key,
consumer_secret,
access_token: a.token,
access_token_secret: a.token_secret,
});
})
.then(() => twitter.sendAuthenticatedAccount())
.catch(e => {
log.error('Give up: Second authentication try failed. If you use environment variables for tokens, please check them:', e);
});
})
.then(() => Promise.all([
twitter.fetchMuteIds(),
twitter.fetchNoRetweets(),
twitter.fetchBlockIds(),
twitter.fetchHomeTimeline(),
twitter.fetchMentionTimeline(),
]))
.then(([mute_ids, no_retweet_ids, block_ids, tweets, mentions]) => {
// Note: Merge mute list with block list
for (const m of mute_ids) {
if (block_ids.indexOf(m) === -1) {
block_ids.push(m);
}
}
log.debug('Total rejected ids: ', block_ids.length);
twitter.sender.send('yf:rejected-ids', block_ids);
twitter.sender.send('yf:no-retweet-ids', no_retweet_ids);
for (const tw of tweets) {
twitter.sender.send('yf:tweet', tw);
}
twitter.sender.send('yf:mentions', mentions);
})
.then(() => twitter.connectToStream())
.catch((e: any) => log.error('Unexpected error on streaming', e));
//.........这里部分代码省略.........
示例6:
click:() => {
mainWindow.setFullScreen(!mainWindow.isFullScreen());
}