[英]How can I save the output of a color Dialog into a ini-file?
我目前正在編寫我的第一個應用程序。 我將用戶配置保存到一個 ini 文件中。 現在我需要保存一個顏色代碼,它是程序從 colorDialog 中獲取的。
這是代碼的一部分:
public void button1_Click(object sender, EventArgs e)
{
ColorDialog colorDialog1 = new ColorDialog();
colorDialog1.ShowDialog();
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
string input = null;
var userprofile_location = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Appdata\Roaming\GameCentral";
var settings = new IniFile(userprofile_location + @"\settings.ini");
//IniFile.Write;
settings.Write("1", input, "Color");
}
}
如下設置輸入並將輸入寫入ini文件。 它應該保存十六進制代碼。
string input = (colorDialog1.Color.ToArgb() & 0x00FFFFFF).ToString("X6")
如果你想使用返回的十六進制碼,這樣做:
string code = "FFDDAA";
Color color = Color.FromArgb(Convert.ToInt32(code, 16));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.