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


TypeScript BrowserWindow.maximize方法代码示例

本文整理汇总了TypeScript中electron.BrowserWindow.maximize方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserWindow.maximize方法的具体用法?TypeScript BrowserWindow.maximize怎么用?TypeScript BrowserWindow.maximize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.BrowserWindow的用法示例。


在下文中一共展示了BrowserWindow.maximize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createWindow

async function createWindow() {

    let width = 800;
    let height = 600;
    let maximized = false;

    try {
        const str = await readFileAsString("./preference.json");
        const pref: Preference = JSON.parse(str);
        width = pref.widthOfWindow;
        height = pref.heightOfWindow;
        maximized = pref.maximized;
    } catch (err) {
        console.log(err);
    }

    mainWindow = new BrowserWindow({ width, height });
    if (maximized) { mainWindow.maximize(); }

    mainWindow.loadURL("file://" + __dirname + "/views/index.html");

    mainWindow.webContents.openDevTools();

    mainWindow.on("closed", () => {
        mainWindow = undefined;
    });
}
开发者ID:Zzzen,项目名称:YAP,代码行数:27,代码来源:main.ts

示例2: createWindow

async function createWindow(openDevTools: boolean) {
  // Create the browser window.
  mainWindow = new BrowserWindow({ width: 800, height: 600 });

  // create menubar
  buildMenu(mainWindow.webContents);

  mainWindow.maximize();
  // and load the index.html of the app.
  mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
  }));

  // Open the DevTools.
  if (openDevTools) mainWindow.webContents.openDevTools();

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
}
开发者ID:andrew-ni,项目名称:warcraft2-tools-unofficial,代码行数:26,代码来源:main.ts

示例3: _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!)
   }
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例4: BrowserWindow

app.on('ready', () => {
    mainWindow = new BrowserWindow({ width: 500, height: 500 });
    mainWindow.loadURL('file://' + __dirname + '/index.html');

    if (_.contains(process.argv, "--debug_mode")) {
        mainWindow.maximize();
        mainWindow.webContents.openDevTools();
    }
});
开发者ID:ip821,项目名称:NodeJsTest,代码行数:9,代码来源:boot.ts

示例5: BrowserWindow

app.on('ready', () => {
    let cursorPos = screen.getCursorScreenPoint()
    let workAreaSize = screen.getDisplayNearestPoint(cursorPos).workAreaSize

    app.setName('Ansel')

    mainWindow = new BrowserWindow({
        width: 1356,
        height: 768,
        title: 'Ansel',
        titleBarStyle: 'hiddenInset',
        backgroundColor: '#37474f',  // @blue-grey-800
        webPreferences: {
            experimentalFeatures: true,
            blinkFeatures: 'CSSGridLayout'
        }
    })

    if (workAreaSize.width <= 1366 && workAreaSize.height <= 768)
        mainWindow.maximize()

    mainWindow.loadURL('file://' + __dirname + '/../../static/index.html')
    mainWindow.setTitle('Ansel')
    initBackgroundService(mainWindow)
    initForegroundClient(mainWindow)

    //let usb = new Usb()
    //
    //usb.scan((err, drives) => {
    //  mainWindow.webContents.send('scanned-devices', drives)
    //})
    //
    //usb.watch((err, action, drive) => {
    //  if (action === 'add')
    //    mainWindow.webContents.send('add-device', drive)
    //  else
    //    mainWindow.webContents.send('remove-device', drive)
    //})

    if (fs.existsSync(config.settings)) {
        initLibrary(mainWindow)
    } else {
        initDb()
        ipcMain.on('settings-created', () => initLibrary(mainWindow))
    }

    // Emitted when the window is closed.
    mainWindow.on('closed', () => {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        mainWindow = null
    })
})
开发者ID:m0g,项目名称:ansel,代码行数:54,代码来源:entry.ts

示例6: createWindow

function createWindow() {
    win = new BrowserWindow({ width: 800, height: 600, show: false });
    win.setMenu(null);
    win.setMenuBarVisibility(false);
    win.maximize();
    win.loadURL("http://localhost:8080");

    win.once('ready-to-show', () => {
        win && win.show()
    });

    win.on("closed", () => {
        win = null;
    });
}
开发者ID:remipassmoilesel,项目名称:Abcmap,代码行数:15,代码来源:electron-main.ts

示例7: BrowserWindow

