Esempio n. 1
0
        private void DrawMark(WriteableBitmap wb, int gi, int ci, HitTestArea area)
        {
            var g  = _groups[gi];
            var x1 = wb.CheckX(GetClientX(g.Start));
            var x2 = wb.CheckX(GetClientX(g.End));
            var y1 = wb.CheckY(GetClientY(g.Cells[ci].Start));
            var y2 = wb.CheckY(GetClientY(g.Cells[ci].End));

            if (y1 - y2 == 0 || x1 - x2 == 0)
            {
                return;
            }
            if (area.HasFlag(HitTestArea.GroupStart))
            {
                wb.FillEllipse(wb.CheckX(x1 - 2), wb.CheckY((y2 + y1) / 2 - 2), wb.CheckX(x1 + 2), wb.CheckY((y2 + y1) / 2 + 2), g.Cells[ci].BackColor.GetContrastColor());
            }
            else if (area.HasFlag(HitTestArea.GroupEnd))
            {
                wb.FillEllipse(wb.CheckX(x2 - 2), wb.CheckY((y2 + y1) / 2 - 2), wb.CheckX(x2 + 2), wb.CheckY((y2 + y1) / 2 + 2), g.Cells[ci].BackColor.GetContrastColor());
            }
            else if (area.HasFlag(HitTestArea.CellStart))
            {
                wb.FillEllipse(wb.CheckX((x1 + x2) / 2 - 2), wb.CheckY(y1 - 2), wb.CheckX((x1 + x2) / 2 + 2), wb.CheckY(y1 + 2), g.Cells[ci].BackColor.GetContrastColor());
            }
            else if (area.HasFlag(HitTestArea.CellEnd))
            {
                wb.FillEllipse(wb.CheckX((x1 + x2) / 2 - 2), wb.CheckY(y2 - 2), wb.CheckX((x1 + x2) / 2 + 2), wb.CheckY(y2 + 2), g.Cells[ci].BackColor.GetContrastColor());
            }
            else if (area.HasFlag(HitTestArea.CellBody))
            {
                wb.DrawRectangle(wb.CheckX(x1 + 1), wb.CheckY(y1 + 1), wb.CheckX(x2), wb.CheckY(y2), g.Cells[ci].BackColor.GetContrastColor());
            }
        }
Esempio n. 2
0
 public TableChartHitTestResult(bool success, HitTestArea area, int groupIndex, int cellIndex)
     : base(success)
 {
     CellIndex  = cellIndex;
     GroupIndex = groupIndex;
     Area       = area;
 }
Esempio n. 3
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            HitTestResult hitTestResult = GetHitTest();
            HitTestArea   hitArea       = hitTestResult.HitArea;
            int           index         = hitTestResult.Index;
            string        toolTip       = string.Empty;

            base.OnMouseMove(e);

            if (hitArea == HitTestArea.TabStrip && index != -1)
            {
                Rectangle rectTab = GetTabRectangle(index);
                if (rectTab.Width < GetTabOriginalWidth(index))
                {
                    toolTip = GetVisibleContent(index).Text;
                }
            }

            if (m_toolTip.GetToolTip(this) != toolTip)
            {
                m_toolTip.Active = false;
                m_toolTip.SetToolTip(this, toolTip);
                m_toolTip.Active = true;
            }
        }
Esempio n. 4
0
 public MarkData(HitTestArea area, int groupIndex, int cellIndex, bool locked)
     : this()
 {
     this.Area       = area;
     this.GroupIndex = groupIndex;
     this.CellIndex  = cellIndex;
     IsLocked        = locked;
 }
Esempio n. 5
0
        public void SetMark(int gi, int ci, HitTestArea area, bool locked)
        {
            if (_markData.IsLocked)
            {
                return;
            }
            var oldMark = _markData;

            _markData = new MarkData(area, gi, ci, locked);
            RedrawGroup(oldMark.Area != HitTestArea.None ? oldMark.GroupIndex : gi);
        }
