예제 #1
0
        private void UpdateSetup()
        {
            var contextNode = Xml.SetValue(_setupNode, "Display", string.Empty);

            Xml.SetValue(contextNode, "Height", toolStripTextBoxResolutionY.Text);
            Xml.SetValue(contextNode, "Width", toolStripTextBoxResolutionX.Text);
            Xml.SetValue(contextNode, "PixelSize", _cellSize.ToString(CultureInfo.InvariantCulture));
            Xml.SetValue(contextNode, "Brightness", trackBarBrightness.Value.ToString(CultureInfo.InvariantCulture));
            if (_originalBackground != null)
            {
                if (_backgroundImageFileName != string.Empty)
                {
                    using (var stream = new FileStream(_backgroundImageFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        var buffer = new byte[stream.Length];
                        stream.Read(buffer, 0, (int)stream.Length);
                        var backgroundImageNode = _setupNode.SelectSingleNode("BackgroundImage");
                        if (backgroundImageNode != null)
                        {
                            backgroundImageNode.InnerText = Convert.ToBase64String(buffer);
                        }
                    }
                }
            }
            else
            {
                var backgroundImageNode = _setupNode.SelectSingleNode("BackgroundImage");
                if (backgroundImageNode != null)
                {
                    backgroundImageNode.InnerText = Convert.ToBase64String(new byte[0]);
                }
            }
            var emptyNodeAlways   = Xml.GetEmptyNodeAlways(_setupNode, "Channels");
            var channelDictionary = new List <byte>();

            foreach (var num in _channelDictionary.Keys)
            {
                channelDictionary.Clear();
                var node = Xml.SetNewValue(emptyNodeAlways, "Channel", string.Empty);
                Xml.SetAttribute(node, "number", (num + _startChannel).ToString(CultureInfo.InvariantCulture));
                foreach (var num2 in _channelDictionary[num])
                {
                    channelDictionary.AddRange(BitConverter.GetBytes(num2));
                }
                node.InnerText = Convert.ToBase64String(channelDictionary.ToArray());
            }
            _setupData.SetBoolean(_setupNode, "RedirectOutputs", checkBoxRedirectOutputs.Checked);
        }