Example #1
0
        private void addSimfileToGrid(Simfile simfile, bool useDarkLine)
        {
            gridSimfiles.RowDefinitions.Add(new RowDefinition { //Add a new row to the grid for this simfile
                Height = GridLength.Auto
            });

            Label labelTitle = new Label { //Then add the label for the file's title
                Content    = simfile.Name,
                Background = Simfile.GetBGColor(useDarkLine),
            };

            Grid.SetColumn(labelTitle, 0);
            Grid.SetRow(labelTitle, simfiles.IndexOf(simfile) + 1);
            gridSimfiles.Children.Add(labelTitle);

            foreach (StepChart chart in simfile.StepCharts)   //Iterate through charts to add to the grid
            {
                if (simfile.StepCharts.IndexOf(chart) + 1 > 5)
                {
                    continue;                     //Only display up to 5 charts in the grid
                }
                Label labelDifficulty = new Label //Add the difficulty rating/color to the grid
                {
                    Content = chart.Rating,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    Foreground = Simfile.GetDifficultyColor(chart.ChartDifficulty),
                    Background = Simfile.GetBGColor(useDarkLine),
                };
                Grid.SetColumn(labelDifficulty, simfile.StepCharts.IndexOf(chart) + 1);
                Grid.SetRow(labelDifficulty, simfiles.IndexOf(simfile) + 1);
                gridSimfiles.Children.Add(labelDifficulty);
            }

            //Now add the radio buttons for what scale to set a chart to
            RadioButton setScaleOld = new RadioButton
            {
                Content             = "To Old",
                GroupName           = simfile.Name,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          = Simfile.GetBGColor(useDarkLine),
            };

            setScaleOld.Click += (sender, EventArgs) => { rbSetScale_Click(sender, EventArgs, simfile, RatingScaleChange.ToOld); };
            rbsToOld.Add(setScaleOld);
            Grid.SetColumn(setScaleOld, 6);
            Grid.SetRow(setScaleOld, simfiles.IndexOf(simfile) + 1);
            gridSimfiles.Children.Add(setScaleOld);

            RadioButton setScaleKeep = new RadioButton
            {
                Content             = "Keep",
                GroupName           = simfile.Name,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          = Simfile.GetBGColor(useDarkLine),
            };

            setScaleKeep.Click += (sender, EventArgs) => { rbSetScale_Click(sender, EventArgs, simfile, RatingScaleChange.NoChange); };
            rbsKeep.Add(setScaleKeep);
            Grid.SetColumn(setScaleKeep, 7);
            Grid.SetRow(setScaleKeep, simfiles.IndexOf(simfile) + 1);
            gridSimfiles.Children.Add(setScaleKeep);

            RadioButton setScaleX = new RadioButton
            {
                Content             = "To X",
                GroupName           = simfile.Name,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          = Simfile.GetBGColor(useDarkLine),
            };

            setScaleX.Click += (sender, EventArgs) => { rbSetScale_Click(sender, EventArgs, simfile, RatingScaleChange.ToX); };
            rbsToX.Add(setScaleX);
            Grid.SetColumn(setScaleX, 8);
            Grid.SetRow(setScaleX, simfiles.IndexOf(simfile) + 1);
            gridSimfiles.Children.Add(setScaleX);

            setScaleKeep.IsChecked = true; //Set the current row's "keep" button as checked
        }