Esempio n. 6
0
        public void UnsetMark(HitTestArea area)
        {
            if (_markData.IsLocked)
            {
                return;
            }
            var a = _markData.Area & (~area);

            _markData = new MarkData(a, _markData.GroupIndex, _markData.CellIndex, false);
            RedrawGroup(_markData.GroupIndex);
        }
Esempio n. 7
0
        /// <param name="spawnPosition">The starting position on-screen for this object.</param>
        /// <param name="renderer">Used to render a visual representation of this object to a surface.</param>
        /// <param name="initialDirection">This direction this object or its children face when first created.</param>
        /// <param name="moveSpeed">The distance this object can travel on-screen each game-cycle.</param>
        /// <param name="winConditions">Used to determine if this object has won the game.</param>
        protected GameObject(Position spawnPosition, IRenderer renderer, Direction initialDirection, int moveSpeed, IWinCondition[] winConditions)
        {
            Position     = new Position(spawnPosition.XPos, spawnPosition.YPos);
            HitTestArea  = new HitTestArea(new Position(0, 0), 0, 0);
            ChildObjects = new List <GameObject>();

            _renderer      = renderer;
            _direction     = initialDirection;
            _moveSpeed     = moveSpeed;
            _spawnPosition = spawnPosition;
            _winConditions = winConditions;
        }
Esempio n. 8
0
 /// <summary>
 /// Create instance of <see cref="HitTestInfo"/>. Use this to get the HitTest information.
 /// </summary>
 /// <param name="control"><see cref="SuperMarquee"/> for which HitTest is to be performed.</param>
 /// <param name="testPoint">HitTest Point</param>
 public HitTestInfo(SuperMarquee control, Point testPoint)
 {
     if (control != null)
     {
         HitTestInfo test = control.HitTest(testPoint);
         index = test.index;
         point = test.point;
         area  = test.area;
     }
     else
     {
         index = -1;
         point = testPoint;
         area  = HitTestArea.None;
     }
 }
 /// <summary>
 /// Create instance of <see cref="HitTestInfo"/>. Use this to get the HitTest information.
 /// </summary>
 /// <param name="control"><see cref="SuperMarquee"/> for which HitTest is to be performed.</param>
 /// <param name="testPoint">HitTest Point</param>
 public HitTestInfo(SuperMarquee control, Point testPoint)
 {
     if (control != null)
     {
         HitTestInfo test = control.HitTest(testPoint);
         index = test.index;
         point = test.point;
         area = test.area;
     }
     else
     {
         index = -1;
         point = testPoint;
         area = HitTestArea.None;
     }
 }
 public RangePainterHitTestEventArgs(Point point, HitTestArea hitTestArea)
 {
     this.Point       = point;
     this.HitTestArea = hitTestArea;
 }
Esempio n. 11
0
 public HitTestResult(HitTestArea hitTestArea, int index)
 {
     HitArea = hitTestArea;
     Index   = index;
 }
Esempio n. 12
0
 public HitTestResult(HitTestArea hitTestArea)
 {
     HitArea = hitTestArea;
     Index   = -1;
 }
Esempio n. 13
0
 public HitTestResult(HitTestArea hitTestArea, int index)
 {
     this.HitArea = hitTestArea;
     this.Index = index;
 }
Esempio n. 14
0
 public bool Check(HitTestArea area, int itemIndex, int itemPart)
 {
     return ItemIndex == itemIndex && Area == area && ItemPart == itemPart;
 }
Esempio n. 15
0
 public bool CollidedWith(GameObject otherObject)
 {
     return(HitTestArea.HasCollidedWith(otherObject.HitTestArea) ||
            ChildObjects.Any(child => child.CollidedWith(otherObject)));
 }
Esempio n. 16
0
			public HitTestResult(HitTestArea hitTestArea)
			{
				HitArea = hitTestArea;
				Index = -1;
			}
Esempio n. 17
0
 public HitTestResult(HitTestArea area, int itemIndex, int itemPart)
 {
     Area = area;
     ItemIndex = itemIndex;
     ItemPart = itemPart;
 }
