Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Migrate to XML Data structure
Browse files Browse the repository at this point in the history
**WARNING**: XML File lcation isn't set dynamically
- Remove SQLCommands
- Remove Data.mdf
  • Loading branch information
hailstorm75 committed May 1, 2017
1 parent 092435c commit ce75d60
Show file tree
Hide file tree
Showing 44 changed files with 239 additions and 161 deletions.
Binary file modified .vs/guitarToolsForm/v15/.suo
Binary file not shown.
12 changes: 11 additions & 1 deletion FretboardLibrary/FretNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Windows.Controls;
using System.Windows.Media;
using ServicesLibrary;
using System.Linq;
using System.Xml.Linq;
using System.Text;

namespace FretboardLibrary
{
Expand Down Expand Up @@ -97,7 +100,14 @@ public void ShiftTuning(int ShiftBy)
private void SetToolTip()
{
IntLimited interval = new IntLimited(Index - Root, 0, 12);
noteBody.ToolTip = SQLCommands.FetchList<string>("SELECT Ratio + ' ' + Name AS Value FROM tableRatios WHERE Id =" + interval.Value)[0];
noteBody.ToolTip = (from node in XDocument.Load(@"C:\Users\Denis\Documents\Visual Studio 2017\Projects\Guitar-Tools\guitarTools\Data\Data.xml")
.Descendants("Ratios").Elements("Ratio")
where node.Attribute("id").Value == interval.Value.ToString()
select new StringBuilder(node.Element("Value").Value)
.Append(" ")
.Append(node.Element("Name").Value)
.ToString()).Single();

}
}
}
40 changes: 23 additions & 17 deletions FretboardLibrary/Fretboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Windows.Media;
using System.Windows.Shapes;
using ServicesLibrary;
using System.Xml.Linq;

