/// <summary>
        /// determines if the settings collection already contains this setting type
        /// </summary>
        public bool Contains <TSetting>(TSetting item)
            where TSetting : ISetting
        {
            var itemType = item.GetType();

            return(!item.IsMultipleAllowed() && SettingsList.Any(s => s.GetType().IsAssignableFrom(itemType)));
        }
示例#2
0
        public SettingsList RegisterAssembly(LoadedLibrary library, Assembly assembly)
        {
            lock (_assemblies)
            {
                try
                {
                    RegisteredAssembly localAssembly = new RegisteredAssembly(assembly, library);
                    if (!_assemblies.Contains(assembly.FullName))
                    {
                        SettingsList classes = GetClassList(assembly);
                        foreach (SettingsItem setting in classes.Values)
                        {
                            RegisteredClass classValue = new RegisteredClass(setting.Name, library, localAssembly, setting.Value);
                            _classes.Add(classValue);
                        }
                        _assemblies.Add(localAssembly);
                        return(classes);
                    }

                    return(new SettingsList());
                }
                catch
                {
                    UnregisterAssembly(library, assembly);
                    throw;
                }
            }
        }
示例#3
0
        public void AddSetting()
        {
            StringCollection scopes = new StringCollection();

            scopes.Add(Setting.Scopes.Base.ToString());
            scopes.Add(Setting.Scopes.DistributionSource.ToString());
            scopes.Add(Setting.Scopes.DistributionTarget.ToString());
            scopes.Add(Setting.Scopes.DistributionExe.ToString());
            foreach (var tab in Tabs)
            {
                scopes.Add(tab.TabName);
            }
            var dialog = new SettingCreationDialog()
            {
                Owner = Application.Current.MainWindow, Scopes = scopes
            };                                                                                                    // TODO #GUI access SettingsDialog

            if (dialog.ShowDialog() == true)
            {
                View.MainWindow mainWindow = (View.MainWindow)System.Windows.Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    SettingsList.Add(new Setting()
                    {
                        Scope = dialog.Scope, Key = dialog.Key, Value = dialog.Value
                    });
                }
            }
        }
示例#4
0
        public string GetCsvConfigString(string targetFilePath, string templateName)
        {
            //Read a default config file
            var defaultConfigPath = Path.Combine(Path.GetDirectoryName(targetFilePath), "Default.config.csx");

            if (File.Exists(defaultConfigPath))
            {
                var configText = File.ReadAllText(defaultConfigPath, Encoding.UTF8);
                CurrentConfigFilePath = defaultConfigPath;
                return(configText);
            }

            //Read a config file from selected template.
            if (SettingsList.Skip(1).Contains(templateName))
            {
                var templateFilePath = Path.Combine(ConfigFileDirectory, templateName + ".config.csx");
                if (!File.Exists(templateFilePath))
                {
                    return($"Error! \"{templateFilePath}\" is not found.");
                }
                var configText = File.ReadAllText(templateFilePath, Encoding.UTF8);
                CurrentConfigFilePath = templateFilePath;
                return(configText);
            }

            //Generate a new config template.
            if (true != _dialogService.ShowModal())
            {
                return("");
            }

            var configFileSettings = _dialogService.Result;

            return(GenerateCsvConfig(targetFilePath, configFileSettings));
        }
