/// <summary> /// Updates the content. /// </summary> private void UpdateContent() { // Update the standings list FittingContentListBox.BeginUpdate(); try { IList <KillLogItem> items = m_killLog.Items.ToList(); IEnumerable <IGrouping <KillLogFittingContentGroup, KillLogItem> > groups = items .GroupBy(item => item.FittingContentGroup).OrderBy(x => x.Key); // Scroll through groups FittingContentListBox.Items.Clear(); foreach (IGrouping <KillLogFittingContentGroup, KillLogItem> group in groups) { FittingContentListBox.Items.Add(group.Key); foreach (KillLogItem item in group) { // Add the item to the list AddItem(item); if (!item.Items.Any()) { continue; } // Add items in a container to the list foreach (KillLogItem itemInItem in item.Items) { AddItem(itemInItem); } } } // Display or hide the "no standings" label. noItemsLabel.Visible = !items.Any(); FittingContentListBox.Visible = items.Any(); // Invalidate display FittingContentListBox.Invalidate(); } finally { FittingContentListBox.EndUpdate(); ItemsCostLabel.Text = GetTotalCost(); } }
/// <summary> /// Handles the Resize event of the FittingContentListBox control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void FittingContentListBox_Resize(object sender, EventArgs e) { FittingContentListBox.Invalidate(); }
/// <summary> /// Handles the KillLogItemImageUpdated event of the item control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void item_KillLogItemImageUpdated(object sender, EventArgs e) { // Force to redraw FittingContentListBox.Invalidate(); }
/// <summary> /// Handles the MouseWheel event of the FittingContentListBox control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> private void FittingContentListBox_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta == 0) { return; } // Update the drawing based upon the mouse wheel scrolling int numberOfItemLinesToMove = e.Delta * SystemInformation.MouseWheelScrollLines / Math.Abs(e.Delta); int lines = numberOfItemLinesToMove; if (lines == 0) { return; } // Compute the number of lines to move int direction = lines / Math.Abs(lines); int[] numberOfPixelsToMove = new int[lines * direction]; for (int i = 1; i <= Math.Abs(lines); i++) { object item = null; // Going up if (direction == Math.Abs(direction)) { // Retrieve the next top item if (FittingContentListBox.TopIndex - i >= 0) { item = FittingContentListBox.Items[FittingContentListBox.TopIndex - i]; } } // Going down else { // Compute the height of the items from current the topindex (included) int height = 0; for (int j = FittingContentListBox.TopIndex + i - 1; j < FittingContentListBox.Items.Count; j++) { height += FittingDetailHeight; } // Retrieve the next bottom item if (height > FittingContentListBox.ClientSize.Height) { item = FittingContentListBox.Items[FittingContentListBox.TopIndex + i - 1]; } } // If found a new item as top or bottom if (item != null) { numberOfPixelsToMove[i - 1] = FittingDetailHeight * direction; } else { lines -= direction; } } // Scroll if (lines != 0) { FittingContentListBox.Invalidate(); } }