コード例 #1
0
        /// <summary>
        /// Sets the theme used to render the switchboard panels.
        /// </summary>
        public DigitalSystem GetSystem()
        {
            XmlSettingsItem item   = null;
            DigitalSystem   system = null;

            Logger.LogDebug(this, "[CLASS].GetSystem()");

            try
            {
                item = this.Settings.GetItem(SystemManager.SETTINGS_SYSTEMS_KEY);
                if (item != null)
                {
                    Assembly assembly = Assembly.LoadFrom(item.GetString(SystemManager.SETTINGS_SYSTEM_PATH));
                    if (assembly == null)
                    {
                        return(null);
                    }

                    Type type = assembly.GetType(item.GetString(SystemManager.SETTINGS_SYSTEM_CLASS));
                    if (type == null)
                    {
                        return(null);
                    }

                    system = (DigitalSystem)Activator.CreateInstance(type);
                }

                return(system);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);
                throw ex;
            }
        }
コード例 #2
0
        private void LoadWinLogger()
        {
            ImageComboBoxItem item;
            XmlSettingsItem   logger = Logger.ModuleManager.GetLibrary(typeof(WinLogger).Name);

            foreach (Logger.LogLevel level in Enum.GetValues(typeof(Logger.LogLevel)))
            {
                item             = new ImageComboBoxItem();
                item.Description = level.ToString();
                item.Value       = level;
                item.ImageIndex  = (int)level;
                cboLogWindowsLevel.Properties.Items.Add(item);

                if (logger != null && level == Logger.StringToLogLevel(logger.GetString(Logger.SETTING_LOG_LEVEL)))
                {
                    cboLogWindowsLevel.SelectedItem = item;
                }
            }

            if (cboLogWindowsLevel.SelectedItem == null)
            {
                cboLogWindowsLevel.SelectedItem = cboLogWindowsLevel.Properties.Items[0];
            }
            else
            {
                txtLogWindowsName.Text   = logger.GetString(WinLogger.SETTING_LOG_NAME);
                txtLogWindowsSource.Text = logger.GetString(WinLogger.SETTING_LOG_SOURCE);
            }
        }
コード例 #3
0
        public Plugin Get(string pluginId)
        {
            Logger.LogDebug(this, "[CLASS].Get('{0}')", pluginId);

            try
            {
                XmlSettingsItem pluginSection = this.Settings.GetItem(PluginManager.SETTINGS_KEY_PLUGINS);
                if (pluginSection != null)
                {
                    XmlSettingsItem xmlPlugin = pluginSection.GetItem(pluginId);
                    Plugin          plugin    = new Plugin();
                    plugin.ID   = xmlPlugin.Key;
                    plugin.Name = xmlPlugin.Value;
                    plugin.File = xmlPlugin.GetString("assembly-file");

                    return(plugin);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
        }
コード例 #4
0
        public List <Plugin> GetAll()
        {
            List <Plugin> plugins = new List <Plugin>();

            Logger.LogDebug(this, "[CLASS].GetAll()");

            try
            {
                XmlSettingsItem pluginSection = this.Settings.GetItem(PluginManager.SETTINGS_KEY_PLUGINS);
                if (pluginSection != null)
                {
                    foreach (XmlSettingsItem item in pluginSection.Items.Values)
                    {
                        XmlSettingsItem xmlPlugin = pluginSection.GetItem(item.Key);
                        Plugin          plugin    = new Plugin();
                        plugin.ID   = xmlPlugin.Key;
                        plugin.Name = xmlPlugin.Value;
                        plugin.File = xmlPlugin.GetString("assembly-file");

                        plugins.Add(plugin);
                    }

                    return(plugins);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
        }
コード例 #5
0
ファイル: Plugin.cs プロジェクト: gllortc/railwaystudio
        /// <summary>
        /// returns a new instance of <see cref="Plugin"/>.
        /// </summary>
        /// <param name="node">An instance of <see cref="XmlSettingsItem"/> containing all plugin settings.</param>
        public Plugin(XmlSettingsItem node)
        {
            this.ID   = node.Key;
            this.Name = node.Value;

            this.SetAssemblyFile(node.GetString(Plugin.SETTING_KEY_FILE));
        }
コード例 #6
0
ファイル: ThemeManager.cs プロジェクト: gllortc/railwaystudio
        /// <summary>
        /// Sets the theme used to render the switchboard panels.
        /// </summary>
        public ITheme GetTheme()
        {
            XmlSettingsItem item  = null;
            ITheme          theme = null;

            Logger.LogDebug(this, "[CLASS].GetTheme()");

            try
            {
                if (this.Themes == null || this.Themes.Count <= 0)
                {
                    this.GetAll();
                }

                item = this.Settings.GetItem(ThemeManager.SETTINGS_THEMES_KEY);
                if (item != null && !string.IsNullOrWhiteSpace(item.Value))
                {
                    Assembly assembly = Assembly.LoadFrom(item.GetString(ThemeManager.SETTINGS_THEME_PATH));
                    Type     type     = assembly.GetType(item.GetString(ThemeManager.SETTINGS_THEME_CLASS));

                    theme = (ITheme)Activator.CreateInstance(type);
                }

                if (theme == null && this.Themes.Count > 0)
                {
                    theme = this.Themes[0];
                }

                return(theme);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
        }