Esempio n. 18
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            var renderRequest = new RenderRequest
            {
                IsHitTest   = true,
                CursorPoint = e.Location
            };

            Render(renderRequest);

            switch (e.Button)
            {
            case MouseButtons.XButton1:
            case MouseButtons.XButton2:

                // TODO: Redo this so that the paragraph selected in the text is the selected one
                // TODO: Mouse4 changes start, mouse5 changes end
                // TODO: The note should not have to be visible; remake the NoteMoved so the note is not required


                // Middle mouse button should resize the note according to the most closely clicked location, in relevance to the location that the user is in the text
                var    clickedByteIndex = ClientXToByteIndex(e.X);
                var    clickedInterval  = new Interval(clickedByteIndex, clickedByteIndex);
                long[] closestDistances = null;
                var    closestDistance  = long.MaxValue;
                Note   closestNote      = null;
                foreach (var note in renderRequest.Notes)
                {
                    if (note.IsFocused)
                    {
                        closestNote      = note;
                        closestDistances = note.Interval.GetDistanceFromOverlap(clickedByteIndex);
                        break;
                    }
                }

                if (closestNote == null)
                {
                    foreach (var note in renderRequest.Notes)
                    {
                        var distance = note.Interval.GetDistanceFromOverlap(clickedByteIndex);
                        if (note.IsFocused || note.Interval.IsOverlapping(clickedInterval))
                        {
                            closestNote      = note;
                            closestDistances = distance;
                            break;
                        }

                        var actualDistance = Math.Min(Math.Abs(distance[0]), Math.Abs(distance[1]));
                        if (actualDistance < closestDistance)
                        {
                            closestNote      = note;
                            closestDistances = distance;
                            closestDistance  = actualDistance;
                        }
                    }
                }

                if (closestNote != null)
                {
                    var isStart = Math.Abs(closestDistances[0]) < Math.Abs(closestDistances[1]);

                    if (NoteMoved != null)
                    {
                        var args = new NoteMovedEventArgs
                        {
                            Area      = isStart ? HitTestArea.NoteLeft : HitTestArea.NoteRight,
                            ByteIndex = clickedByteIndex,
                            Note      = closestNote
                        };

                        NoteMoved(this, args);
                    }
                }

                break;

            case MouseButtons.Middle:
                break;

                #region old zoom code

                /*
                 * if (this._mouseDraggingZoom)
                 * {
                 * // Let's set the time zoom!
                 * var low = Math.Max(0, Math.Min(this._mouseDragStartX, this._mouseDragEndX));
                 * var high = Math.Min(this.ClientRectangle.Width, Math.Max(this._mouseDragStartX, this._mouseDragEndX));
                 *
                 * // Set as approximative as we can.
                 * var timeStart = this.ClientXToByteIndex(low);
                 * var timeEnd = this.ClientXToByteIndex(high);
                 *
                 * this._zoomStack.Push((timeEnd - timeStart) / (double)this._bytesTotal);
                 *
                 * // Restart the processing, since we've now zoomed in.
                 * this.ClearWork();
                 * this.QueueWork(new Work(this.GetCurrentViewPortStart(), this.GetCurrentViewPortEnd()));
                 * }
                 * else
                 * {
                 * // The user clicked Middle Mouse, but had not selected anything. Let's zoom out.
                 * // Zoom out to the previous zoom level.
                 * if (this._zoomStack.Count > 0)
                 * {
                 *  this._zoomStack.Pop();
                 *  this.ClearWork();
                 *  this.QueueWork(new Work(this.GetCurrentViewPortStart(), this.GetCurrentViewPortEnd()));
                 * }
                 * }
                 */

                #endregion

            case MouseButtons.Left:
                if (_mouseDraggingPan == false)
                {
                    var note = renderRequest.FocusedObject as Note;
                    if (note != null)
                    {
                        if (NoteClicked != null)
                        {
                            NoteClicked(this, new NoteClickedEventArgs
                            {
                                Note = note,
                                Area = renderRequest.HitTestArea
                            });
                        }
                    }
                }

                break;
            }

            if (_mouseDraggingPan)
            {
                if (_mouseDraggingObject == null && IsCaretInsideViewPort)
                {
                    var distanceIntoViewPort = GetCurrentBytePosition() - GetCurrentViewPortStart();
                    _caretOffset = distanceIntoViewPort / (double)GetCurrentViewPortDistance();
                }
                else
                {
                    // Since we stopped panning outside of the currently playing viewport, we'll set the caret offset to NaN.
                    // This means that the viewport will stay where it is, while the track is playing.
                    switch (Bass.ChannelIsActive(_playChannel))
                    {
                    case PlaybackState.Playing:
                        _caretOffset = double.NaN;
                        break;
                    }
                }

                // Let's get the new area that should be rendered, and queue the work.
                // We'll add the whole visible viewport, and it will automatically be split and merged properly.
                var work = new Work(GetCurrentViewPortStart(), GetCurrentViewPortEnd());
                QueueWork(work);
            }

            Cursor               = Cursors.Default;
            _mouseDraggingZoom   = false;
            _mouseDraggingPan    = false;
            _mouseDown           = false;
            _mouseDraggingObject = null;
            _mouseDraggingArea   = HitTestArea.None;

            Invalidate();
        }