示例#5
0
        public static Options.SettingsList LoadStatic()
        {
            if (!initialized)
            {
                Initialize(SettingsManager.UserSettingsFilename, SettingsManager.SystemSettingsFilename);
            }

            SettingsList list = new SettingsList();

            // We need to find the root (main) node.
            XmlNode mainNode = null;

            foreach (XmlNode mainNodeTemp in userSettings.ChildNodes)
            {
                if (mainNodeTemp.Name.ToLower() == "settings")
                {
                    mainNode = mainNodeTemp;
                }
            }

            // The main node could not be found.
            if (mainNode == null)
            {
                return(list);
            }

            foreach (XmlNode xmlGroup in mainNode.ChildNodes)
            {
                if (xmlGroup.Name.ToLower() == "group")
                {
                    string group = "";
                    foreach (XmlAttribute attr in xmlGroup.Attributes)
                    {
                        if (attr.Name == "name")
                        {
                            group = attr.Value;
                        }
                    }
                    foreach (XmlNode xmlSetting in xmlGroup.ChildNodes)
                    {
                        if (xmlSetting.Name.ToLower() == "setting")
                        {
                            string name = "";
                            foreach (XmlAttribute attr in xmlSetting.Attributes)
                            {
                                if (attr.Name == "name")
                                {
                                    name = attr.Value;
                                }
                            }
                            Setting setting = new Setting(group, name);
                            setting.Data = xmlSetting.InnerText;
                            list.Add(setting);
                        }
                    }
                }
            }

            return(list);
        }
    static void Main(string[] args)
    {
        // Make sure we don't overwrite the previous run's settings.
        if (String.IsNullOrEmpty(Settings.Default.SettingsObjects))
        {
            // Create the initial settings.
            var list = new SettingsList <SettingsObject> {
                new SettingsObject {
                    Property = "alpha"
                },
                new SettingsObject {
                    Property = "beta"
                }
            };
            Console.WriteLine("settingsObject.Property[0] is {0}", list[0].Property);
            //Save initial values to Settings
            Settings.Default.SettingsObjects = list.ToBase64();
            Settings.Default.Save();
            // Change a property
            list[0].Property = "theta";
            // This is where you went wrong, settings will not be persisted at this point
            // because you have only modified the in memory list.

            // You need to set the property on settings again to persist the value.
            Settings.Default.SettingsObjects = list.ToBase64();
            Settings.Default.Save();
        }
        // pull that property back out & make sure it saved.
        var deserialized = SettingsList <SettingsObject> .FromBase64(Settings.Default.SettingsObjects);

        Console.WriteLine("settingsObject.Property[0] is {0}", deserialized[0].Property);
        Console.WriteLine("Finished! Press any key to continue.");
        Console.ReadKey();
    }
