コード例 #1
0
        internal void OverrideWith(GuiColourDictionary other)
        {
            if (other == null)
            {
                return;
            }

            foreach (var elem in other)
            {
                Dictionary[elem.Key] = elem.Value;
            }
        }
コード例 #2
0
        internal static GuiColourDictionary FromXml(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            var res = new GuiColourDictionary();

            foreach (var elem in xml.Elements())
            {
                res.Dictionary[elem.Name.LocalName] = GuiColourMatrix.FromXml(elem);
            }

            return(res);
        }
コード例 #3
0
ファイル: GraphicsConfig.cs プロジェクト: poveden/EliteChroma
        /// <summary>
        /// Read the graphics configuration from the given file.
        /// </summary>
        /// <param name="path">The path to the graphics configuration file.</param>
        /// <returns>The graphics configuration, or <c>null</c> if the file couldn't be read (e.g. in the middle of an update).</returns>
        public static GraphicsConfig FromFile(string path)
        {
            if (!File.Exists(path))
            {
                return(null);
            }

            XDocument xml;

            using (var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                if (fs.Length == 0)
                {
                    return(null);
                }

                xml = XDocument.Load(fs);
            }

            return(new GraphicsConfig
            {
                GuiColour = GuiColourDictionary.FromXml(xml.Root.Element("GUIColour")),
            });
        }