コード例 #1
0
        List<Selector> GetVisibleSelectors()
        {
            var ret = new List<Selector>();
            var chord = SelectedChord;
            if ((SelectedChord != null && SelectedChord.IsDeleted) || chord == null || chord.HasNotes == false)
                return ret;

            Point p = PointToClient(MousePosition);

            var minMaxY = GetChordYMinMax(chord);
            var start = GetClientPointFromTick(chord.DownTick);
            var end = GetClientPointFromTick(chord.UpTick);

            var chordScreen = new Rectangle(start, minMaxY.X, end - start, minMaxY.Y - minMaxY.X);

            var distC = p.Distance(chordScreen);

            if (distC <= Utility.ShowSelectorDist)
            {

                for (int sl = 0; sl < 2; sl++)
                {
                    var selector = new Rectangle(
                        chordScreen.X,
                        chordScreen.Top,
                        Utility.SelectorWidth,
                        chordScreen.Height);

                    Point startPos;

                    if (sl == 0)
                    {
                        selector.X += chordScreen.Width - Utility.SelectorWidth;

                        startPos = new Point(
                            chordScreen.Right - selector.Width,
                            chordScreen.Top);
                    }
                    else
                    {
                        startPos = new Point(chordScreen.X,
                            chordScreen.Top);
                    }

                    var sel = new Selector()
                    {
                        StartPoint = startPos,
                        CurrentPoint = startPos,
                        Chord = SelectedChord,
                        IsRight = sl == 0
                    };

                    Rectangle r = sel.GetCurrentRect(this);

                    var dist = p.Distance(r);

                    sel.IsMouseOver = false;
                    if (dist <= Utility.ShowSelectorDist)
                    {
                        sel.IsMouseNear = true;
                        if (r.Contains(p))
                        {
                            sel.IsMouseOver = true;

                        }
                    }
                    ret.Add(sel);
                }
            }

            return ret;
        }
コード例 #2
0
        void DrawSelector(Graphics g,
            Selector sel)
        {
            var c = Utility.noteBGBrushSel.Color;
            var color = Color.FromArgb(40, 80, 40);
            if (sel == null || sel.Chord.HasNotes == false)
                return;

            var trans = sel.IsMouseOver ? 205 : sel.IsMouseNear ? 120 : 80;

            var r = sel.GetCurrentRect(this);

            using (Pen pn = new Pen(Color.FromArgb(trans, color), 1.0f))
            {
                int w = 3;
                if (sel.IsMouseOver == false)
                    w = 2;
                for (int j = 0; j < w; j++)
                {
                    Point[] p = new Point[2];
                    if (sel.IsRight)
                    {
                        p[0] = new Point(
                            r.X + Utility.SelectorWidth - 1 + j,
                            r.Y - 1);
                        p[1] = new Point(
                            r.X + Utility.SelectorWidth - 1 + j,
                            r.Y + r.Height + 2);
                    }
                    else
                    {
                        p[0] = new Point(
                             r.X - 1 + j,
                            r.Y - 1);
                        p[1] = new Point(
                            r.X - 1 + j,
                            r.Y + r.Height + 2);
                    }

                    g.DrawLine(pn, p[0], p[1]);
                }

                g.DrawLine(pn,
                    r.X,
                    r.Y - 1,
                    r.X + r.Width,
                    r.Y - 2);
                g.DrawLine(pn,
                    r.X,
                    r.Y + r.Height + 2,
                    r.X + r.Width,
                    r.Y + r.Height + 2);
            }
        }