示例#7
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            Type[] types = typeof(Base).Assembly.GetTypes();

            foreach (Type type in types)
            {
                if (type.Equals(typeof(Base)) || type.IsSubclassOf(typeof(Base)))
                {
                    classes.Add(new SettingsItem(type.FullName, type.AssemblyQualifiedName));
                }
            }

            classes.Add(new SettingsItem("FHIR.Core.FHIRObjectConveyor", typeof(FHIRObjectConveyor).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.GenerateTypesNode", typeof(GenerateTypesNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.FHIRAsJSONSelectorNode", typeof(FHIRAsJSONSelectorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.FHIRAsJSONReadAccessorNode", typeof(FHIRAsJSONReadAccessorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.FHIRAsJSONWriteAccessorNode", typeof(FHIRAsJSONWriteAccessorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.FHIRAsXMLSelectorNode", typeof(FHIRAsXMLSelectorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.FHIRAsXMLReadAccessorNode", typeof(FHIRAsXMLReadAccessorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.FHIRAsXMLWriteAccessorNode", typeof(FHIRAsXMLWriteAccessorNode).AssemblyQualifiedName));

            classes.Add(new SettingsItem("FHIR.Core.SatisfiesSearchParamNode", typeof(SatisfiesSearchParamNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.CurrentNode", typeof(NilaryCurrentNode).AssemblyQualifiedName));

            return(classes);
        }
示例#8
0
        /// <summary>
        /// Gets or creates a new document window
        /// </summary>
        /// <param name="type">Can be either a QDockWindow or a UserControl </param>
        /// <param name="key">Key should be the serialized settingslist </param>
        /// <returns></returns>
        public Form GetOrCreateDocument(Type type, string key)
        {
            DocumentsDictionary docs = _documents[type];

            if (docs.ContainsKey(key))
            {
                return(docs[key]);
            }
            else //create new
            {
                SettingsList settings = SettingsList.Deserialize(key);
                var          obj      = _container.Resolve(type);
                var          qWindow  = obj as QDockingWindow;
                if (qWindow != null)
                {
                    qWindow.FormClosed += (s, o) => docs.Remove(key);
                    docs.Add(key, qWindow);
                    qWindow.Settings = settings;
                    return(qWindow);
                }

                var control = obj as UserControl;
                if (control != null)
                {
                    qWindow             = new QViewForm(control);
                    qWindow.FormClosed += (s, o) => docs.Remove(key);
                    docs.Add(key, qWindow);
                    qWindow.Settings = settings;
                    return(qWindow);
                }
                return(null);
            }
        }
示例#9
0
        private string GenerateCsvConfig(string targetFilePath, GenerateConfigSettings newSettings)
        {
            if (!File.Exists(targetFilePath))
            {
                throw new FileNotFoundException("Target CSV file not exist.", targetFilePath);
            }

            var targetFileDir  = Path.GetDirectoryName(targetFilePath);
            var targetFileName = Path.GetFileNameWithoutExtension(targetFilePath);
            var configFilePath = Path.Combine(targetFileDir, targetFileName + ".config.csx");

            if (File.Exists(configFilePath))
            {
                throw new InvalidOperationException($"Config File \"{configFilePath}\" already exists.");
            }

            //Generate a CSV config template.
            var configText = GenerateCsvConfigText(targetFilePath, newSettings.TargetFileEncoding, newSettings.HasHeaderRecord);
            //Save to template file.
            var templateFilePath = Path.Combine(ConfigFileDirectory, newSettings.TemplateName + ".config.csx");

            File.WriteAllText(templateFilePath, configText);

            CurrentConfigFilePath = templateFilePath;
            SettingsList.Add(newSettings.TemplateName);
            return(configText);
        }
        protected void btnSaveSettings_OnClick(object sender, EventArgs e)
        {
            PhBrowseFields.Visible    = false;
            PhBrowseTemplates.Visible = false;
            PhBrowseTree.Visible      = false;

            var saveName = txtSaveSettingsName.Value;

            var settingsData = new ExportSettingsData()
            {
                Database            = ddDatabase.SelectedValue,
                IncludeIds          = chkIncludeIds.Checked,
                StartItem           = inputStartitem.Value,
                FastQuery           = txtFastQuery.Value,
                Templates           = inputTemplates.Value,
                IncludeTemplateName = chkIncludeTemplate.Checked,
                Fields           = inputFields.Value,
                IncludeLinkedIds = chkIncludeLinkedIds.Checked,
                IncludeRaw       = chkIncludeRawHtml.Checked,
                Workflow         = chkWorkflowName.Checked,
                WorkflowState    = chkWorkflowState.Checked,
                GetAllLanguages  = chkAllLanguages.Checked
            };

            var settingsObject = new ExportSettings()
            {
                Name = saveName,
                Data = settingsData
            };

            var serializer = new JavaScriptSerializer();

            var savedSettings = ReadSettingsFromFile();

            if (savedSettings == null)
            {
                var settingsList = new SettingsList();
                settingsList.Settings = new List <ExportSettings>()
                {
                    settingsObject
                };
                var settingsJson = serializer.Serialize(settingsList);
                File.WriteAllText(_settingsFilePath, settingsJson);
            }
            else
            {
                if (savedSettings.Settings.Any(x => x.Name == saveName))
                {
                    phOverwriteScript.Visible = true;
                    return;
                }

                savedSettings.Settings.Insert(0, settingsObject);
                var settingsListJson = serializer.Serialize(savedSettings);
                File.WriteAllText(_settingsFilePath, settingsListJson);
            }
            litSavedMessage.Text = "Saved!";
            SetSavedSettingsDropdown();
            ddSavedSettings.SelectedValue = saveName;
        }
示例#11
0
 public bool CanRename(string oldName, string newName)
 {
     return((oldName != AutoGenerateTemplateName) &&
            (!string.IsNullOrWhiteSpace(newName)) &&
            SettingsList.Contains(oldName) &&
            !SettingsList.Contains(newName));
 }
示例#12
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            Type[] types = typeof(DAERegister).Assembly.GetTypes();

            foreach (Type type in types)
            {
                // Node
                if (type.IsSubclassOf(typeof(InstructionNodeBase)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Schema.Object.Unqualify(type.Name)), type.AssemblyQualifiedName));
                }

                // Conveyor
                if (type.IsSubclassOf(typeof(Conveyor)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Schema.Object.Unqualify(type.Name)), type.AssemblyQualifiedName));
                }

                // DeviceOperator
                if (type.IsSubclassOf(typeof(Schema.DeviceOperator)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Schema.Object.Unqualify(type.Name)), type.AssemblyQualifiedName));
                }

                // DeviceScalarType
                if (type.IsSubclassOf(typeof(Schema.DeviceScalarType)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Schema.Object.Unqualify(type.Name)), type.AssemblyQualifiedName));
                }
            }

            return(classes);
        }
