const { app, BrowserWindow,globalShortcut} = require('electron');
const remote = require("@electron/remote/main")
remote.initialize()
var cp = require('child_process');
const path = require('path');
if (require('electron-squirrel-startup')) {
  app.quit();
}

function createWindow () {
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    autoHideMenuBar: true,
    webPreferences:{
      nodeIntegration:true,
      contextIsolation:false
    },
    maximizable: false,
    resizable: false,
    icon:path.join(__dirname, "imr.ico")
  });

  mainWindow.loadFile(path.join(__dirname, 'index.html'));

  globalShortcut.register('CommandOrControl+Shift+i', function () {
    mainWindow.webContents.openDevTools({mode:'undocked'})
  })
  remote.enable(mainWindow.webContents)
}

app.whenReady().then(()=>{
  createWindow()
})

app.on('window-all-closed', () => {
  cp.exec('taskkill /f /t /im dotnet.exe',()=>{
    if (process.platform !== 'darwin') {
      app.quit()
    }
  })
});