public MainViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent <ScriptInfoAddedEvent>().Subscribe(OnScriptInfoAdded);
            _eventAggregator.GetEvent <ScriptInfoChangedEvent>().Subscribe((scriptInfo) => ScriptInfo = scriptInfo);
            _eventAggregator.GetEvent <SettingsChangedEvent>().Subscribe((settings) => LoadSettings(settings));

            // Disable global hotkeys while user is changing hotkey
            _eventAggregator.GetEvent <SettingsWindowOpenEvent>().Subscribe(
                () => _winService.GlobalKeyDown -= OnGlobalHotkeyDown);
            _eventAggregator.GetEvent <SettingsWindowClosedEvent>().Subscribe(
                () => _winService.GlobalKeyDown += OnGlobalHotkeyDown);

            _settingsAccess = new SettingsAccess();
            _scriptAccess   = new ScriptAccess();

            _dialogService = new DialogService();
            _scriptService = new ScriptService();

            _winService = new WinService();
            _winService.GlobalKeyDown += OnGlobalHotkeyDown;
            _winService.GlobalKeyUp   += OnGlobalHotkeyUp;

            _automationService = new AutomationService();
            _automationService.RemoveFileModificationDetectedDialogOnCreated();

            _settings = _settingsAccess.LoadSettings();

            FormViewModel = new ScriptInfoViewModel(eventAggregator, SaveScriptInfoAction);

            LoadCommands();
            LoadSettings(_settings, firstTime: true);
            ScriptNames = _scriptAccess.GetScriptNames();
        }
Beispiel #2
0
        public static void Initialize()
        {
            sessionAccess  = new SessionAccess();
            settingsAccess = new SettingsAccess();

            var sessionResult  = sessionAccess.LoadSession();
            var settingsResult = settingsAccess.LoadSettings();

            if (sessionResult.Status != Status.Success)
            {
                sessionResult.Print();
            }

            if (settingsResult.Status != Status.Success)
            {
                settingsResult.Print();
            }

            Session  = sessionResult.Data;
            Settings = settingsResult.Data;


            Author        = "Near Huscarl";
            License       = "BSD 3-Clauses";
            SourceCodeURL = "https://github.com/NearHuscarl/Breakout";

            ScoreFont = new FontShape(width: 6, height: 18);
            MenuFont  = new FontShape(width: 9, height: 20);

            SpriteData = new SpriteData();

            Theme = new Dictionary <string, Color>()
            {
                { "Red", "#c0392b".ToColor() },
                { "Orange", "#d35400".ToColor() },
                { "Yellow", "#f39c12".ToColor() },
                { "Green", "#27ae60".ToColor() },
                { "Blue", "#2980b9".ToColor() },
                { "Cyan", "#16a085".ToColor() },
                { "Magenta", "#8e44ad".ToColor() },
                { "Gray", "#7f8c8d".ToColor() },
                { "Black", "#2c3e50".ToColor() },

                { "LightRed", "#e74c3c".ToColor() },
                { "LightOrange", "#e67e22".ToColor() },
                { "LightYellow", "#f1c40f".ToColor() },
                { "LightGreen", "#2ecc71".ToColor() },
                { "LightBlue", "#3498db".ToColor() },
                { "LightCyan", "#1abc9c".ToColor() },
                { "LightMagenta", "#9b59b6".ToColor() },
                { "LightGray", "#95a5a6".ToColor() },
                { "Dark", "#34495e".ToColor() },

                { "Silver", "#bdc3c7".ToColor() },
                { "White", "#ecf0f1".ToColor() },
            };

            ExplosiveRadius = 40;
        }
Beispiel #3
0
        public Settings LoadSettings()
        {
            var result = settingsAccess.LoadSettings();

            if (result.Status == Status.Success)
            {
                return(result.Data);
            }

            return(Settings.Default);
        }
Beispiel #4
0
        public CreateNewScriptViewModel(IEventAggregator eventAggregator, Action closeAction)
        {
            _eventAggregator = eventAggregator;
            _scriptService   = new ScriptService();
            _scriptAccess    = new ScriptAccess();
            _settingsAccess  = new SettingsAccess();

            _settings = _settingsAccess.LoadSettings();

            FormViewModel      = new ScriptInfoViewModel(eventAggregator, AddScriptInfoAction);
            FormViewModel.Mode = ChangeMode.Add;

            Close        = closeAction;
            CloseCommand = new DelegateCommand(() => Close());
        }
        public OptionViewModel(IEventAggregator eventAggregator, Action closeAction)
        {
            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent <SettingsWindowOpenEvent>().Publish();
            _settingsAccess = new SettingsAccess();

            _settings = _settingsAccess.LoadSettings();

            CopyToClipboardHotkey   = _settings.CopyToClipboardHotkey;
            CompileHotkey           = _settings.CompileHotkey;
            CompileAndRunHotkey     = _settings.CompileAndRunHotkey;
            GenerateExtensionScript = _settings.GenerateExtensionScript;

            Close = closeAction;

            SaveSettingsCommand = new DelegateCommand(SaveSettings);
            CloseCommand        = new DelegateCommand(() => Close());
        }