示例#13
0
 public void SaveConfigFile(string configText, string templateName = null)
 {
     File.WriteAllText(CurrentConfigFilePath, configText);
     if (templateName != null && !SettingsList.Contains(templateName))
     {
         SettingsList.Add(templateName);
     }
 }
示例#14
0
        /// <summary>
        /// removes the specified setting type from the SettingsCollection
        /// </summary>
        /// <typeparam name="TSetting">the settings type that is to be removed</typeparam>
        public SettingsCollection Remove <TSetting>(TSetting setting)
            where TSetting : ISetting
        {
            var settingType = setting.GetType();

            SettingsList.RemoveAll(s => s.GetType().IsAssignableFrom(settingType));
            return(this);
        }
示例#15
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            classes.Add(new SettingsItem("Alphora.Dataphor.DAE.Connection.DataDirect.Oracle.OracleConnection,Alphora.Dataphor.DAE.Connection.DataDirect.Oracle", typeof(OracleConnection).AssemblyQualifiedName));

            return(classes);
        }
示例#16
0
 /// <summary>
 /// Add the main volume setting
 /// </summary>
 public AudioSettings()
 {
     ClassName = "Audio";
     SettingsList.Add(new Setting("Main Volume", "mainvol", 1f, typeof(float)));
     //SettingsList.Add(new Setting("Music Volume", "musicvol", "", typeof(float)));
     //SettingsList.Add(new Setting("Dialogue Volume", "dialvol", "", typeof(float)));
     //SettingsList.Add(new Setting("Effects Volume", "efxvol", "", typeof(float)));
 }
示例#17
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "OracleConnection"), typeof(OracleConnection).AssemblyQualifiedName));

            return(classes);
        }
示例#18
0
 private static void CheckSettingsList <TItem>(SettingsList <TItem> target, SettingsList <TItem> copy)
     where TItem : IKeyContainer <string>, IXmlSerializable
 {
     Assert.AreEqual(target.Count, copy.Count);
     for (int i = 0; i < target.Count; i++)
     {
         AssertEx.Cloned(target[i], copy[i]);
     }
 }
示例#19
0
    /// <summary>
    /// Checks all setting keys, if are enabled in actual scope.
    /// If no settings are specified, true is returned.
    /// </summary>
    /// <returns>If no settings are specified, true is returned, otherwise all settings have to be true in actual scope.</returns>
    private bool IsModuleEnabledBySettingKeys()
    {
        if (AtLeastOne)
        {
            return(SettingsList.Any(key => IsSettingEnabledInActualScope(key)));
        }

        return(!SettingsList.Exists(key => !IsSettingEnabledInActualScope(key)));
    }
