public virtual void AddScripts(List <DatabaseClass> scripts, bool listViewOnly = false) { List <ListViewItem> items = new List <ListViewItem>(); foreach (DatabaseClass script in scripts) { CustomListViewItem lvi = new CustomListViewItem(GetListViewKeyValue(script)); lvi.Script = script; lvi.Name = GetListViewKeyValue(script); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals(ListViewKey))) { if (_excludedProperties.Contains(propInfo.Name)) { continue; } lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } if (!listViewOnly) { _scripts.Add(script); } items.Add(lvi); } Items.AddRange(items.ToArray()); }
public void ReplaceScript(DatabaseClass script) { CustomListViewItem lvi = Items.Cast <CustomListViewItem>().SingleOrDefault(p => p.Script == script); if (lvi == null) { return; } lvi.SubItems.Clear(); lvi.Name = GetListViewKeyValue(script); lvi.Text = GetListViewKeyValue(script); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals(ListViewKey))) { if (_excludedProperties.Contains(propInfo.Name)) { continue; } lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } _scripts[_scripts.IndexOf(lvi.Script)] = script; }
/// <summary> /// Store the champion selected into the five most recent champion list. /// </summary> /// <param name="listViewItemInput">The CustomListViewItem to add</param> private void storeRecentChampion(CustomListViewItem listViewItemInput) { // Add in the new item and shifting everything else to the right this.AddAndShift(listViewItemInput); this.refreshRecentChampList(); }
public virtual int AddScript(DatabaseClass script, bool listViewOnly = false, bool selectNewItem = false) { CustomListViewItem lvi = new CustomListViewItem(GetListViewKeyValue(script)); lvi.Script = script; lvi.Name = GetListViewKeyValue(script); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals(ListViewKey))) { if (_excludedProperties.Contains(propInfo.Name)) { continue; } lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } if (!listViewOnly) { _scripts.Add(script); } ListViewItem newItem = Items.Add(lvi); if (selectNewItem) { newItem.Selected = true; newItem.Focused = true; Select(); EnsureVisible(newItem.Index); } return(newItem.Index); }
/// <summary> /// Read in the JSON settings, if the JSON file exists. /// </summary> private void readjsonSettingsFile() { // Initialize index to 0 int recentPlayedIndex = 0; // Initialize the length of the recent champs to 0 int recentChampLen = 0; // Only read in JSON file if the file exists if (System.IO.File.Exists(this.jsonSettingsFile)) { // Read in the JSON file first System.IO.StreamReader reader = new System.IO.StreamReader(this.jsonSettingsFile); string jsonString = reader.ReadToEnd(); // Convert JSON String to a C# object SettingsJsonObject jsonStuff = JsonConvert.DeserializeObject <SettingsJsonObject> (jsonString); // Set the correct sites for (int i = 0, i2 = jsonStuff.sitesSelected.Length; i < i2; i++) { bool boolSite = jsonStuff.sitesSelected[i]; ((CheckBox)this.FindName(this.m_siteNames[i])).IsChecked = boolSite; } // Set the most recent 5 champions mostRecentChamps.Items.Clear(); recentChampLen = jsonStuff.fiveRecentChampions.Length; for (int i = 0, i2 = recentChampLen; i < i2; i++) { String curChamp = jsonStuff.fiveRecentChampions[i]; CustomListViewItem lvi = new CustomListViewItem(); lvi.Content = curChamp; lvi.Selected += SelectItemHandler; this.mostRecentChamps.Items.Add(lvi); this.m_arrRecentlyPlayedChamps[recentPlayedIndex++] = lvi; } reader.Close(); } // If there are less than 5 champs, add in empty placeholders int diff = MAX_RECENT_CHAMPS - recentChampLen; for (int i = 0; i < diff; i++) { CustomListViewItem lvi = new CustomListViewItem(); lvi.Focusable = false; lvi.Content = ""; this.mostRecentChamps.Items.Add(lvi); this.m_arrRecentlyPlayedChamps[recentPlayedIndex++] = lvi; } }
/// <summary> /// Add to the beginning of m_arrRecentlyPlayedChamps, then shift every item to the right /// </summary> /// <param name="setInput"></param> private void AddAndShift(CustomListViewItem listViewItemToAdd) { // Shift first for (int i = this.m_arrRecentlyPlayedChamps.Length - 1; i >= 1; i--) { this.m_arrRecentlyPlayedChamps[i] = this.m_arrRecentlyPlayedChamps[i - 1]; } // Add to the beginning this.m_arrRecentlyPlayedChamps[0] = listViewItemToAdd; }
/// <summary> /// Reset the recent champion list. /// </summary> private void resetRecentChampList() { for (int i = 0, i2 = this.m_arrRecentlyPlayedChamps.Length; i < i2; i++) { CustomListViewItem cvli = new CustomListViewItem(); cvli.Content = ""; cvli.Focusable = false; this.m_arrRecentlyPlayedChamps[i] = cvli; } this.refreshRecentChampList(); }
private void SelectItemHandler(object sender, RoutedEventArgs e) { // Unselect the currently selected first if (this.currentlySelectedLvi != null) { this.currentlySelectedLvi.IsSelected = false; } CustomListViewItem selected = (CustomListViewItem)sender; this.currentlySelectedLvi = selected; }
/// <summary> /// Setup the ListView /// </summary> private void setupListView() { // Setup the All Champions ListView foreach (String s in this.allChampions) { CustomListViewItem lvi = new CustomListViewItem(); lvi.Selected += SelectItemHandler; lvi.Content = s; ChampionListView.Items.Add(lvi); } }
public void AddScripts(List <SmartScript> scripts, bool listViewOnly = false) { List <ListViewItem> items = new List <ListViewItem>(); foreach (SmartScript script in scripts) { CustomListViewItem lvi = new CustomListViewItem(script.entryorguid.ToString()) { Script = script, Name = script.entryorguid.ToString() }; foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid"))) { if (_excludedProperties.Contains(propInfo.Name)) { continue; } lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } if (!listViewOnly) { _scripts.Add(script); } if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0) { if (!_phaseColors.ContainsKey(script.event_phase_mask)) { if (_colors.Count == 0) { MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _phaseColors.Add(script.event_phase_mask, _colors.Pop()); lvi.BackColor = _phaseColors[script.event_phase_mask]; } lvi.BackColor = _phaseColors[script.event_phase_mask]; } items.Add(lvi); } Items.AddRange(items.ToArray()); }
private void PrintscreenCollectionChanged(object sender, ListChangedEventArgs e) { var s = (BindingList <Printscreen>)sender; mainView.ThumbList.Clear(); mainView.ImageViewItems.Clear(); for (int i = 0; i < s.Count; i++) { CustomListViewItem item = new CustomListViewItem { ImageIndex = i, Text = printscreens[i].GUID.ToString() }; mainView.ThumbList.Add(printscreens[i].Thumb); mainView.ImageViewItems.Add(item); } }
private void filterListViewAndRefresh(object sender, DoWorkEventArgs e) { // Ref: https://stackoverflow.com/a/9732853 // We need to do this for multi threading this.Dispatcher.Invoke(() => { // Check for selected index //if (String.IsNullOrEmpty(this.currentlySelected)) List <CustomListViewItem> matches = new List <CustomListViewItem>(); int count = this.allChampions.Count; // Get all items in the ListBox for (int i = 0, i2 = count; i < i2; i++) { String s = this.allChampions[i]; // If name matches if (this.ChampNameFilter(s)) { CustomListViewItem lvi = new CustomListViewItem(); lvi.Content = s; lvi.Selected += SelectItemHandler; matches.Add(lvi); } } ChampionListView.Items.Clear(); // Re-add back in foreach (CustomListViewItem lvi in matches) { ChampionListView.Items.Add(lvi); if (lvi == this.currentlySelectedLvi) { ChampionListView.SelectedItem = lvi; } } }); }
public int AddCondition(Condition condition, bool listViewOnly = false, bool selectNewItem = false) { CustomListViewItem lvi = new CustomListViewItem(condition.SourceTypeOrReferenceId.ToString()); lvi.Script = condition; lvi.Name = condition.SourceTypeOrReferenceId.ToString(); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("SourceTypeOrReferenceId"))) { if (_excludedProperties.Contains(propInfo.Name)) continue; lvi.SubItems.Add(propInfo.GetValue(condition).ToString()); } if (!listViewOnly) _conditions.Add(condition); ListViewItem newItem = Items.Add(lvi); newItem.Selected = selectNewItem; return newItem.Index; }
public void ReplaceScript(SmartScript script) { base.ReplaceScript(script); CustomListViewItem lvi = Items.Cast <CustomListViewItem>().SingleOrDefault(p => p.Script == script); if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0) { if (!_phaseColors.ContainsKey(script.event_phase_mask)) { if (_colors.Count == 0) { MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _phaseColors.Add(script.event_phase_mask, _colors.Pop()); } lvi.BackColor = _phaseColors[script.event_phase_mask]; } }
public int AddSmartScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false) { CustomListViewItem lvi = new CustomListViewItem(script.entryorguid.ToString()); lvi.Script = script; lvi.Name = script.entryorguid.ToString(); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid"))) { if (_excludedProperties.Contains(propInfo.Name)) continue; lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } if (!listViewOnly) _smartScripts.Add(script); ListViewItem newItem = Items.Add(lvi); if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0) { if (!_phaseColors.ContainsKey(script.event_phase_mask)) { if (_colors.Count == 0) { MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error); return -1; } _phaseColors.Add(script.event_phase_mask, _colors.Pop()); } newItem.BackColor = _phaseColors[script.event_phase_mask]; } newItem.Selected = selectNewItem; return newItem.Index; }
private void ListView1_DrawItem(object sender, DrawListViewItemEventArgs e) { var G = e.Graphics; CustomListViewItem clvi = e.Item as CustomListViewItem; if (clvi == null) { return; } if (clvi.Selected) { G.FillRectangle(Brushes.Blue, e.Bounds); } if (clvi.Gerb.visible) { G.FillRectangle(new SolidBrush(clvi.Gerb.Color), new Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, 10, 10)); } G.DrawRectangle(new Pen(Color.FromArgb(20, 20, 20), 1), new Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, 10, 10)); G.DrawString(Path.GetFileName(clvi.Gerb.File.Name), new Font("Arial", 10), Brushes.Black, e.Bounds.Left + 13, e.Bounds.Top); }
/// <summary> /// Clear the this.mostRecentChamps list, then re-add in the current list. /// </summary> private void refreshRecentChampList() { // Re-Add to the Most Recent Champs List this.mostRecentChamps.Items.Clear(); foreach (CustomListViewItem item in this.m_arrRecentlyPlayedChamps) { // We need to add a new item as the first CustomListViewItem already has a parent CustomListViewItem item2 = new CustomListViewItem(); item2.Content = item.Content; bool contentNull = String.IsNullOrEmpty(item.Content.ToString()); // Only add a select handler if the content is not null if (false == contentNull) { item2.Selected += this.SelectItemHandler; } // Set focusable to false if the content is null item2.Focusable = !contentNull; this.mostRecentChamps.Items.Add(item2); } }
public void AddConditions(List<Condition> conditions, bool listViewOnly = false) { List<ListViewItem> items = new List<ListViewItem>(); foreach (Condition condition in conditions) { CustomListViewItem lvi = new CustomListViewItem(condition.SourceTypeOrReferenceId.ToString()); lvi.Script = condition; lvi.Name = condition.SourceTypeOrReferenceId.ToString(); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("SourceTypeOrReferenceId"))) { if (_excludedProperties.Contains(propInfo.Name)) continue; lvi.SubItems.Add(propInfo.GetValue(condition).ToString()); } if (!listViewOnly) _conditions.Add(condition); items.Add(lvi); } Items.AddRange(items.ToArray()); }
private void listaCuvinteCheie_Selected(object sender, EventArgs e) { if (listaCuvinteCheie.SelectedNode == null) return; var treeNode = listaCuvinteCheie.SelectedNode as CustomTreeNode<CuvantCheie>; if (treeNode == null || treeNode.IsCustomParent) return; if (splitContainerCuvinteCheie.Panel2Collapsed) splitContainerCuvinteCheie.Panel2Collapsed = false; listaRezultateCautareProbleme.Items.Clear(); foreach (Problema problema in treeNode.ListaProbleme) { var item = new CustomListViewItem<Problema>(problema.Titlu, problema) { Group = listaProbleme.Groups[problema.Tip] }; listaRezultateCautareProbleme.Items.Add(item); } }
public virtual int AddScript(DatabaseClass script, bool listViewOnly = false, bool selectNewItem = false) { CustomListViewItem lvi = new CustomListViewItem(GetListViewKeyValue(script)); lvi.Script = script; lvi.Name = GetListViewKeyValue(script); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals(ListViewKey))) { if (_excludedProperties.Contains(propInfo.Name)) continue; lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } if (!listViewOnly) _scripts.Add(script); ListViewItem newItem = Items.Add(lvi); if (selectNewItem) { newItem.Selected = true; newItem.Focused = true; Select(); EnsureVisible(newItem.Index); } return newItem.Index; }
public virtual void AddScripts(List<DatabaseClass> scripts, bool listViewOnly = false) { List<ListViewItem> items = new List<ListViewItem>(); foreach (DatabaseClass script in scripts) { CustomListViewItem lvi = new CustomListViewItem(GetListViewKeyValue(script)); lvi.Script = script; lvi.Name = GetListViewKeyValue(script); foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals(ListViewKey))) { if (_excludedProperties.Contains(propInfo.Name)) continue; lvi.SubItems.Add(propInfo.GetValue(script).ToString()); } if (!listViewOnly) _scripts.Add(script); items.Add(lvi); } Items.AddRange(items.ToArray()); }
/// <summary> /// Handle what happens when the user clicks on the "Find Builds" button. /// </summary> private void FindBuildsBtn_Click(object sender, RoutedEventArgs e) { // If nothing is selected if (this.currentlySelectedLvi == null) { MessageBox.Show("No champion is selected yet!"); } else { // Start the website int idListLength = this.m_siteNames.Length; // Get a RegEx pattern: delete all characters that is not a-z, A-Z, or 0-9 string pattern = "[^a-zA-Z0-9]"; for (int i = 0; i < idListLength; i++) { String id1 = this.m_siteNames[i]; var elem = (CheckBox)this.FindName(id1); bool isChecked = (bool)elem.IsChecked; if (isChecked) { String url1 = ""; String formattedChamp = this.currentlySelectedLvi.Content.ToString(); // Special cases! // Nunu if (formattedChamp.Equals("Nunu & Willump")) { formattedChamp = "Nunu"; } // Replace using regex pattern: // delete all characters that is not a-z, A-Z, or 0-9 formattedChamp = Regex.Replace(formattedChamp, pattern, ""); // Uppercase first character, lowercase the rest formattedChamp = this.ToLowerExceptFirstChar(formattedChamp); switch (i) { // If it is u.gg case 0: url1 = String.Format("https://u.gg/lol/champions/{0}/build", formattedChamp); break; // op.gg case 1: url1 = String.Format("https://na.op.gg/champion/{0}", formattedChamp); break; // lolalytics case 2: // Need to replace the formatted champ name first, if needed string fc = formattedChamp.ToLower(); if (this.m_lolalyticsChampNames.ContainsKey(fc)) { formattedChamp = this.m_lolalyticsChampNames[fc]; } url1 = String.Format("https://lolalytics.com/ranked/worldwide/platinum/plus/champion/{0}", formattedChamp); break; // champion.gg case 3: url1 = String.Format("https://champion.gg/champion/{0}", formattedChamp); break; } System.Diagnostics.Process.Start(url1); // Check if the recently clicked on champion is already in the most // recent champions selected bool notInRecentList = true; for (int j = 0, j2 = this.m_arrRecentlyPlayedChamps.Length; j < j2; j++) { String currentlySelected = this.currentlySelectedLvi.Content.ToString(); String curRecentChamp = this.m_arrRecentlyPlayedChamps[j].Content.ToString(); // If there is equal, switch if (currentlySelected.Equals(curRecentChamp)) { // Switch to top CustomListViewItem temp = this.m_arrRecentlyPlayedChamps[j]; this.m_arrRecentlyPlayedChamps[j] = this.m_arrRecentlyPlayedChamps[0]; this.m_arrRecentlyPlayedChamps[0] = temp; notInRecentList = false; // Then refresh the list this.refreshRecentChampList(); break; } } // Store the champion in the most recent champions selected only if it is // not in the list yet if (notInRecentList) { this.storeRecentChampion(this.currentlySelectedLvi); } } } } }