Ejemplo n.º 1
0
        /// <summary>
        /// CTOR
        /// </summary>
        public MainWindowViewModel()
        {
            // Initialize commands
            this.InitializeCommands();

            // Read config file
            IConfigurationFile configFile = this.LoadApplicationConfigFile();

            // Register EventAggregator
            DependencyFactory.RegisterInstance <IEventAggregator>(GeneralConstants.EventAggregator, new EventAggregator());
            // Register services
            DependencyFactory.RegisterInstance <ILocalizerService>(ServiceNames.LocalizerService, new LocalizerService("de-DE"));
            //TODO: Add debug mode. When enabled register OHW Debug Service, otherwise OHW Service as normal
            DependencyFactory.RegisterInstance <IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementDebugService, new OpenHardwareMonitorManagementServiceDebug());
            DependencyFactory.RegisterInstance <IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementService, new OpenHardwareMonitorManagementService());
            DependencyFactory.RegisterInstance <IHardwareInformationService>(ServiceNames.WmiHardwareInformationService, new WmiHardwareInfoService());
            DependencyFactory.RegisterInstance <IExceptionReporterService>(ServiceNames.ExceptionReporterService, new ExceptionReporterService());
            DependencyFactory.RegisterInstance <ILoggingService>(ServiceNames.LoggingService, new LoggingServiceNLog());
            DependencyFactory.RegisterInstance <IFanControllerService>(ServiceNames.MainboardFanControllerService, new MainboardFanControllerService());

            // Start Fan-Controller-Service
            DependencyFactory.Resolve <IFanControllerService>(ServiceNames.MainboardFanControllerService).Start();

            // Application title
            string appVersion = DependencyFactory.Resolve <ILocalizerService>(ServiceNames.LocalizerService).GetLocalizedString("MainWindowTitle");

            this.ApplicationTitle = String.Format(appVersion, Assembly.GetEntryAssembly().GetName().Version.ToString());

            // Create appearance ViewModel
            DependencyFactory.RegisterInstance <AppearanceViewModel>(GeneralConstants.ApperanceViewModel, new AppearanceViewModel());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check general settings
        /// </summary>
        /// <param name="configFile"></param>
        private void CheckGeneralSettings(IConfigurationFile configFile)
        {
            // Check if section exists
            if (configFile.Sections["GeneralSettings"] == null)
            {
                configFile.Sections.Add("GeneralSettings");
            }

            // Check settings
            if (configFile.Sections["GeneralSettings"].Settings["Theme"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("Theme", "light", "light", typeof(System.String));
            }
            if (configFile.Sections["GeneralSettings"].Settings["FontSize"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("FontSize", "large", "large", typeof(System.String));
            }
            if (configFile.Sections["GeneralSettings"].Settings["Language"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("Language", "de-DE", "de-DE", typeof(System.String));
            }
            if (configFile.Sections["GeneralSettings"].Settings["AccentColor"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("AccentColor", "#FF1BA1E2", "#FF1BA1E2", typeof(System.String));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Check tile settings
        /// </summary>
        /// <param name="configFile"></param>
        private void CheckTileSettings(IConfigurationFile configFile)
        {
            // Check if section exists
            if (configFile.Sections["TileSettings"] == null)
            {
                configFile.Sections.Add("TileSettings");
            }

            // Check settings
            if (configFile.Sections["TileSettings"].Settings["CpuTilesColor"] == null)
            {
                configFile.Sections["TileSettings"].Settings.Add("CpuTilesColor", "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            }
            if (configFile.Sections["TileSettings"].Settings["GpuTilesColor"] == null)
            {
                configFile.Sections["TileSettings"].Settings.Add("GpuTilesColor", "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            }
            if (configFile.Sections["TileSettings"].Settings["MainboardTilesColor"] == null)
            {
                configFile.Sections["TileSettings"].Settings.Add("MainboardTilesColor", "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            }

            //foreach (var s in Enum.GetValues(typeof(OpenHardwareMonitor.Hardware.SensorType)))
            //{
            //    if (configFile.Sections["TileSettings"].Settings[s.ToString()] == null)
            //    {
            //        configFile.Sections["TileSettings"].Settings.Add(s.ToString(), "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            //    }
            //}
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public void AddConfigurationFile(IConfigurationFile configFile)
        {
            //if (_configurationFiles.ContainsKey(configFile.Name))
            //    throw new ConfigurationException($"There is already a configuration file with the same name '{configFile.Name}'");

            _configurationFiles[configFile.Name] = configFile;
        }
        /// <summary>
        /// Standard CTOR
        /// </summary>
        public ShellSettingsFlyoutViewModel()
        {
            this.localizerService = UnityContainer.Resolve<ILocalizerService>(ServiceNames.LocalizerService);

            // Get the config file
            this.applicationConfig = this.UnityContainer.Resolve<IConfigurationFile>(FileAndFolderConstants.ApplicationConfigFile);

            // create metro theme color menu items for the demo
            this.ApplicationThemes = ThemeManager.AppThemes
                                           .Select(a => new ApplicationTheme() { Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush })
                                           .ToList();

            // create accent colors list
            this.AccentColors = ThemeManager.Accents
                                            .Select(a => new AccentColor() { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush })
                                            .ToList();

            this.Swatches = new SwatchesProvider().Swatches;

            // Language
            var languageTag = applicationConfig.Sections["GeneralSettings"].Settings["Language"].Value;
            var localizerService = this.UnityContainer.Resolve<ILocalizerService>(ServiceNames.LocalizerService);
            if (localizerService != null)
            {
                this.SelectedLanguage = localizerService.SupportedLanguages.Where(l => l.IetfLanguageTag.Equals(languageTag)).FirstOrDefault();
            }

            // Theme
            string themeName = applicationConfig.Sections["GeneralSettings"].Settings["Theme"].Value;
            this.SelectedTheme = this.ApplicationThemes.Where(t => t.Name.Equals(themeName)).FirstOrDefault();

            // Accent color
            string accentColor = applicationConfig.Sections["GeneralSettings"].Settings["AccentColor"].Value;
            this.SelectedAccentColor = this.AccentColors.Where(t => t.Name.Equals(accentColor)).FirstOrDefault();
        }
        protected override void SolutionLoaded(IConfigurationFile config)
        {
            base.SolutionLoaded(config);
            InitialDirectory = _solutionHelper.GetCurrentSolutionPath();



            {
                if (_currentSolutionConfigFile.TryGetValue(ConfigKeys.SqlLinq_Dbml, out DatabaseConfigurationSerializable val))
                {
                    DatabaseConfigurations = (DatabaseConfiguration)val;
                }
                else
                {
                    DatabaseConfigurations = new DatabaseConfiguration();
                }
            }

            {
                if (_currentSolutionConfigFile.TryGetValue(ConfigKeys.SqlLinq_Projects_Models, out ModelProjectConfigurationSerializable val))
                {
                    ModelConfigurations = (ModelProjectConfiguration)val;
                }
                else
                {
                    ModelConfigurations = new ModelProjectConfiguration();
                }
            }
            {
                if (_currentSolutionConfigFile.TryGetValue(ConfigKeys.SqlLinq_Projects_Data, out DataProjectConfigurationSerializable val))
                {
                    DataConfigurations = (DataProjectConfiguration)val;
                }
                else
                {
                    DataConfigurations = new DataProjectConfiguration();
                }
            }
            {
                if (_currentSolutionConfigFile.TryGetValue(ConfigKeys.SqlLinq_Projects_LinQ, out LinqProjectConfigurationSerializable val))
                {
                    LinqConfigurations = (LinqProjectConfiguration)val;
                }
                else
                {
                    LinqConfigurations = new LinqProjectConfiguration();
                }
            }
            {
                if (_currentSolutionConfigFile.TryGetValue(ConfigKeys.SqlLinq_Projects_Rest, out RestProjectConfigurationSerializable val))
                {
                    RestConfigurations = (RestProjectConfiguration)val;
                }
                else
                {
                    RestConfigurations = new RestProjectConfiguration();
                }
            }
        }
Ejemplo n.º 7
0
        bool FileExists(IConfigurationFile file)
        {
            var tmp    = (file.Path?.StartsWith('/') ?? false) ? '.' + file.Path : file.Path;
            var path   = Path.Combine(instance.Path, "Configuration", tmp);
            var result = File.Exists(path);

            return(result);
        }
Ejemplo n.º 8
0
        public ConfigurationFileTests()
        {
            //setup our dependency injection so we can find the implementation of IConfigurationFile
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IConfigurationFile, ConfigurationFileService>()
                                  .BuildServiceProvider();

            service = serviceProvider.GetService <IConfigurationFile>();
        }
 public AdministrationController(IDatabase db, IScrapManager manager,
                                 ILogger <AdministrationController> logger, IScreenScraperAPI api,
                                 IConfigurationFile config)
 {
     _db      = (Database)db;
     _manager = (ScrapManager)manager;
     _api     = (ScreenScraperAPI)api;
     _logger  = logger;
     _config  = config;
 }
Ejemplo n.º 10
0
 /// <inheritdoc />
 public void Initialize(string fileLocation, IConfigurationFile defaultConfigurationFile)
 {
     if (defaultConfigurationFile == null)
     {
         defaultConfigurationFile =
             new ConfigurationFile(_defaultConfigFile,
                                   Path.Combine(fileLocation,
                                                $"{_defaultConfigFile}.config"));
     }
     _configurationFiles.Clear();
     AddConfigurationFile(defaultConfigurationFile);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initialize the configuration manager
 /// </summary>
 /// <param name="builder">the application builder.</param>
 /// <param name="fileLocation"></param>
 /// <param name="defaultFile">The default configurations file.</param>
 public static IApplicationBuilder UseConfigurationFile(
     this IApplicationBuilder builder,
     string fileLocation,
     IConfigurationFile defaultFile = null)
 {
     builder.BuildActionsCoordinator.AddAction(DefaultBuildActions.ConfigFileBuildAction((container) =>
     {
         var config = container.Resolve <IConfigurationManager>();
         config.Initialize(fileLocation, defaultFile);
     }));
     return(builder);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// CTOR
        /// </summary>
        public TileSettingsViewModel()
        {
            this.configFile = DependencyFactory.Resolve <IConfigurationFile>(ConfigFileNames.ApplicationConfig);
            this.openHardwareMonitorManagementDebugService = DependencyFactory.Resolve <IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementDebugService);

            if (this.configFile != null)
            {
                this.SelectedColorForCpuTiles       = ColorHelper.GetColorFromString(configFile.Sections["TileSettings"].Settings["CpuTilesColor"].Value);
                this.SelectedColorForGpuTiles       = ColorHelper.GetColorFromString(configFile.Sections["TileSettings"].Settings["GpuTilesColor"].Value);
                this.SelectedColorForMainboardTiles = ColorHelper.GetColorFromString(configFile.Sections["TileSettings"].Settings["MainboardTilesColor"].Value);
            }
        }
        private IEnumerable <IApduCommand> GetWriteCommands(byte fileNumber, IConfigurationFile configurationFile)
        {
            ushort offset   = 0;
            var    fileData = configurationFile.GetFileContent();

            foreach (var batch in fileData.Batch(batchSize:DataBatchMaxLength))
            {
                var data = batch.ToArray();
                yield return(_cardWriteDataCommand.GetApdu(fileNumber, offset, data));

                offset += (ushort)data.Length;
            }
        }
Ejemplo n.º 14
0
        protected override void SolutionLoaded(IConfigurationFile config)
        {
            _loading = true;
            _config  = config;

            if (config.TryGetValue(ConfigKeys.LocalizationWatcher_KeysFile, out string keysFile))
            {
                KeysFile = keysFile;
            }
            if (config.TryGetValue(ConfigKeys.LocalizationWatcher_ResxFiles, out List <LocalizationResourceFileConfig> resourceFiles))
            {
                LocalizationResourceFiles.ClearAndFill(resourceFiles.Select(CreateLocalizationResourceFile));
            }
            Watch();
            _loading = false;
        }
        public ApplicationSettingsViewModel(IUnityContainer unityContainer, IRegionManager regionManager, IEventAggregator eventAggrgator) :
            base(unityContainer, regionManager, eventAggrgator)
        {
            this.localizerService = Container.Resolve <ILocalizerService>(ServiceNames.LocalizerService);

            // Get the config file
            this.applicationConfig = this.Container.Resolve <IConfigurationFile>(FileAndFolderConstants.ApplicationConfigFile);

            // create metro theme color menu items for the demo
            this.ApplicationThemes = ThemeManager.AppThemes
                                     .Select(a => new ApplicationTheme()
            {
                Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush
            })
                                     .ToList();

            // create accent colors list
            this.AccentColors = ThemeManager.Accents
                                .Select(a => new AccentColor()
            {
                Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush
            })
                                .ToList();

            this.Swatches = new SwatchesProvider().Swatches;

            // Language
            var languageTag      = applicationConfig.Sections["GeneralSettings"].Settings["Language"].Value;
            var localizerService = this.Container.Resolve <ILocalizerService>(ServiceNames.LocalizerService);

            if (localizerService != null)
            {
                this.SelectedLanguage = localizerService.SupportedLanguages.Where(l => l.IetfLanguageTag.Equals(languageTag)).FirstOrDefault();
            }

            // Theme
            string themeName = applicationConfig.Sections["GeneralSettings"].Settings["Theme"].Value;

            this.SelectedTheme = this.ApplicationThemes.Where(t => t.Name.Equals(themeName)).FirstOrDefault();

            // Accent color
            string accentColor = applicationConfig.Sections["GeneralSettings"].Settings["AccentColor"].Value;

            this.SelectedAccentColor = this.AccentColors.Where(t => t.Name.Equals(accentColor)).FirstOrDefault();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// CTOR
        /// </summary>
        public TilePageViewModel()
        {
            this.configurationFile = new TileViewConfigurationFile();

            // Intialize commands
            this.InitializeCommands();

            // Create the main grid
            this.CreateMainGrid(this.numberOfColumns, 150, this.numberOfRows, 110);

            this.openHardwareManagementService = DependencyFactory.Resolve <IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementService);
            this.applicationConfigFile         = DependencyFactory.Resolve <IConfigurationFile>(ConfigFileNames.ApplicationConfig);

            for (int r = 0; r < this.numberOfRows; r++)
            {
                for (int c = 0; c < this.numberOfColumns; c++)
                {
                    var tile = this.configurationFile.Tiles.Where(t => t.GridRow == r && t.GridColumn == c).FirstOrDefault();

                    if (tile != null)
                    {
                        var sensor = this.openHardwareManagementService.GetSensor(tile.SensorCategory, tile.SensorName, tile.SensorType);

                        if (sensor != null)
                        {
                            this.AddSensorTile(sensor, tile.GridRow, tile.GridColumn, tile.SensorCategory);
                        }
                    }
                    else
                    {
                        TileViewDropTarget dropTarget = new TileViewDropTarget();
                        dropTarget.SetValue(Grid.RowProperty, r);
                        dropTarget.SetValue(Grid.ColumnProperty, c);
                        this.MainGrid.Children.Add(dropTarget);
                    }
                }
            }

            // Register for events
            DependencyFactory.Resolve <IEventAggregator>(GeneralConstants.EventAggregator).GetEvent <OpenHardwareMonitorManagementServiceTimerTickEvent>().Subscribe(this.OpenHardwareMonitorManagementServiceTimerTickEventHandler, ThreadOption.UIThread);
            DependencyFactory.Resolve <IEventAggregator>(GeneralConstants.EventAggregator).GetEvent <SensorTilePositionChangedEvent>().Subscribe(this.SensorTilePositionChangedEventHandler, ThreadOption.UIThread);
            DependencyFactory.Resolve <IEventAggregator>(GeneralConstants.EventAggregator).GetEvent <SensorTileAddedEvent>().Subscribe(this.SensorTileAddedEventHandler, ThreadOption.UIThread);
            DependencyFactory.Resolve <IEventAggregator>(GeneralConstants.EventAggregator).GetEvent <SensorTileDeletedEvent>().Subscribe(this.SensorTileDeletedEventHandler, ThreadOption.UIThread);
        }
        public ConfigurationSettingsService(IConfigurationFile configFileService)
        {
            // inject a service that implements the configuration file interface

            this.configFileService = configFileService;

            if (this.configFileService != null)
            {
                // go to the configuration file (app.config) to determine our running values ...

                maxInt = this.configFileService.GetInteger("MAX_INT");

                romanNumeralI = this.configFileService.GetString("I");

                romanNumeralIV = this.configFileService.GetString("IV");

                romanNumeralV = this.configFileService.GetString("V");

                romanNumeralIX = this.configFileService.GetString("IX");

                romanNumeralX = this.configFileService.GetString("X");

                romanNumeralXL = this.configFileService.GetString("XL");

                romanNumeralL = this.configFileService.GetString("L");

                romanNumeralXC = this.configFileService.GetString("XC");

                romanNumeralC = this.configFileService.GetString("C");

                romanNumeralCD = this.configFileService.GetString("CD");

                romanNumeralD = this.configFileService.GetString("D");

                romanNumeralCM = this.configFileService.GetString("CM");

                romanNumeralM = this.configFileService.GetString("M");
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Check general settings
        /// </summary>
        /// <param name="configFile"></param>
        private void CheckGeneralSettings(IConfigurationFile configFile)
        {
            // Check if section exists
            if (configFile.Sections["GeneralSettings"] == null)
            {
                configFile.Sections.Add("GeneralSettings");
            }

            // Check settings
            if (configFile.Sections["GeneralSettings"].Settings["Theme"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("Theme", "BaseLight", "BaseLight", typeof(System.String));
            }
            if (configFile.Sections["GeneralSettings"].Settings["Language"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("Language", "de", "de", typeof(System.String));
            }
            if (configFile.Sections["GeneralSettings"].Settings["AccentColor"] == null)
            {
                configFile.Sections["GeneralSettings"].Settings.Add("AccentColor", "Cyan", "Cyan", typeof(System.String));
            }
        }
 public HostConfigurationManager(IRestCache cache,IConfigurationFile configFile)
 {
     _cache = cache;
     _file = configFile;
 }
Ejemplo n.º 20
0
 protected override void SolutionLoaded(IConfigurationFile config)
 {
     base.SolutionLoaded(config);
     ReadConfig();
 }
Ejemplo n.º 21
0
 public ApplicantController(ILogger <ApplicantController> logger, IApplicantService applicantService, IConfigurationFile configurationFile)
 {
     this.logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     this.applicantService  = applicantService ?? throw new ArgumentNullException(nameof(applicantService));
     this.configurationFile = configurationFile ?? throw new ArgumentNullException(nameof(configurationFile));
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Check tile settings
        /// </summary>
        /// <param name="configFile"></param>
        private void CheckTileSettings(IConfigurationFile configFile)
        {
            // Check if section exists
            if (configFile.Sections["TileSettings"] == null)
                configFile.Sections.Add("TileSettings");

            // Check settings
            if (configFile.Sections["TileSettings"].Settings["CpuTilesColor"] == null)
                configFile.Sections["TileSettings"].Settings.Add("CpuTilesColor", "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            if (configFile.Sections["TileSettings"].Settings["GpuTilesColor"] == null)
                configFile.Sections["TileSettings"].Settings.Add("GpuTilesColor", "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            if (configFile.Sections["TileSettings"].Settings["MainboardTilesColor"] == null)
                configFile.Sections["TileSettings"].Settings.Add("MainboardTilesColor", "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));

            //foreach (var s in Enum.GetValues(typeof(OpenHardwareMonitor.Hardware.SensorType)))
            //{
            //    if (configFile.Sections["TileSettings"].Settings[s.ToString()] == null)
            //    {
            //        configFile.Sections["TileSettings"].Settings.Add(s.ToString(), "#FFFFFFFF", "#FFFFFFFF", typeof(System.String));
            //    }
            //}
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Check general settings
        /// </summary>
        /// <param name="configFile"></param>
        private void CheckGeneralSettings(IConfigurationFile configFile)
        {
            // Check if section exists
            if (configFile.Sections["GeneralSettings"] == null)
                configFile.Sections.Add("GeneralSettings");

            // Check settings
            if (configFile.Sections["GeneralSettings"].Settings["Theme"] == null)
                configFile.Sections["GeneralSettings"].Settings.Add("Theme", "light", "light", typeof(System.String));
            if (configFile.Sections["GeneralSettings"].Settings["FontSize"] == null)
                configFile.Sections["GeneralSettings"].Settings.Add("FontSize", "large", "large", typeof(System.String));
            if (configFile.Sections["GeneralSettings"].Settings["Language"] == null)
                configFile.Sections["GeneralSettings"].Settings.Add("Language", "de-DE", "de-DE", typeof(System.String));
            if (configFile.Sections["GeneralSettings"].Settings["AccentColor"] == null)
                configFile.Sections["GeneralSettings"].Settings.Add("AccentColor", "#FF1BA1E2", "#FF1BA1E2", typeof(System.String));
        }
Ejemplo n.º 24
0
 protected virtual void SolutionLoaded(IConfigurationFile config)
 {
     _currentSolutionConfigFile = config;
 }
 public ConfigurationDataItem(IConfigurationFile configuration, DataGroup @group)
     : base(configuration.UniqueId, configuration.ConfigurationDate, configuration.AircraftProgrammImage,  @group, 28, 25)
 {
     _configuration = configuration;
 }
 public void SaveConfigurationForCustomer(IConfigurationFile configuration, string customerId)
 {
     var configurations = GetConfigurationFilesForCustomer(customerId);
     configurations.Add(configuration);
 }
Ejemplo n.º 27
0
        /// <summary>
        /// CTOR
        /// </summary>
        public TileSettingsViewModel()
        {
            this.configFile = DependencyFactory.Resolve<IConfigurationFile>(ConfigFileNames.ApplicationConfig);
            this.openHardwareMonitorManagementDebugService = DependencyFactory.Resolve<IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementDebugService);

            if (this.configFile != null)
            {
                this.SelectedColorForCpuTiles = ColorHelper.GetColorFromString(configFile.Sections["TileSettings"].Settings["CpuTilesColor"].Value);
                this.SelectedColorForGpuTiles = ColorHelper.GetColorFromString(configFile.Sections["TileSettings"].Settings["GpuTilesColor"].Value);
                this.SelectedColorForMainboardTiles = ColorHelper.GetColorFromString(configFile.Sections["TileSettings"].Settings["MainboardTilesColor"].Value);
            }
        }
Ejemplo n.º 28
0
 protected override void SolutionLoaded(IConfigurationFile config)
 {
     base.SolutionLoaded(config);
     GetDbTitle();
 }
Ejemplo n.º 29
0
        // Read config file
        private void ReadConfigFile()
        {
            this.applicationConfigFile = DependencyFactory.Resolve <IConfigurationFile>(ConfigFileNames.ApplicationConfig);

            if (this.applicationConfigFile != null)
            {
                // Theme
                if (this.applicationConfigFile.Sections["GeneralSettings"].Settings["Theme"] == null)
                {
                    // Add entry
                    this.applicationConfigFile.Sections["GeneralSettings"].Settings.Add("Theme", GeneralConstants.ThemeLight, GeneralConstants.ThemeLight, typeof(System.String));
                    AppearanceManager.Current.ThemeSource = AppearanceManager.LightThemeSource;
                    this.applicationConfigFile.Save();
                }
                else
                {
                    var theme = this.applicationConfigFile.Sections["GeneralSettings"].Settings["Theme"].Value;
                    if (theme.Equals(GeneralConstants.ThemeLight))
                    {
                        AppearanceManager.Current.ThemeSource = AppearanceManager.LightThemeSource;
                    }
                    else if (theme.Equals(GeneralConstants.ThemeDark))
                    {
                        AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
                    }
                    // Fallback value
                    else
                    {
                        AppearanceManager.Current.ThemeSource = AppearanceManager.LightThemeSource;
                    }
                }

                // Font size
                if (this.applicationConfigFile.Sections["GeneralSettings"].Settings["FontSize"] == null)
                {
                    this.applicationConfigFile.Sections["GeneralSettings"].Settings.Add("FontSize", GeneralConstants.FontLarge, GeneralConstants.FontLarge, typeof(System.String));
                    this.SelectedFontSize = GeneralConstants.FontLarge;
                    AppearanceManager.Current.FontSize = FontSize.Large;
                }
                else
                {
                    var fontSize = this.applicationConfigFile.Sections["GeneralSettings"].Settings["FontSize"].Value;
                    if (fontSize.Equals(GeneralConstants.FontLarge))
                    {
                        this.SelectedFontSize = GeneralConstants.FontLarge;
                        AppearanceManager.Current.FontSize = FontSize.Large;
                    }
                    else if (fontSize.Equals(GeneralConstants.FontSmall))
                    {
                        this.SelectedFontSize = GeneralConstants.FontSmall;
                        AppearanceManager.Current.FontSize = FontSize.Small;
                    }
                    else
                    {
                        this.SelectedFontSize = GeneralConstants.FontLarge;
                        AppearanceManager.Current.FontSize = FontSize.Large;
                    }
                }

                // Color
                if (this.applicationConfigFile.Sections["GeneralSettings"].Settings["AccentColor"] == null)
                {
                    this.applicationConfigFile.Sections["GeneralSettings"].Settings.Add("AccentColor", AppearanceManager.Current.AccentColor.ToString(), AppearanceManager.Current.AccentColor.ToString(), typeof(System.String));
                    this.applicationConfigFile.Save();
                }
                else
                {
                    var color = this.applicationConfigFile.Sections["GeneralSettings"].Settings["AccentColor"].Value;
                    if (!String.IsNullOrEmpty(color) && color.Length == 9)
                    {
                        AppearanceManager.Current.AccentColor = ColorHelper.GetColorFromString(color);
                    }
                }

                // Check if all settings are in config file
                if (this.applicationConfigFile.Sections["GeneralSettings"].Settings["Language"] == null)
                {
                    this.applicationConfigFile.Sections["GeneralSettings"].Settings.Add("Language", "de-DE", "de-DE", typeof(System.String));
                    this.SelectedLanguage = this.AvailableLanguages.Where(l => l.IetfLanguageTag.Equals("de-DE")).FirstOrDefault();
                }
                else
                {
                    var language = this.applicationConfigFile.Sections["GeneralSettings"].Settings["Language"].Value;
                    this.SelectedLanguage = this.AvailableLanguages.Where(l => l.IetfLanguageTag.Equals(language)).FirstOrDefault();
                }
            }
        }
Ejemplo n.º 30
0
 public ApplicantService(IApplicantRepository applicantRepository, IConfigurationFile configurationFile)
 {
     this.applicantRepository = applicantRepository ?? throw new ArgumentNullException(nameof(applicantRepository));
     this.configurationFile   = configurationFile ?? throw new ArgumentNullException(nameof(configurationFile));
 }
 private async void GetDataFromConfigurationFile(IConfigurationFile configurationFile)
 {
     if (await TryToLoadConfiguration(configurationFile)) return;
 }
 private async Task<bool> TryToLoadConfiguration(IConfigurationFile configurationFile)
 {
     await _model.LoadConfigurationFromFileSystemAndSetItAsCurrentConfiguration(configurationFile.Filename);
     InitializeDataGrid();
     return true;
 }
 /// <inheritdoc />
 public Task DeleteEmptyDirectory(IConfigurationFile directory, CancellationToken cancellationToken) => ApiClient.Delete(Routes.Configuration, directory, instance.Id !.Value, cancellationToken);
Ejemplo n.º 34
0
        /// <summary>
        /// CTOR
        /// </summary>
        public TilePageViewModel()
        {
            this.configurationFile = new TileViewConfigurationFile();

            // Intialize commands
            this.InitializeCommands();

            // Create the main grid
            this.CreateMainGrid(this.numberOfColumns, 150, this.numberOfRows, 110);

            this.openHardwareManagementService = DependencyFactory.Resolve<IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementService);
            this.applicationConfigFile = DependencyFactory.Resolve<IConfigurationFile>(ConfigFileNames.ApplicationConfig);

            for (int r = 0; r < this.numberOfRows; r++)
            {
                for (int c = 0; c < this.numberOfColumns; c++)
                {
                    var tile = this.configurationFile.Tiles.Where(t => t.GridRow == r && t.GridColumn == c).FirstOrDefault();

                    if (tile != null)
                    {
                        var sensor = this.openHardwareManagementService.GetSensor(tile.SensorCategory, tile.SensorName, tile.SensorType);

                        if (sensor != null)
                            this.AddSensorTile(sensor, tile.GridRow, tile.GridColumn, tile.SensorCategory);
                    }
                    else
                    {
                        TileViewDropTarget dropTarget = new TileViewDropTarget();
                        dropTarget.SetValue(Grid.RowProperty, r);
                        dropTarget.SetValue(Grid.ColumnProperty, c);
                        this.MainGrid.Children.Add(dropTarget);
                    }
                }
            }

            // Register for events
            DependencyFactory.Resolve<IEventAggregator>(GeneralConstants.EventAggregator).GetEvent<OpenHardwareMonitorManagementServiceTimerTickEvent>().Subscribe(this.OpenHardwareMonitorManagementServiceTimerTickEventHandler, ThreadOption.UIThread);
            DependencyFactory.Resolve<IEventAggregator>(GeneralConstants.EventAggregator).GetEvent<SensorTilePositionChangedEvent>().Subscribe(this.SensorTilePositionChangedEventHandler, ThreadOption.UIThread);
            DependencyFactory.Resolve<IEventAggregator>(GeneralConstants.EventAggregator).GetEvent<SensorTileAddedEvent>().Subscribe(this.SensorTileAddedEventHandler, ThreadOption.UIThread);
            DependencyFactory.Resolve<IEventAggregator>(GeneralConstants.EventAggregator).GetEvent<SensorTileDeletedEvent>().Subscribe(this.SensorTileDeletedEventHandler, ThreadOption.UIThread);
        }