Пример #1
0
		public ISettingsSection CreateSection(string name) {
			Debug.Assert(name != null);
			if (name == null)
				throw new ArgumentNullException(nameof(name));

			var section = new SettingsSection(name);
			sections.Add(section);
			return section;
		}
Пример #2
0
        public ISettingsSection GetOrCreateSection(Guid guid)
        {
            var name = guid.ToString();
            ISettingsSection section;
            if (sections.TryGetValue(name, out section))
                return section;

            section = new SettingsSection(name);
            sections[name] = section;
            return section;
        }
Пример #3
0
		public ISettingsSection GetOrCreateSection(string name) {
			Debug.Assert(name != null);
			if (name == null)
				throw new ArgumentNullException(nameof(name));

			var section = sections.FirstOrDefault(a => StringComparer.Ordinal.Equals(name, a.Name));
			if (section != null)
				return section;
			sections.Add(section = new SettingsSection(name));
			return section;
		}
Пример #4
0
        public bool GetBool(SettingsSection section, string keyName, bool defaultValue)
        {
            var setting = GetSetting(section.ToString(), keyName);
            if (setting == null || string.IsNullOrEmpty(setting.Value))
                return defaultValue;
            if (setting.Value.Equals("true", StringComparison.CurrentCultureIgnoreCase) || setting.Value == "1")
                return true;
            if (setting.Value.Equals("false", StringComparison.CurrentCultureIgnoreCase) || setting.Value == "0")
                return false;

            return defaultValue;
        }
Пример #5
0
		public ISettingsSection GetOrCreateSection(Guid guid) {
			if (guid == Guid.Empty)
				throw new ArgumentOutOfRangeException(nameof(guid));

			var name = guid.ToString();
			ISettingsSection section;
			if (sections.TryGetValue(name, out section))
				return section;

			section = new SettingsSection(name);
			sections[name] = section;
			return section;
		}
