internal static RehersalViewModel GetBasicRehersal() { BasicRehersal basicRehersalData = new BasicRehersal(); var basicTimeBarData = basicRehersalData.TimeBars.FirstOrDefault(); var basicRehersalInstance = new RehersalViewModel() { Name = basicRehersalData.Name, TimeBars = new ObservableCollection <TimeBarViewModel>() { GetBasicTimeBar("1") } }; return(basicRehersalInstance); }
internal static XmlDocument CreateXmlDocByData(RehersalViewModel rehersalData) { XmlDocument rehersalDoc = new XmlDocument(); XmlElement rootNode = rehersalDoc.CreateElement(RootNodeName); rehersalDoc.AppendChild(rootNode); XmlElement rehersalNameNode = rehersalDoc.CreateElement(RehersalNameNodeName); rehersalNameNode.InnerText = rehersalData.Name; rootNode.AppendChild(rehersalNameNode); XmlElement timeBarsNode = rehersalDoc.CreateElement(TBarsNodeName); rootNode.AppendChild(timeBarsNode); foreach (var timeBarData in rehersalData.TimeBars) { XmlElement timeBarNode = rehersalDoc.CreateElement(TBarNodeName); timeBarsNode.AppendChild(timeBarNode); XmlElement tbNameNode = rehersalDoc.CreateElement(TBNameNodeName); tbNameNode.InnerText = timeBarData.Name; timeBarNode.AppendChild(tbNameNode); XmlElement tbTempoNode = rehersalDoc.CreateElement(TBTempoNodeName); tbTempoNode.InnerText = timeBarData.Tempo.ToString(); timeBarNode.AppendChild(tbTempoNode); XmlElement tbTicksCountNode = rehersalDoc.CreateElement(TBTicksCountNodeName); tbTicksCountNode.InnerText = timeBarData.TicksCount.ToString(); timeBarNode.AppendChild(tbTicksCountNode); XmlElement tbTickTimeValueNode = rehersalDoc.CreateElement(TBTickTimeValueNodeName); tbTickTimeValueNode.InnerText = timeBarData.TickTimeValue.ToString(); timeBarNode.AppendChild(tbTickTimeValueNode); XmlElement tbRepeatsNode = rehersalDoc.CreateElement(TBRepeatsNodeName); tbRepeatsNode.InnerText = timeBarData.Repeats.ToString(); timeBarNode.AppendChild(tbRepeatsNode); } return(rehersalDoc); }
internal static async Task <ObservableCollection <RehersalViewModel> > GetLocalDataAsync() { try { StorageFolder localDataFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(LocalDataFolderName); var rehersalsDataCollection = new ObservableCollection <RehersalViewModel>(); var rehersalFiles = await localDataFolder.GetFilesAsync().AsTask().ConfigureAwait(false); foreach (var xmlFile in rehersalFiles) { RehersalViewModel rehersalData = await XmlParser.GetDataByXmlDocAsync(xmlFile); rehersalsDataCollection.Add(rehersalData); } return(rehersalsDataCollection); } catch (FileNotFoundException) { throw new FileNotFoundException("Local data folder is empty.", LocalDataFolderName); } }