本文整理汇总了C#中Chart.QuantizeMeasureLengths方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.QuantizeMeasureLengths方法的具体用法?C# Chart.QuantizeMeasureLengths怎么用?C# Chart.QuantizeMeasureLengths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.QuantizeMeasureLengths方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertChart
public static void ConvertChart(Chart chart, Configuration config, string filename, int index, int[] map)
{
if (config == null)
{
config = LoadConfig();
}
int quantizeNotes = config["BMS"].GetValue("QuantizeNotes");
int quantizeMeasure = config["BMS"].GetValue("QuantizeMeasure");
int difficulty = config["IIDX"].GetValue("Difficulty" + index.ToString());
string title = config["BMS"]["Players" + config["IIDX"]["Players" + index.ToString()]] + " " + config["BMS"]["Difficulty" + difficulty.ToString()];
title = title.Trim();
if (quantizeMeasure > 0)
chart.QuantizeMeasureLengths(quantizeMeasure);
using (MemoryStream mem = new MemoryStream())
{
BMS bms = new BMS();
bms.Charts = new Chart[] { chart };
string name = "";
if (chart.Tags.ContainsKey("TITLE"))
name = chart.Tags["TITLE"];
if (name == "")
name = Path.GetFileNameWithoutExtension(Path.GetFileName(filename)); //ex: "1204 [1P Another]"
// write some tags
bms.Charts[0].Tags["TITLE"] = name;
if (chart.Tags.ContainsKey("ARTIST"))
bms.Charts[0].Tags["ARTIST"] = chart.Tags["ARTIST"];
if (chart.Tags.ContainsKey("GENRE"))
bms.Charts[0].Tags["GENRE"] = chart.Tags["GENRE"];
if (difficulty > 0)
bms.Charts[0].Tags["DIFFICULTY"] = difficulty.ToString();
if (bms.Charts[0].Players > 1)
bms.Charts[0].Tags["PLAYER"] = "3";
else
bms.Charts[0].Tags["PLAYER"] = "1";
name = name.Replace(":", "_");
name = name.Replace("/", "_");
name = name.Replace("?", "_");
name = name.Replace("\\", "_");
if (title != null && title.Length > 0)
{
name += " [" + title + "]";
}
string output = Path.Combine(Path.GetDirectoryName(filename), @"@" + name + ".bms");
if (map == null)
bms.GenerateSampleMap();
else
bms.SampleMap = map;
if (quantizeNotes > 0)
bms.Charts[0].QuantizeNoteOffsets(quantizeNotes);
bms.GenerateSampleTags();
bms.Write(mem, true);
File.WriteAllBytes(output, mem.ToArray());
}
}