當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript screen.getDisplayMatching方法代碼示例

本文整理匯總了TypeScript中electron.screen.getDisplayMatching方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript screen.getDisplayMatching方法的具體用法?TypeScript screen.getDisplayMatching怎麽用?TypeScript screen.getDisplayMatching使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在electron.screen的用法示例。


在下文中一共展示了screen.getDisplayMatching方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 const rememberBounds = () => {
     const bounds = mainWindow.getBounds();
     dispatch<WindowStateAction>({
         type: 'Window_RememberBounds',
         state: {
             displayId: Electron.screen.getDisplayMatching(bounds).id,
             width: bounds.width,
             height: bounds.height,
             left: bounds.x,
             top: bounds.y
         }
     });
 }
開發者ID:sarthakfx,項目名稱:BotFramework-Emulator,代碼行數:13,代碼來源:main.ts

示例2: isValidWindowState

function isValidWindowState(windowState: WindowState) {
    if (windowState && windowState.bounds && windowState.displayBounds) {
        // check if the display where the window was last open is still available
        var displayBounds = screen.getDisplayMatching(windowState.bounds).bounds;
        if (
            windowState.displayBounds.x == displayBounds.x &&
            windowState.displayBounds.y == displayBounds.y &&
            windowState.displayBounds.width == displayBounds.width &&
            windowState.displayBounds.height == displayBounds.height
        ) {
            return true;
        }
    }

    return false;
}
開發者ID:eez-open,項目名稱:studio,代碼行數:16,代碼來源:settings.ts

示例3: ensureWindowInsideDisplay

/**
 * Make sure the window isn't outside the bounds of the screen,
 * cf. https://github.com/itchio/itch/issues/1051
 */
function ensureWindowInsideDisplay(nativeWindow: Electron.BrowserWindow) {
  if (!nativeWindow || !nativeWindow.isVisible()) {
    return;
  }

  const originalBounds = nativeWindow.getBounds();
  logger.debug(
    `Ensuring ${JSON.stringify(originalBounds)} is inside a display`
  );

  const display = screen.getDisplayMatching(originalBounds);
  if (!display) {
    logger.warn(`No display found matching ${JSON.stringify(originalBounds)}`);
    return;
  }

  const displayBounds = display.bounds;
  logger.debug(`Display bounds: ${JSON.stringify(displayBounds)}`);

  let bounds = originalBounds;

  const displayLeft = displayBounds.x;
  if (bounds.x < displayLeft) {
    bounds = { ...bounds, x: displayLeft };
  }

  const displayTop = displayBounds.y;
  if (bounds.y < displayTop) {
    bounds = { ...bounds, y: displayTop };
  }

  const displayRight = displayBounds.width + displayBounds.x;
  if (bounds.x + bounds.width > displayRight) {
    bounds = { ...bounds, x: displayRight - bounds.width };
  }

  const displayBottom = displayBounds.height + displayBounds.y;
  if (bounds.y + bounds.height > displayBottom) {
    bounds = { ...bounds, y: displayBottom - bounds.height };
  }

  if (bounds !== originalBounds) {
    logger.debug(`New bounds: ${JSON.stringify(bounds)}`);
    nativeWindow.setBounds(bounds);
  }
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:50,代碼來源:main-window.ts

示例4: 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

示例5: updateState

    function updateState() {
        var windowBounds = window.getBounds();

        if (!window.isMaximized() && !window.isMinimized() && !window.isFullScreen()) {
            normalWindowBounds = Object.assign({}, windowBounds);
        }

        var displayBounds = screen.getDisplayMatching(windowBounds).bounds;

        action(() => {
            settings.windowStates[windowId] = {
                bounds: normalWindowBounds,
                isMaximized: window.isMaximized(),
                isFullScreen: window.isFullScreen(),
                displayBounds: Object.assign({}, displayBounds)
            };
        })();
    }
開發者ID:eez-open,項目名稱:studio,代碼行數:18,代碼來源:settings.ts

示例6:

 socket.on('screen-getDisplayMatching', (rectangle) => {
     var display = screen.getDisplayMatching(rectangle);
     socket.emit('screen-getDisplayMatchingCompleted', display);
 });
開發者ID:E024,項目名稱:Electron.NET,代碼行數:4,代碼來源:screen.ts


注:本文中的electron.screen.getDisplayMatching方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。