Esempio n. 19
0
 public HitTestInfo(
     HitTestArea area)
 {
     _area  = area;
     _point = null;
 }
Esempio n. 20
0
 public HitTestInfo(
     GradientPoint point)
 {
     _area  = HitTestArea.Point;
     _point = point;
 }
 internal HitTestResult(ILegendItem item, HitTestArea hti)
 {
     Item        = item;
     HitTestArea = hti;
 }
Esempio n. 22
0
 public bool Check(HitTestArea area, int itemPart)
 {
     return Area == area && ItemPart == itemPart;
 }
Esempio n. 23
0
			public HitTestResult(HitTestArea hitTestArea, int index)
			{
				HitArea = hitTestArea;
				Index = index;
			}
Esempio n. 24
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            switch (e.Button)
            {
            case MouseButtons.Right:

                // Set the caret position, so that we'll start following with the viewport
                _viewPortStart = GetCurrentViewPortStart();

                // Start playing at the location that was clicked.
                var clickedByteIndex = ClientXToByteIndex(e.Location.X);

                switch (Bass.ChannelIsActive(_playChannel))
                {
                case PlaybackState.Playing:
                    StartPlaying(clickedByteIndex);
                    break;

                default:
                    SetLocation(clickedByteIndex);
                    break;
                }

                if (double.IsNaN(_caretOffset) == false)
                {
                    _caretOffset = e.X / (double)ClientRectangle.Width;
                }
                break;

            case MouseButtons.Middle:
                _mouseDown       = true;
                _mouseDragStartX = e.Location.X;
                break;

            case MouseButtons.Left:

                var request = new RenderRequest
                {
                    IsHitTest   = true,
                    CursorPoint = e.Location
                };

                Render(request);

                _mouseDown         = true;
                _mouseDragStartX   = e.Location.X;
                _mouseDraggingArea = HitTestArea.None;

                var note = request.FocusedObject as Note;
                if (note != null)
                {
                    _mouseDraggingArea   = request.HitTestArea;
                    _mouseDraggingObject = request.FocusedObject;
                    _viewPortStart       = GetCurrentViewPortStart();

                    switch (Bass.ChannelIsActive(_playChannel))
                    {
                    case PlaybackState.Playing:
                        _caretOffset = double.NaN;
                        break;
                    }

                    switch (request.HitTestArea)
                    {
                    case HitTestArea.NoteLeft:
                        _mouseDragByteIndexStart = note.Interval.Start;
                        break;

                    case HitTestArea.NoteRight:
                        _mouseDragByteIndexStart = note.Interval.End;
                        break;

                    case HitTestArea.NoteCenter:
                        _mouseDragByteIndexStart = note.Interval.Start;
                        break;
                    }

                    Cursor = request.CursorResult ?? Cursors.Default;
                }
                else
                {
                    _mouseDragByteIndexStart = GetCurrentViewPortStart();
                    _viewPortStart           = _mouseDragByteIndexStart;
                    _caretOffset             = double.NaN;
                }

                break;
            }
        }