Exemplo n.º 1
0
        /// <summary>
        /// Get a label for a clef
        /// </summary>
        /// <param name="clef">The clef to get the label for</param>
        /// <returns>A label of a clef</returns>
        public static Label RenderClef(Clef clef, double fontSize)
        {
            string symbol;

            switch (clef.sign)
            {
            case ClefSign.G:
                symbol = Constants.Clefs.TREBLE;
                break;

            case ClefSign.C:
                symbol = Constants.Clefs.BASS;
                break;

            //todo: rest of clefs
            default:
                symbol = "";
                break;
            }

            Label clefLabel = WPFRendering.GetMusicalLabel(symbol, fontSize); //todo: get the clef from getmusic label

            clefLabel.VerticalAlignment = VerticalAlignment.Top;
            WPFRendering.RecalculateSize(clefLabel);
            return(clefLabel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Render a rest
        /// </summary>
        /// <param name="note">Representation of the rest to render</param>
        /// <returns>The rest rendered on a Framework Element</returns>
        private static FrameworkElement RenderRest(Note note, double fontSize)
        {
            string restChar = "";

            switch (note.type.Value)
            {
            case NoteTypeValue.whole:
                restChar = Constants.RestCharacters.WHOLE_REST;
                break;

            case NoteTypeValue.half:
                restChar = Constants.RestCharacters.HALF_REST;
                break;

            case NoteTypeValue.quarter:
                restChar = Constants.RestCharacters.QUARTER_REST;
                break;

            case NoteTypeValue.eighth:
                restChar = Constants.RestCharacters.EIGHTH_REST;
                break;

            case NoteTypeValue.Item16th:
                restChar = Constants.RestCharacters.SIXTEETH_REST;
                break;

            case NoteTypeValue.Item32nd:
                restChar = Constants.RestCharacters.THIRTYSECOND_REST;
                break;

            case NoteTypeValue.Item64th:
                restChar = Constants.RestCharacters.SIXTYFOURTH_REST;
                break;

            case NoteTypeValue.Item128th:
                restChar = Constants.RestCharacters.ONETWENTYEIGHTH_REST;
                break;

            case NoteTypeValue.Item256th:
                restChar = "!";
                break;

            case NoteTypeValue.Item512th:
                restChar = "!";
                break;
            }
            //todo: it is a rest
            FrameworkElement restLabel = WPFRendering.GetMusicalLabel(restChar, fontSize);

            WPFRendering.RecalculateSize(restLabel);
            return(restLabel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Render the time signature to a Grid
        /// </summary>
        /// <param name="time">The time signature to render</param>
        /// <param name="fontSize">The size of the font currently being used</param>
        /// <returns>Time signature on a grid</returns>
        public static FrameworkElement RenderTimeSignature(Time time, double fontSize)
        {
            double halfFont = fontSize / 2;
            //todo: make proper time signature label
            //todo: measure font size stuff properly
            Panel grid       = WPFRendering.CreateAutoSizingGrid();
            Label beatsLabel = WPFRendering.GetMusicalLabel(time.Beats, halfFont);

            grid.Children.Add(beatsLabel);

            Label beatType = WPFRendering.GetMusicalLabel(time.BeatType, halfFont);

            beatType.Margin = new Thickness(0, WPFRendering.GetFontHeight(fontSize / 3, Constants.MusicFonts.DEFAULT), 0, 0);
            grid.Children.Add(beatType);

            //todo: interchangable and other type of time signature, see definition of Time to hunt it down
            grid.VerticalAlignment = VerticalAlignment.Top;
            WPFRendering.RecalculateSize(grid);
            return(grid);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Parse the barline information given and create an appropriate label that can be put onto a canvas.
        /// </summary>
        /// <param name="barline">The Barline information to parse</param>
        /// <param name="fontSize">The fontsize to use</param>
        /// <returns>Label that holds the barline</returns>
        public static FrameworkElement RenderBarline(Barline barline, double fontSize)
        {
            string barlineChar;

            switch (barline.barStyle.Value)
            {
            case BarStyle.regular:
                barlineChar = Constants.Barlines.REGULAR;
                break;

            case BarStyle.lightlight:
                barlineChar = Constants.Barlines.LIGHT_LIGHT;
                break;

            case BarStyle.lightheavy:
                barlineChar = Constants.Barlines.LIGHT_HEAVY;
                break;

            case BarStyle.heavylight:
                barlineChar = Constants.Barlines.HEAVY_LIGHT;
                break;

            case BarStyle.dashed:
                barlineChar = Constants.Barlines.DASHED;
                break;

            default:
                barlineChar = Constants.Barlines.REGULAR;
                break;
                //todo: remainder of barlines
            }

            FrameworkElement barlineLabel = WPFRendering.GetMusicalLabel(barlineChar, fontSize);

            WPFRendering.RecalculateSize(barlineLabel);
            return(barlineLabel);
        }