示例#20
0
        public void RemoveConfigFile(string name)
        {
            SettingsList.Remove(name);
            var path = MakeCurrentConfigFilePath(name);

            if (File.Exists(path))
            {
                File.Delete(path);
            }
        }
示例#21
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "MSSQLConnection"), typeof(MSSQLConnection).AssemblyQualifiedName));
            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "OLEDBConnection"), typeof(OLEDBConnection).AssemblyQualifiedName));
            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "SQLCEConnection"), typeof(SQLCEConnection).AssemblyQualifiedName));
            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "ClearAllPoolsNode"), typeof(ClearAllPoolsNode).AssemblyQualifiedName));

            return(classes);
        }
示例#22
0
        public SettingsViewModel()
        {
            SettingsList.Add(new ColorSettingsViewModel(GlobalSettings.GlobalSettings.ColorSettings));
            SettingsList.Add(new UnitSettingsViewModel(GlobalSettings.GlobalSettings.UnitSettings));
            SettingsList.Add(new FrameRateSettingsViewModel(GlobalSettings.GlobalSettings.FrameRateSettings));

            foreach (BaseSettingsViewModel viewModel in SettingsList)
            {
                viewModel.LoadSettings(null, null);
            }
        }
示例#23
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            Type[] types = typeof(DAERegister).Assembly.GetTypes();

            foreach (Type type in types)
            {
                // Nodes
                if (type.IsSubclassOf(typeof(PlanNode)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Schema.Object.Unqualify(type.Name)), type.AssemblyQualifiedName));
                }

                // Devices
//				if (LType.IsSubclassOf(typeof(Schema.Device)))
//					LClasses.Add(new SettingsItem(String.Format("{0}.{1}", CD4ClassDefinitionNameSpace, Schema.Object.Unqualify(LType.Name)), LType.AssemblyQualifiedName));
//
//				// Conveyors
//				if (LType.IsSubclassOf(typeof(Conveyor)))
//					LClasses.Add(new SettingsItem(String.Format("{0}.{1}", CD4ClassDefinitionNameSpace, Schema.Object.Unqualify(LType.Name)), LType.AssemblyQualifiedName));
//
//				// DeviceOperator
//				if (LType.IsSubclassOf(typeof(Schema.DeviceOperator)))
//					LClasses.Add(new SettingsItem(String.Format("{0}.{1}", CD4ClassDefinitionNameSpace, Schema.Object.Unqualify(LType.Name)), LType.AssemblyQualifiedName));
//
//				// DeviceScalarType
//				if (LType.IsSubclassOf(typeof(Schema.DeviceScalarType)))
//					LClasses.Add(new SettingsItem(String.Format("{0}.{1}", CD4ClassDefinitionNameSpace, Schema.Object.Unqualify(LType.Name)), LType.AssemblyQualifiedName));
            }

            classes.Add(new SettingsItem("Newtonsoft.Json.Linq.JObject", typeof(JObject).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.JSONObjectConveyor", typeof(JSONObjectConveyor).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicEqualNode", typeof(DynamicEqualNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicSelectorNode", typeof(DynamicSelectorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicContentSelectorNode", typeof(DynamicContentSelectorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicContentReadAccessorNode", typeof(DynamicContentReadAccessorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicContentWriteAccessorNode", typeof(DynamicContentWriteAccessorNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicGetNode", typeof(DynamicGetNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicGetTypeNode", typeof(DynamicGetTypeNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicSetNode", typeof(DynamicSetNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToListNode", typeof(DynamicToListNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToBooleanNode", typeof(DynamicToBooleanNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToByteNode", typeof(DynamicToByteNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToShortNode", typeof(DynamicToShortNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToIntegerNode", typeof(DynamicToIntegerNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToLongNode", typeof(DynamicToLongNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToStringNode", typeof(DynamicToStringNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToDecimalNode", typeof(DynamicToDecimalNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToTimeSpanNode", typeof(DynamicToTimeSpanNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("FHIR.Core.DynamicToDateTimeNode", typeof(DynamicToDateTimeNode).AssemblyQualifiedName));

            return(classes);
        }
示例#24
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "DocOperator"), typeof(DocOperator).AssemblyQualifiedName));
            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "DocLibrary"), typeof(DocLibrary).AssemblyQualifiedName));
            // register ObjectMetaDataNode for testing/proof of concept, todo: move to System later
            classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, "ObjectMetaDataNode"), typeof(ObjectMetaDataNode).AssemblyQualifiedName));

            return(classes);
        }
