Exemplo n.º 1
0
        public SongForm()
        {
            InitializeComponent();

            workoutSong = new Workout.WorkoutSong();
            Manequins = workoutSong.Manequins;
        }
Exemplo n.º 2
0
        public static Workout LoadWorkout(string workoutPath)
        {
            string str = string.Empty;
            DataSet ds = new DataSet();

            using (StreamReader sr = new StreamReader(workoutPath))
            {
                str = sr.ReadToEnd();

                using (StringReader reader = new StringReader(str))
                {
                    ds.ReadXml(reader);
                }
            }

            Workout workout = Workout.FromTemplate(WorkoutTemplate.LoadTemplate(ds.Tables["Workout"].Rows[0]["Template"].ToString()));

            workout.Title = ds.Tables["Workout"].Rows[0]["Title"].ToString();

            foreach (DataRow row in ds.Tables["WorkoutPart"].Rows)
            {
                WorkoutPart part = workout.WorkoutParts.FirstOrDefault(x => x.Title == row["Title"].ToString());

                if (part != null)
                {
                    foreach (DataRow songsRows in row.GetChildRows("WorkoutPart_WorkoutSongs"))
                    {
                        foreach (DataRow songRow in songsRows.GetChildRows("WorkoutSongs_WorkoutSong"))
                        {
                            WorkoutSong song = new WorkoutSong()
                            {
                                Title = songRow["Title"].ToString(),
                                Artist = songRow["Artist"].ToString(),
                                Album = songRow["Album"].ToString(),
                                Bpm1 = songRow["Bpm1"].ToString().ToInt(),
                                Bpm2 = songRow["Bpm2"].ToString().ToInt(),
                                Description = songRow["Description"].ToString(),
                                FromTime = songRow["FromTime"].ToString().ToInt(),
                                ToTime = songRow["ToTime"].ToString().ToInt(),
                                OriginalLength = songRow["OriginalLength"].ToString().ToInt(),
                                Link = songRow["Link"].ToString()
                            };

                            string manequins = songRow["Manequins"].ToString();

                            manequins = manequins.Replace("&apos;", "'").Replace("&quot;", "\"").Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&").Trim();

                            song.Manequins = SongManequins.FromString(manequins);

                            part.Songs.Add(song);

                            //sb.AppendLine(Manequins.ToString().Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;"));

                        }
                    }
                }
            }

            return workout;
        }
Exemplo n.º 3
0
        public void LoadPlacement(WorkoutCreator.Workout.Workout workout)
        {
            this.workout = workout;

            workoutPartComboBox.Items.Clear();
            workoutPartComboBox.DisplayMember = "Title";
            workoutPartComboBox.ValueMember = "Title";

            fromToComboBox.Items.Clear();

            fromToComboBox.DisplayMember = "Title";
            fromToComboBox.ValueMember = "PlacementValue";

            //fromToComboBox.Items.Add(new SongPlacement() { PlacementValue = 0, Title = "Flytta inte" });
            fromToComboBox.Items.Add(new SongPlacement() { PlacementValue = 1, Title = "Före vald låt" });
            fromToComboBox.Items.Add(new SongPlacement() { PlacementValue = 2, Title = "Efter vald låt" });
            fromToComboBox.SelectedIndex = 0;

            foreach (Workout.WorkoutPart part in workout.WorkoutParts)
            {
                workoutPartComboBox.Items.Add(part);

                Workout.WorkoutSong song = part.Songs.FirstOrDefault(x =>
                    x.Album == albumTextBox.Text &&
                    x.Artist == artistTextBox.Text &&
                    x.Bpm1 == bpm1TextBox.Text.ToInt() &&
                    x.Bpm2 == bpm2TextBox.Text.ToInt() &&
                    x.Description == descriptionTextBox.Text &&
                    x.FromTime == fromTimeTextBox.TotalSeconds &&
                    x.ToTime == toTimeTextBox.TotalSeconds &&
                    x.Title == titleTextBox.Text);

                if (song != null)
                {
                    currentSong = song;
                    currentPart = part;
                    workoutPartComboBox.SelectedItem = part;
                }
            }
        }
Exemplo n.º 4
0
        private void EditSong(WorkoutSong workoutSong)
        {
            using (SongForm form = new SongForm())
            {
                form.WorkoutSong = workoutSong;
                form.LoadPlacement(workout);

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    WorkoutSong song = form.WorkoutSong;

                    workoutSong.Title = song.Title;
                    workoutSong.Artist = song.Artist;
                    workoutSong.Album = song.Album;
                    workoutSong.Bpm1 = song.Bpm1;
                    workoutSong.Bpm2 = song.Bpm2;
                    workoutSong.OriginalLength = song.OriginalLength;
                    workoutSong.FromTime = song.FromTime;
                    workoutSong.ToTime = song.ToTime;
                    workoutSong.Description = song.Description;
                    workoutSong.Manequins = song.Manequins;

                    RefreshWorkout();
                }
            }
        }