private void OnSongQueueUpdate(object source, HuntingHornSongEventArgs args)
        {
            if (args.IsCastingSongs)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
            {
                if (SongQueue.Children.Count == args.SongsQueued)
                {
                    int index = args.RawSongIndexesQueue[args.LastSongIndex];

                    if (args.Songs.Length < index + 1 || index < 0)
                    {
                        return;
                    }

                    sHuntingHornSong song = args.Songs[index];

                    SongComponent songComponent = new SongComponent()
                    {
                        SongName = GStrings.GetAbnormalityByID("HUNTINGHORN", song.BuffId, 0)
                    };
                    songComponent.SetSong(song.Notes, cachedBrushes);
                    SongQueue.Children.Insert(0, songComponent);

                    SongQueue.Children.RemoveAt(SongQueue.Children.Count - 1);
                }
                else
                {
                    bool insert = SongQueue.Children.Count > 0;
                    // Add remaning songs to the queue based on the SongQueue length
                    for (int i = 0; SongQueue.Children.Count < args.SongsQueued; i++)
                    {
                        int index             = args.SongIndexesQueue[i];
                        sHuntingHornSong song = args.Songs[index];

                        SongComponent songComponent = new SongComponent()
                        {
                            SongName = GStrings.GetAbnormalityByID("HUNTINGHORN", song.BuffId, 0)
                        };
                        songComponent.SetSong(song.Notes, cachedBrushes);

                        if (insert)
                        {
                            SongQueue.Children.Insert(0, songComponent);
                        }
                        else
                        {
                            SongQueue.Children.Add(songComponent);
                        }
                    }
                }
            }));
        }
        public static void RenderEightsSpecial(Graphics g, List <SongComponent> listSc)
        {
            for (int i = 0; i < listSc.Count; i++)
            {
                SongComponent sa = listSc[i];
                //Verkrijg x en y van songcomponent
                int  x         = sa.X;
                int  y         = sa.Octave == 4 ? sa.Y + 7 : sa.Y;
                bool up        = sa.Octave == 4 ? true : false;
                int  indexLast = listSc.Count - 1;
                int  xLast     = (listSc[indexLast].X * NOTE_FULL_WIDTH) + NOTE_RENDER_PADDING;
                int  yLast     = (listSc[indexLast].Y * LINE_PADDING_VERTICAL);
                int  xFirst    = (listSc[0].X * NOTE_FULL_WIDTH) + NOTE_RENDER_PADDING;
                int  yFirst    = (listSc[0].Y * LINE_PADDING_VERTICAL);

                //Set grid coordinaten om naar realtime coordinaten
                int realX = x * NOTE_FULL_WIDTH;
                int realY = y * LINE_PADDING_VERTICAL;

                //Als onderstaande voorwaarde true is wordt er een kruis voor de noot getekend
                Note sc = (Note)sa;
                if (sc.Black)
                {
                    g.DrawImage(IMAGE_NOTE_BES, (realX - 11), realY - 12);
                }

                g.TranslateTransform(realX, realY);
                g.RotateTransform(-30f);
                g.TranslateTransform(-realX, -realY);
                g.FillEllipse(BRUSH, realX, realY - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                g.ResetTransform();

                RenderVerticalLine(g, y, realX, realY);
                if (i == 0)
                {
                    RenderStokje(g, up, realX, realY, NOTE_LINE_HEIGHT);
                    if (up)
                    {
                        g.DrawLine(THICKER_PEN, xFirst, yFirst, xLast, yLast);
                    }
                    else
                    {
                        g.DrawLine(THICKER_PEN, xFirst - 11, yFirst + NOTE_LINE_HEIGHT, xLast - 9, yLast + NOTE_LINE_HEIGHT);
                    }
                }
                else if (i == (listSc.Count - 1))
                {
                    RenderStokje(g, up, realX, realY, NOTE_LINE_HEIGHT);
                }
            }
        }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (this.WindowPanelEditor.Controls.Count != 0)
     {
         if (authorTextfield.Text.Trim() != "" && titelSongTextField.Text.Trim() != "")
         {
             int counterForAbsX = 0;
             List <SongComponent> compiledList = new List <SongComponent>();
             foreach (var list in this.WindowPanelEditor.Controls.OfType <Row>())
             {
                 for (int i = 0; i < list.ListWithSongComponents.Count; i++)
                 {
                     SongComponent tempComponent = list.ListWithSongComponents[i];
                     tempComponent.AbsoluteX = counterForAbsX;
                     compiledList.Add(tempComponent);
                     counterForAbsX += 2;
                 }
             }
             using (DatabaseContext db = new DatabaseContext())
             {
                 db.Songs.Add(new Song()
                 {
                     Author = authorTextfield.Text,
                     Level  = Int32.Parse(levelSelectBox.SelectedValue.ToString()),
                     Name   = titelSongTextField.Text
                 });
                 db.SaveChanges();
                 Song song =
                     db.Songs.Select(x => x)
                     .Where(x => x.Name == titelSongTextField.Text && x.Author == authorTextfield.Text)
                     .FirstOrDefault();
                 int songId = song.SongID;
                 foreach (SongComponent sc in compiledList)
                 {
                     sc.songID = songId;
                     sc.X      = (sc.X % 8);
                     db.SongComponents.Add(sc);
                 }
                 db.SaveChanges();
                 MessageBox.Show("Het lied is toegevoegd");
                 wsvc.Show();
                 this.Close();
             }
         }
     }
     else
     {
         MessageBox.Show("U heeft geen rijen aangemaakt");
     }
 }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (authorTextfield.Text.Trim() != "" && titelSongTextField.Text.Trim() != "")
     {
         int counterForAbsX = 0;
         List <SongComponent> compiledList = new List <SongComponent>();
         foreach (var list in this.WindowPanelEditor.Controls.OfType <Row>())
         {
             for (int i = 0; i < list.ListWithSongComponents.Count; i++)
             {
                 SongComponent tempComponent = list.ListWithSongComponents[i];
                 tempComponent.AbsoluteX = counterForAbsX;
                 compiledList.Add(tempComponent);
                 counterForAbsX += 2;
             }
         }
         if (compiledList.Count == 0)
         {
             MessageBox.Show("Lied bevat geen componenten");
             return;
         }
         using (DatabaseContext db = new DatabaseContext())
         {
             var result = db.Songs.Where(x => x.Name == titelSongTextField.Text && x.Author == authorTextfield.Text);
             if (result.Count() >= 1)
             {
                 MessageBox.Show("Lied met dezelfde titel en auteur bestaat al! Kies a.u.b. een andere titel of auteur.");
                 return;
             }
             Song song = new Song()
             {
                 Author = authorTextfield.Text, Level = Int32.Parse(numericUpDown1.Value.ToString()), Name = titelSongTextField.Text
             };
             db.Songs.Add(song);
             db.SaveChanges();
             int songId = song.SongID;
             foreach (SongComponent sc in compiledList)
             {
                 sc.songID = songId;
                 sc.X      = (sc.X % 8);
                 db.SongComponents.Add(sc);
             }
             db.SaveChanges();
             this.Hide();
             wsvc.Show();
             MessageBox.Show("Het lied is toegevoegd");
         }
     }
 }
        private static void RenderRest(Graphics g, int realX, int realY, SongComponent sc)
        {
            switch (sc.Length)
            {
            case ComponentLength.FULL: g.FillRectangle(BRUSH, realX, realY + 30, 15, 6); break;

            case ComponentLength.HALF: g.FillRectangle(BRUSH, realX, realY + 37, 15, 6); break;

            case ComponentLength.QUARTER: g.DrawImage(IMAGE_REST_QAURTER, realX - 0, realY + 28); break;

            case ComponentLength.EIGHTH: g.DrawImage(IMAGE_REST_EIGHT, realX - 0, realY + 30); break;

            default: break;
            }
        }
        private void ReconstructQueue()
        {
            for (int i = 0; SongQueue.Children.Count < Context.SongsQueued; i++)
            {
                int index             = Context.SongIndexesQueue[i];
                sHuntingHornSong song = Context.Songs[index];

                SongComponent songComponent = new SongComponent()
                {
                    SongName = GStrings.GetAbnormalityByID("HUNTINGHORN", song.BuffId, 0)
                };
                songComponent.SetSong(song.Notes, cachedBrushes);

                SongQueue.Children.Add(songComponent);
            }
        }