示例#25
0
        public bool LoadSettings()
        {
            SettingsList.Clear();

            // Loads in the config in XML format
            try
            {
                _configFile = XElement.Load(Settings.Default.ChromaConfigPath);

                if (_configFile == null)
                {
                    SettingsLoaded = false;
                    return(SettingsLoaded);
                }
            }
            catch (Exception ex)
            {
                LastError = ex.ToString();
                Hs.Instance._log.LogException("Error Loading Chroma Config", ex);
                SettingsLoaded = false;
                return(SettingsLoaded);
            }

            // Parses out the XML doc into settings
            try
            {
                foreach (var setting in _configFile.Descendants("setting"))
                {
                    if (setting.Attribute("name") == null)
                    {
                        continue;
                    }

                    var name = setting.Attribute("name")?.Value;
                    var val  = setting.Value;

                    SettingsList.Add(new ChromaSetting()
                    {
                        SettingName = name, SettingValue = val
                    });
                }

                SettingsLoaded = true;
            }
            catch (Exception ex)
            {
                LastError = ex.ToString();
                Hs.Instance._log.LogException("Error Parsing Chroma Config", ex);
                return(false);
            }

            return(true);
        }
        private void LoadSettingsSave()
        {
            string modSettingsFile = Helper.CombinePaths(modsFolderFilePath, "Config", "Mod Settings", ID, "settings.json");

            if (File.Exists(modSettingsFile))
            {
                string       jsonContent = File.ReadAllText(modSettingsFile);
                SettingsList list        = JsonConvert.DeserializeObject <SettingsList>(jsonContent);
                showBoltSizeSetting.Value  = list.settings[0].Value;
                ignoreUpdatesSetting.Value = list.settings[1].Value;
            }
        }
        public static void SetUpdateDate(string name, DateTime newUpdateDate)
        {
            SettingsList.FirstOrDefault(s => s.Name == name).LastUpdateDate = newUpdateDate;
            var settings = SettingsList;

            // serialize JSON directly to a file again
            using (StreamWriter file = File.CreateText($@"{Environment.CurrentDirectory}\IntegrationSettings.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, SettingsList);
            }
        }
示例#28
0
        private void SelectedIndexChangedEvent(ComboBox combo,
                                               SettingsList <StaticMod> listSettingsMods, IList <ExplicitMod> listExplicitMods,
                                               IList <ComboBox> listCombo, IList <int> listSelectedIndex, int indexAA,
                                               bool selectEither)
        {
            int selectedIndexLast = listSelectedIndex[indexAA];

            if (AddItemSelected(combo))
            {
                StaticMod itemNew = listSettingsMods.NewItem(this, null, null);
                if (!Equals(itemNew, null))
                {
                    listSettingsMods.Add(itemNew);
                    string itemAdd = (string)combo.SelectedItem;
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, itemNew.GetKey(),
                              selectEither);
                    // If the selection was not successfully set to the new modification,
                    // return to the previous selection.
                    if (Equals(combo.SelectedItem, itemAdd))
                    {
                        combo.SelectedIndex = selectedIndexLast;
                    }
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            else if (EditListSelected(combo))
            {
                IEnumerable <StaticMod> listNew = listSettingsMods.EditList(this, null);
                if (listNew != null)
                {
                    listSettingsMods.Clear();
                    listSettingsMods.AddRange(listNew);

                    string selectedItemLast = null;
                    if (selectedIndexLast != -1)
                    {
                        selectedItemLast = combo.Items[selectedIndexLast].ToString();
                    }
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, selectedItemLast,
                              selectEither);
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            listSelectedIndex[indexAA] = combo.SelectedIndex;
        }
示例#29
0
        public static SettingsList GetClasses()
        {
            SettingsList classes = new SettingsList();

            Type[] types = typeof(Authority).Assembly.GetTypes();

            foreach (Type type in types)
            {
                if (type.IsClass)
                {
                    classes.Add(new SettingsItem(type.FullName, type.AssemblyQualifiedName));
                }
            }

            classes.Add(new SettingsItem("PHINVADS.Core.GenerateTypesNode", typeof(GenerateTypesNode).AssemblyQualifiedName));


            //classes.Add(new SettingsItem("FHIR.Core.FHIRObjectConveyor", typeof(FHIRObjectConveyor).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.GenerateTypesNode", typeof(GenerateTypesNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.FHIRAsJSONSelectorNode", typeof(FHIRAsJSONSelectorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.FHIRAsJSONReadAccessorNode", typeof(FHIRAsJSONReadAccessorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.FHIRAsJSONWriteAccessorNode", typeof(FHIRAsJSONWriteAccessorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.FHIRAsXMLSelectorNode", typeof(FHIRAsXMLSelectorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.FHIRAsXMLReadAccessorNode", typeof(FHIRAsXMLReadAccessorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.FHIRAsXMLWriteAccessorNode", typeof(FHIRAsXMLWriteAccessorNode).AssemblyQualifiedName));

            classes.Add(new SettingsItem("PHINVADS.Core.SatisfiesSearchParamNode", typeof(SatisfiesSearchParamNode).AssemblyQualifiedName));
            classes.Add(new SettingsItem("PHINVADS.Core.CurrentNode", typeof(NilaryCurrentNode).AssemblyQualifiedName));

            //classes.Add(new SettingsItem("Newtonsoft.Json.Linq.JObject", typeof(JObject).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.JSONObjectConveyor", typeof(JSONObjectConveyor).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicEqualNode", typeof(DynamicEqualNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicSelectorNode", typeof(DynamicSelectorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicContentSelectorNode", typeof(DynamicContentSelectorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicContentReadAccessorNode", typeof(DynamicContentReadAccessorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicContentWriteAccessorNode", typeof(DynamicContentWriteAccessorNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicGetNode", typeof(DynamicGetNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicGetTypeNode", typeof(DynamicGetTypeNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicSetNode", typeof(DynamicSetNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToListNode", typeof(DynamicToListNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToBooleanNode", typeof(DynamicToBooleanNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToByteNode", typeof(DynamicToByteNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToShortNode", typeof(DynamicToShortNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToIntegerNode", typeof(DynamicToIntegerNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToLongNode", typeof(DynamicToLongNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToStringNode", typeof(DynamicToStringNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToDecimalNode", typeof(DynamicToDecimalNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToTimeSpanNode", typeof(DynamicToTimeSpanNode).AssemblyQualifiedName));
            //classes.Add(new SettingsItem("FHIR.Core.DynamicToDateTimeNode", typeof(DynamicToDateTimeNode).AssemblyQualifiedName));

            return(classes);
        }
示例#30
0
        public void LoadSettings()
        {
            try
            {
                Proxies.AppClient AppClient = new Proxies.AppClient();

                var query = AppClient.LoadSettings();

                SettingsType SettingXML = new SettingsType();
                SettingXML.Code  = "APP";
                SettingXML.Value = query;
                string UnparsedXML = (string)SettingXML.Value;

                if (UnparsedXML != "<>")
                {
                    XDocument SettingsXML = XDocument.Parse(UnparsedXML);
                    Type      T           = this.GetType();

                    var settings = from rs in SettingsXML.Descendants()
                                   select new
                    {
                        objectvalue = rs.Value,
                        code        = rs.Name
                    };

                    foreach (var item in settings)
                    {
                        SettingsList.Add(new SettingsType {
                            Code = item.code.ToString(), Value = item.objectvalue
                        });

                        PropertyInfo PropToAssign = T.GetProperty(item.code.ToString());

                        if (PropToAssign != null)
                        {
                            PropToAssign.SetValue(this, item.objectvalue);
                        }
                    }
                }
                else
                {
                    var firsttime = new Stocky.Views.FirstTimeView();
                    firsttime.ShowDialog();
                }
            }


            catch (Exception)
            {
                throw;
            }
        }
示例#31
0
        public PublishDocumentDlg(IDocumentUIContainer docContainer, SettingsList<Server> servers, string fileName)
        {
            IsLoaded = false;
            InitializeComponent();
            Icon = Resources.Skyline;

            _docContainer = docContainer;

            _panoramaServers = servers;
            tbFilePath.Text = FileEx.GetTimeStampedFileName(fileName);

            treeViewFolders.ImageList = new ImageList();
            treeViewFolders.ImageList.Images.Add(Resources.Panorama);
            treeViewFolders.ImageList.Images.Add(Resources.LabKey);
            treeViewFolders.ImageList.Images.Add(Resources.ChromLib);
            treeViewFolders.ImageList.Images.Add(Resources.Folder);

            ServerTreeStateRestorer = new TreeViewStateRestorer(treeViewFolders);
        }
 public SettingsConfigurationLoader(SettingsList predefinedSettings, IContext context)
     : base(context)
 {
     _predefinedSettings = predefinedSettings;
 }
        protected ISettingsList LoadSectionSettings(XElement sectionElement)
        {
            SettingsList settings = new SettingsList();

            XNamespace sectionNamespace = sectionElement.GetDefaultNamespace();
            var settingsList = from settingNode in sectionElement.Descendants(sectionNamespace + "setting")
                               select CreateSetting(settingNode);

            foreach (var setting in settingsList)
            {
                settings.Add(setting);
            }

            return settings;
        }
示例#34
0
        private void SelectedIndexChangedEvent(ComboBox combo,
            SettingsList<StaticMod> listSettingsMods, IList<ExplicitMod> listExplicitMods,
            IList<ComboBox> listCombo, IList<int> listSelectedIndex, int indexAA,
            bool selectEither)
        {
            int selectedIndexLast = listSelectedIndex[indexAA];
            if (AddItemSelected(combo))
            {
                StaticMod itemNew = listSettingsMods.NewItem(this, null, null);
                if (!Equals(itemNew, null))
                {
                    listSettingsMods.Add(itemNew);
                    string itemAdd = (string) combo.SelectedItem;
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, itemNew.GetKey(),
                        selectEither);
                    // If the selection was not successfully set to the new modification,
                    // return to the previous selection.
                    if (Equals(combo.SelectedItem, itemAdd))
                        combo.SelectedIndex = selectedIndexLast;
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            else if (EditListSelected(combo))
            {
                IEnumerable<StaticMod> listNew = listSettingsMods.EditList(this, null);
                if (listNew != null)
                {
                    listSettingsMods.Clear();
                    listSettingsMods.AddRange(listNew);

                    string selectedItemLast = null;
                    if (selectedIndexLast != -1)
                        selectedItemLast = combo.Items[selectedIndexLast].ToString();
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, selectedItemLast,
                        selectEither);
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            listSelectedIndex[indexAA] = combo.SelectedIndex;
        }
 public SettingsConfigurationLoader(SettingsList predefinedSettings)
     : this(predefinedSettings, NullContext.Instance) { }