当前位置: 首页>>代码示例>>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;未经允许,请勿转载。