Пример #6
0
        private void LoadAndParseSettingsFiles()
        {
            SettingsSection userLevelToAddTo = null;
            Category        categoryToAddTo  = null;
            Group           groupToAddTo     = null;
            SubGroup        subGroupToAddTo  = null;

            foreach (string line in AggContext.StaticData.ReadAllLines(Path.Combine("SliceSettings", "Layouts.txt")))
            {
                if (line.Length > 0)
                {
                    string sanitizedLine = line.Replace('"', ' ').Trim();
                    switch (CountLeadingSpaces(line))
                    {
                    case 0:
                        userLevelToAddTo = new SettingsSection(sanitizedLine);
                        UserLevels.Add(sanitizedLine, userLevelToAddTo);
                        break;

                    case 2:
                        categoryToAddTo = new Category(sanitizedLine, userLevelToAddTo);
                        userLevelToAddTo.Categories.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new Group(sanitizedLine, categoryToAddTo);
                        categoryToAddTo.Groups.Add(groupToAddTo);
                        break;

                    case 6:
                        subGroupToAddTo = new SubGroup(sanitizedLine, groupToAddTo);
                        groupToAddTo.SubGroups.Add(subGroupToAddTo);
                        break;

                    case 8:
                        SliceSettingData data = GetSettingsData(sanitizedLine);
                        if (data != null)
                        {
                            subGroupToAddTo.Settings.Add(data);
                            data.OrganizerSubGroup = subGroupToAddTo;
                            userLevelToAddTo.AddSetting(data.SlicerConfigName, subGroupToAddTo);
                        }

                        break;

                    default:
                        throw new Exception("Bad file, too many spaces (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }
Пример #7
0
        private static void LoadConfiguration()
        {
            ValidateResultRepositoryBase.LoadBaseConfiguration();

            SettingsSection settings = SettingsSection.GetSection();

            if (settings != null && settings.RepositorySettings != null)
            {
                CookieDomain = GetValue("CookieDomain", settings.RepositorySettings);

                SetTimespanFromRepositorySettings(
                    settings.RepositorySettings, "CookieExpiration", (value) => CookieExpiration = value);
            }
        }
        public void TestUpacConfiguration()
        {
            SettingsSection settings = Upac.Configuration.ConfigurationManager.Settings;

            Assert.IsNotNull(settings);

            BoolElement element = settings.SetWidthOnRichTextEditorViaTemplateAlias;

            Assert.IsNotNull(element);

            Assert.IsTrue(element.Value);

            settings = Upac.Configuration.ConfigurationManager.Settings;
        }
Пример #9
0
        protected static void LoadBaseConfiguration()
        {
            SettingsSection settings = SettingsSection.GetSection();

            if (settings != null && settings.RepositorySettings != null)
            {
                SetTimespanFromRepositorySettings(
                    settings.RepositorySettings, "IdleExpiration", (value) => IdleExpiration = value);
            }
            if (settings != null && settings.RepositorySettings != null)
            {
                SetBooleanFromRepositorySettings(
                    settings.RepositorySettings, "ExtendValidity", (value) => ExtendValidity = value);
            }
        }
Пример #10
0
        private static float getBaseHue(SettingsSection section)
        {
            switch (section)
            {
            case ConfigSection _:
                return(200 / 360f);    // Blue

            case StyleSection _:
                return(333 / 360f);    // Pink

            case ScoringSection _:
                return(46 / 360f);    // Orange

            default:
                throw new ArgumentException($@"{section} colour scheme does not provide a hue value in {nameof(getBaseHue)}.");
            }
        }
Пример #11
0
        private void LoadAndParseLayoutFile()
        {
            SettingsSection sectionToAddTo  = null;
            Category        categoryToAddTo = null;
            Group           groupToAddTo    = null;

            foreach (string line in AggContext.StaticData.ReadAllLines(Path.Combine("SliceSettings", "Layouts.txt")))
            {
                if (line.Length > 0)
                {
                    string sanitizedLine = line.Replace('"', ' ').Trim();
                    var    leadingSpaces = CountLeadingSpaces(line);
                    switch (leadingSpaces)
                    {
                    case 0:
                        sectionToAddTo = new SettingsSection(sanitizedLine);
                        Sections.Add(sanitizedLine, sectionToAddTo);
                        break;

                    case 2:
                        categoryToAddTo = new Category(sanitizedLine, sectionToAddTo);
                        sectionToAddTo.Categories.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new Group(sanitizedLine, categoryToAddTo);
                        categoryToAddTo.Groups.Add(groupToAddTo);
                        break;

                    case 6:
                        if (PrinterSettings.SettingsData.TryGetValue(sanitizedLine, out SliceSettingData data))
                        {
                            groupToAddTo.Settings.Add(data);
                            data.OrganizerGroup = groupToAddTo;
                            sectionToAddTo.AddSetting(data.SlicerConfigName, groupToAddTo);
                        }

                        break;

                    default:
                        throw new Exception($"Bad file, too many spaces - {leadingSpaces} (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }
Пример #12
0
        public bool GetBool(SettingsSection section, string keyName, bool defaultValue)
        {
            var setting = GetSetting(section.ToString(), keyName);

            if (setting == null || string.IsNullOrEmpty(setting.Value))
            {
                return(defaultValue);
            }
            if (setting.Value.Equals("true", StringComparison.CurrentCultureIgnoreCase) || setting.Value == "1")
            {
                return(true);
            }
            if (setting.Value.Equals("false", StringComparison.CurrentCultureIgnoreCase) || setting.Value == "0")
            {
                return(false);
            }

            return(defaultValue);
        }
Пример #13
0
        private static SettingsSection LoadConfiguration()
        {
            object          section       = ConfigurationManager.GetSection(SettingsSection.SectionName);
            SettingsSection configSection = section as SettingsSection;

            if (section != null && configSection == null)
            {
                throw new ConfigurationErrorsException(String.Format(
                                                           CultureInfo.CurrentCulture,
                                                           Properties.Resources.InvalidConfigurationSectionType,
                                                           SettingsSection.SectionName, typeof(SettingsSection)));
            }

            if (configSection == null)
            {
                configSection = new SettingsSection();
            }
            return(configSection);
        }
Пример #14
0
        /// <summary>
        ///     Maps a <see cref="SettingsSection"/> to the corresponding
        ///     <see cref="WinUI.Expander"/>.
        /// </summary>
        public WinUI.Expander ConvertSettingsSection(SettingsSection section)
        {
            switch (section)
            {
            case SettingsSection.SaveLocation:
                return(ExpanderSaveLocation);

            case SettingsSection.AutoRotation:
                return(ExpanderAutoRotate);

            case SettingsSection.FileNaming:
                return(ExpanderFileName);

            case SettingsSection.ScanOptions:
                return(ExpanderScanOptions);

            case SettingsSection.ScanAction:
                return(ExpanderScanAction);

            case SettingsSection.Theme:
                return(ExpanderTheme);

            case SettingsSection.EditorOrientation:
                return(ExpanderEditorOrientation);

            case SettingsSection.Animations:
                return(ExpanderAnimations);

            case SettingsSection.ErrorReports:
                return(ExpanderFeedbackReportsLogs);

            case SettingsSection.Surveys:
                return(ExpanderFeedbackSurveys);

            case SettingsSection.MeasurementUnits:
                return(ExpanderMeasurementUnits);

            default:
                break;
            }
            return(null);
        }
Пример #15
0
        private static void Initialize()
        {
            if (!_initialized)
            {
                lock (_lock)
                {
                    if (!_initialized)
                    {
                        try
                        {
                            SettingsSection section = ConfigurationManager.GetSection("lionsguard/settings") as SettingsSection;
                            if (section != null)
                            {
                                _redirectUrlAfterLogin  = section.RedirectUrlAfterLogin;
                                _redirectUrlAfterLogout = section.RedirectUrlAfterLogout;
                                _redirectUrlAfterSignUp = section.RedirectUrlAfterSignUp;

                                _providers = new Lionsguard.Providers.SettingsProviderCollection();
                                ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(Lionsguard.Providers.SettingsProvider));
                                _provider = _providers[section.DefaultProvider];
                                if (_provider == null)
                                {
                                    throw new ConfigurationErrorsException("Default SettingsProvider not found in application configuration file.", section.ElementInformation.Properties["defaultProvider"].Source, section.ElementInformation.Properties["defaultProvider"].LineNumber);
                                }

                                _settings = _provider.GetSettings();
                            }
                        }
                        catch (Exception ex)
                        {
                            _initException = ex;
                        }
                        _initialized = true;
                    }
                }
            }
            if (_initException != null)
            {
                throw _initException;
            }
        }
Пример #16
0
        public Settings(SettingsSection settings)
        {
            _settings = settings;
            InitializeComponent();

            cbEnterOTP.Checked            = _settings.EnterOTP.Enabled;
            cboEnterOTPKey.SelectedItem   = _settings.EnterOTP.Key.ToUpper();
            cbEnterOTPCtrl.Checked        = _settings.EnterOTP.Ctrl;
            cbEnterOTPAlt.Checked         = _settings.EnterOTP.Alt;
            cbEnterOTPWin.Checked         = _settings.EnterOTP.Win;
            txtEnterOTPEnterKeyDelay.Text = _settings.EnterOTP.EnterKeyDelay.ToString();

            cbIncrementSession.Checked          = _settings.IncrementSession.Enabled;
            cboIncrementSessionKey.SelectedItem = _settings.IncrementSession.Key.ToUpper();
            cbIncrementSessionCtrl.Checked      = _settings.IncrementSession.Ctrl;
            cbIncrementSessionAlt.Checked       = _settings.IncrementSession.Alt;
            cbIncrementSessionWin.Checked       = _settings.IncrementSession.Win;

            cbMinimizeToSysTray.Checked = _settings.MinimizeToSysTray;
            cbStartMinimized.Enabled    = _settings.MinimizeToSysTray;
            cbStartMinimized.Checked    = _settings.StartMinimized;
        }
Пример #17
0
        protected override List <SettingsSection> ReadConfig()
        {
            var context        = FabricRuntime.GetActivationContext();
            var configuration  = context.GetConfigurationPackageObject(DefaultConfigurationPackageName);
            var fabricSettings = configuration.Settings;
            var settings       = new List <SettingsSection>();

            foreach (var section in fabricSettings.Sections)
            {
                var ss = new SettingsSection(section.Name);

                foreach (var param in section.Parameters)
                {
                    var value = param.IsEncrypted && !string.IsNullOrEmpty(param.Value) ? param.DecryptValue().ConvertToUnsecureString() : param.Value;
                    ss.Settings.Add(new Setting(param.Name, value));
                }

                settings.Add(ss);
            }

            return(settings);
        }
Пример #18
0
        public HomePresenter(IStateManager manager) : base(manager)
        {
            Form = (IHomeView) FormFactory.CreateForm("MainForm", new object[] {this});
            //onClosingEvent to stop the application
            ((Form) Form).FormClosing += (sender, args) => ApplicationState.IsRunning = false;
            ProductSection = new ProductSection(Form.ProductDataTable, this, Form);
            SettingsSection = new SettingsSection(this);

            StateManager.EventManager.AddEvent(new Event(
                Config.EventListenerImmediate,
                CheckIsLoginHandler,
                GetStateManager().EventManager,
                true));

            IsProductsDisplayed = false;
            Form.TabLabelText = Tab1LabelText;
            Form.SetSearchParams(ProductSection.GetSearchParameters());


            if (!StateManager.UserSession.IsActive) //prevent any actions till login
                return;
        }
Пример #19
0
        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            SettingsSection settings = (SettingsSection)config.GetSection("settings");
            Settings        window   = new Settings(settings);

            if (!this.Visible)
            {
                window.ShowInTaskbar = true;
            }
            DialogResult result = window.ShowDialog();

            if (result == DialogResult.OK)
            {
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("settings");
                if (!this.Visible && !settings.MinimizeToSysTray)
                {
                    notifyIcon1_Restore(sender, e);
                }
                RegisterHotkeys();
            }
        }
Пример #20
0
		public static SerializedTab TryCreate(IFileTabContentFactoryManager creator, IFileTab tab) {
			var contentSect = new SettingsSection(CONTENT_SECTION);
			var guid = creator.Serialize(tab.Content, contentSect);
			if (guid == null)
				return null;
			contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

			var uiSect = new SettingsSection(UI_SECTION);
			tab.UIContext.SaveSerialized(uiSect, tab.UIContext.Serialize());

			var tabUISect = new SettingsSection(TAB_UI_SECTION);
			tab.SerializeUI(tabUISect);

			var paths = new List<SerializedPath>();
			foreach (var node in tab.Content.Nodes)
				paths.Add(SerializedPath.Create(node));

			var autoLoadedFiles = new List<DnSpyFileInfo>();
			foreach (var f in GetAutoLoadedFiles(tab.Content.Nodes))
				autoLoadedFiles.Add(f);

			return new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedFiles);
		}
Пример #21
0
        private bool UpdateSettingsXml(XDocument xml)
        {
            bool changed = false;

            foreach (var section in SettingsSection.FromXmlSettingsFile(xml.Root))
            {
                Properties container;
                try {
                    container = dte.Properties(section.Item1);
                } catch (Exception ex) {
                    logger.Log("Warning: Not saving unsupported category " + section.Item1 + " in existing settings file; you may be missing an extension.  Error: " + ex.Message);
                    continue;
                }

                // Single (bitwise) or to avoid short-circuiting & always run merge
                changed = changed | XmlMerger.MergeElements(
                    section.Item2,
                    container.Cast <Property>().Select(p => XmlValue(section.Item1, p)).Where(x => x != null),
                    x => x.Attribute("name").Value
                    );
            }
            return(changed);
        }
Пример #22
0
        public void ShouldGenerateEvaluatedNuGetConfigFile(string sourceNuGet, SettingsSection targetSettings)
        {
            using (var projectFolder = new DisposableFolder())
            {
                // Generate files and directories
                var sourceFolder = Path.Combine(projectFolder.Path, "Source");
                var sourceScript = Path.Combine(sourceFolder, "script.cs");
                var targetFolder = Path.Combine(projectFolder.Path, "Target");
                Directory.CreateDirectory(targetFolder);
                Directory.CreateDirectory(sourceFolder);

                var rootTokens = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:" : string.Empty;

                var resolvedSourceNuGet = string.Format(sourceNuGet, rootTokens);
                File.WriteAllText(Path.Combine(sourceFolder, Settings.DefaultSettingsFileName), resolvedSourceNuGet);

                // Evaluate and generate the NuGet config file
                NuGetUtilities.CreateNuGetConfigFromLocation(sourceScript, targetFolder);

                // Validate the generated NuGet config file
                var targetNuGetPath = Path.Combine(targetFolder, Settings.DefaultSettingsFileName);
                Assert.True(File.Exists(targetNuGetPath), $"NuGet.config file was not generated at {targetNuGetPath}");

                sourceFolder += Path.DirectorySeparatorChar;
                var settings = new Settings(targetFolder);
                foreach (var expectedSettings in targetSettings)
                {
                    foreach (var expectedSetting in expectedSettings.Value)
                    {
                        var value = settings.GetValue(expectedSettings.Key, expectedSetting.Key);
                        var resolvedExpectedSetting = string.Format(expectedSetting.Value, sourceFolder, rootTokens);
                        Assert.Equal(resolvedExpectedSetting, value);
                    }
                }
            }
        }
Пример #23
0
        void Awake()
        {
            lux = LuxManager.Instance;
            lux.onStarted.AddListener(() =>
            { // Update UI once
                MainSection.UpdateUI();
                SettingsSection.UpdateUI();
                isUpdating = true;
            });

            lux.onStopped.AddListener(() =>
            {
                isUpdating = false;
            });


            mb_fio = ModalBackground.GetComponent <FadeInOutUI>();
            mb_ci  = ModalBackground.GetComponent <ClickableImage>();
            mb_ci.onClick.AddListener(() =>
            {
                HideModalView(); // can refactor here, decouple from specifically SettingsUIController
            });
            mb_fio.FadeOut(true);
        }
Пример #24
0
        XElement XmlValue(SettingsSection section, Property prop)
        {
            string name = prop.Name;

            if (KnownSettings.ShouldSkip(section, name))
            {
                return(null);
            }

            object value;

            try {
                value = prop.Value;
            } catch (COMException ex) {
                logger.Log((string)("An error occurred while saving " + section + "#" + name + ": " + ex.Message));
                return(null);
            } catch (InvalidOperationException) {
                // The InvalidOperationException is thrown when property is internal, read only or write only, so
                // property value cannot be set or get.
                return(null);
            }
            var collection = value as ICollection;

            if (collection == null)
            {
                return(new XElement("PropertyValue", new XAttribute("name", name), value));
            }

            return(new XElement("PropertyValue",
                                new XAttribute("name", name),
                                new XAttribute("ArrayType", "VT_VARIANT"),
                                new XAttribute("ArrayElementCount", collection.Count),
                                ((IEnumerable <object>)value)
                                .Select((v, i) => new XElement("PropertyValue", new XAttribute("name", i), v))
                                ));
        }
Пример #25
0
 public static Properties Properties(this DTE dte, SettingsSection section)
 {
     return dte.Properties[section.Category, section.Subcategory];
 }
Пример #26
0
 public string Get(SettingsSection section, string keyName, string defaultValue)
 {
     var setting = GetSetting(section.ToString(), keyName);
     return setting == null ? defaultValue : setting.Value ?? defaultValue;
 }
Пример #27
0
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // CONSTRUCTORS / FACTORIES /////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public SettingsRequestMessage(SettingsSection settingsSection)
 {
     SettingsSection = settingsSection;
 }
Пример #28
0
 protected SettingsProvider(SettingsSection settings)
 {
     Name             = settings.Name;
     Path             = settings.Path;
     ConnectionString = settings.ConnectionString;
 }
Пример #29
0
 public KaraokeConfigPageTabItem(SettingsSection value)
     : base(value)
 {
 }
Пример #30
0
 public void Set(SettingsSection section, string keyName, string value)
 {
     Dictionary<string, Setting> sectionSettings;
     if (!_allSettings.TryGetValue(section.ToString(), out sectionSettings))
     {
         sectionSettings = new Dictionary<string, Setting>();
         _allSettings.Add(section.ToString(), sectionSettings);
     }
     Setting setting;
     if (!sectionSettings.TryGetValue(keyName, out setting))
     {
         sectionSettings.Add(
             keyName, new Setting(value) {IsDirty = true});
     }
     else if (setting.Value != value)
     {
         setting.Value = value;
         setting.IsDirty = true;
     }
 }
Пример #31
0
        public string Get(SettingsSection section, string keyName, string defaultValue)
        {
            var setting = GetSetting(section.ToString(), keyName);

            return(setting == null ? defaultValue : setting.Value ?? defaultValue);
        }
Пример #32
0
 public int GetInt(SettingsSection section, string keyName, int defaultValue)
 {
     var setting = GetSetting(section.ToString(), keyName);
     if (setting == null) return defaultValue;
     int value;
     return int.TryParse(setting.Value, out value) ? value : defaultValue;
 }
Пример #33
0
		public static SerializedTab TryCreate(IDocumentTabContentFactoryService documentTabContentFactoryService, IDocumentTab tab) {
			var contentSect = new SettingsSection(CONTENT_SECTION);
			var guid = documentTabContentFactoryService.Serialize(tab.Content, contentSect);
			if (guid == null)
				return null;
			contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

			var uiSect = new SettingsSection(UI_SECTION);
			tab.UIContext.SerializeUIState(uiSect, tab.UIContext.CreateUIState());

			var tabUISect = new SettingsSection(TAB_UI_SECTION);
			tab.SerializeUI(tabUISect);

			var paths = new List<SerializedPath>();
			foreach (var node in tab.Content.Nodes)
				paths.Add(SerializedPath.Create(node));

			var autoLoadedDocuments = new List<DsDocumentInfo>();
			foreach (var f in GetAutoLoadedDocuments(tab.Content.Nodes))
				autoLoadedDocuments.Add(f);

			return new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedDocuments);
		}
Пример #34
0
 bool IsPresent(SettingsSection section)
 {
     try {
         dte.Properties(section);
         return true;
     } catch (COMException) { return false; } catch (NotImplementedException) { return false; }
 }
Пример #35
0
        XElement XmlValue(SettingsSection section, Property prop)
        {
            string name = prop.Name;
            if (KnownSettings.ShouldSkip(section, name))
                return null;

            object value;
            try {
                value = prop.Value;
            } catch (COMException ex) {
                logger.Log((string)("An error occurred while saving " + section + "#" + name + ": " + ex.Message));
                return null;
            }
            var collection = value as ICollection;
            if (collection == null)
                return new XElement("PropertyValue", new XAttribute("name", name), value);

            return new XElement("PropertyValue",
                new XAttribute("name", name),
                new XAttribute("ArrayType", "VT_VARIANT"),
                new XAttribute("ArrayElementCount", collection.Count),
                ((IEnumerable<object>)value)
                    .Select((v, i) => new XElement("PropertyValue", new XAttribute("name", i), v))
            );
        }
Пример #36
0
 public Color4 GetContent2Colour(SettingsSection section) => getColour(section, 0.4f, 0.9f);
Пример #37
0
        public static SerializedTab TryCreate(IFileTabContentFactoryManager creator, IFileTab tab)
        {
            var contentSect = new SettingsSection(CONTENT_SECTION);
            var guid = creator.Serialize(tab.Content, contentSect);
            if (guid == null)
                return null;
            contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

            var uiSect = new SettingsSection(UI_SECTION);
            tab.UIContext.SaveSerialized(uiSect, tab.UIContext.Serialize());

            var tabUISect = new SettingsSection(TAB_UI_SECTION);
            tab.SerializeUI(tabUISect);

            var paths = new List<SerializedPath>();
            foreach (var node in tab.Content.Nodes)
                paths.Add(SerializedPath.Create(node));

            var autoLoadedFiles = new List<DnSpyFileInfo>();
            foreach (var f in GetAutoLoadedFiles(tab.Content.Nodes))
                autoLoadedFiles.Add(f);

            return new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedFiles);
        }
Пример #38
0
 public Color4 GetBackground3Colour(SettingsSection section) => getColour(section, 0.1f, 0.15f);
Пример #39
0
        public void DefineSettings()
        {
            StringResources stx = new StringResources( "Settings" );

            string CurrentLang = Properties.LANGUAGE;
            SettingsSection LangSection = new SettingsSection()
            {
                Title = stx.Text( "Language" )
                , Data = new ActiveItem[]
                {
                    new ActionItem(
                        stx.Text( "Language_E")
                        , CurrentLang == "en-US"
                            ? stx.Text( "Desc_Language_C" )
                            : stx.Text( "Desc_Language_AE" )
                        , "en-US"
                    )
                    , new ActionItem(
                        stx.Text( "Language_T")
                        , CurrentLang == "zh-TW"
                            ? stx.Text( "Desc_Language_C" )
                            : stx.Text( "Desc_Language_AT" )
                        , "zh-TW"
                    )
                    , new ActionItem(
                        stx.Text( "Language_S")
                        , CurrentLang == "zh-CN"
                            ? stx.Text( "Desc_Language_C" )
                            : stx.Text( "Desc_Language_AS" )
                        , "zh-CN"
                    )
                    , new ActionItem(
                        stx.Text( "Language_J")
                        , CurrentLang == "ja"
                            ? stx.Text( "Desc_Language_C" )
                            : stx.Text( "Desc_Language_AJ" )
                        , "ja"
                    )
                }
                , ItemAction = ChangeLanguage
                , IsEnabled = true
            };

            if ( MainStage.Instance.IsPhone )
            {
                if ( CurrentLang != "en-US" ) LangSection.Data.ElementAt( 0 ).Desc = "Mobile user may not be able change the language here, please visit the wiki for help";
                if ( CurrentLang != "zh-TW" ) LangSection.Data.ElementAt( 1 ).Desc = "\u624B\u6A5F\u7528\u6236\u53EF\u80FD\u7121\u6CD5\u8B8A\u66F4\u8A9E\u8A00\uFF0C\u8A73\u60C5\u8ACB\u53C3\u770B\u5E6B\u52A9";
                if ( CurrentLang != "zh-CN" ) LangSection.Data.ElementAt( 2 ).Desc = "\u624B\u673A\u7528\u6237\u53EF\u80FD\u65E0\u6CD5\u53D8\u66F4\u8BED\u8A00\uFF0C\u8BE6\u60C5\u8BF7\u53C2\u770B\u5E2E\u52A9";
                if ( CurrentLang != "ja" ) LangSection.Data.ElementAt( 3 ).Desc = "\u643A\u5E2F\u96FB\u8A71\u30E6\u30FC\u30B6\u30FC\u306F\u3001\u8A00\u8A9E\u3092\u5909\u66F4\u3067\u304D\u306A\u3044\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002\u8A73\u7D30\u306B\u3064\u3044\u3066\u306F\u3001\u30D8\u30EB\u30D7\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
            }

            MainView.ItemsSource = new SettingsSection[]
            {
                new SettingsSection()
                {
                    Title = stx.Text( "Storage" )
                    , Data = new ActiveItem[]
                    {
                        new ActionItem( stx.Text( "Data_Cache"), stx.Text( "Desc_Data_Cache" ), typeof( Data.Cache ) )
                        , new ActionItem( stx.Text( "Data_Illustration"), stx.Text( "Desc_Data_Illustration" ), typeof( Data.Illustration ) )
                        , new ActionItem( stx.Text( "Data_Preload"), stx.Text( "Desc_Data_Preload" ), typeof( Data.Preload ) )
                        , new ActionItem( stx.Text( "EBWin"), stx.Text( "Desc_EBWin_Short" ), typeof( Data.EBWin ) )
                        , OneDriveButton = new ActionItem( "OneDrive", Properties.ENABLE_ONEDRIVE ? stx.Text( "Enabled" ) : stx.Text( "Disabled" ), false )
                        // , new ActionItem( stx.Text( "Data_Connection"), stx.Text( "Desc_Data_Connection" ), typeof( Data.Cache ) )
                    }
                    , ItemAction = PopupSettings
                    , IsEnabled = true
                }
                , new SettingsSection()
                {
                    Title = stx.Text( "Appearance" )
                    , Data = new ActiveItem[]
                    {
                        new ActionItem( stx.Text( "Appearance_ContentReader"), stx.Text( "Desc_Appearance_ContentReader" ), typeof( Themes.ContentReader ) )
                        , new ActionItem( stx.Text( "Appearance_Theme"), stx.Text( "Desc_Appearance_Backgrounds" ), typeof( Themes.ThemeColors ) )
                        , new ActionItem( stx.Text( "Appearance_Layout"), stx.Text( "Desc_Appearance_Layout" ), typeof( Themes.Layout ) )
                    }
                    , ItemAction = PopupSettings
                    , IsEnabled = true
                }
                , LangSection
                , new SettingsSection()
                {
                    Title = stx.Text( "Advanced" )
                    , Data = new ActiveItem[]
                    {
                        new ActionItem( stx.Text( "Advanced_Server"), stx.Text( "Desc_Advanced_Server" ), typeof( Advanced.ServerSelector ) )
                        , new ActionItem( stx.Text( "Advanced_Misc"), stx.Text( "Desc_Advanced_Misc" ), typeof( Advanced.Misc ) )
#if DEBUG || TESTING 
                        , new ActionItem( stx.Text( "Advanced_Debug"), stx.Text( "Desc_Advanced_Debug" ), typeof( Advanced.Debug ) )
#endif
                    }
                    , ItemAction = PopupSettings
                    , IsEnabled = true
                }
                , new SettingsSection()
                {
                    Title = stx.Text( "Help" )
                    , Data = new ActiveItem[]
                    {
                        new ActionItem( stx.Text( "Help_Wiki"), stx.Text( "Desc_Help_Wiki" ), "https://github.com/tgckpg/wenku10/wiki" )
                        , new ActionItem( stx.Text( "Help_Slack"), stx.Text( "Desc_Help_Slack" ), "https://blog.astropenguin.net/article/view/wenku10-%E7%9A%84%E8%A8%8E%E8%AB%96%E7%B5%84/" )
                        , new ActionItem( stx.Text( "Help_BugFeature"), stx.Text( "Desc_Help_BugFeature" ), "https://bugzilla.astropenguin.net/" )
                    }
                    , ItemAction = HelpAction
                    , IsEnabled = true
                }
            };
        }
Пример #40
0
 private Color4 getColour(SettingsSection section, float saturation, float lightness) => Color4.FromHsl(new Vector4(getBaseHue(section), saturation, lightness, 1));
Пример #41
0
        private void load(OsuGame game)
        {
            var sections = new SettingsSection[]
            {
                new GeneralSection(),
                new GraphicsSection(),
                new GameplaySection(),
                new AudioSection(),
                new SkinSection(),
                new InputSection(),
                new OnlineSection(),
                new MaintenanceSection(),
                new DebugSection(),
            };

            Children = new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = Color4.Black,
                    Alpha            = 0.6f,
                },
                sectionsContainer = new SettingsSectionsContainer
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = width,
                    Margin           = new MarginPadding {
                        Left = SIDEBAR_WIDTH
                    },
                    ExpandableHeader = new SettingsHeader(),
                    FixedHeader      = searchTextBox = new SearchTextBox
                    {
                        RelativeSizeAxes = Axes.X,
                        Origin           = Anchor.TopCentre,
                        Anchor           = Anchor.TopCentre,
                        Width            = 0.95f,
                        Margin           = new MarginPadding
                        {
                            Top    = 20,
                            Bottom = 20
                        },
                        Exit = Hide,
                    },
                    Sections = sections,
                    Footer   = new SettingsFooter()
                },
                sidebar = new Sidebar
                {
                    Width    = SIDEBAR_WIDTH,
                    Children = sidebarButtons = sections.Select(section =>
                                                                new SidebarButton
                    {
                        Section = section,
                        Action  = sectionsContainer.ScrollContainer.ScrollIntoView,
                    }
                                                                ).ToArray()
                }
            };

            selectedSidebarButton          = sidebarButtons[0];
            selectedSidebarButton.Selected = true;

            sectionsContainer.SelectedSection.ValueChanged += section =>
            {
                selectedSidebarButton.Selected = false;
                selectedSidebarButton          = sidebarButtons.Single(b => b.Section == section);
                selectedSidebarButton.Selected = true;
            };

            searchTextBox.Current.ValueChanged += newValue => sectionsContainer.SearchContainer.SearchTerm = newValue;

            sectionsContainer.Padding = new MarginPadding {
                Top = game?.Toolbar.DrawHeight ?? 0
            };
        }
Пример #42
0
 public void Set(SettingsSection section, string keyName, int value)
 {
     Set(section, keyName, value.ToString());
 }
Пример #43
0
        ///<summary>Reads settings from the XML file into Visual Studio's global settings.</summary>
        private void LoadSettings()
        {
            var  xml      = XDocument.Load(SettingsPath, LoadOptions.PreserveWhitespace);
            bool modified = false;

            foreach (var section in SettingsSection.FromXmlSettingsFile(xml.Root))
            {
                if (!KnownSettings.IsAllowed(section.Item1))
                {
                    logger.Log("Warning: Not loading unsafe category " + section.Item1 + ".  You may have a malicious Rebracer.xml file.");
                    continue;
                }

                Properties container;
                try {
                    container = dte.Properties(section.Item1);
                } catch (Exception ex) {
                    logger.Log("Warning: Not loading unsupported category " + section.Item1 + " from settings file; you may be missing an extension.  Error: " + ex.Message);
                    continue;
                }

                List <XElement> elements = section.Item2.Elements("PropertyValue").ToList();

                foreach (var property in elements)
                {
                    string name = property.Attribute("name").Value;
                    if (KnownSettings.ShouldSkip(section.Item1, name))
                    {
                        continue;
                    }
                    try {
                        Property p;

                        try {
                            p = container.Item(name);
                        } catch (ArgumentException ex) {
                            if ((uint)ex.HResult == 0x80070057)                             // E_INVALIDARG, Property does not exists.
                            {
                                // This error occurs when the IDE property does not exist at this time.

                                continue;
                            }
                            logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file.  Error: " + ex.Message);
                            continue;
                        }

                        p.Value = VsValue(property);
                    } catch (COMException ex) {
                        if ((uint)ex.HResult == 0x80020003)                         // DISP_E_MEMBERNOTFOUND
                        {
                            // MSDN: A return value indicating that the requested member does not exist, or the call to Invoke
                            // tried to set the value of a read-only property. So this is not error.

                            continue;
                        }

                        logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file.  Error: " + ex.Message);
                    } catch (Exception ex) {
                        logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file.  Error: " + ex.Message);
                    }
                }
            }
        }
Пример #44
0
 private void CreateLayout(SettingsSection section, (string categoryName, (string groupName, string[] settings)[] groups)[] layout, Func <string, bool> includeSetting = null)
Пример #45
0
 public Category(string categoryName, SettingsSection settingsSection)
 {
     this.Name            = categoryName;
     this.SettingsSection = settingsSection;
 }
Пример #46
0
 public void Set(SettingsSection section, string keyName, bool value)
 {
     Set(section, keyName, value ? "True" : "False");
 }