private void RestoreSettings() { //Restores settings from the previous session. (angles, fixed decimals). Output window text is still in progress. _Settings.Angle1 = Convert.ToDecimal(Properties.Settings.Default.Angle1); _Settings.Angle2 = Convert.ToDecimal(Properties.Settings.Default.Angle2); _Settings.Angle3 = Convert.ToDecimal(Properties.Settings.Default.Angle3); _Settings.Angle4 = Convert.ToDecimal(Properties.Settings.Default.Angle4); _Settings.CurrentAngle = Convert.ToDecimal(Properties.Settings.Default.CurrentAngle); _Settings.FixedDecimals = Convert.ToString(Properties.Settings.Default.FixedDecimal); _Settings.HaveSeenTrayIconInstructions = Convert.ToBoolean(Properties.Settings.Default.HaveSeenTrayIconInstructions); StringCollection stringCollection = new StringCollection(); stringCollection = Properties.Settings.Default.OutputWindowStringCollection; List <string> stringList = new List <string>(); stringList = stringCollection.Cast <string>().ToList(); foreach (var item in stringList) { _OutputWindowList.Add(Convert.ToDecimal(item)); } Angle1Label.Text = Convert.ToString(Math.Round(_Settings.Angle1, 4)); Angle2Label.Text = Convert.ToString(Math.Round(_Settings.Angle2, 4)); Angle3Label.Text = Convert.ToString(Math.Round(_Settings.Angle3, 4)); Angle4Label.Text = Convert.ToString(Math.Round(_Settings.Angle4, 4)); RoundingNumberPicker.Value = Convert.ToDecimal(_Settings.FixedDecimals.Substring(1)); OutputWindowStringBuilder(); }
private void listViewList_KeyDown(object sender, KeyEventArgs e) { // Deleteキーが押されたら項目を削除 if (e.KeyData == Keys.Delete || e.KeyData == Keys.Back || (e.KeyCode == Keys.X && e.Control)) { removeSelectedItem(); } if (e.KeyCode == Keys.Enter) { playSelectedItem(); } if (e.KeyCode == Keys.A && e.Control) { try { listViewList.BeginUpdate(); foreach (ListViewItem item in listViewList.Items) { item.Selected = true; } } finally { listViewList.EndUpdate(); } } if (e.KeyCode == Keys.V && e.Control) { System.Collections.Specialized.StringCollection files = Clipboard.GetFileDropList(); if (files != null) { ListViewItem lvi = null; try { listViewList.BeginUpdate(); listViewList.SelectedItems.Clear(); lvi = addAllFiles(files.Cast <string>().ToArray(), lvi); } finally { listViewList.EndUpdate(); lvi?.EnsureVisible(); } } } }
public static void StringCollection2List() { StringCollection stringCollection = new StringCollection(); stringCollection.Add("String 1"); stringCollection.Add("String 2"); stringCollection.Add("String 3"); Console.WriteLine("*** StringCollection:"); foreach (String s in stringCollection) { Console.WriteLine(s); } List<String> stringList = stringCollection.Cast<String>().ToList(); Console.WriteLine("*** List<String>:"); foreach (String s in stringList) { Console.WriteLine(s); } }
private void StripElementAttributes(params string[] attributeNames) { StringCollection selectors = new StringCollection(); foreach (string attribute in attributeNames) { selectors.Add(String.Format("*[{0}]", attribute)); } CQ elementsWithAttributes = _document.Find(String.Join(",", selectors.Cast<string>().ToList())); foreach (var item in elementsWithAttributes) { foreach (string attribute in attributeNames) { item.RemoveAttribute(attribute); } } }
/// <summary> /// Parses the wurfl file into a instance of WurflFile. /// </summary> /// <param name="devices">Instance of Devices to store data.</param> /// <param name="wurflFilePath">Wurfl file path.</param> /// <param name="capabilitiesWhiteList">List of capabilities to be used. If none, all capabilities will be loaded into the memory.</param> /// <param name="wurflPatchFiles">Null, string or array of strings representing the wurfl patch files /// which must be applied against the main file.</param> /// <returns>Returns an instance of WurflFile. /// <remarks>If none file is found a null value will be returned.</remarks> /// </returns> /// <exception cref="System.IO.FileNotFoundException">Thrown if the parameter <paramref name="wurflFilePath"/> /// referes to a file that does not exists.</exception> /// <exception cref="System.ArgumentNullException">Thrown if the parameter <paramref name="wurflFilePath"/> /// is an empty string or a null value.</exception> private static void ParseWurflFiles( Provider devices, string wurflFilePath, StringCollection capabilitiesWhiteList, params string[] wurflPatchFiles) { if (string.IsNullOrEmpty(wurflFilePath)) throw new ArgumentNullException("wurflFilePath"); if (!File.Exists(wurflFilePath)) throw new FileNotFoundException(Constants.WurflFileNotFound, wurflFilePath); // Load white listed capabilities if (capabilitiesWhiteList != null) { _loadOnlyCapabilitiesWhiteListed = capabilitiesWhiteList.Count > 0; #if VER4 foreach (string capability in capabilitiesWhiteList.Cast<string>().Where(capability => !_capabilitiesWhiteListed.Contains(capability))) { _capabilitiesWhiteListed.Add(capability); } #elif VER2 foreach (string capability in capabilitiesWhiteList) if (!_capabilitiesWhiteListed.Contains(capability)) _capabilitiesWhiteListed.Add(capability); #endif } StringCollection wurflFilePaths = new StringCollection(); wurflFilePaths.Add(wurflFilePath); wurflFilePaths.AddRange(wurflPatchFiles); ParseWurflFiles(devices, wurflFilePaths, File.GetCreationTimeUtc(wurflFilePath)); }
protected void AddQuery(string fieldName, BoolQuery<ESDocument> query, StringCollection filter) { fieldName = fieldName.ToLower(); if (filter.Count > 0) { if (filter.Count == 1) { if (!String.IsNullOrEmpty(filter[0])) { AddQuery(fieldName, query, filter[0].ToLower()); } } else { var booleanQuery = new BoolQuery<ESDocument>(); var containsFilter = false; foreach (var index in filter.Cast<string>().Where(index => !String.IsNullOrEmpty(index))) { booleanQuery.Should(q => q.Custom("{{\"wildcard\" : {{ \"{0}\" : \"{1}\" }}}}", fieldName.ToLower(), index.ToLower())); containsFilter = true; } if (containsFilter) query.Must(q => q.Bool(b => booleanQuery)); } } }
public static string FromCollection(StringCollection collection) { return string.Join(Environment.NewLine, collection.Cast<string>().ToArray()); }
private static IEnumerable<string> TransformScript(StringCollection script) { Trace.WriteLine(script.Cast<string>().Aggregate((s1, s2) => s1 + Environment.NewLine + s2)); return script.Cast<string>() .Where(c => !c.StartsWith("USE ", StringComparison.OrdinalIgnoreCase)) .Select(c => { // some SMO statements are prefixed with a comment like: /**** bla bla ****/\r\n string endOfComment = "*/" + Environment.NewLine; int endOfCommentIndex = c.IndexOf(endOfComment, StringComparison.OrdinalIgnoreCase); if (endOfCommentIndex > 0) { return c.Substring(endOfCommentIndex + endOfComment.Length); } return c; }); }