コード例 #1
0
ファイル: LingTree.cs プロジェクト: cdyangupenn/CarlaLegacy
        void loadTree()
        {
            try
            {
            #if UseXmlSerialization
                XmlSerializer mySerializer = new XmlSerializer(tree.GetType());
                StreamReader myReader = new StreamReader(m_strTreeFile);
                tree = (LingTreeTree)mySerializer.Deserialize(myReader);
                tree.setFontsFromXml();
                myReader.Close();
            #else
                XmlDocument doc = new XmlDocument();
                doc.Load(m_strTreeFile);
                tree.Description = GetNodeContent("/LingTreeTree/Description", doc);
                tree.VerticalGap = GetIntFromNodeContent("/LingTreeTree/VerticalGap", doc);

                tree.HorizontalGap = GetIntFromNodeContent("/LingTreeTree/HorizontalGap", doc);
                tree.InitialXCoord = GetIntFromNodeContent("/LingTreeTree/InitialXCoord", doc);
                tree.InitialYCoord = GetIntFromNodeContent("/LingTreeTree/InitialYCoord", doc);
                tree.HorizontalOffset = GetIntFromNodeContent("/LingTreeTree/HorizontalOffset", doc);
                tree.LexGlossGapAdjustment = GetIntFromNodeContent("/LingTreeTree/LexGlossGapAdjustment", doc);
                tree.TrySmoothing = GetBoolFromNodeContent("/LingTreeTree/TrySmoothing", doc);
                tree.TryPixelOffset = GetBoolFromNodeContent("/LingTreeTree/TryPixelOffset", doc);
                tree.GlossFontFace = GetNodeContent("/LingTreeTree/GlossFontFace", doc);
                tree.GlossFontSize = GetIntFromNodeContent("/LingTreeTree/GlossFontSize", doc);
                tree.GlossFontStyle = GetFontStyleFromNodeContent("/LingTreeTree/GlossFontStyle", doc);
                tree.LexFontFace = GetNodeContent("/LingTreeTree/LexFontFace", doc);
                tree.LexFontSize = GetIntFromNodeContent("/LingTreeTree/LexFontSize", doc);
                tree.LexFontStyle = GetFontStyleFromNodeContent("/LingTreeTree/LexFontStyle", doc);
                tree.NTFontFace = GetNodeContent("/LingTreeTree/NTFontFace", doc);
                tree.NTFontSize = GetIntFromNodeContent("/LingTreeTree/NTFontSize", doc);
                tree.NTFontStyle = GetFontStyleFromNodeContent("/LingTreeTree/NTFontStyle", doc);
                tree.GlossColorArgb = GetIntFromNodeContent("/LingTreeTree/GlossColorArgb", doc);
                tree.LexColorArgb = GetIntFromNodeContent("/LingTreeTree/LexColorArgb", doc);
                tree.NTColorArgb = GetIntFromNodeContent("/LingTreeTree/NTColorArgb", doc);
                tree.LinesColorArgb = GetIntFromNodeContent("/LingTreeTree/LinesColorArgb", doc);
                tree.BackgroundColorArgb = GetIntFromNodeContent("/LingTreeTree/BackgroundColorArgb", doc);
                if (tree.BackgroundColorArgb == 0)
                    tree.BackgroundColorArgb = -1; // use white instead of transparent since transparent crashes
                tree.LineWidth = GetIntFromNodeContent("/LingTreeTree/LineWidth", doc);
                tree.CustomColors = GetCustomColorsFromNodeContent(doc);

                tree.NTFont = new Font(tree.NTFontFace, tree.NTFontSize, tree.NTFontStyle);
                tree.GlossFont = new Font(tree.GlossFontFace, tree.GlossFontSize, tree.GlossFontStyle);
                tree.LexFont = new Font(tree.LexFontFace, tree.LexFontSize, tree.LexFontStyle);
            #endif
            }
            catch (Exception exc)
            {
                MessageBox.Show("An error occurred while trying to load the tree description file: " + exc.Message,
                    "Load error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            setIsDirty(false);
        }