當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。