当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript screen.getPrimaryDisplay方法代码示例

本文整理汇总了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;
        });
    }
开发者ID:MikeCook9994,项目名称:TwitchPlaysTinder,代码行数:25,代码来源:main.ts

示例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
   });
 };
开发者ID:chauey,项目名称:ngrev,代码行数:7,代码来源: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: BrowserWindow

app.on('ready', () => {
	var size = screen.getPrimaryDisplay().workAreaSize;
	mainWindow = new BrowserWindow({ width: size.width, height: size.height });
});
开发者ID:longlho,项目名称:DefinitelyTyped,代码行数:4,代码来源:github-electron-renderer-tests.ts

示例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;
}
开发者ID:F2Ealexis,项目名称:black-screen,代码行数:33,代码来源:Main.ts

示例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,
        };
    }
}
开发者ID:admix,项目名称:black-screen,代码行数:14,代码来源:Main.ts

示例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}`);
});
开发者ID:yasupeke,项目名称:niconico-desktop,代码行数:24,代码来源:app.ts

示例8:

 socket.on('screen-getPrimaryDisplay', () => {
     var display = screen.getPrimaryDisplay();
     socket.emit('screen-getPrimaryDisplayCompleted', display);
 });
开发者ID:E024,项目名称:Electron.NET,代码行数:4,代码来源:screen.ts

示例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;
}
开发者ID:Sheshouzuo,项目名称:Shiba,代码行数:69,代码来源:mainu.ts


注:本文中的electron.screen.getPrimaryDisplay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。