public static ShowResult Show(IList <IChartFormat> formats, Form parent) { ChartForm form = new ChartForm(); form.Formats = formats; ShowResult result = new ShowResult(); result.Result = form.ShowDialog(parent); result.Format = form.ChartCombo.SelectedItem as IChartFormat; result.Coop = form.CoopCheckbox.Checked; result.ExpertPlus = form.ExpertPlusCheckbox.Checked; result.FixForQuickplay = form.FixCheckbox.Checked; result.Milo = form.MiloTextbox.Text; result.Weights = form.WeightsTextbox.Text; result.Pan = form.PanTextbox.Text; return(result); }
private void ReplaceChartButton_Click(object sender, EventArgs e) { OpenDialog.Multiselect = false; OpenDialog.Title = "Select a note chart file"; OpenDialog.Filter = "Supported Files (*.mid, *.chart)|*.mid;*.chart|All Files|*"; if (OpenDialog.ShowDialog(this) == DialogResult.Cancel) { return; } Stream stream = new FileStream(OpenDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); Mid mid = Mid.Create(stream); stream.Position = 0; Chart chart = mid == null?Chart.Create(stream) : null; if (mid == null && chart == null) { stream.Close(); throw new FormatException(); } List <IChartFormat> formats = new List <IChartFormat>(); if (mid != null) { formats.Add(ChartFormatRB.Instance); formats.Add(ChartFormatGH2.Instance); } if (chart != null) { formats.Add(ChartFormatChart.Instance); } ChartForm.ShowResult result = ChartForm.Show(formats, this); if (result.Result == DialogResult.Cancel) { return; } if (mid != null || chart != null) { foreach (IFormat format in Data.GetFormats(FormatType.Chart)) { foreach (string chartstream in Data.GetStreamNames(format)) { Data.DeleteStream(chartstream); } } } Stream milo = null; Stream pan = null; Stream weights = null; FormatData data = new TemporaryFormatData(Data.Song); if (result.Format == ChartFormatRB.Instance) { if (result.Milo.HasValue()) { milo = new FileStream(result.Milo, FileMode.Open, FileAccess.Read, FileShare.Read); } if (result.Weights.HasValue()) { weights = new FileStream(result.Weights, FileMode.Open, FileAccess.Read, FileShare.Read); } if (result.Pan.HasValue()) { pan = new FileStream(result.Pan, FileMode.Open, FileAccess.Read, FileShare.Read); } ChartFormatRB.Instance.Create(data, stream, pan, weights, milo, result.ExpertPlus, result.FixForQuickplay, Song.Game); } else if (result.Format == ChartFormatGH2.Instance) { ChartFormatGH2.Instance.Create(data, stream, result.Coop); } else if (result.Format == ChartFormatChart.Instance) { ChartFormatChart.Instance.Create(data, stream, result.Coop); } data.SaveTo(Data); stream.Close(); if (milo != null) { milo.Close(); } if (pan != null) { pan.Close(); } if (weights != null) { weights.Close(); } UpdateChartSizes(); }