app.on('ready', () => {
    mainWindow = new BrowserWindow({
        width: 800,
        height: 600,
        show: false,
        darkTheme: true,
        hasShadow: true,
        title: 'SpyNgin'
    });
    mainWindow.maximize();
    mainWindow.loadURL(`file://${__dirname}/resources/views/main.html`);

    mainWindow.on('ready-to-show', () => {
        mainWindow.show();
    });
});
开发者ID:TheColorRed,项目名称:game-engine,代码行数:16,代码来源:main.ts

示例8: ready

    private ready() {
        const optionsWin = {
            center: true,
            height: 800,
            maximizable: true,
            title: 'SpeedSeed',
            width: 1000,
        }

        win = new BrowserWindow(optionsWin)

        win.maximize()

        win.on('closed', () => {
            win = null

            app.quit()
        })

        win.loadURL(`file://${__dirname}/-build/index.html`)
    }
开发者ID:ifedu,项目名称:generator-speedseed-multi-tic-tac-toe,代码行数:21,代码来源:main.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

示例10: openMainBracketsWindow

export function openMainBracketsWindow(query: {} | string = {}): Electron.BrowserWindow {

    // compose path to brackets' index file
    const indexPath = "file:///" + convertWindowsPathToUnixPath(path.resolve(__dirname, "www", "index.html"));

    // build a query for brackets' window
    let queryString = "";
    if (_.isObject(query) && !_.isEmpty(query)) {
        const queryObj = query as _.Dictionary<string>;
        queryString = "?" + _.map(queryObj, function (value, key) {
            return key + "=" + encodeURIComponent(value);
        }).join("&");
    } else if (_.isString(query)) {
        const queryStr = query as string;
        const io1 = queryStr.indexOf("?");
        const io2 = queryStr.indexOf("#");
        if (io1 !== -1) {
            queryString = queryStr.substring(io1);
        } else if (io2 !== -1) {
            queryString = queryStr.substring(io2);
        } else {
            queryString = "";
        }
    }

    const indexUrl = indexPath + queryString;

    const winOptions = {
        title: appInfo.productName,
        x: shellConfig.getNumber("window.posX"),
        y: shellConfig.getNumber("window.posY"),
        width: shellConfig.getNumber("window.width"),
        height: shellConfig.getNumber("window.height"),
        webPreferences: {
            nodeIntegration: false,
            preload: path.resolve(__dirname, "preload.js")
        }
    };

    const bracketsPreferences = readBracketsPreferences();

    const blinkFeatures = _.get(bracketsPreferences, "shell.blinkFeatures");
    if (typeof blinkFeatures === "string" && blinkFeatures.length > 0) {
        _.set(winOptions, "webPreferences.blinkFeatures", blinkFeatures);
    }

    const disableBlinkFeatures = _.get(bracketsPreferences, "shell.disableBlinkFeatures");
    if (typeof disableBlinkFeatures === "string" && disableBlinkFeatures.length > 0) {
        _.set(winOptions, "webPreferences.disableBlinkFeatures", disableBlinkFeatures);
    }

    const smoothScrolling = _.get(bracketsPreferences, "shell.smoothScrolling", true);
    if (!smoothScrolling) {
        app.commandLine.appendSwitch("disable-smooth-scrolling");
    }

    // create the browser window
    const win = new BrowserWindow(winOptions);
    if (process.argv.indexOf("--devtools") !== -1) {
        win.webContents.openDevTools({ mode: "detach" });
    }
    wins.push(win);

    // load the index.html of the app
    log.info(`loading brackets window at ${indexUrl}`);
    win.loadURL(indexUrl);
    if (shellConfig.get("window.maximized")) {
        win.maximize();
    }

    // emitted when the window is closed
    win.on("closed", function () {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        const io = wins.indexOf(win);
        if (io !== -1) { wins.splice(io, 1); }
    });

    // this is used to remember the size from the last time
    // emitted before the window is closed
    win.on("close", function () {
        saveWindowPositionSync(win);
    });
    win.on("maximize", function () {
        saveWindowPosition(win);
    });
    win.on("unmaximize", function () {
        saveWindowPosition(win);
    });
    win.on("resize", function () {
        saveWindowPosition(win);
    });
    win.on("move", function () {
        saveWindowPosition(win);
    });

    return win;
}
开发者ID:zaggino,项目名称:brackets-electron,代码行数:99,代码来源:main.ts


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