Пример #1
0
        public Tuple<Point, Point, Point> DrawNote(Tone tone, int notePositionX)
        {
            int toneIndex = ToneGraph.GetReferenceToneIndex(tone);
            Point notePosition = new Point();
            notePosition.X = notePositionX;
            notePosition.Y = 226 - 15 * toneIndex;

            int ledgerLineTop;

            if (toneIndex < 12)
            {
                ledgerLineTop = (LowestNotePositionY - 1) - (int)(toneIndex / 2) * DistanceBetweenLines;
            }
            else
            {
                ledgerLineTop = (LowestNotePositionY - 1) - (int)((toneIndex - 1) / 2) * DistanceBetweenLines;
            }

            Point ledgerLinePosition = new Point();
            ledgerLinePosition.X = notePositionX - 5;
            ledgerLinePosition.Y = ledgerLineTop;

            Point sharpFlatSymbolPosition = SharpFlatSymbolPosition(tone, notePositionX);

            return new Tuple<Point, Point, Point>(notePosition, ledgerLinePosition, sharpFlatSymbolPosition);
        }
Пример #2
0
        public Bitmap DrawNote(Bitmap stave, Bitmap note, Tone tone, int notePositionX)
        {
            int index = ToneGraph.GetReferenceToneIndex(tone);
            Bitmap newBitmap = new Bitmap(stave.Width, stave.Height);

            using (Graphics graphics = Graphics.FromImage(newBitmap))
            {
                Rectangle ImageSize = new Rectangle(0, 0, stave.Width, stave.Height);
                graphics.FillRectangle(Brushes.White, ImageSize);

                if (tone.ChromaticChange != 0)
                {
                    DrawFlatSharpSymbol(newBitmap, tone, index, notePositionX);
                }

                graphics.DrawImage(note, new Point(notePositionX, this.LowestNotePositionY -
                                                                 (this.DistanceBetweenLines / 2) * index));
                DrawLedgerLine(newBitmap, tone, index, notePositionX);
                graphics.CompositingMode = CompositingMode.SourceOver;
                stave.MakeTransparent(Color.White);
                graphics.DrawImage(stave, 0, 0);
            }

            return newBitmap;
        }
Пример #3
0
 public Scale(string name, string type, Tone startingTone, int keySignature)
 {
     this.Name = name;
     this.Type = type;
     this.StartingTone = startingTone;
     this.KeySignature = keySignature;
 }
Пример #4
0
        private ToneRelationship GetBasicToneRelationship(Tone tone)
        {
            for (int i = 0; i < tone.Neighbors.Count; i++)
            {
                ToneRelationship toneRelationship = tone.Neighbors.ElementAt(i);

                if (ToneGraph.IsBasicTone(toneRelationship.Tone2))
                {
                    return(toneRelationship);
                }
            }

            return(null);
        }
Пример #5
0
        private void DisplayNextNote()
        {
            int  actualNoteIndex = Convert.ToInt32(this.ActualNoteIndex.Value);
            Tone nextTone        = this.GetNextToneToDisplay();

            if (nextTone != null)
            {
                StaveObjectsPosition        sop          = new StaveObjectsPosition(226, 30);
                Tuple <Point, Point, Point> notePosition = sop.DrawNote(nextTone, 150 + (117 * (actualNoteIndex - 1)));

                this.ActualNoteIndex.Value = (Convert.ToInt32(this.ActualNoteIndex.Value) + 1).ToString();
                this.PreviousTone.Value    = nextTone.Name;

                switch (actualNoteIndex)
                {
                case 1: this.ChangePositionOfNote(notePosition, this.Note1, this.LedgerLine1, this.SharpFlatSymbol1,
                                                  nextTone);
                    break;

                case 2: this.ChangePositionOfNote(notePosition, this.Note2, this.LedgerLine2, this.SharpFlatSymbol2,
                                                  nextTone);
                    break;

                case 3: this.ChangePositionOfNote(notePosition, this.Note3, this.LedgerLine3, this.SharpFlatSymbol3,
                                                  nextTone);
                    break;

                case 4: this.ChangePositionOfNote(notePosition, this.Note4, this.LedgerLine4, this.SharpFlatSymbol4,
                                                  nextTone);
                    break;

                case 5: this.ChangePositionOfNote(notePosition, this.Note5, this.LedgerLine5, this.SharpFlatSymbol5,
                                                  nextTone);
                    break;

                case 6: this.ChangePositionOfNote(notePosition, this.Note6, this.LedgerLine6, this.SharpFlatSymbol6,
                                                  nextTone);
                    break;

                case 7: this.ChangePositionOfNote(notePosition, this.Note7, this.LedgerLine7, this.SharpFlatSymbol7,
                                                  nextTone);
                    break;

                case 8: this.ChangePositionOfNote(notePosition, this.Note8, this.LedgerLine8, this.SharpFlatSymbol8,
                                                  nextTone);
                    this.SetQuestionAsAnswered();
                    break;
                }
            }
        }
