public virtual void AddChildSection(SectionSettings parentSection, SectionSettings section) { // // Make sure this section doesn't already exist // // // Add section to tree // SectionTreeNode treeNode = new SectionTreeNode(section); if (parentSection == null) { // // Add to the root // sectionTree.Nodes.Add(treeNode); } else { // // Add to the parent node // SectionTreeNode parentTreeNode = (SectionTreeNode)settingSections[parentSection.Text]; parentTreeNode.Nodes.Add(treeNode); } settingSections.Add(section.Text, treeNode); //treeNode.EnsureVisible(); }
/// <summary> /// Adds a settings object from a section in configuration /// </summary> /// <typeparam name="T">The type of settings object to create</typeparam> /// <param name="encryptionKey">The encryption key used for encrypting and serializing the settings object</param> /// <param name="sectionName">The name of the section in config</param> public void AddSettingsFromConfig <TSettings, TSection>(string encryptionKey, string sectionName) where TSettings : IConfigurableSettings <TSection>, new() where TSection : ConfigurationSection { // get the section from config TSection section = (TSection)ConfigurationManager.GetSection(sectionName); // if the section exists... if (section != null) { // create a new settings object TSettings settings = new TSettings(); // populate the object from the section settings.PopulateFromConfigurationSection(section); // create new settings data object, with the new settings object serialized SectionSettings.Add(new ConfigurableSettingsData() { Name = sectionName, TypeAssemblyQualifiedName = typeof(TSettings).AssemblyQualifiedName, TypeFullName = typeof(TSettings).FullName, SerializedData = DataContractUtility.Serialize(typeof(TSettings), settings, encryptionKey) }); } }
public override void OnSectionActivated() { // // Clear any existing entries // sharesListBox.Items.Clear(); // // Load picture shares // SectionSettings section = GetSection("Picture Folders"); if (section != null) { ArrayList shares = (ArrayList)section.GetSetting("shares"); foreach (string share in shares) { // // Add to share to list box and default to selected // sharesListBox.Items.Add(share, CheckState.Checked); } } UpdateControlStatus(); }
public IDictionary <string, string> GetActivitySettings(string section) { if (!SectionSettings.ContainsKey(section)) { return(new Dictionary <string, string>()); } return(SectionSettings[section]); }
static void DeleteFiles(SectionSettings settings, string rootOutputDirectory) { string path = Path.Combine(rootOutputDirectory, settings.Path); foreach (string file in Directory.GetFiles(path)) { string fileName = Path.GetFileName(file); if (!file.EndsWith(".Extension.cs") && (settings.FixedFiles == null || Array.IndexOf(settings.FixedFiles, fileName) < 0)) { File.Delete(file); } } }
public SettingsController() { GlobalSettings g = new GlobalSettings(); SectionSettings s = new SectionSettings("Sports"); UserSettings u = new UserSettings("User1"); GuestSettings gu = new GuestSettings(); readableSettings.Add(g); readableSettings.Add(s); readableSettings.Add(u); readableSettings.Add(gu); writableSettings.Add(g); writableSettings.Add(s); writableSettings.Add(u); }
public void ShouldBeProperlyInitialized() { // Arrange var sut = new SectionSettings(); // Assert using (new AssertionScope()) { sut.Center.Should().BeNull(); sut.FontName.Should().BeNull(); sut.FontSize.Should().BeNull(); sut.HtmlUrl.Should().BeNull(); sut.Left.Should().BeNull(); sut.Line.Should().BeNull(); sut.Right.Should().BeNull(); sut.Spacing.Should().BeNull(); } }
private void DrawSectionSettings(SectionSettings settings, int index) { data.SetSectionName(EditorGUILayout.TextField("Section name", settings.name), index); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label("Cost to section"); GUILayout.Space(15); GUILayout.Label("Cost weight"); GUILayout.Space(40); GUILayout.EndHorizontal(); for (int i = 0; i < settings.sectionInfos.Count; i++) { GUILayout.BeginHorizontal(); settings.SetSectionIndex( i, EditorGUILayout.Popup(settings.sectionInfos[i].GetIndex() - 1, sectionsNames.ToArray()) + 1 ); GUILayout.Space(15); settings.SetSectionWeight( i, EditorGUILayout.FloatField(settings.sectionInfos[i].GetWeight()) ); if (GUILayout.Button("X", GUILayout.Width(25))) { settings.sectionInfos.RemoveAt(i); i--; } GUILayout.EndHorizontal(); } if (GUILayout.Button("Add section info", GUILayout.MaxWidth(200))) { settings.AddNewSectionInfo(data.sectionSettings.Count); } }
public override void OnSectionActivated() { // // Disable the complete Page, when the Music Player is not the BASS engine // SectionSettings section = GetSection("Music"); if (section != null) { string player = (string)section.GetSetting("audioPlayer"); if (player.IndexOf("BASS") == -1) { this.Enabled = false; MessageBox.Show(this, "ASIO is only available with the BASS music player selected.", "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { this.Enabled = true; } } }
public override void OnSectionActivated() { // // Disable the complete Tab Page, when the Music Player is not the BASS engine // SectionSettings section = GetSection("Music"); if (section != null) { string player = (string)section.GetSetting("audioPlayer"); if (player.ToLowerInvariant().IndexOf("internal dshow player") > -1) { MusicDSPTabCtl.Enabled = false; MessageBox.Show(this, "DSP effects are only available with the BASS music player selected.", "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MusicDSPTabCtl.Enabled = true; } } }
private void WriteSectionSettings(string section) { var userDefinedActivitySettings = _settingsReader.GetSection($"{section}Settings"); if (userDefinedActivitySettings == null || userDefinedActivitySettings.Count == 0) { SectionSettings.Add(section, new Dictionary <string, string>()); foreach (var setting in DefaultValues[$"{section}Settings"]) { _settingsReader.WriteSetting($"{section}Settings", setting.Key, setting.Value.ToString()); SectionSettings[section].Add(setting); } } else { SectionSettings.Add(section, new Dictionary <string, string>()); foreach (var setting in userDefinedActivitySettings) { SectionSettings[section].Add(setting); } } }
public override void OnSectionActivated() { // // Clear any existing entries // sharesListBox.Items.Clear(); // // Load selected shares // SectionSettings section = GetSection("Music Folders"); if (section != null) { sharesData = (List <BaseShares.ShareData>)section.GetSetting("sharesdata"); foreach (BaseShares.ShareData share in sharesData) { // // Add to share to list box and select them based on the settings // sharesListBox.Items.Add(share.Folder, share.ScanShare); } } // // Fetch extensions // section = GetSection("Music Extensions"); if (section != null) { string extensions = (string)section.GetSetting("extensions"); Extensions = extensions.Split(new char[] { ',' }); } UpdateControlStatus(); }
public void ShouldAllowToSetValues() { // Arrange var center = _fixture.Create <string>(); var fontName = _fixture.Create <string>(); var fontSize = _fixture.Create <int>(); var htmlUrl = _fixture.Create <string>(); var left = _fixture.Create <string>(); var line = _fixture.Create <bool>(); var right = _fixture.Create <string>(); var spacing = _fixture.Create <double>(); // Act var sut = new SectionSettings { Center = center, FontName = fontName, FontSize = fontSize, HtmlUrl = htmlUrl, Left = left, Line = line, Right = right, Spacing = spacing, }; // Assert using (new AssertionScope()) { sut.Center.Should().Be(center); sut.FontName.Should().Be(fontName); sut.FontSize.Should().Be(fontSize); sut.HtmlUrl.Should().Be(htmlUrl); sut.Left.Should().Be(left); sut.Line.Should().Be(line); sut.Right.Should().Be(right); sut.Spacing.Should().Be(spacing); } }
private void useASIOCheckBox_CheckedChanged(object sender, EventArgs e) { asioDeviceComboBox.Items.Clear(); asioDeviceComboBox.Enabled = useASIOCheckBox.Checked; if (useASIOCheckBox.Checked) { // We must not have checked the "Upmixing" checkbox in the Music setting the same time SectionSettings section = GetSection("Music"); if (section != null) { bool mixing = (bool)section.GetSetting("mixing"); if (mixing) { useASIOCheckBox.Checked = false; MessageBox.Show(this, "ASIO and Upmixing (in the Music Tab) must not be used at the same time", "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // Get all available ASIO devices and add them to the combo box BASS_ASIO_DEVICEINFO[] asioDevices = BassAsio.BASS_ASIO_GetDeviceInfos(); if (asioDevices.Length == 0) { MessageBox.Show(this, "No ASIO Devices available in the system.", "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); asioDeviceComboBox.Enabled = false; btSettings.Enabled = false; useASIOCheckBox.Checked = false; } else { asioDeviceComboBox.Items.AddRange(asioDevices); asioDeviceComboBox.SelectedIndex = 0; btSettings.Enabled = true; } } }
public void fEvacLevel() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Document acDoc = acApp.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Utils.Layers.fFilterFdsObstEvacLayers(); // Get Z-min level PromptDoubleResult zMinLevel; PromptDoubleOptions zMinLevelO = new PromptDoubleOptions("\nEnter Z-min level"); zMinLevelO.DefaultValue = zMinOld; zMinLevel = ed.GetDouble(zMinLevelO); if (zMinLevel.Status != PromptStatus.OK) { Utils.Utils.End(); return; } else { zMinOld = zMinLevel.Value; } Extents3d boundingBox = Utils.Utils.GetAllElementsBoundingBox(); double yHalf = (boundingBox.MaxPoint.Y - boundingBox.MinPoint.Y) / 2; Point3dCollection pts = new Point3dCollection { new Point3d(boundingBox.MinPoint.X - 1, boundingBox.MinPoint.Y + yHalf, zMinLevel.Value), new Point3d(boundingBox.MaxPoint.X + 1, boundingBox.MinPoint.Y + yHalf, zMinLevel.Value) }; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { // Open the Block table record for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; SectionType st = SectionType.LiveSection; try { // Now let's create our section Section sec = new Section(pts, Vector3d.YAxis, Vector3d.ZAxis); sec.State = SectionState.Volume; // The section must be added to the drawing ObjectId secId = acBlkTblRec.AppendEntity(sec); acTrans.AddNewlyCreatedDBObject(sec, true); // Set up some of its direct properties sec.SetHeight(SectionHeight.HeightAboveSectionLine, yHalf + 1); sec.SetHeight(SectionHeight.HeightBelowSectionLine, yHalf + 1); // ... and then its settings SectionSettings ss = (SectionSettings)acTrans.GetObject(sec.Settings, OpenMode.ForWrite); // Set our section type ss.CurrentSectionType = st; // We only set one additional option if "Live" sec.IsLiveSectionEnabled = true; acTrans.Commit(); } catch (System.Exception ex) { ed.WriteMessage("\nException: " + ex.Message); } } }
public virtual void AddSection(SectionSettings section) { AddChildSection(null, section); }
public virtual bool ActivateSection(SectionSettings section) { return(true); }