Пример #1
0
        public static async void OpenMainWindow()
        {
            ShortcutsChanged += UpdateShortcuts;
            Commands          = await ShortcutGenerator.GetCurrentCommandListAsync();

            var options = new BrowserWindowOptions()
            {
                Show = false,
            };

            var mainWindow = await Electron.WindowManager.CreateWindowAsync(options);

            mainWindow.OnReadyToShow += () =>
            {
                mainWindow.Show();
                var openFiles = ApplicationState.Instance.FileHandlerInstance.GetOpenFilePaths();

                // If history is present, set the first file as selected. Otherwise open a new file and set it as selected.
                if (openFiles.Count > 0)
                {
                    MenuActions.SetCurrentFilePath(openFiles.First());
                }
                else
                {
                    ApplicationState.Instance.FileHandlerInstance.OpenFile("new.txt");
                    ApplicationState.Instance.FileHandlerInstance.GetFileBuffer("new.txt").FillBufferFromFile();
                    MenuActions.SetCurrentFilePath("new.txt");
                }
            };

            mainWindow.OnClosed += () => { Electron.App.Quit(); };

            SetMenu();
        }