Exemplo n.º 1
0
        private void listBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            try
            {
                ListBox lb = sender as ListBox;
                if (lb != null)
                {
                    var data = danceList[this.listBox1.SelectedItem.ToString()];


                    Dance selected = new Dance();
                    selected.name       = data["name"].ToString();
                    selected.stepString = data["stepString"].ToString();
                    danceSelected       = selected;


                    dance.Text      = data["name"].ToString();
                    difficulty.Text = data["difficulty"].ToString();
                    steps.Text      = data["stepString"].ToString().Length.ToString();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Exemplo n.º 2
0
        void AddDance(object sender, KeyPressEventArgs ev)
        {
            if (ev.KeyChar == last_keyPressed)
            {
                return;
            }

            if (ev.KeyChar == '9')
            {
                Dance newDance = new Dance();
                newDance.name       = Form2.newDanceName;
                newDance.stepString = string.Join("", newDanceCombo.ToArray()).ToString().ToLower();
                newDance.difficulty = "Beginner";
                newDance.steps      = null;

                Form2.danceList.Add(Form2.newDanceName, JToken.FromObject(newDance));
                //Form2.danceList.Remove("pesho");
                Debug.WriteLine(Form2.danceList.ToString());

                if (newDance.stepString.Length != 0)
                {
                    File.WriteAllText(@"D:\dances.json", Form2.danceList.ToString());
                }


                Form2 main = new Form2();
                this.Hide();
                main.ShowDialog();
                this.Close();
            }

            last_keyPressed = ev.KeyChar;
            PictureBox move = this.Controls.Find("key_" + ev.KeyChar.ToString(), true).FirstOrDefault() as PictureBox;

            if (move == null)
            {
                return;
            }

            newDanceCombo.Add(ev.KeyChar);
            move.Image = Project.Properties.Resources.step_true;
        }