File: Generate%20VLF.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 35,880 kB
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (47 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using org.kbinani.apputil;
using org.kbinani.vsq;
using org.kbinani.windows.forms;

public class GenerateVLF{
    public static bool Edit( VsqFile vsq ){
        int track = 1;
        InputBox ib = new InputBox( "Input target track index" );
        ib.setResult( track.ToString() );
        if ( ib.ShowDialog() != DialogResult.OK ) {
            return false;
        }
        if ( !int.TryParse( ib.getResult(), out track ) ) {
            MessageBox.Show( "integer parse error" );
            return false;
        }
        if ( track <= 0 || vsq.Track.size() <= track ) {
            MessageBox.Show( "invalid target track" );
            return false;
        }
        using ( SaveFileDialog sfd = new SaveFileDialog() ) {
            if ( sfd.ShowDialog() != DialogResult.OK ) {
                return false;
            }
            using ( StreamWriter sw = new StreamWriter( sfd.FileName, false, Encoding.GetEncoding( 932 ) ) ) {
                sw.WriteLine( "vlf\t2.0" );
                sw.WriteLine( "vlfpart\tPhrase1\t0\t0" );
                for ( int i = 0; i < vsq.Track.get( track ).getEventCount(); i++ ) {
                    VsqEvent ve = vsq.Track.get( track ).getEvent( i );
                    if ( ve.ID.type == VsqIDType.Anote ) {
                        string symbol = "";
                        for ( int j = 0; j < ve.ID.LyricHandle.L0.getPhoneticSymbolList().Count; j++ ) {
                            symbol += (" " + ve.ID.LyricHandle.L0.getPhoneticSymbolList()[j]);
                        }
                        symbol = symbol.Trim();
                        sw.WriteLine( ve.ID.LyricHandle.L0.Phrase + "\t" + symbol + "\t0" );
                    }
                }
            }
        }
        return true;
    }
}