コード例 #1
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            ColorChimeConfig config = new ColorChimeConfig();

            config.captureMode = ((KeyValuePair <int, string>)comboCaptureMode.SelectedItem).Key;
            if (config.captureMode == CAPMODE_CTRL_PS || config.captureMode == CAPMODE_DOTNET_API)
            {
                if (targetWindow != null)
                {
                    config.targetWindowClass = targetWindow.className;
                    config.targetWindowTitle = targetWindow.windowText;
                }
            }
            config.waveFilePath  = txtWavFilePath.Text;
            config.watchInterval = (int)numUDWatchInterval.Value;
            config.pointAx       = (int)numUD_ax.Value;
            config.pointAy       = (int)numUD_ay.Value;
            config.pointBx       = (int)numUD_bx.Value;
            config.pointBy       = (int)numUD_by.Value;
            config.watchColors   = targetColors;


            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ColorChimeConfig));
            System.IO.StreamWriter sw = new System.IO.StreamWriter(configPath, false, new System.Text.UTF8Encoding(false));
            serializer.Serialize(sw, config);
            sw.Close();
        }
コード例 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(configPath))
            {
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ColorChimeConfig));
                System.IO.StreamReader sr     = new System.IO.StreamReader(configPath, new System.Text.UTF8Encoding(false));
                ColorChimeConfig       config = (ColorChimeConfig)serializer.Deserialize(sr);
                sr.Close();

                foreach (var item in comboCaptureMode.Items)
                {
                    if (((KeyValuePair <int, string>)item).Key == config.captureMode)
                    {
                        comboCaptureMode.SelectedItem = item;
                    }
                }
                if (config.captureMode == CAPMODE_CTRL_PS || config.captureMode == CAPMODE_DOTNET_API)
                {
                    if (config.hasTargetWindow)
                    {
                    }
                }
                txtWavFilePath.Text      = config.waveFilePath;
                numUDWatchInterval.Value = config.watchInterval;
                numUD_ax.Value           = config.pointAx;
                numUD_ay.Value           = config.pointAy;
                numUD_bx.Value           = config.pointBx;
                numUD_by.Value           = config.pointBy;
                //txtInputColor.Text      = config.watchColor;
                foreach (ColorItem color in config.watchColors)
                {
                    lsbTargetColors.Items.Add(color);
                    targetColors.Add(color);
                }
            }
        }