Ejemplo n.º 7
0
        private void ReconstructQueue()
        {
            for (int i = 0; SongQueue.Children.Count < Context.SongsQueued; i++)
            {
                int index             = Context.SongIndexesQueue[i];
                sHuntingHornSong song = Context.Songs[index];

                SongComponent songComponent = new SongComponent()
                {
                    SongName = GMD.GetMusicSkillNameById(song.BuffId)
                };
                songComponent.SetSong(song.Notes, cachedBrushes);

                SongQueue.Children.Add(songComponent);
            }
        }
Ejemplo n.º 8
0
        public static void RenderDoubleEighthSongComponent(Graphics g, SongComponent sc, int x, int y)
        {
            //int scY = CalculateLineY(sc.Y, sc.Octave);
            int  scY = sc.Y + (1 + (Piano.BASE_OCTAAF - sc.Octave)) * 7;
            bool up  = sc.Octave == 4 ? true : false;

            // Verreken de scY (lijn index) in de Y coordinaat
            y += (scY * LINE_PADDING_VERTICAL);
            y += (ROW_PADDING_COUNT - 3) * LINE_PADDING_VERTICAL;

            // Gooi de HASHTAG/BES breedte op de X coordinaat
            x += NOTE_WIDTH_PRE;

            // Horizontaal lijntje tekenen
            scY -= 3;
            if (scY % 2 == 0 && (scY < 0 || scY > 8)) //  Zit hij OVER het lijntje
            {
                g.DrawLine(PEN, x - NOTE_LINE_LENGTH, y, x + NOTE_RENDER_PADDING + NOTE_LINE_LENGTH, y);
            }
            else if (scY < -1 && scY % 2 != 0) // Zit hij ONDER het lijntje
            {
                g.DrawLine(PEN, x - NOTE_LINE_LENGTH, y + LINE_PADDING_VERTICAL, x + NOTE_RENDER_PADDING + NOTE_LINE_LENGTH, y + LINE_PADDING_VERTICAL);
            }
            else if (scY > 9 && scY % 2 != 0) // Zit hij BOVEN het lijntje
            {
                g.DrawLine(PEN, x - NOTE_LINE_LENGTH, y - LINE_PADDING_VERTICAL, x + NOTE_RENDER_PADDING + NOTE_LINE_LENGTH, y - LINE_PADDING_VERTICAL);
            }
            scY += 3;

            g.TranslateTransform(x, y);
            g.RotateTransform(-30f);
            g.TranslateTransform(-x, -y);

            g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
            g.ResetTransform();

            RenderStokje(g, up, x, y);
        }
