private void OnSelectedMachineWidePackageSourceChanged(object sender, EventArgs e)
        {
            PackageSourcesListBox.ClearSelected();
            UpdateUI();

            UpdateTextBoxes((PackageSourceContextInfo)_machineWidepackageSources.Current);
        }
Beispiel #2
0
 private void PackageSourcesListBox_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         PackageSourcesListBox.SelectedIndex = PackageSourcesListBox.IndexFromPoint(e.Location);
     }
 }
        private void TogglePackageSourceEnabled(int itemIndex)
        {
            if (itemIndex < 0 || itemIndex >= PackageSourcesListBox.Items.Count)
            {
                return;
            }

            var item = (PackageSource)PackageSourcesListBox.Items[itemIndex];

            item.IsEnabled = !item.IsEnabled;

            PackageSourcesListBox.Invalidate(GetCheckBoxRectangleForListBoxItem(itemIndex));
        }
        private Rectangle GetCheckBoxRectangleForListBoxItem(int itemIndex)
        {
            const int edgeMargin = 8;

            Rectangle itemRectangle = PackageSourcesListBox.GetItemRectangle(itemIndex);

            // this is the bound of the checkbox
            var checkBoxRectangle = new Rectangle(
                itemRectangle.Left + edgeMargin + 2,
                itemRectangle.Top + edgeMargin,
                _checkBoxSize.Width,
                _checkBoxSize.Height);

            return(checkBoxRectangle);
        }
Beispiel #5
0
        private void PackageSourcesListBox_MouseMove(object sender, MouseEventArgs e)
        {
            int index = PackageSourcesListBox.IndexFromPoint(e.X, e.Y);

            if (index >= 0 && index < PackageSourcesListBox.Items.Count && e.Y <= PackageSourcesListBox.PreferredHeight)
            {
                string newToolTip     = ((PackageSource)PackageSourcesListBox.Items[index]).Source;
                string currentToolTip = packageListToolTip.GetToolTip(PackageSourcesListBox);
                if (currentToolTip != newToolTip)
                {
                    packageListToolTip.SetToolTip(PackageSourcesListBox, newToolTip);
                }
            }
            else
            {
                packageListToolTip.SetToolTip(PackageSourcesListBox, null);
                packageListToolTip.Hide(PackageSourcesListBox);
            }
        }
 private void PackageSourcesListBox_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         PackageSourcesListBox.SelectedIndex = PackageSourcesListBox.IndexFromPoint(e.Location);
     }
     else if (e.Button == MouseButtons.Left)
     {
         int itemIndex = PackageSourcesListBox.IndexFromPoint(e.Location);
         if (itemIndex >= 0 && itemIndex < PackageSourcesListBox.Items.Count)
         {
             Rectangle checkBoxRectangle = GetCheckBoxRectangleForListBoxItem(itemIndex);
             // if the mouse click position is inside the checkbox, toggle the IsEnabled property
             if (checkBoxRectangle.Contains(e.Location))
             {
                 TogglePackageSourceEnabled(itemIndex);
             }
         }
     }
 }