Exemplo n.º 1
0
        public StackPanel StandardSheet()
        {
            GreatStaffModel greatStaffModel = new GreatStaffModel();

            Sheet = new SheetModel();
            Sheet.GreatStaffModelList.Add(greatStaffModel);
            return(Sheet.DrawSheet());
        }
Exemplo n.º 2
0
        private void DrawEnd(GreatStaffModel greatStaff)
        {
            AddMeasureLine(greatStaff, 1055 - 10);

            Line endline        = GetSymbolMeasureline();
            Grid greatstaffgrid = greatStaff.GreatStaffGrid;

            Grid.SetColumn(endline, 1);
            endline.StrokeThickness     = 5;
            endline.HorizontalAlignment = HorizontalAlignment.Left;
            Thickness margin = endline.Margin;

            margin.Left    = 1055 - 5;
            endline.Margin = margin;

            endline.VerticalAlignment = VerticalAlignment.Stretch;
            greatstaffgrid.Children.Add(endline);
        }
Exemplo n.º 3
0
        private void AddMeasureLine(GreatStaffModel greatStaff, decimal totalwidth)
        {
            Line measureline    = GetSymbolMeasureline();
            Grid greatstaffgrid = greatStaff.GreatStaffGrid;

            Grid.SetColumn(measureline, 1);
            measureline.HorizontalAlignment = HorizontalAlignment.Left;
            Thickness margin = measureline.Margin;

            if (totalwidth > 1055)
            {
                margin.Left = 1050;
            }
            else
            {
                margin.Left = (float)totalwidth;
            }
            measureline.Margin = margin;


            measureline.VerticalAlignment = VerticalAlignment.Stretch;
            greatstaffgrid.Children.Add(measureline);
        }
Exemplo n.º 4
0
        public void DrawNotes()
        {
            decimal totalwidth = 0;
            int     idx        = 0;

            foreach (var greatStaff in mPc.Sheet.GreatStaffModelList)
            {
                stave      = greatStaff;
                totalwidth = 0;
                if (greatStaff.MeasureList.Count() == 0)
                {
                    DrawEnd(mPc.Sheet.GreatStaffModelList[idx]);
                }

                AddMeasureLine(greatStaff, totalwidth);

                foreach (var measure in greatStaff.MeasureList)
                {
                    scale += measure.Width;
                }
                if (scale != 0)
                {
                    scale = 1050 / scale;
                }

                foreach (var measure in greatStaff.MeasureList)
                {
                    totalwidth += measure.Width * scale;

                    //make a list with all the notes
                    List <Note> notelist = new List <Note>();
                    foreach (var measureel in measure.MeasureElements)
                    {
                        if (measureel.Type.Equals(MeasureElementType.Note))
                        {
                            Note noot = (Note)measureel.Element;
                            notelist.Add(noot);
                        }
                    }
                    //get the first note
                    Note prevnote = notelist.First();

                    foreach (var note in notelist)
                    {
                        StaffModel staff;
                        //check whether the note belongs to the upper staff or not
                        if (note.Staff.Equals(1))
                        {
                            staff = greatStaff.StaffList.First <StaffModel>();
                        }
                        else
                        {
                            staff = greatStaff.StaffList.Last <StaffModel>();
                        }
                        Grid staveGrid = staff.stave;
                        GNote(note, note.Pitch, staff, staveGrid, totalwidth, measure.Width * scale, prevnote, measure);
                        prevnote = note;
                    }



                    //check if this is the last measure of the piece
                    if (measure == greatStaff.MeasureList.Last <Measure>() && greatStaff == mPc.Sheet.GreatStaffModelList.Last <GreatStaffModel>())
                    {
                        //draw the end if so
                        DrawEnd(greatStaff);
                    }
                    else
                    {
                        //draw a measureline if not
                        if (measure != greatStaff.MeasureList.Last <Measure>())
                        {
                            AddMeasureLine(greatStaff, totalwidth);
                        }
                        else
                        {
                            AddMeasureLine(greatStaff, 1050);
                        }
                    }
                    Console.WriteLine("Measure finished");
                }

                Console.WriteLine("Great stave finished");
            }
            Console.WriteLine("Notes finished.");
        }