public void SetAGCMode(bool AgcEnable, bool digitalGainEnable) { int agcModeValue = AgcEnable ? 1 : 0; int digitalGainValue = digitalGainEnable ? 1 : 0; var nameValues = new NameObjectCollection(); nameValues.Add(_AgcMode, agcModeValue); nameValues.Add(_DigitalGain, digitalGainValue); string uri = BuildUri(nameValues); SetCameraProperty(uri); }
public void NameObjectCollection_Constructor_Default_UsesKeyComparer() { NameObjectCollection<int> collection = new NameObjectCollection<int>(StringComparer.OrdinalIgnoreCase); collection.Add("test", 42); Assert.That(collection.Get("TEST"), Is.EqualTo(42)); }
public void GetResourcePath_WithInvalidTypeInVariable() { _variables.Add("InvalidType", 1); var resourceObject = new ResourceObjectWithVarRef(new WxeVariableReference("InvalidType")); resourceObject.GetResourcePath(_variables); }
private static NameObjectCollection ParseCameraProperties(System.IO.Stream replyStream) { var nameValues = new NameObjectCollection(); using (StreamReader rdr = new StreamReader(replyStream)) { while (true) { var line = rdr.ReadLine(); if (line == null)//end of stream { break; } if (ShouldSkip(line)) { continue; } try { var keyValue = ParseSemicommaSplittedLine(line); if (!nameValues.ContainsKey(keyValue.Key)) { nameValues.Add(keyValue.Key, keyValue.Value); } } catch (System.ArgumentException) {} } return(nameValues); } }
public void NameObjectCollection_Add_Default_AddsTheEntry() { NameObjectCollection<int> collection = new NameObjectCollection<int>(StringComparer.Ordinal); collection.Add("test", 42); Assert.That(collection, Has.Count.EqualTo(1)); }
private void PopulateShutterLevels() { var shutterLevels = new NameObjectCollection(); shutterLevels.Add(new NameObjectPair("25", 0)); shutterLevels.Add(new NameObjectPair("50", 1)); shutterLevels.Add(new NameObjectPair("120", 2)); shutterLevels.Add(new NameObjectPair("250", 3)); shutterLevels.Add(new NameObjectPair("500", 4)); shutterLevels.Add(new NameObjectPair("1000", 5)); shutterLevels.Add(new NameObjectPair("2000", 6)); shutterLevels.Add(new NameObjectPair("4000", 7)); shutterLevels.Add(new NameObjectPair("10000", 8)); PopulateComboBox(shutterLevels, this.shutterLevel); this.shutterLevel.SelectedIndex = 0; }
void Tree_SelectionChanged(object sender, EventArgs e) { TreePath tpath = Tree.GetPath(Tree.SelectedNode); NameObjectCollection path = new NameObjectCollection(tpath.FullPath.Length); foreach (var obj in tpath.FullPath) { Entry ent = (Entry)obj; path.Add(ent != null ? ent.InternalName : null, ent); } pathDisplay.SetPath(path); }
public void SetShutter(ShutterMode mode, int speedLevel) { int modeValue = 0; string speedPropertyName = null; switch (mode) { case ShutterMode.Off: modeValue = 0; speedPropertyName = "dummy"; break; case ShutterMode.Short: modeValue = 1; speedPropertyName = _ShutterShortSpeedLevel; break; case ShutterMode.Long: modeValue = 2; speedPropertyName = _ShutterLongSpeedLevel; break; default: throw new InvalidEnumArgumentException("mode"); break; } var nameValues = new NameObjectCollection(); nameValues.Add(_ShutterMode, modeValue); nameValues.Add(speedPropertyName, speedLevel); string uri = BuildUri(nameValues); SetCameraProperty(uri); }
/// <summary> Sorts the <paramref name="menuItems"/> by their categories." </summary> /// <param name="menuItems"> Must not be <see langword="null"/> or contain items that are <see langword="null"/>. </param> /// <param name="generateSeparators"> <see langword="true"/> to generate a separator before starting a new category. </param> /// <returns> The <paramref name="menuItems"/>, sorted by their categories. </returns> public static WebMenuItem[] GroupMenuItems(WebMenuItem[] menuItems, bool generateSeparators) { ArgumentUtility.CheckNotNullOrItemsNull("menuItems", menuItems); // <string category, ArrayList menuItems> NameObjectCollection groupedMenuItems = new NameObjectCollection(); ArrayList categories = new ArrayList(); for (int i = 0; i < menuItems.Length; i++) { WebMenuItem menuItem = menuItems[i]; string category = menuItem.Category ?? string.Empty; ArrayList menuItemsForCategory; if (groupedMenuItems.Contains(category)) { menuItemsForCategory = (ArrayList)groupedMenuItems[category]; } else { menuItemsForCategory = new ArrayList(); groupedMenuItems.Add(category, menuItemsForCategory); categories.Add(category); } menuItemsForCategory.Add(menuItem); } ArrayList arrayList = new ArrayList(); bool isFirst = true; for (int i = 0; i < categories.Count; i++) { string category = (string)categories[i]; if (generateSeparators) { if (isFirst) { isFirst = false; } else { arrayList.Add(WebMenuItem.GetSeparator()); } } arrayList.AddRange((ArrayList)groupedMenuItems[category]); } return((WebMenuItem[])arrayList.ToArray(typeof(WebMenuItem))); }
public void UpdateProperty() { EnsureConnected(); var nameValues = new NameObjectCollection(); nameValues.Add("status", 1); var uri = this.BuildUri(nameValues); var reply = this.GetHttpRequest(uri, this.cookies, true); try { var properties = ParseCameraProperties(reply.GetResponseStream()); this.properties = properties; } finally { reply.Close(); } }
public void AddValues(string name, IEnumerable <object> values) { _namedValues.Add(name, values); }
private NameObjectCollection<int> GetTestCollection() { NameObjectCollection<int> collection = new NameObjectCollection<int>(StringComparer.Ordinal); collection.Add("0", 0); collection.Add("1", 1); collection.Add("test", 42); return collection; }
public override void Add(string name, object value) { _items.Add(name, value); }
public void SetIris(IrisMode mode, int level) { int irisModeValue = 0; string propertyName = null; switch (mode) { case IrisMode.Auto: irisModeValue = 0; propertyName = _IrisAutoLevel; break; case IrisMode.Manual: irisModeValue = 1; propertyName = _IrisManualLevel; break; default: throw new InvalidEnumArgumentException("mode is invalid"); break; } var nameValues = new NameObjectCollection(); nameValues.Add(_IrisMode, irisModeValue); nameValues.Add(propertyName, level); var uri = BuildUri(nameValues); SetCameraProperty(uri); }
private static NameObjectCollection ParseCameraProperties(System.IO.Stream replyStream) { var nameValues = new NameObjectCollection(); using (StreamReader rdr = new StreamReader(replyStream)) { while (true) { var line = rdr.ReadLine(); if (line == null)//end of stream { break; } if (ShouldSkip(line)) continue; try { var keyValue = ParseSemicommaSplittedLine(line); if (!nameValues.ContainsKey(keyValue.Key)) { nameValues.Add(keyValue.Key, keyValue.Value); } } catch (System.ArgumentException){} } return nameValues; } }
private void PopulateDigitalGains() { var digitalGains = new NameObjectCollection(); digitalGains.Add(new NameObjectPair("关", 0)); digitalGains.Add(new NameObjectPair("开", 1)); this.PopulateComboBox(digitalGains, this.digitalGain); }
/// <summary> /// Creates the Html element collection. /// </summary> /// <param name="htmlContent"> The HTML Content.</param> /// <param name="tagName"> The tag name.</param> /// <returns> A string value.</returns> public static NameObjectCollection CreateHtmlElement(string htmlContent, string tagName) { NameObjectCollection collection = new NameObjectCollection(); string elementValue = string.Empty; StringBuilder rex = new StringBuilder(); rex.Append(@"(?<header><(?i:"); rex.Append(tagName); rex.Append(@")[^>]*?)(>|>(?<source>[\w|\t|\r|\W]*?)</(?i:"); rex.Append(tagName); rex.Append(@")>)"); Regex getElements = new Regex(rex.ToString(), RegexOptions.None); Regex getAttributes = (Regex)regex["GetAttributes"]; // Get elements matches MatchCollection matches = getElements.Matches(htmlContent); // Example: // <input name='Username' ... // <input name='Username' ... // <input name='Password' ... // for each element for( int i=0;i<matches.Count;i++ ) { string element = matches[i].Value; #region Search for element with name // get attributes MatchCollection attributes = getAttributes.Matches(element); int j=0; foreach (Match m in attributes) { string name = m.Groups["name"].Value; string value = m.Groups["value"].Value.ToLower(System.Globalization.CultureInfo.InvariantCulture); name = name.ToLower(System.Globalization.CultureInfo.InvariantCulture); // Create Item in collection if ( name == "name" ) { if ( collection[value] != null ) { HtmlLightParserElement liteElement = (HtmlLightParserElement)collection[value]; if ( !liteElement.Contains(element) ) { liteElement.Add(element); } } else { collection.Add(value, new HtmlLightParserElement(element)); } } if ( name == "id" ) { if ( collection[value] != null ) { HtmlLightParserElement liteElement = (HtmlLightParserElement)collection[value]; if ( !liteElement.Contains(element) ) { liteElement.Add(element); } } else { collection.Add(value, new HtmlLightParserElement(element)); } } if ( collection[tagName] != null ) { HtmlLightParserElement liteElement = (HtmlLightParserElement)collection[tagName]; if ( !liteElement.Contains(element) ) { liteElement.Add(element); } } else { collection.Add(tagName, new HtmlLightParserElement(element)); } j++; } #endregion } return collection; }