Ejemplo n.º 1
0
        /// <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();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the MouseMove event of the FittingContentListBox control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void FittingContentListBox_MouseMove(object sender, MouseEventArgs e)
        {
            for (int i = 0; i < FittingContentListBox.Items.Count; i++)
            {
                // Skip until we found the mouse location
                Rectangle rect = FittingContentListBox.GetItemRectangle(i);
                if (!rect.Contains(e.Location))
                {
                    continue;
                }

                Object item = FittingContentListBox.Items[i];
                FittingContentListBox.Cursor = item is KillLogItem ? CustomCursors.ContextMenu : Cursors.Default;

                return;
            }

            // If we went so far, we're not over anything
            FittingContentListBox.Cursor = Cursors.Default;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the MouseDown event of the FittingContentListBox control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void FittingContentListBox_MouseDown(object sender, MouseEventArgs e)
        {
            // Retrieve the item at the given point and quit if none
            int index = FittingContentListBox.IndexFromPoint(e.Location);

            if (index < 0 || index >= FittingContentListBox.Items.Count)
            {
                return;
            }

            KillLogItem killLogItem = FittingContentListBox.Items[index] as KillLogItem;

            // Beware, this last index may actually means a click in the whitespace at the bottom
            // Let's deal with this special case
            if (index == FittingContentListBox.Items.Count - 1)
            {
                Rectangle itemRect = FittingContentListBox.GetItemRectangle(index);
                if (!itemRect.Contains(e.Location))
                {
                    killLogItem = null;
                }
            }

            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // Right click reset the cursor
            FittingContentListBox.Cursor = Cursors.Default;

            // Set the selected item
            m_selectedItem = killLogItem?.Item;

            // Display the context menu
            contextMenuStrip.Show(FittingContentListBox, e.Location);
        }
Ejemplo n.º 4
0
 /// <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();
 }
Ejemplo n.º 5
0
 /// <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();
 }
Ejemplo n.º 6
0
        /// <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();
            }
        }