Example #1
0
        public DataModelService(IPluginManagementService pluginManagementService)
        {
            // Add data models of already loaded plugins
            foreach (Module module in pluginManagementService.GetFeaturesOfType <Module>().Where(p => p.IsEnabled))
            {
                AddModuleDataModel(module);
            }
            foreach (BaseDataModelExpansion dataModelExpansion in pluginManagementService.GetFeaturesOfType <BaseDataModelExpansion>().Where(p => p.IsEnabled))
            {
                AddDataModelExpansionDataModel(dataModelExpansion);
            }

            // Add data models of new plugins when they get enabled
            pluginManagementService.PluginFeatureEnabled += OnPluginFeatureEnabled;
        }
        public GeneralSettingsTabViewModel(
            IKernel kernel,
            IWindowManager windowManager,
            IDialogService dialogService,
            IDebugService debugService,
            ISettingsService settingsService,
            IUpdateService updateService,
            IPluginManagementService pluginManagementService,
            IMessageService messageService)
        {
            DisplayName = "GENERAL";

            _kernel          = kernel;
            _windowManager   = windowManager;
            _dialogService   = dialogService;
            _debugService    = debugService;
            _settingsService = settingsService;
            _updateService   = updateService;
            _messageService  = messageService;

            LogLevels    = new BindableCollection <ValueDescription>(EnumUtilities.GetAllValuesAndDescriptions(typeof(LogEventLevel)));
            ColorSchemes = new BindableCollection <ValueDescription>(EnumUtilities.GetAllValuesAndDescriptions(typeof(ApplicationColorScheme)));
            RenderScales = new List <Tuple <string, double> > {
                new("10%", 0.1)
            };
            for (int i = 25; i <= 100; i += 25)
            {
                RenderScales.Add(new Tuple <string, double>(i + "%", i / 100.0));
            }

            TargetFrameRates = new List <Tuple <string, int> >();
            for (int i = 10; i <= 30; i += 5)
            {
                TargetFrameRates.Add(new Tuple <string, int>(i + " FPS", i));
            }

            List <LayerBrushProvider> layerBrushProviders = pluginManagementService.GetFeaturesOfType <LayerBrushProvider>();

            LayerBrushDescriptors        = new BindableCollection <LayerBrushDescriptor>(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors));
            _defaultLayerBrushDescriptor = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
            {
                LayerBrushProviderId = "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba",
                BrushType            = "SolidBrush"
            });

            WebServerPortSetting          = _settingsService.GetSetting("WebServer.Port", 9696);
            WebServerPortSetting.AutoSave = true;
        }
        public void Update()
        {
            if (_modules == null)
            {
                _modules = _pluginManagementService.GetFeaturesOfType <Module>().Select(m => new ModuleOrderModuleViewModel(m)).ToList();
            }
            NormalModules.Clear();
            NormalModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Normal).OrderBy(m => m.Module.Priority));

            ApplicationModules.Clear();
            ApplicationModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Application).OrderBy(m => m.Module.Priority));

            OverlayModules.Clear();
            OverlayModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Overlay).OrderBy(m => m.Module.Priority));

            foreach (ModuleOrderModuleViewModel moduleOrderModuleViewModel in _modules)
            {
                moduleOrderModuleViewModel.Update();
            }
        }