Пример #6
0
        private void DetermineAnswer(int chromaticChange)
        {
            int actualNoteIndex = Convert.ToInt32(this.ActualNoteIndex.Value);

            Tone toneAux     = ToneGraph.GetBasicToneByIndex(Convert.ToInt32(this.ToneClicked.Value));
            Tone toneClicked = ToneGraph.GetToneByReferenceToneAndChromaticChange(toneAux, chromaticChange);

            Tone nextTone = this.GetNextToneToDisplay();

            if (toneClicked.Name.Equals(nextTone.Name))
            {
                this.DisplayNextNote();
            }
        }
Пример #7
0
        private void DrawFlatSharpSymbol(Bitmap newBitmap, Tone tone, int index, int notePositionX)
        {
            Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange);

            // ideal distance from note is 7/29 of height of note
            int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29))
                                  - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0
            int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange);
            int symbolPositionY       = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * index;

            using (Graphics graphics = Graphics.FromImage(newBitmap))
            {
                graphics.DrawImage(symbol, new Point(symbolPositionX, symbolPositionY));
            }
        }
Пример #8
0
        private ToneRelationship GetDerivedToneRelationship(Tone tone, int halftoneDifference)
        {
            for (int i = 0; i < tone.Neighbors.Count; i++)
            {
                ToneRelationship toneRelationship = tone.Neighbors.ElementAt(i);

                if (!ToneGraph.IsBasicTone(toneRelationship.Tone2) &&
                    Math.Abs(halftoneDifference - toneRelationship.NumberOfHalftones) < Math.Abs(halftoneDifference))
                {
                    return(toneRelationship);
                }
            }

            return(null);
        }
Пример #9
0
        private static void ReadTones()
        {
            string[] lines = VyukaHN.Properties.Resources.Tones.Split(null);

            foreach (var line in lines)
            {
                if (line.Equals(""))
                {
                    continue;
                }

                var  items = line.Split(';');
                Tone tone  = new Tone(items[0], items[1], Convert.ToInt32(items[2]), ReadDistancesOfTones(items[0]));
                toneList.Add(tone);
            }
        }
Пример #10
0
        private Point SharpFlatSymbolPosition(Tone tone, int notePositionX)
        {
            if (tone.ChromaticChange == 0)
            {
                return(new Point());
            }

            Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange);

            // ideal distance from note is 7/29 of height of note
            int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29))
                                  - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0
            int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange);
            int symbolPositionY       = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * ToneGraph.GetReferenceToneIndex(tone);

            return(new Point(symbolPositionX, symbolPositionY));
        }
Пример #11
0
        private Tone GenerateStartingTone(GeneralInterval itv)
        {
            int  randomNumber = this.RandomNumber(0, 14 - (itv.numeral - 1));
            Tone tone         = ToneGraph.GetBasicToneByIndex(randomNumber);

            int randomNumber2 = this.RandomNumber(-1, 3);

            if (randomNumber2 != 0)
            {
                if (tone.Name != "h")
                {
                    tone = this.GetDerivedToneRelationship(tone, randomNumber2).Tone2;
                }
                else
                {
                    tone = this.GetDerivedToneRelationship(tone, Math.Abs(randomNumber2)).Tone2;
                }
            }

            return(tone);
        }
