Example #1
0
        internal void save(string filename, Tune tune, MotifTreeView motifTreeView)
        {
            List <TreeNode> nodes = motifTreeView.Nodes.Cast <TreeNode>().ToList();

            //Pack all data in one class
            KeyValuePair <Tune, List <TreeNode> > data = new KeyValuePair <Tune, List <TreeNode> >(tune, nodes);

            FileStream        stream   = File.Open(filename, FileMode.Create);
            XmlWriterSettings settings = new XmlWriterSettings {
                Indent = true
            };

            //TreeNode needs to be a KnownType.
            List <Type> knowntypes = new List <Type>();

            knowntypes.Add(typeof(TreeNode));

            using (var file = XmlWriter.Create(stream, settings))
            {
                var ser = new DataContractSerializer(typeof(KeyValuePair <Tune, List <TreeNode> >), knowntypes);
                ser.WriteObject(file, data);
            }
            stream.Flush();
            stream.Close();
        }
Example #2
0
        internal void load(string filename, out Tune tune, MotifTreeView motifTreeView)
        {
            FileStream stream = File.Open(filename, FileMode.Open);

            //TreeNode needs to be a KnownType.
            List <Type> knowntypes = new List <Type>();

            knowntypes.Add(typeof(TreeNode));

            KeyValuePair <Tune, List <TreeNode> > data;

            using (var file = XmlReader.Create(stream))
            {
                var ser = new DataContractSerializer(typeof(KeyValuePair <Tune, List <TreeNode> >), knowntypes);
                data = (KeyValuePair <Tune, List <TreeNode> >)ser.ReadObject(file);
            }
            stream.Flush();
            stream.Close();

            //MotifTreeView
            motifTreeView.Nodes.Clear();
            TreeNode[] nodeList = data.Value.ToArray();
            motifTreeView.Nodes.AddRange(nodeList);

            //Tune
            tune = data.Key;
        }
Example #3
0
 public Controller(Tune tune, AxWMPLib.AxWindowsMediaPlayer wmpTune, AxWMPLib.AxWindowsMediaPlayer wmpMotif, MotifTreeView mtv, PlayList playlist, MusicaMinimalista.MainWindow mainWindow)
 {
     this.tune                       = tune;
     this.mainWindow                 = mainWindow;
     this.motifTreeView              = mtv;
     this.motifTreeView.AfterSelect += motifTreeView_AfterSelect;
     this.playlist                   = playlist;
     this.actionList                 = new List <ProgramAction>();
     this.actionIndex                = 0;
     this.projectUtil                = new ProjectUtil();
     this.mediaPlayer                = new MediaPlayer(wmpTune, wmpMotif, playlist);
     this.executingAction            = false;
 }