Ejemplo n.º 9
0
 public DiskJokey(SongComponent newSongList)
 {
     songList = newSongList;
 }
Ejemplo n.º 10
0
 public DiscJockey(SongComponent newSongList)
 {
     songList = newSongList;
 }
Ejemplo n.º 11
0
        public static void RenderSongComponent(Graphics g, SongComponent sc, int x, int y)
        {
            //int scY = CalculateLineY(sc.Y, sc.Octave);
            int scY = sc.Y + (1 + (Piano.BASE_OCTAAF - sc.Octave)) * 7;

            // Verreken de scY (lijn index) in de Y coordinaat
            y += (scY * LINE_PADDING_VERTICAL);
            y += (ROW_PADDING_COUNT - 3) * LINE_PADDING_VERTICAL;

            // Is het een noot?
            if (sc is Note)
            {
                Note n = (Note)sc;

                // Is hij zwart?
                if (n.Black)
                {
                    g.DrawImage(IMAGE_NOTE_HASHTAG, x, y - 12);
                }
            }

            // Gooi de HASHTAG/BES breedte op de X coordinaat
            x += NOTE_WIDTH_PRE;

            if (sc is Note)
            {
                // Horizontaal lijntje tekenen
                scY -= 3;
                if (scY % 2 == 0 && (scY < 0 || scY > 8)) //  Zit hij OVER het lijntje
                {
                    g.DrawLine(PEN, x - NOTE_LINE_LENGTH, y, x + NOTE_RENDER_PADDING + NOTE_LINE_LENGTH, y);
                }
                else if (scY < -1 && scY % 2 != 0) // Zit hij ONDER het lijntje
                {
                    g.DrawLine(PEN, x - NOTE_LINE_LENGTH, y + LINE_PADDING_VERTICAL, x + NOTE_RENDER_PADDING + NOTE_LINE_LENGTH, y + LINE_PADDING_VERTICAL);
                }
                else if (scY > 9 && scY % 2 != 0) // Zit hij BOVEN het lijntje
                {
                    g.DrawLine(PEN, x - NOTE_LINE_LENGTH, y - LINE_PADDING_VERTICAL, x + NOTE_RENDER_PADDING + NOTE_LINE_LENGTH, y - LINE_PADDING_VERTICAL);
                }
                scY += 3;

                if (sc.Octave != Piano.BASE_OCTAAF)
                {
                    // Kijkt welke noot afgebeeld moet worden op het notenschrift
                    switch (sc.Length)
                    {
                    case ComponentLength.FULL:
                        g.FillEllipse(BRUSH, x, y - 6, NOTE_RENDER_PADDING + 3, NOTE_HEAD_HEIGHT);
                        g.FillEllipse(BRUSH_BACKGROUND, x + 5, y - 5, 6, 9);
                        break;

                    case ComponentLength.HALF:
                        g.TranslateTransform(x, y);
                        g.RotateTransform(-30f);
                        g.TranslateTransform(-x, -y);

                        g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                        g.FillEllipse(BRUSH_BACKGROUND, x + 2, y + 2, NOTE_RENDER_PADDING - 3, 4);
                        g.ResetTransform();

                        RenderStokje(g, false, x, y);
                        break;

                    case ComponentLength.QUARTER:
                        g.TranslateTransform(x, y);
                        g.RotateTransform(-30f);
                        g.TranslateTransform(-x, -y);

                        g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                        g.ResetTransform();

                        RenderStokje(g, false, x, y);
                        break;

                    case ComponentLength.EIGHTH:
                        // Zorg dat we niet te ver naar links gaan
                        g.TranslateTransform(IMAGE_NOTE_EIGHT_FLAG.Width, 0);

                        // Draaien om het ovaaltje schuin te tekenen
                        g.TranslateTransform(x, y);
                        g.RotateTransform(-30f);
                        g.TranslateTransform(-x, -y);

                        // Ovaal schuin tekenen en resetten
                        g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                        g.ResetTransform();

                        // Zorgen dat onze lijn en vlag ook wat opgeschoven zijn
                        g.TranslateTransform(IMAGE_NOTE_EIGHT_FLAG.Width, 0);
                        g.DrawImage(IMAGE_NOTE_EIGHT_FLAG_FLIP, x + 2, y - NOTE_LINE_HEIGHT + 52);
                        RenderStokje(g, false, x, y);

                        // Reset alsnog
                        g.ResetTransform();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    // Kijkt welke noot afgebeeld moet worden op het notenschrift
                    switch (sc.Length)
                    {
                    case ComponentLength.FULL:
                        g.FillEllipse(BRUSH, x, y - 6, NOTE_RENDER_PADDING + 3, 12);
                        g.FillEllipse(BRUSH_BACKGROUND, x + 5, y - 5, 6, 9);
                        break;

                    case ComponentLength.HALF:
                        g.TranslateTransform(x, y);
                        g.RotateTransform(-30f);
                        g.TranslateTransform(-x, -y);

                        g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                        g.FillEllipse(BRUSH_BACKGROUND, x + 2, y + 2, NOTE_RENDER_PADDING - 3, 4);
                        g.ResetTransform();

                        RenderStokje(g, true, x, y);
                        break;

                    case ComponentLength.QUARTER:
                        g.TranslateTransform(x, y);
                        g.RotateTransform(-30f);
                        g.TranslateTransform(-x, -y);

                        g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                        g.ResetTransform();

                        RenderStokje(g, true, x, y);
                        break;

                    case ComponentLength.EIGHTH:
                        g.TranslateTransform(x, y);
                        g.RotateTransform(-30f);
                        g.TranslateTransform(-x, -y);

                        g.FillEllipse(BRUSH, x, y - 2, NOTE_RENDER_PADDING + 1, NOTE_HEAD_HEIGHT);
                        g.ResetTransform();

                        g.DrawImage(IMAGE_NOTE_EIGHT_FLAG, x + 14, y - NOTE_LINE_HEIGHT + 1);
                        RenderStokje(g, true, x, y);
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                // Kijkt welke rust afgebeeld moet worden op het notenschrift
                switch (sc.Length)
                {
                case ComponentLength.FULL: g.FillRectangle(BRUSH, x, y - 12, 15, 6); break;

                case ComponentLength.HALF: g.FillRectangle(BRUSH, x, y - 6, 15, 6); break;

                case ComponentLength.QUARTER: g.DrawImage(IMAGE_REST_QAURTER, x - 0, y - 17); break;

                case ComponentLength.EIGHTH: g.DrawImage(IMAGE_REST_EIGHT, x - 0, y - 6); break;

                default: break;
                }
            }
        }
        private void OnSongsCast(object source, HuntingHornSongCastEventArgs args)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
            {
                if (args.IsCastingBuffs && !args.IsDoubleCasting)
                {
                    if (SongQueue.Children.Count < args.PlayStartAt + 1)
                    {
                        return;
                    }

                    // When the player is interrupted by monsters/taking damage
                    // This was hell to fix, please save me
                    if (args.IsCastingInterrupted)
                    {
                        foreach (SongComponent castedSong in SongQueue.Children)
                        {
                            if (castedSong.IsCasted)
                            {
                                castedSong.IsCasted = false;
                            }
                        }
                        SongQueue.Children.Clear();
                        castOrder.Clear();
                        ReconstructQueue();
                        return;
                    }
                    for (int i = args.PlayStartAt; i < SongQueue.Children.Count; i++)
                    {
                        SongComponent song = (SongComponent)SongQueue.Children[i];
                        if (!song.IsCasted)
                        {
                            castOrder.Add(i);
                            song.IsCasted = true;
                            break;
                        }
                    }
                }
                else if (args.IsCastingBuffs && args.IsDoubleCasting)
                {
                    int castedSongs = SongQueue.Children.Cast <SongComponent>().Where(e => e.IsCasted).Count();
                    if (castedSongs > args.PlayCurrentAt && args.PlayCurrentAt > 0)
                    {
                        ((SongComponent)SongQueue.Children[castOrder.Last()]).IsCasted = false;
                    }
                    foreach (SongComponent castedSong in SongQueue.Children)
                    {
                        if (castedSong.IsCasted)
                        {
                            castedSong.IsDoubleCasted = true;
                        }
                    }
                    castOrder.Clear();
                }
                else
                {
                    foreach (SongComponent song in SongQueue.Children)
                    {
                        if (song.IsCasted)
                        {
                            song.Dispose();
                        }
                    }
                }
            }));
        }