Exemplo n.º 1
0
        private void CreateSettingsWindow()
        {
            var settingsWindow = new SettingsWindow(_appSettings)
            {
                IsVisible = true
            };

            _imGuiManager.AddElement(settingsWindow);

            settingsWindow.SaveChangesRequested += (sender, args) =>
            {
                _appSettings.ScriptFolderPath     = settingsWindow.ScriptFolderPath;
                _appSettings.TextEditorExecutable = settingsWindow.TextEditorExecutable;
                SettingsIo.Save(_appSettings);

                _imGuiManager.RemoveElement(settingsWindow);
            };

            settingsWindow.PropertyChanged += (sender, args) =>
            {
                switch (args.PropertyName)
                {
                case nameof(SettingsWindow.CloseRequested):
                    _imGuiManager.RemoveElement(settingsWindow);
                    break;
                }
            };
        }
Exemplo n.º 2
0
        public App()
        {
            // ReSharper disable once ObjectCreationAsStatement
            new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = Width,
                PreferredBackBufferHeight = Height,
                PreferMultiSampling       = true
            };

            IsMouseVisible = true;

            _appSettings = SettingsIo.Load() ?? new AppSettings
            {
                ScriptFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                                                "SharpPlotter"),
                TextEditorExecutable = "code",
            };

            _onScreenLogger = new OnScreenLogger();
            _onScreenLogger.LogMessage(OnLoadText());

            _camera       = new Camera(Width, Height, _onScreenLogger);
            _graphedItems = new GraphedItems();

            // Do a first render to get pixel data from the image for initial byte data allocation
            using var image  = _camera.Render(null, null);
            _rawCanvasPixels = new byte[image.Height * image.PeekPixels().RowBytes];

            _scriptManager = new ScriptManager(_appSettings, _onScreenLogger);
        }
Exemplo n.º 3
0
        private void OpenScriptFile(string fileName)
        {
            try
            {
                _scriptManager.OpenExistingScript(fileName?.Trim());
            }
            catch (Exception exception)
            {
                _onScreenLogger.LogMessage($"Exception opening file: {exception.Message}");
                return;
            }

            SettingsIo.Save(_appSettings);
            _onScreenLogger.Clear();
        }
Exemplo n.º 4
0
        private void CreateNewFileDialog()
        {
            var dialog = new NewFileDialog {
                IsVisible = true
            };

            _imGuiManager.AddElement(dialog);

            dialog.CreateFileRequested += (sender, args) =>
            {
                try
                {
                    _scriptManager.CreateNewScript(dialog.FileName?.Trim(), dialog.SelectedLanguage);
                }
                catch (InvalidOperationException exception)
                {
                    dialog.ErrorText = exception.Message;
                    return;
                }
                catch (Exception exception)
                {
                    dialog.ErrorText = $"Exception: {exception}";
                    return;
                }

                _imGuiManager.RemoveElement(dialog);
                SettingsIo.Save(_appSettings);
                _onScreenLogger.Clear();
            };

            dialog.PropertyChanged += (sender, args) =>
            {
                switch (args.PropertyName)
                {
                case nameof(NewFileDialog.CloseRequested):
                    _imGuiManager.RemoveElement(dialog);
                    break;
                }
            };
        }