Пример #12
0
        public static Tone GetToneByReferenceToneAndChromaticChange(Tone referenceTone, int chromaticChange)
        {
            if(referenceTone.ChromaticChange != 0 || referenceTone == null || chromaticChange > 3 || chromaticChange < -3)
            {
                return null;
            }

            if (chromaticChange == 0)
            {
                return referenceTone;
            }

            Tone tone = null;
            foreach (Tone t in toneList)
            {
                if (t.ReferenceTone.Name.Equals(referenceTone.Name) && t.ChromaticChange == chromaticChange)
                {
                    tone = t;
                }
            }

            return tone;
        }
Пример #13
0
        public static Tone GetToneByReferenceToneAndChromaticChange(Tone referenceTone, int chromaticChange)
        {
            if (referenceTone.ChromaticChange != 0 || referenceTone == null || chromaticChange > 3 || chromaticChange < -3)
            {
                return(null);
            }

            if (chromaticChange == 0)
            {
                return(referenceTone);
            }

            Tone tone = null;

            foreach (Tone t in toneList)
            {
                if (t.ReferenceTone.Name.Equals(referenceTone.Name) && t.ChromaticChange == chromaticChange)
                {
                    tone = t;
                }
            }

            return(tone);
        }
Пример #14
0
 private int GetNoteFlatSharpSymbolWidth(Tone tone)
 {
     return(this.GetFlatSharpSymbol(tone.ChromaticChange) == null ?
            0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Width);
 }
Пример #15
0
 public static bool IsBasicTone(Tone tone)
 {
     return basicTones.Any(item => item.Equals(tone.Name));
 }
Пример #16
0
 public static int GetReferenceToneIndex(Tone tone)
 {
     return basicTones.FindIndex(x => x.Contains(tone.ReferenceTone.Name));
 }
Пример #17
0
        private static void ReadTones()
        {
            string[] lines = VyukaHN.Properties.Resources.Tones.Split(null);

            foreach (var line in lines)
            {
                if (line.Equals(""))
                {
                    continue;
                }

                var items = line.Split(';');
                Tone tone = new Tone(items[0], items[1], Convert.ToInt32(items[2]), ReadDistancesOfTones(items[0]));
                toneList.Add(tone);
            }
        }
        private void ChangePositionOfNote(Tuple<Point, Point, Point> notePosition, HtmlImage Note, 
                                          HtmlGenericControl LedgerLine, HtmlImage SharpFlatSymbol, Tone tone)
        {
            Note.Style.Add("visibility", "visible");
            Note.Style.Add("left", notePosition.Item1.X.ToString() + "px");
            Note.Style.Add("top", notePosition.Item1.Y.ToString() + "px");

            LedgerLine.Style.Add("visibility", "visible");
            LedgerLine.Style.Add("left", notePosition.Item2.X.ToString() + "px");
            LedgerLine.Style.Add("top", notePosition.Item2.Y.ToString() + "px");

            string sharpFlatSymbolSrc = this.SharpFlatSymbolSrc(tone.ChromaticChange);

            if (sharpFlatSymbolSrc.Equals(""))
            {
                SharpFlatSymbol.Style.Add("visibility", "hidden");
            }
            else
            {
                SharpFlatSymbol.Style.Add("visibility", "visible");
                SharpFlatSymbol.Src = this.SharpFlatSymbolSrc(tone.ChromaticChange);
            }

            SharpFlatSymbol.Style.Add("left", notePosition.Item3.X.ToString() + "px");
            SharpFlatSymbol.Style.Add("top", notePosition.Item3.Y.ToString() + "px");
        }
Пример #19
0
 public static int GetReferenceToneIndex(Tone tone)
 {
     return(basicTones.FindIndex(x => x.Contains(tone.ReferenceTone.Name)));
 }
Пример #20
0
        private Point SharpFlatSymbolPosition(Tone tone, int notePositionX)
        {
            if (tone.ChromaticChange == 0)
            {
                return new Point();
            }

            Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange);

            // ideal distance from note is 7/29 of height of note
            int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29))
                                  - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0
            int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange);
            int symbolPositionY = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * ToneGraph.GetReferenceToneIndex(tone);

            return new Point(symbolPositionX, symbolPositionY);
        }
