// The mouse is clicked on the panel. Change the selection.
        // Show the popup menu if appropriate.
        private void descriptionPanel_MouseDown(object sender, MouseEventArgs e)
        {
            HitTestResult hitTest = renderer.HitTest(e.Location);

            if (hitTest.firstLine < 0)
            {
                return;             // clicked outside the description.
            }
            bool alreadySelected = (hitTest.firstLine == firstSelectedLine);

            if (!alreadySelected)
            {
                // Move the selected line.
                SetSelection(hitTest.firstLine, hitTest.lastLine);
                if (SelectedIndexChange != null)
                {
                    SelectedIndexChange(this, EventArgs.Empty);
                }
            }

            // If the left-click the selected line, or right-click anywhere, then possible show a popup menu.
            if ((e.Button == MouseButtons.Right || alreadySelected) && hitTest.kind != HitTestKind.None)
            {
                // Clicked on the selected line, in a potentially interesting place. Show a menu (maybe).
                PopupMenu(hitTest);
            }
        }
Exemple #2
0
        void CheckHitTest(DescriptionRenderer renderer, Point pt, HitTestKind expectedKind, int expectedFirstLine, int expectedLastLine, int expectedBox, RectangleF expectedRect)
        {
            HitTestResult result;

            result = renderer.HitTest(pt);

            Assert.AreEqual(expectedKind, result.kind);
            Assert.AreEqual(expectedFirstLine, result.firstLine);
            Assert.AreEqual(expectedLastLine, result.lastLine);
            Assert.AreEqual(expectedBox, result.box);
            Assert.AreEqual(expectedRect, result.rect);
        }
Exemple #3
0
        private void pictureBoxDescription_MouseDown(object sender, MouseEventArgs e)
        {
            hitTest               = descriptionRenderer.HitTest(e.Location);
            labelPoint.Text       = string.Format("Location: ({0},{1})", e.X, e.Y);
            labelHitTestKind.Text = string.Format("Hit: {0}", hitTest.kind);
            labelHitTestCol.Text  = string.Format("Box: {0}", hitTest.box);
            labelHitTestLine.Text = string.Format("Line: {0}-{1}", hitTest.firstLine, hitTest.lastLine);
            labelHitTestRect.Text = string.Format("Rect: ({0},{1}) wid={2} hgt={3}", hitTest.rect.Left, hitTest.rect.Top, hitTest.rect.Width, hitTest.rect.Height);
            this.Invalidate(true);

            /*
             *
             * int column = (int) ((e.X - descriptionRenderer.Margin) / descriptionRenderer.CellSize);
             * int line = (int)((e.Y - descriptionRenderer.Margin) / descriptionRenderer.CellSize);
             *
             * if (column >= 0 && column <= 7) {
             *  ShowDropDown((char)('A' + column), line, new Point((int)((e.X - descriptionRenderer.Margin) / descriptionRenderer.CellSize + 1) * (int)descriptionRenderer.CellSize - 11, (int)((e.Y - descriptionRenderer.Margin) / descriptionRenderer.CellSize + 1) * (int)descriptionRenderer.CellSize - 5));
             * }
             */
        }
        void CheckHitTest(DescriptionRenderer renderer, Point pt, HitTestKind expectedKind, int expectedFirstLine, int expectedLastLine, int expectedBox, RectangleF expectedRect)
        {
            HitTestResult result;
            result = renderer.HitTest(pt);

            Assert.AreEqual(expectedKind, result.kind);
            Assert.AreEqual(expectedFirstLine, result.firstLine);
            Assert.AreEqual(expectedLastLine, result.lastLine);
            Assert.AreEqual(expectedBox, result.box);
            Assert.AreEqual(expectedRect, result.rect);
        }