Exemplo n.º 1
0
        public static void LoadKits()
        {
            string dir = startDir + MusicKitsPath;

            MusicKits = new List <MusicKit>();

            if (Directory.Exists(dir))
            {
                foreach (string filePath in Directory.GetFiles(dir))
                {
                    if (!filePath.EndsWith(".json"))
                    {
                        continue;
                    }
                    string jsonFile = "";

                    try
                    {
                        jsonFile = File.ReadAllText(filePath);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception when trying to load music kits.");
                        Console.WriteLine(e.StackTrace);
                    }
                    finally
                    {
                        MusicKit musicKit = JsonConvert.DeserializeObject <MusicKit>(jsonFile);
                        MusicKits.Add(musicKit);
                    }
                }
            }
            else
            {
                Directory.CreateDirectory(dir);
            }

            //Find a value for SelectedKit if applicable
            if (MusicKits.Count > 0)
            {
                foreach (MusicKit musicKit in MusicKits)
                {
                    if (musicKit.Name.Equals(SelectedKitName))
                    {
                        SelectedKit = musicKit;
                    }
                }

                if (SelectedKit == null)
                {
                    SelectedKit = MusicKits[0];
                }
            }
        }
Exemplo n.º 2
0
        public MusicSelector(MusicKit newKit, bool?createKit)
        {
            InitializeComponent();
            MaximizeBox = false;

            if (createKit.HasValue)
            {
                createMode = createKit.Value;
            }
            currentKit = newKit;

            LoadKitParameters();
        }
Exemplo n.º 3
0
 private static void SetKit(MusicKit newKit)
 {
     selectedKit     = newKit;
     SelectedKitName = selectedKit.Name;
 }