public ListView () { background_color = Color.White;//ThemeEngine.Current.ColorWindow; groups = new ListViewGroupCollection (this); items = new ListViewItemCollection (this); items.Changed += new CollectionChangedHandler (OnItemsChanged); checked_indices = new CheckedIndexCollection (this); checked_items = new CheckedListViewItemCollection (this); columns = new ColumnHeaderCollection (this); foreground_color = SystemColors.WindowText; selected_indices = new SelectedIndexCollection (this); selected_items = new SelectedListViewItemCollection (this); items_location = new Point [16]; items_matrix_location = new ItemMatrixLocation [16]; reordered_items_indices = new int [16]; item_tooltip = new ToolTip (); item_tooltip.Active = false; insertion_mark = new ListViewInsertionMark (this); InternalBorderStyle = BorderStyle.Fixed3D; header_control = new HeaderControl (this); header_control.Visible = false; Controls.AddImplicit (header_control); item_control = new ItemControl (this); Controls.AddImplicit (item_control); h_marker = v_marker = 0; keysearch_tickcnt = 0; // scroll bars are disabled initially h_scroll.Visible = false; //h_scroll.ValueChanged += new EventHandler(HorizontalScroller); v_scroll.Visible = false; //v_scroll.ValueChanged += new EventHandler(VerticalScroller); // event handlers base.KeyDown += new KeyEventHandler(ListView_KeyDown); SizeChanged += new EventHandler (ListView_SizeChanged); //GotFocus += new EventHandler (FocusChanged); //LostFocus += new EventHandler (FocusChanged); //MouseWheel += new MouseEventHandler(ListView_MouseWheel); //MouseEnter += new EventHandler (ListView_MouseEnter); Invalidated += new InvalidateEventHandler (ListView_Invalidated); BackgroundImageTiled = false; this.SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick | ControlStyles.UseTextForAccessibility , false); }
public Form1() { InitializeComponent(); DirectoryData = ListViewDirectory.Items; /* * ListViewDirectory */ LoadDirectoryInfo(CurrentDirectory); ListViewDirectory.ItemActivate += (s, a) => { if ((s as ListView).SelectedItems.Count == 1) { Open($"{CurrentDirectory}/{(s as ListView).SelectedItems[0].Text}"); } }; }
public static int getIndexOfLVI(this ListViewItemCollection listViewItemCollection, ListViewItem targetItem) { int count = 0; foreach (ListViewItem item in listViewItemCollection) { if (ProcessCache._processComparer.Equals(item.ToProcessObject(), targetItem.ToProcessObject())) { Debug.WriteLine("Get index of LVI found a match at index: " + count); return(count); } count++; } Debug.WriteLine("Get index of LVI couldn't find a match"); return(-1); }
private static bool IsFirstLastItemInGroup(ListViewGroup g, ListViewItem lvi, bool bFirst) { if (g == null) { Debug.Assert(false); return(false); } ListViewItemCollection c = g.Items; if (c.Count == 0) { Debug.Assert(false); return(false); } return(bFirst ? (c[0] == lvi) : (c[c.Count - 1] == lvi)); }
public ListView() { items = new ListViewItemCollection(this); columns = new ColumnHeaderCollection(this); listItems = new ArrayList(); autoArrange = true; hideSelection = true; labelWrap = true; multiSelect = true; scrollable = true; activation = ItemActivation.Standard; alignStyle = ListViewAlignment.Top; borderStyle = BorderStyle.Fixed3D; headerStyle = ColumnHeaderStyle.Clickable; sorting = SortOrder.None; viewStyle = View.LargeIcon; }
protected Save(string pagename, ref ListView lv, ref TreeView tv) { path = ConfigurationManager.AppSettings["SavePath"].ToString(); if (String.IsNullOrEmpty(path)) { path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } path = Path.Combine(path, "TheScrapper"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } this.pagename = pagename; lvCol = lv.Items; tvcol = tv.Nodes; content = Prepare(); }
public bool PostListview(string url, Hashtable hashtable, ListView listView) { try { WebClient wc = new WebClient(); NameValueCollection nameValue = new NameValueCollection(); foreach (DictionaryEntry data in hashtable) { nameValue.Add(data.Key.ToString(), data.Value.ToString()); } byte[] result = wc.UploadValues(url, "POST", nameValue); string resultStr = Encoding.UTF8.GetString(result); ArrayList list = JsonConvert.DeserializeObject <ArrayList>(resultStr); listView.Items.Clear(); for (int i = 0; i < list.Count; i++) { JArray jArray = (JArray)list[i]; string[] arr = new string[jArray.Count]; for (int j = 0; j < jArray.Count; j++) { arr[j] = jArray[j].ToString(); } listView.Items.Add(new ListViewItem(arr)); listView.HeaderStyle = ColumnHeaderStyle.Nonclickable; } ListViewItemCollection col = listView.Items; for (int j = 0; j < col.Count; j++) { for (int k = 0; k < col[j].SubItems.Count; k++) { col[j].SubItems[k].Font = new Font("맑은 고딕", 12, FontStyle.Regular); } } return(true); } catch (Exception) { return(false); } }
private void OrderlistLoad() { int allprice = 0; ListViewItemCollection col = lv.Items; for (int j = 0; j < col.Count; j++) { for (int k = 0; k < col[j].SubItems.Count; k++) { col[j].SubItems[k].Font = new Font("맑은고딕", 12, FontStyle.Regular); } } for (int i = 0; i < lv.Items.Count; i++) { //lv.Items[i].SubItems[5].Text = (Convert.ToInt32(lv.Items[i].SubItems[5].Text) + Convert.ToInt32(lv.Items[i].SubItems[2].Text) * 500).ToString(); allprice += Convert.ToInt32(lv.Items[i].SubItems[5].Text) * Convert.ToInt32(lv.Items[i].SubItems[4].Text); } label.Text = "총 가격 : " + allprice + "원"; }
public bool ListView(string url, ListView listView) { try { WebClient wc = new WebClient(); Stream stream = wc.OpenRead(url); StreamReader sr = new StreamReader(stream); string result = sr.ReadToEnd(); ArrayList list = JsonConvert.DeserializeObject <ArrayList>(result); listView.Items.Clear(); for (int i = 0; i < list.Count; i++) { JArray jArray = (JArray)list[i]; string[] arr = new string[jArray.Count]; for (int j = 0; j < jArray.Count; j++) { arr[j] = jArray[j].ToString(); } listView.Items.Add(new ListViewItem(arr)); listView.HeaderStyle = ColumnHeaderStyle.Nonclickable; listView.Font = new Font("맑은 고딕", 14, FontStyle.Bold); } ListViewItemCollection col = listView.Items; // listview subitems 글꼴 바꾸기 for (int j = 0; j < col.Count; j++) { for (int k = 0; k < col[j].SubItems.Count; k++) { col[j].SubItems[k].Font = new Font("맑은 고딕", 12, FontStyle.Regular); } } return(true); } catch { return(false); } }
public void AutoResizeColumns() { try { int count = this.Columns.Count; int MaxWidth = 0; Graphics graphics = this.CreateGraphics(); Font font = this.Font; ListViewItemCollection items = this.Items; string str; int width; this.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); for (int i = 0; i < count; i++) { str = this.Columns[i].Text; MaxWidth = this.Columns[i].Width; foreach (ListViewItem item in items) { str = item.SubItems[i].Text; width = (int)graphics.MeasureString(str, font).Width; if (width > MaxWidth) { MaxWidth = width; } } if (i == 0) { this.Columns[i].Width = MaxWidth; } this.Columns[i].Width = MaxWidth; } } catch { } }
//////////////////// // LIST VIEWS // //////////////////// private void UpdateLists_() { foreach (KeyValuePair <WordType, ListView> listView in listViewes_) { ListViewItemCollection items = listView.Value.Items; for (int i = 0; i < items.Count; ++i) { if (i == currentCommand_.GetSelIndex(listView.Key)) { if (items[i].BackColor != changedColor_) { items[i].BackColor = changedColor_; } } else { if (items[i].BackColor == changedColor_) { items[i].BackColor = enabledColor_; } } } } }
private void timer1_Tick(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { toolStripStatusLabel1.Text = treeView1.SelectedNode.Parent != null ? treeView1.SelectedNode.Parent.Text + " --> " + treeView1.SelectedNode.Text : treeView1.SelectedNode.Text; } if (prevItems != replyList.Items && treeView1.SelectedNode != null) { Data selectedData = nodes[treeView1.SelectedNode]; for (int i = 1; i < 10; i++) { if (replyList.Items.Count > i - 1) { selectedData.SetValue(i, replyList.Items[i - 1].Text); } else { selectedData.SetValue(i, null); } } } prevItems = replyList.Items; }
public TerrainListViewItemCollection(ListViewItemCollection baseCollection) { _bc = baseCollection; }
public void AddRange(ListViewItemCollection items) {}
/// <include file='doc\ListView.uex' path='docs/doc[@for="ListViewItemCollection.FindInternal"]/*' /> /// <devdoc> /// <para>Searches for Controls by their Name property, builds up an arraylist /// of all the controls that match. /// </para> /// </devdoc> /// <internalonly/> private ArrayList FindInternal(string key, bool searchAllSubItems, ListViewItemCollection listViewItems, ArrayList foundItems) { if ((listViewItems == null) || (foundItems == null)) { return null; // } for (int i = 0; i < listViewItems.Count; i++) { if (WindowsFormsUtils.SafeCompareStrings(listViewItems[i].Name, key, /* ignoreCase = */ true)) { foundItems.Add(listViewItems[i]); } else { if (searchAllSubItems) { // start from 1, as we've already compared subitems[0] for(int j = 1; j < listViewItems[i].SubItems.Count; j++) { if (WindowsFormsUtils.SafeCompareStrings(listViewItems[i].SubItems[j].Name, key, /* ignoreCase = */ true)) { foundItems.Add(listViewItems[i]); break; } } } } } return foundItems; }
public UpLoad(ListViewItemCollection listViewItemCollection, string fileAddress) { this.listViewItemCollection = listViewItemCollection; this.fileAddress = fileAddress; InitializeComponent(); }
void CalculateDetailsGroupItemsCount () { int items = 0; groups.DefaultGroup.ItemCount = GetDefaultGroupItems (); for (int i = 0; i < groups.InternalCount; i++) { ListViewGroup group = groups.GetInternalGroup (i); int items_in_group = group.GetActualItemCount (); if (items_in_group == 0) continue; group.starting_item = items; group.current_item = 0; // Reset layout. items += items_in_group; } }
/// <summary> /// Går igenom en hel lista o sätt autokat. /// </summary> /// <param name="items"></param> /// <param name="infoToCheck">empty string means all, null means none</param> internal static void UpdateCategoriesWithAutoCatList(ListViewItemCollection items, string infoToCheck) { #region Uppdera listan men nya entries // Todo: egen funktionför detta // Todo: uppdera listan men nya entries. ladda oxo om filen ev. . Om det kommer fler, fast då används ju minnet som är uppdaterat ändå. foreach (ListViewItem listViewItem in items) { var newKe = (KontoEntry)listViewItem.Tag; if (newKe == null) { continue; } // Slå upp autokategori var lookedUpCat = CategoriesHolder.AllCategories.AutocategorizeType(newKe.Info); if (lookedUpCat == null) { continue; } // Om det är info man nyss har ändrat, eller om infon är en tom sträng (skulle kunna ha null istället) if (!newKe.Info.Equals(infoToCheck) && !infoToCheck.Equals(string.Empty)) { continue; } // Skippa att fråga om o sätta exakt samma kategori. if (newKe.TypAvKostnad != null && newKe.TypAvKostnad.Equals(lookedUpCat)) { continue; } // Ska man skriva över vald autocat? det är nog upp till användaren... if (!string.IsNullOrEmpty(newKe.TypAvKostnad)) { var autoCatMessage = "Rad har redan en typ av kostnad. Ska den nu valda skrivas över? Alltså att byta från:" + Environment.NewLine + newKe.TypAvKostnad + Environment.NewLine + "Till:" + Environment.NewLine + lookedUpCat + Environment.NewLine + "?" + Environment.NewLine + "För info:" + Environment.NewLine + newKe.Info + Environment.NewLine + Environment.NewLine + "För rad (ihopskriven):" + newKe.KeyForThis; if (!UserAcceptsFurtherAction(autoCatMessage, AutoCatCpation)) { continue; } } // Har man kommit förbi alla contines, så ska kategorin bytas. newKe.TypAvKostnad = lookedUpCat; // Sätt ny kategori i listan också, så anv. ser att det ändrats. listViewItem.SubItems[ValuesandConsts.TypAvKostnadKolumnnummer].Text = newKe.TypAvKostnad; } #endregion }
public void AddRange(ListViewItemCollection items) { throw null; }
public ListView() { base.SetStyle(ControlStyles.UserPaint, false); base.SetStyle(ControlStyles.StandardClick, false); base.SetStyle(ControlStyles.UseTextForAccessibility, false); this.odCacheFont = this.Font; this.odCacheFontHandle = base.FontHandle; base.SetBounds(0, 0, 0x79, 0x61); this.listItemCollection = new ListViewItemCollection(new ListViewNativeItemCollection(this)); this.columnHeaderCollection = new ColumnHeaderCollection(this); }
private void init(object sender, EventArgs e) { List <String> files = new List <string>(); try { files = Directory.GetFiles("tests", "*.dll").ToList(); } catch (Exception ex) { log.Error("Ошибка получения файлов из директории tests", ex); MessageBox.Show("Ошибка получения файлов из директории tests", "Ошибка!", MessageBoxButtons.OK); Application.Exit(); } //загрузка сборок с тестами foreach (string file in files) { try { Assembly assembly = Assembly.LoadFrom(file); foreach (Type type in assembly.GetTypes()) { if (typeof(Test).IsAssignableFrom(type)) { resultAssemblies.Add(assembly); break; } } } catch (Exception ex) { log.Error(String.Format("Ошибка загрузки сборки из {0}", file), ex); MessageBox.Show(String.Format("Ошибка загрузки сборки из {0}", file), "Ошибка", MessageBoxButtons.OK); } } //обнаружение xlsx try { List <String> xlsxes = Directory.GetFiles("config", "*.xlsx").ToList(); List <String> cfg = Directory.GetFiles("config", "config*.xlsx").ToList(); xlsxFiles.AddRange(xlsxes.Except(cfg)); } catch (Exception ex) { log.Error("Ошибка получения xlsx файлов из директории config", ex); MessageBox.Show("Ошибка получения файлов xlsx из директории config", "Ошибка!", MessageBoxButtons.OK); Application.Exit(); } //вывод dll в список foreach (Assembly assembly in resultAssemblies) { String assemblyName = assembly.GetName().Name; dllView.Items.Add(assemblyName); ListViewItemCollection xlsxCollection = new ListViewItemCollection(xlsxView); List <String> xlsxFileCopy = xlsxFiles.Select(item => (String)item.Clone()).ToList(); ListViewItem[] items = xlsxFileCopy.Select(item => new ListViewItem(item)).ToArray(); dllToXlsx.Add(assemblyName, items); } //создание представления конфигурирования теста если оно есть foreach (Assembly assembly in resultAssemblies) { foreach (Type type in assembly.GetTypes()) { try { if (typeof(TestConfigurationView).IsAssignableFrom(type)) { TestConfigurationView tcv = (TestConfigurationView)Activator.CreateInstance(type); dllToConfig.Add(assembly.GetName().Name, tcv); } } catch (Exception ex) { log.Error("Ошибка создания экземпляра представления конфигурации теста", ex); MessageBox.Show("Ошибка создания экземпляра представления конфигурации теста", "Ошибка!"); } } } dllView.Items[0].Selected = true; //установка настроек в интерфейсе в соответствии с конфиг файлом //конфигурирование try { Configuration config = Configuration.getInstance(); JObject json = config.Config; foreach (Assembly assembly in resultAssemblies) { if (json.ContainsKey(assembly.GetName().Name)) { JObject asemblyConfig = (JObject)json[assembly.GetName().Name]; if (asemblyConfig.ContainsKey("data")) { JArray data = (JArray)asemblyConfig["data"]; ListViewItem[] listItems = dllToXlsx[assembly.GetName().Name]; List <String> items = listItems.Select(item => item.Text).ToList(); List <String> dataFiles = data.ToObject <List <String> >(); List <String> checkedFiles = dataFiles.Intersect(items).ToList(); foreach (String checkedFile in checkedFiles) { listItems.Where(item => item.Text == checkedFile).Single().Checked = true; } } TestConfigurationView tcv = dllToConfig[assembly.GetName().Name]; if (asemblyConfig.ContainsKey("urls")) { tcv.Config["urls"] = (JArray)asemblyConfig["urls"]; } if (asemblyConfig.ContainsKey("compare")) { tcv.Config["compare"] = (String)asemblyConfig["compare"]; } tcv.init(); } } } catch (ConfigurationException ex) { log.Error("Ошибка конфигурирования приложения", ex); MessageBox.Show("Ошибка конфигурирования приложения", "Ошибка!", MessageBoxButtons.OK); Application.Exit(); } }
/// /// <summary> /// Handles the Tick event of the ServerTimer control. /// This is where the server logic is performed. /// </summary> /// /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// private void ServerTimer_Tick(Object sender, EventArgs e) { // Update the clients list. ListViewItemCollection players = new ListViewItemCollection(PlayersView); players.Clear(); foreach (NetConnection client in server.Connections) { players.Add(new ListViewItem(new String[] { client.Status.ToString(), client.RemoteEndPoint.Address.ToString() })); } // Read all incoming messages. NetIncomingMessage message; int messageCount = 0; while ((message = server.ReadMessage()) != null) { messageCount++; switch (message.MessageType) { case NetIncomingMessageType.VerboseDebugMessage: case NetIncomingMessageType.DebugMessage: case NetIncomingMessageType.WarningMessage: case NetIncomingMessageType.ErrorMessage: log("Info", message.ReadString()); break; case NetIncomingMessageType.Data: switch (message.ReadUInt32()) { // Client requested world refresh. case Game.NETWORK_REFRESH_REQUEST: sendWorldRefresh(message.SenderConnection); log("Info", "Sent a world refresh to " + message.SenderConnection); break; case Game.NETWORK_TILE_UPDATE_REQUEST: int tileX = message.ReadInt32(); int tileZ = message.ReadInt32(); Tile updatedTile = Tile.readFromNetwork(ref message); world.tiles[tileX, tileZ] = updatedTile; log("Info", "Received new tile data at " + tileX + ", " + tileZ + ". (" + world.tiles[tileX, tileZ].getName() + ")"); foreach (NetConnection client in server.Connections) { NetOutgoingMessage tileUpdateResponse = server.CreateMessage(); tileUpdateResponse.Write(Game.NETWORK_TILE_UPDATE_RESPONSE); tileUpdateResponse.Write(tileX); tileUpdateResponse.Write(tileZ); writeTileData(tileX, tileZ, ref tileUpdateResponse); server.SendMessage(tileUpdateResponse, client, NetDeliveryMethod.ReliableOrdered); //log("Info", "Relaying tile data to " + client.RemoteEndPoint.Address.ToString()); //sendWorldRefresh(client); } break; case Game.NETWORK_NEW_ITEM_REQUEST: float itemX = message.ReadFloat(); float itemZ = message.ReadFloat(); Item newItem = Item.readFromNetwork(ref message); newItem.position = new Vector2(itemX, itemZ); world.items.Add(newItem); foreach (NetConnection client in server.Connections) { NetOutgoingMessage newItemResponse = server.CreateMessage(); newItemResponse.Write(Game.NETWORK_NEW_ITEM_RESPONSE); newItemResponse.Write(itemX); newItemResponse.Write(itemZ); writeItemData(newItem, ref newItemResponse); server.SendMessage(newItemResponse, client, NetDeliveryMethod.ReliableOrdered); log("Info", "Relaying item data to " + client.RemoteEndPoint.Address.ToString()); } break; default: log("Error", "Unknown message from client!"); break; } break; case NetIncomingMessageType.ConnectionApproval: message.SenderConnection.Approve(); break; case NetIncomingMessageType.DiscoveryRequest: NetOutgoingMessage response = server.CreateMessage(); server.SendDiscoveryResponse(response, message.SenderEndPoint); break; case NetIncomingMessageType.StatusChanged: log("Net", "Server->Client status changed: " + message.SenderConnection.Status); break; default: log("Error", "Unhandled message type: " + message.MessageType); break; } server.Recycle(message); } }
public ItemCollection(ListViewItemCollection rowCollection) { _base = rowCollection; }
void CalculateRowsAndCols (Size item_size, bool left_aligned, int x_spacing, int y_spacing) { Rectangle area = ClientRectangle; if (UseCustomColumnWidth) CalculateCustomColumnWidth (); if (UsingGroups) { // When groups are used the alignment is always top-aligned rows = 0; cols = 0; int items = 0; groups.DefaultGroup.ItemCount = GetDefaultGroupItems (); for (int i = 0; i < groups.InternalCount; i++) { ListViewGroup group = groups.GetInternalGroup (i); int items_in_group = group.GetActualItemCount (); if (items_in_group == 0) continue; int group_cols = (int) Math.Floor ((double)(area.Width - v_scroll.Width + x_spacing) / (double)(item_size.Width + x_spacing)); if (group_cols <= 0) group_cols = 1; int group_rows = (int) Math.Ceiling ((double)items_in_group / (double)group_cols); group.starting_row = rows; group.rows = group_rows; group.starting_item = items; group.current_item = 0; // Reset layout cols = Math.Max (group_cols, cols); rows += group_rows; items += items_in_group; } } else { // Simple matrix if no groups are used if (left_aligned) { rows = (int) Math.Floor ((double)(area.Height - h_scroll.Height + y_spacing) / (double)(item_size.Height + y_spacing)); if (rows <= 0) rows = 1; cols = (int) Math.Ceiling ((double)items.Count / (double)rows); } else { if (UseCustomColumnWidth) cols = (int) Math.Floor ((double)(area.Width - v_scroll.Width) / (double)(custom_column_width)); else cols = (int) Math.Floor ((double)(area.Width - v_scroll.Width + x_spacing) / (double)(item_size.Width + x_spacing)); if (cols < 1) cols = 1; rows = (int) Math.Ceiling ((double)items.Count / (double)cols); } } item_index_matrix = new int [rows, cols]; }
/// <include file='doc\ListView.uex' path='docs/doc[@for="ListView.ListView"]/*' /> /// <devdoc> /// Creates an empty ListView with default styles. /// </devdoc> public ListView() : base() { listViewState = new System.Collections.Specialized.BitVector32(LISTVIEWSTATE_scrollable | LISTVIEWSTATE_multiSelect | LISTVIEWSTATE_labelWrap | LISTVIEWSTATE_hideSelection | LISTVIEWSTATE_autoArrange | LISTVIEWSTATE_showGroups); listViewState1 = new System.Collections.Specialized.BitVector32(LISTVIEWSTATE1_useCompatibleStateImageBehavior); SetStyle(ControlStyles.UserPaint, false); SetStyle(ControlStyles.StandardClick, false); SetStyle(ControlStyles.UseTextForAccessibility, false); odCacheFont = Font; odCacheFontHandle = FontHandle; SetBounds(0,0,121,97); listItemCollection = new ListViewItemCollection(new ListViewNativeItemCollection(this)); columnHeaderCollection = new ColumnHeaderCollection(this); }
public void AddRange (ListViewItemCollection items) { if (items == null) throw new ArgumentNullException ("Argument cannot be null!", "items"); ListViewItem[] itemArray = new ListViewItem[items.Count]; items.CopyTo (itemArray,0); this.AddRange (itemArray); }
/// <include file='doc\ListView.uex' path='docs/doc[@for="ListView.ListViewItemCollection.AddRange"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void AddRange(ListViewItemCollection items) { if (items == null) { throw new ArgumentNullException("items"); } ListViewItem[] itemArray = new ListViewItem[items.Count]; items.CopyTo(itemArray, 0); InnerList.AddRange(itemArray); }
internal static void UpdateCategoriesWithAutoCatList(ListViewItemCollection items) { UpdateCategoriesWithAutoCatList(items, string.Empty); }
public void AddRange(ListViewItemCollection items) { }