简体   繁体   English

如何将彩色对话框的 output 保存到 ini 文件中?

[英]How can I save the output of a color Dialog into a ini-file?

I'm currently coding my first app.我目前正在编写我的第一个应用程序。 I am saving the Userconfiguration into an ini-file.我将用户配置保存到一个 ini 文件中。 Now I need to save a color code, which the program gets from a colorDialog.现在我需要保存一个颜色代码,它是程序从 colorDialog 中获取的。

Here's the section of the code:这是代码的一部分:

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");
    }
}

Set input as below and write input to ini file.如下设置输入并将输入写入ini文件。 it should save hexcode.它应该保存十六进制代码。

string input = (colorDialog1.Color.ToArgb() & 0x00FFFFFF).ToString("X6")

if you want to use back hexcode, do like this:如果你想使用返回的十六进制码,这样做:

string code = "FFDDAA";

Color color = Color.FromArgb(Convert.ToInt32(code, 16));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM