public void Show() { ListView.ListViewItemCollection itemCollection = Program.Form.torrentListView.Items; if (!itemCollection.Contains(this)) { lock (Program.Form.torrentListView) { if (!itemCollection.Contains(this)) { this.UpdateUi(false); itemCollection.Add(this); } } } }
public static void UpdateDirectories(ListView.ListViewItemCollection list, string path) { DirectoryInfo di = new DirectoryInfo(path); DirectoryInfo[] directories = di.GetDirectories(); foreach (DirectoryInfo info in directories) { ListViewItem lvi = new ListViewItem(); lvi.ImageIndex = 1; lvi.Text = info.Name; lvi.Tag = "directory"; list.Add(lvi); } }
protected RegistryKey OpenSubKey(ListView.ListViewItemCollection collection, RegistryKey rk, string name, DataEntry[] de) { if (rk == null) { return(null); } RegistryKey res = rk.OpenSubKey(name); if (res == null) { collection.Add(this, "Registry key is missing.", de, new DataEntry("Key", string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", rk, name))); } return(res); }
// есть ли в списке итем с текстом CompareItemText public static bool isExistListViewItem(ListView lv, string CompareItemText) { if (lv.Items.Count > 0) { ListView.ListViewItemCollection lvicol = lv.Items; foreach (ListViewItem item in lvicol) { if (CompareItemText.Equals(item.Text)) { return(true); } } } return(false); }
public static void UpdateFiles(ListView.ListViewItemCollection list, string pat) { DirectoryInfo di = new DirectoryInfo(pat); FileInfo[] files = di.GetFiles(); foreach (FileInfo info in files) { ListViewItem lvi = new ListViewItem(); lvi.ImageIndex = 0; lvi.Text = info.Name; lvi.Tag = "file"; list.Add(lvi); } }
public static IEnumerable <ListViewItem> GetCollectionItems(ListView.ListViewItemCollection listViewItemCollection) { List <ListViewItem> listViewItems = new List <ListViewItem>(); // build the new list foreach (ListViewItem listViewItem in listViewItemCollection) { listViewItems.Add(listViewItem); } // custom sorting listViewItems.Sort(new ObjectTypeComparer()); return(listViewItems); }
/// <summary> /// 提取选择进行消息发送的微信好友 /// </summary> /// <returns></returns> string[] PickUpSelectFriend() { ListView.ListViewItemCollection datas = lstSelectFriend.Items; if (datas.Count == 0) { return(new string[0]); } List <string> select = new List <string>(); foreach (ListViewItem item in datas) { select.Add(item.Tag as string); } return(select.ToArray()); }
public SIBuilderInfo() { this.ProjectName = ""; this.Projects = null; this.OutputDir = ""; this.LogDir = ""; this.PackageScript = ""; this.PackageOutputFile = ""; this.DevenvLocation = ""; this.majorVersion = 0; this.minorVersion = 0; this.buildNumber = 0; this.LogOutputStream = null; }
public saveIconsWnd(ListView.SelectedListViewItemCollection itemList, IntPtr[] iconHandles, int size) { InitializeComponent(); items = new ListView.ListViewItemCollection(new ListView()); foreach (ListViewItem item in itemList) { items.Add((ListViewItem)item.Clone()); } iHandles = iconHandles; dimensions = size; imgFormat = new ImageFormat[6]; InitializeImageFormats(); }
private void updateDefineValues() { ListView.ListViewItemCollection zCollection = listViewDefines.Items; for (int nIdx = 0; nIdx < zCollection.Count; nIdx++) { var zItem = zCollection[nIdx]; if (CardMakerSettings.DefineTranslatePrimitiveCharacters) { zItem.SubItems[1].Text = ((string)zItem.Tag).Replace("<c>", ",").Replace("<q>", "\"").Replace("\\c", ",").Replace("\\q", "\""); } else { zItem.SubItems[1].Text = (string)zItem.Tag; } } }
private List <SaleDetail> SaleDetails(ListView.ListViewItemCollection items) { var products = new List <SaleDetail>(); foreach (ListViewItem item in items) { var product = productsService.Find(item.SubItems[0].Text); int qty = Convert.ToInt32(item.SubItems[1].Text); products.Add(new SaleDetail { ProductId = product.Id, Qty = qty }); } return(products); }
public Graphic(int[][] _table, int[] _sequence) { table = _table; sequnce = _sequence; tmp = Algorithm.matrixMethod(table); downtimes = countDowntimes(); InitializeComponent(); Color[] colors = GetColors(); ListView.ListViewItemCollection items = detailsViewBox.Items; items.Add("Простой"); items[0].BackColor = colors[0]; for (int i = 0; i < sequnce.Length; i++) { items.Add((sequnce[i] + 1).ToString() + "-я деталь").BackColor = colors[sequnce[i] + 1]; } }
private ListView.ListViewItemCollection getListViewItems(ListView lstview) { ListView.ListViewItemCollection temp = new ListView.ListViewItemCollection(new ListView()); if (!lstview.InvokeRequired) { foreach (ListViewItem item in lstview.Items) { temp.Add((ListViewItem)item.Clone()); } return(temp); } else { return((ListView.ListViewItemCollection) this.Invoke(new GetItems(getListViewItems), new object[] { lstview })); } }
private void ImportMultipleFiles(ListView.ListViewItemCollection listViewItemCollection) { foreach (ListViewItem item in listViewItemCollection) { string line; try { line = GetAllText(item.Text).Trim(); } catch { line = string.Empty; } line = line.Replace("|", Environment.NewLine); if (comboBoxLineBreak.Text.Length > 0) { foreach (string splitter in comboBoxLineBreak.Text.Split(';')) { var tempSplitter = splitter.Trim(); if (tempSplitter.Length > 0) { line = line.Replace(tempSplitter, Environment.NewLine); } } } if (string.IsNullOrWhiteSpace(line)) { if (!checkBoxRemoveEmptyLines.Checked) { _subtitle.Paragraphs.Add(new Paragraph()); } } else if (!PlainTextImporter.ContainsLetters(line)) { if (!checkBoxRemoveLinesWithoutLetters.Checked) { _subtitle.Paragraphs.Add(new Paragraph(0, 0, line.Trim())); } } else { _subtitle.Paragraphs.Add(new Paragraph(0, 0, line.Trim())); } } }
public EGenRptSetPUE(ListView.ListViewItemCollection Grouplist) { this.InitializeComponent(); this.textBoxTP1.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.textBoxTP2.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.textBoxTP3.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.textBoxTP4.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.m_Grouplist = Grouplist; for (int i = 0; i < this.m_Grouplist.Count; i++) { ListViewItem listViewItem = this.m_Grouplist[i]; switch (i) { case 0: this.labelGN1.Text = listViewItem.SubItems[1].Text; this.labelGT1.Text = listViewItem.SubItems[0].Text; this.labelGN1.Visible = true; this.labelGT1.Visible = true; this.textBoxTP1.Visible = true; break; case 1: this.labelGN2.Text = listViewItem.SubItems[1].Text; this.labelGT2.Text = listViewItem.SubItems[0].Text; this.labelGN2.Visible = true; this.labelGT2.Visible = true; this.textBoxTP2.Visible = true; break; case 2: this.labelGN3.Text = listViewItem.SubItems[1].Text; this.labelGT3.Text = listViewItem.SubItems[0].Text; this.labelGN3.Visible = true; this.labelGT3.Visible = true; this.textBoxTP3.Visible = true; break; case 3: this.labelGN4.Text = listViewItem.SubItems[1].Text; this.labelGT4.Text = listViewItem.SubItems[0].Text; this.labelGN4.Visible = true; this.labelGT4.Visible = true; this.textBoxTP4.Visible = true; break; } } }
/// <summary> /// Swap the positions of 2 items in a ListViewItemCollection, maintaining Selected status. /// Any indexes given outside the bounds of the list are treated as if they point to /// the nearest end of the list. /// </summary> private static void Swap(ListView.ListViewItemCollection itemsList, int indexA, int indexB) { var a = Math.Min(itemsList.Count - 1, Math.Max(0, indexA)); var b = Math.Min(itemsList.Count - 1, Math.Max(0, indexB)); if (a != b) { var itemA = (ListViewItem)itemsList[a].Clone(); bool itemASelected = itemsList[a].Selected; var itemB = (ListViewItem)itemsList[b].Clone(); bool itemBSelected = itemsList[b].Selected; itemsList[a] = itemB; itemsList[a].Selected = itemBSelected; itemsList[b] = itemA; itemsList[b].Selected = itemASelected; } }
private void btn() { watch = Stopwatch.StartNew(); if (pathView.Items.Count != 0) { j = 0; dump = pathView.Items; // Create a copy of the pathView Items Collection to use as a FIFO progressBar1.Style = ProgressBarStyle.Marquee; // Starting the undefined progress bar cwd = dump[0].Text; // We Start to get the first "Root" path dump.RemoveAt(0); // We Remove it from the queue asyncHandler.RunWorkerAsync(); // Let's run it in a separate Threads } else { statusLbl.Text = "Nothing to Import"; } }
/// <summary> /// Converts items from <see cref="ListView"/> to a list of <see cref="Asset"/>. /// </summary> /// <param name="listView">ListView to be converted.</param> /// <returns>List generated from ListView.</returns> public static List <Asset> ConvertItemsToAssetList(this ListView listView) { ListView.ListViewItemCollection itemCollection = listView.Items; var assetList = new List <Asset>(); foreach (ListViewItem item in itemCollection) { var asset = new Asset(item.Text.ToLower(), item.SubItems[1].Text); if (File.Exists(asset.RealPath)) { assetList.Add(asset); } } return(assetList); }
private void AutoResizeColumnWidth(ListView lv) { int count = lv.Columns.Count; int MaxWidth = 0; Graphics graphics = lv.CreateGraphics(); Font font = lv.Font; ListView.ListViewItemCollection items = lv.Items; string str; int width; lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); for (int i = 0; i < count; i++) { str = lv.Columns[i].Text; MaxWidth = lv.Columns[i].Width; foreach (ListViewItem item in items) { if (item.SubItems.Count > i) { str = item.SubItems[i].Text; width = (int)graphics.MeasureString(str, font).Width; if (width > MaxWidth) { MaxWidth = width; } } } if (i == 0) { lv.Columns[i].Width = lv.SmallImageList.ImageSize.Width + MaxWidth; } else if (i == 1) { lv.Columns[i].Width = 60; } else { lv.Columns[i].Width = MaxWidth; } } }
public void RemoveItem() { MainWindow form = Program.Form; int matchingTrackers = 0; ListView.ListViewItemCollection itemCollection = Program.Form.torrentListView.Items; if (itemCollection.Contains(this)) { lock (form.torrentListView) { if (itemCollection.Contains(this)) { itemCollection.Remove(this); } } } else { return; } if (FirstTrackerTrimmed == null) { return; } lock (Program.TorrentIndex) { foreach (KeyValuePair <string, Torrent> torrent in Program.TorrentIndex) { if (torrent.Value.FirstTrackerTrimmed.Equals(FirstTrackerTrimmed)) { matchingTrackers++; } } } if (matchingTrackers <= 0) { lock (form.stateListBox) { form.stateListBox.RemoveItem(FirstTrackerTrimmed); } } }
public ShowCourses() { InitializeComponent(); // We use these three SQLite objects: SQLiteConnection sqlite_conn; SQLiteCommand sqlite_cmd; SQLiteDataReader sqlite_datareader; // create a new database connection: sqlite_conn = new SQLiteConnection("Data Source=database.db;"); // open the connection: sqlite_conn.Open(); // create a new SQL command: sqlite_cmd = sqlite_conn.CreateCommand(); // But how do we read something out of our table ? // First lets build a SQL-Query again: sqlite_cmd.CommandText = "SELECT * FROM Courses"; // Now the SQLiteCommand object can give us a DataReader-Object: sqlite_datareader = sqlite_cmd.ExecuteReader(); ListView.ListViewItemCollection _courses = new ListView.ListViewItemCollection(coursesListView); // ListViewItem.ListViewSubItemCollection _courseNumber = new ListViewItem.ListViewSubItemCollection(_courseName); // The SQLiteDataReader allows us to run through the result lines: while (sqlite_datareader.Read()) // Read() returns true if there is still a result line to read { ListViewItem _courseItem = new ListViewItem(); _courseItem.Text = sqlite_datareader.GetString(1); _courseItem.SubItems.Add(sqlite_datareader.GetString(2)); _courseItem.SubItems.Add(sqlite_datareader.GetString(3)); _courseItem.SubItems.Add(sqlite_datareader.GetString(4)); _courseItem.SubItems.Add(sqlite_datareader.GetString(5)); _courses.Add(_courseItem); } //close connection: sqlite_conn.Close(); }
/// <summary> /// Gets a List of Network adapters for a listview /// </summary> /// <param name="owner">the listview</param> /// <returns>the list of adapters converted to a listview collection</returns> public static ListView.ListViewItemCollection GetDevices(ListView owner) { ListView.ListViewItemCollection result = new ListView.ListViewItemCollection(owner); try { CaptureDeviceList DeviceList = CaptureDeviceList.Instance; for (int i = 0; i < DeviceList.Count; i++) { string desc = DeviceList[i].Description.Substring(17); //mainForm.WriteLine(desc); ListViewItem item = new ListViewItem(desc); item.Tag = DeviceList[i]; result.Add(item); } } catch (Exception ex) { mainForm.WriteLine(ex.Message, Color.Red); } return(result); }
// Used for getting the ListView items from within the BackgroundWorker thread. private ListView.ListViewItemCollection GetListViewItems(ListView listView) { ListView.ListViewItemCollection tmpListViewColl = new ListView.ListViewItemCollection(new ListView()); if (!listView.InvokeRequired) { foreach (ListViewItem item in listView.Items) { tmpListViewColl.Add((ListViewItem)item.Clone()); } return(tmpListViewColl); } else { return((ListView.ListViewItemCollection) this.Invoke(new GetItems(GetListViewItems), new object[] { listView })); } }
internal void BindData(ref ListView.ListViewItemCollection lvic) { listView1.Items.Clear(); foreach (ListViewItem item in lvic) { if ((item.Tag as SRRC_ResourceEntity).Dtype != 1)//不为图片 { lvic.Remove(item); continue; } ListViewItem lvi = item.Clone() as ListViewItem; lvi.Name = item.Name; listView1.Items.Add(lvi); } ListViewItem i = listView1.Items.Find(SROperation2.Instance.BrowserPicId.ToString(), true)[0]; SetSelectedState(i.Index); }
/// <summary> /// Adds a new unique item to the collection. /// </summary> /// <param name="this">The collection to add the item to.</param> /// <param name="item">The text item to add.</param> public static void AddUniqueInvariant(this ListView.ListViewItemCollection @this, string item) { var duplicate = false; foreach (ListViewItem i in @this) { if (i.Text.ToLowerInvariant() == item.ToLowerInvariant()) { duplicate = true; break; } } if (!duplicate) { @this.Add(item); } }
public static void SelectAllSessionWithHostName(string hostName) { ListView.ListViewItemCollection lvItems = FiddlerApplication.UI.lvSessions.Items; foreach (ListViewItem item in lvItems) { // 3 -> index of column host name if (item.SubItems[3].Text.Contains(hostName)) { item.Selected = true; item.BackColor = Color.Yellow; } else { item.BackColor = FiddlerApplication.UI.lvSessions.BackColor; item.Selected = false; } } }
private void EnumModule(ProcessModule m) { this.lvModDetail.Items.Clear(); mits = this.lvModDetail.Items; try { AddNameValuePair("Base Address", m.BaseAddress.ToInt32().ToString("x").ToLower()); AddNameValuePair("Entry Point Address", m.EntryPointAddress.ToInt32().ToString("x").ToLower()); AddNameValuePair("File Name", m.FileName); AddNameValuePair("File Version", m.FileVersionInfo.FileVersion.ToString()); AddNameValuePair("File Description", m.FileVersionInfo.FileDescription); AddNameValuePair("Memory Size", m.ModuleMemorySize.ToString("N0")); } catch (Exception exp) { MessageBox.Show(exp.Message, exp.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal DataTable SeathFile(ListView.ListViewItemCollection pathing, string sovpad, string way, string start, string finish) { try { var formarhiv = ((Arhivator)Application.OpenForms["Arhivator"]); var files = new List <FileInfo>(); var datetimefile = new List <string>(); foreach ( var dirarr in from ListViewItem str in pathing select Directory.GetFiles(str.Text, sovpad).Select(Path.GetFullPath).ToArray()) { formarhiv?.BeginInvoke(new MethodInvoker(() => formarhiv.toolStripStatusLabel1.Text = $@"Собираем файлы для архивации по пути {Path.GetDirectoryName(dirarr[0])}!!!")); formarhiv?.BeginInvoke( new MethodInvoker( delegate { formarhiv.Stat.Value = 0; })); var proc = (100.0f / dirarr.Length); foreach (var file in dirarr) { var date = File.GetLastWriteTime(file).Date.ToString("dd.MM.yyyy"); formarhiv?.BeginInvoke( new MethodInvoker( delegate { formarhiv.backgroundWorker1.ReportProgress((int)(proc * 100.0f)); })); if ((DateTime.Parse(start) <= DateTime.Parse(date) && DateTime.Parse(finish) >= DateTime.Parse(date))) { files.Add(new FileInfo(file)); //Формируем массив файлов datetimefile.Add(date); } } } var fileList = files.OrderBy(f => f.LastWriteTime).ToList(); var unit = new List <string>(datetimefile.Distinct()); var dates = unit.Select(DateTime.Parse).ToList(); dates.Sort(); var fileDataSet = FileToPath(fileList, dates, way); return(fileDataSet); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(null); }
private void buttonShowCompare_Click(object sender, EventArgs e) { List <String> hostsLines = new List <string>(); ListView.ListViewItemCollection lvItems = loadedHosts.Items; foreach (ListViewItem item in lvItems) { String line = item.SubItems[0].Text + '\t' + item.SubItems[1].Text; hostsLines.Add(line); } FormCollection formCollection = Application.OpenForms; foreach (Form form in formCollection.Cast <Form>().ToList()) { if (form is hosteditor.compareForm) { compareForm.Close(); } } compareForm = new hosteditor.compareForm(); compareForm.Show(); String originLine = ""; originhosts.ForEach(delegate(String line) { originLine += line + "\r\n"; }); compareForm.setA(originLine); String resultLine = this.headerString; hostsLines.ForEach(delegate(String line) { resultLine += line + "\r\n"; }); compareForm.setB(resultLine); }
/// <summary> /// Вставить табличную часть на основании таблицы элемента ListView /// </summary> /// <param name="items"></param> /// <param name="columns"></param> public void AppendTabularPart(ListView.ListViewItemCollection items, ListView.ColumnHeaderCollection columns) { XmlElement TabularPart = getTabularPart(); for (int row = 0; row < items.Count; row++) { XmlElement TableRow = Statement2_Document.CreateElement("row"); TabularPart.AppendChild(TableRow); for (byte column = 0; column < items[0].SubItems.Count; column++) { XmlElement XmlColumn = Statement2_Document.CreateElement(columns[column].Tag.ToString()); XmlColumn.InnerText = items[row].SubItems[column].Text; TableRow.AppendChild(XmlColumn); } } Statement2_Document.Save(Config.Statement2_Path); }