Exemplo n.º 1
0
        private void CmdAccept_Click(object sender, EventArgs e)
        {
            if (cboSkin.SelectedItem == null)
            {
                MessageBox.Show("You must select the visual skin.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboSkin.Focus();
                return;
            }

            // Change the current skin
            SkinContainer skin = ((ImageComboBoxItem)cboSkin.SelectedItem).Value as SkinContainer;

            SkinManager.EnableFormSkins();
            DevExpress.LookAndFeel.UserLookAndFeel.Default.Style    = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = skin.SkinName;

            // General settings
            StudioContext.SkinName        = skin.SkinName;
            StudioContext.OpenLastProject = chkProjectsLoadLast.Checked;

            // LOGs settings
            Logger.LogLevel level = this.GetLoggerLevel(cboLogFileLevel);
            if (level == Logger.LogLevel.Disabled)
            {
                Logger.ModuleManager.RemoveLibrary(typeof(FileLogger).Name);
            }
            else
            {
                XmlSettingsItem library = new XmlSettingsItem(typeof(FileLogger).Name, typeof(FileLogger).FullName);
                library.AddSetting(Logger.SETTING_LOG_LEVEL, level.ToString().ToLower());
                Logger.ModuleManager.AddLibrary(library);
            }

            level = this.GetLoggerLevel(cboLogWindowsLevel);
            if (level == Logger.LogLevel.Disabled)
            {
                Logger.ModuleManager.RemoveLibrary(typeof(WinLogger).Name);
            }
            else
            {
                XmlSettingsItem library = new XmlSettingsItem(typeof(WinLogger).Name, typeof(WinLogger).FullName);
                library.AddSetting(Logger.SETTING_LOG_LEVEL, level.ToString().ToLower());
                library.AddSetting(WinLogger.SETTING_LOG_NAME, txtLogWindowsName.Text);
                library.AddSetting(WinLogger.SETTING_LOG_SOURCE, txtLogWindowsSource.Text);
                Logger.ModuleManager.AddLibrary(library);
            }

            OTCContext.Settings.SaveSettings();

            this.RefreshPluginsBar = this.PluginsControl.PluginsChanged;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Install new plug-in package into current instance.
        /// </summary>
        /// <param name="package">Plug-in package to install.</param>
        /// <param name="path">Path (with filename) to the assembly file containing the plugin.</param>
        public void Add(IPluginPackage package)
        {
            Logger.LogDebug(this, "[CLASS].Add([{0}])", package);

            if (package == null)
            {
                return;
            }

            try
            {
                XmlSettingsItem xmlPlugin = new XmlSettingsItem();
                xmlPlugin.Key   = package.ID;
                xmlPlugin.Value = package.GetType().Assembly.Location;

                XmlSettingsItem pluginSection = this.GetPluginsSection();
                pluginSection.AddSetting(xmlPlugin);

                OTCContext.Settings.SaveSettings();

                // Add to current instance
                this.InstalledPackages.Add(package);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);
                throw ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the theme used to render the switchboard panels.
        /// </summary>
        public void SetTheme(Type type)
        {
            Logger.LogDebug(this, "[CLASS].SetTheme([{0}])", type.FullName);

            try
            {
                XmlSettingsItem item = new XmlSettingsItem(ThemeManager.SETTINGS_THEMES_KEY, string.Empty);
                item.AddSetting(ThemeManager.SETTINGS_THEME_PATH, ReflectionUtils.GetAssemblyFile(type));
                item.AddSetting(ThemeManager.SETTINGS_THEME_CLASS, type.FullName);

                this.Settings.AddSetting(item);
                this.Settings.SaveSettings();
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the theme used to render the switchboard panels.
        /// </summary>
        public void SetSystem(Type type)
        {
            Logger.LogDebug(this, "[CLASS].SetSystem([{0}])", type.FullName);

            try
            {
                XmlSettingsItem item = new XmlSettingsItem(SystemManager.SETTINGS_SYSTEMS_KEY, string.Empty);
                item.AddSetting(SystemManager.SETTINGS_SYSTEM_PATH, ReflectionUtils.GetAssemblyFile(type));
                item.AddSetting(SystemManager.SETTINGS_SYSTEM_CLASS, type.FullName);

                this.Settings.AddSetting(item);
                this.Settings.SaveSettings();

                // Force ti reload the digital system according to the selection
                OTCContext.Project.LoadSystem();
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);
                throw ex;
            }
        }
Exemplo n.º 5
0
        static Logger()
        {
            Assembly assembly;
            ILogger  logger;

            Logger.Loggers = new List <ILogger>();

            try
            {
                // Load modules from settings
                Logger.ModuleManager = new LoggerSettingsManager(); // OTCContext.Settings);

                // If no loggers are appended, a FileLogger with ERROR level will be appended to ensure LOG all application exceptions
                if (Logger.ModuleManager.LoggerModules.Count <= 0)
                {
                    XmlSettingsItem module = new XmlSettingsItem("FileLogger", typeof(FileLogger).FullName);
                    module.AddSetting(Logger.SETTING_LOG_LEVEL, LogLevel.Error.ToString());
                    Logger.ModuleManager.LoggerModules.Add(module);
                }

                // Generate the logger instances
                foreach (XmlSettingsItem module in Logger.ModuleManager.LoggerModules)
                {
                    assembly = Assembly.GetExecutingAssembly();
                    logger   = (ILogger)assembly.CreateInstance(module.Value);

                    if (logger != null)
                    {
                        logger.Initialize(module);

                        Logger.Loggers.Add(logger);
                    }
                }

                // To minimize the memory usage
                assembly = null;
                logger   = null;
            }
            catch
            {
                // Empty settings
            }
        }
Exemplo n.º 6
0
        public void Add(Plugin plugin)
        {
            Logger.LogDebug(this, "[CLASS].Add([{0}])", plugin);

            try
            {
                XmlSettingsItem xmlPlugin = new XmlSettingsItem();
                xmlPlugin.Key   = plugin.ID;
                xmlPlugin.Value = plugin.Name;
                xmlPlugin.AddSetting("assembly-file", plugin.File);

                XmlSettingsItem pluginSection = GetPluginsSection();
                pluginSection.AddSetting(xmlPlugin);

                this.Settings.AddSetting(pluginSection);
                this.Settings.SaveSettings();
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
        }