Пример #21
0
 private int GetNoteFlatSharpSymbolWidth(Tone tone)
 {
     return this.GetFlatSharpSymbol(tone.ChromaticChange) == null ?
                                    0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Width;
 }
Пример #22
0
 private int GetNoteFlatSharpSymbolHeight(Tone tone)
 {
     return this.GetFlatSharpSymbol(tone.ChromaticChange) == null ?
                                    0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Height;
 }
Пример #23
0
        private void ChangePositionOfNote(Tuple <Point, Point, Point> notePosition, HtmlImage Note,
                                          HtmlGenericControl LedgerLine, HtmlImage SharpFlatSymbol, Tone tone)
        {
            Note.Style.Add("visibility", "visible");
            Note.Style.Add("left", notePosition.Item1.X.ToString() + "px");
            Note.Style.Add("top", notePosition.Item1.Y.ToString() + "px");

            LedgerLine.Style.Add("visibility", "visible");
            LedgerLine.Style.Add("left", notePosition.Item2.X.ToString() + "px");
            LedgerLine.Style.Add("top", notePosition.Item2.Y.ToString() + "px");

            string sharpFlatSymbolSrc = this.SharpFlatSymbolSrc(tone.ChromaticChange);

            if (sharpFlatSymbolSrc.Equals(""))
            {
                SharpFlatSymbol.Style.Add("visibility", "hidden");
            }
            else
            {
                SharpFlatSymbol.Style.Add("visibility", "visible");
                SharpFlatSymbol.Src = this.SharpFlatSymbolSrc(tone.ChromaticChange);
            }

            SharpFlatSymbol.Style.Add("left", notePosition.Item3.X.ToString() + "px");
            SharpFlatSymbol.Style.Add("top", notePosition.Item3.Y.ToString() + "px");
        }
Пример #24
0
 public Interval(Tone tone1, Tone tone2, GeneralInterval generalInterval)
 {
     this.Tone1           = tone1;
     this.Tone2           = tone2;
     this.GeneralInterval = generalInterval;
 }
Пример #25
0
        private void DrawLedgerLine(Bitmap newBitmap, Tone tone, int index, int XLowestNote)
        {
            int ledgerLinePositionY;

            switch (index)
            {
                case 0:
                case 1:
                    ledgerLinePositionY = this.LowestNotePositionY - 1;
                    break;
                case 13:
                    ledgerLinePositionY = (this.LowestNotePositionY - 1) - 12 * (this.DistanceBetweenLines / 2);
                    break;
                default:
                    return;
            }

            using (Graphics graphics = Graphics.FromImage(newBitmap))
            {
                graphics.DrawImage(VyukaHN.Properties.Resources.pomocnaLinka,
                                   new Point(XLowestNote - ((VyukaHN.Properties.Resources.pomocnaLinka.Width
                                             - VyukaHN.Properties.Resources.nota.Width) / 2), ledgerLinePositionY));
            }
        }
Пример #26
0
 public static bool IsBasicTone(Tone tone)
 {
     return(basicTones.Any(item => item.Equals(tone.Name)));
 }
Пример #27
0
 private int GetNoteFlatSharpSymbolHeight(Tone tone)
 {
     return(this.GetFlatSharpSymbol(tone.ChromaticChange) == null ?
            0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Height);
 }
Пример #28
0
 public Interval(Tone tone1, Tone tone2, GeneralInterval generalInterval)
 {
     this.Tone1 = tone1;
     this.Tone2 = tone2;
     this.GeneralInterval = generalInterval;
 }
Пример #29
0
        private void DrawFlatSharpSymbol(Bitmap newBitmap, Tone tone, int index, int notePositionX)
        {
            Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange);

            // ideal distance from note is 7/29 of height of note
            int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29))
                                  - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0
            int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange);
            int symbolPositionY = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * index;

            using (Graphics graphics = Graphics.FromImage(newBitmap))
            {
                graphics.DrawImage(symbol, new Point(symbolPositionX, symbolPositionY));
            }
        }