namespace FretboardLibrary
{
Expand All @@ -15,6 +16,7 @@ namespace FretboardLibrary
public class Fretboard
{
#region Properties
private XDocument Doc { get; set; }
private List<List<FretNote>> NoteList { get; set; }
private Grid MainGrid { get; set; }
private Grid NoteGrid { get; set; }
Expand All @@ -38,6 +40,7 @@ public Fretboard(Grid mainGrid, ushort strings, ushort frets, List<List<FretNote
NoteGrid.ShowGridLines = false;
MainGrid.Children.Add(NoteGrid);

Doc = new XDocument(XDocument.Load(@"C:\Users\Denis\Documents\Visual Studio 2017\Projects\Guitar-Tools\guitarTools\Data\Data.xml"));
Strings = strings;
Frets = frets;
Width = mainGrid.Width / frets;
Expand Down Expand Up @@ -66,19 +69,14 @@ private void CreateGrid()
private void CreateNotes()
{
// Passing selected tuning from database to array
string[] tuning;
string[] tuning = (from node in Doc.Descendants("Tunings").Elements("Tuning")
where node.Element("Name").Value == Tuning && node.Attribute("strings").Value == Strings.ToString()
select node.Element("Interval").Value).Single().Split(' ');

string[] scale = (from node in Doc.Descendants("Scales").Elements("Scale")
where node.Element("Name").Value == Scale
select node.Element("Interval").Value).Single().Split(' ');

try
{
tuning = SQLCommands.FetchList<string>("SELECT Interval FROM tableTuning WHERE Name = '" + Tuning + "' AND Strings = " + Strings)[0].Split(' ');
}
catch
{
tuning = SQLCommands.FetchList<string>("SELECT Interval FROM tableTuning WHERE Id = 1 AND Strings = " + Strings)[0].Split(' ');
Tuning = SQLCommands.FetchList<string>("SELECT Name FROM tableTuning WHERE Id = 1 AND Strings = " + Strings)[0];
}

string[] scale = SQLCommands.FetchList<string>("SELECT Interval FROM tableScales WHERE Name = '" + Scale + "'")[0].Split(' ');

// Creating notes and adding them to the grid
for (int numString = 0; numString < Strings; numString++)
Expand Down Expand Up @@ -152,7 +150,9 @@ public void UpdateRoot(int newRoot)
{
Root = newRoot;

string[] scale = SQLCommands.FetchList<string>("SELECT Interval FROM tableScales WHERE Name = '" + Scale + "'")[0].Split(' ');
string[] scale = (from node in Doc.Descendants("Scales").Elements("Scale")
where node.Element("Name").Value == Scale
select node.Element("Interval").Value).Single().Split(' ');

// Shifting scale to new root note
foreach (List<FretNote> String in NoteList)
Expand All @@ -170,7 +170,9 @@ public void UpdateRoot(int newRoot)
public void UpdateScale(string newScale)
{
Scale = newScale;
string[] scale = SQLCommands.FetchList<string>("SELECT Interval FROM tableScales WHERE Name = '" + Scale + "'")[0].Split(' ');
string[] scale = (from node in Doc.Descendants("Scales").Elements("Scale")
where node.Element("Name").Value == Scale
select node.Element("Interval").Value).Single().Split(' ');

// Shifting scale to new root note
foreach (List<FretNote> String in NoteList)
Expand All @@ -188,9 +190,13 @@ public void UpdateTuning(string newTuning)
// TODO Clean up
Tuning = newTuning;

string[] scale = SQLCommands.FetchList<string>("SELECT Interval FROM tableScales WHERE Name = '" + Scale + "'")[0].Split(' ');
string[] tuning = SQLCommands.FetchList<string>("SELECT Interval FROM tableTuning WHERE Name = '" + Tuning + "' AND Strings = " + Strings)[0].Split(' ');

string[] scale = (from node in Doc.Descendants("Scales").Elements("Scale")
where node.Element("Name").Value == Scale
select node.Element("Interval").Value).Single().Split(' ');
string[] tuning = (from node in Doc.Descendants("Tunings").Elements("Tuning")
where node.Element("Name").Value == Tuning && node.Attribute("strings").Value == Strings.ToString()
select node.Element("Interval").Value).Single().Split(' ');

for (int numString = 0; numString < NoteList.Count; numString++)
{
int index = int.Parse(tuning[numString]); // Getting individual string tunning
Expand Down
Binary file modified FretboardLibrary/bin/Debug/FretboardLibrary.dll
Binary file not shown.
Binary file modified FretboardLibrary/bin/Debug/FretboardLibrary.pdb
Binary file not shown.
Binary file modified FretboardLibrary/bin/Debug/ServicesLibrary.dll
Binary file not shown.
Binary file modified FretboardLibrary/bin/Debug/ServicesLibrary.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified FretboardLibrary/obj/Debug/FretboardLibrary.dll
Binary file not shown.
Binary file modified FretboardLibrary/obj/Debug/FretboardLibrary.pdb
Binary file not shown.
82 changes: 0 additions & 82 deletions ServicesLibrary/SQLCommands.cs

This file was deleted.

2 changes: 0 additions & 2 deletions ServicesLibrary/ServicesLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
<ItemGroup>
<Compile Include="IntLimited.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SQLCommands.cs" />
<Compile Include="XMLReader.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
25 changes: 0 additions & 25 deletions ServicesLibrary/XMLReader.cs

This file was deleted.

Binary file modified ServicesLibrary/bin/Debug/ServicesLibrary.dll
Binary file not shown.
Binary file modified ServicesLibrary/bin/Debug/ServicesLibrary.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion ServicesLibrary/obj/Debug/CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ead3e67204aa431ff7e29b7e75658ecbbd7b3d60
d8550f8af35e5d891836c012e8ccc79c01a52e26
Binary file modified ServicesLibrary/obj/Debug/ServicesLibrary.dll
Binary file not shown.
Binary file modified ServicesLibrary/obj/Debug/ServicesLibrary.pdb
Binary file not shown.
Binary file removed guitarTools/Data.mdf
Binary file not shown.
Loading

0 comments on commit ce75d60

Please sign in to comment.