Пример #1
0
        public override bool parseXml(XElement xml, TLayer parentLayer)
        {
            if (xml == null || xml.Name != "TextActor")
                return false;

            if (!base.parseXml(xml, parentLayer))
                return false;

            try {
                text = xml.Element("Text").Value;
                FontFamily family = Program.findFontFamily(xml.Element("FontFamilyName").Value);
                float fontSize = TUtil.parseFloatXElement(xml.Element("FontSize"), 12);
                FontStyle fontStyle = (FontStyle)TUtil.parseIntXElement(xml.Element("FontStyle"), 0);
                if (family != null)
                    font = new Font(family, fontSize, fontStyle, GraphicsUnit.Point);
                else
                    font = new Font("Arial", fontSize, fontStyle, GraphicsUnit.Point);
                color = Color.FromArgb(int.Parse(xml.Element("Color").Value));
                BoxSize.Width = float.Parse(xml.Element("SizeWidth").Value);
                BoxSize.Height = float.Parse(xml.Element("SizeHeight").Value);

                refreshMatrix();
                return true;
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                return false;
            }
        }
Пример #2
0
        public override bool parseXml(XElement xml, TLayer parentLayer)
        {
            if (xml == null)
            {
                return(false);
            }

            if (!base.parseXml(xml, parentLayer))
            {
                return(false);
            }

            try {
                Anchor.X     = float.Parse(xml.Element("AnchorX").Value);
                Anchor.Y     = float.Parse(xml.Element("AnchorY").Value);
                Position.X   = float.Parse(xml.Element("PositionX").Value);
                Position.Y   = float.Parse(xml.Element("PositionY").Value);
                Scale.Width  = float.Parse(xml.Element("ScaleWidth").Value);
                Scale.Height = float.Parse(xml.Element("ScaleHeight").Value);
                Skew.Width   = float.Parse(xml.Element("SkewWidth").Value);
                Skew.Height  = float.Parse(xml.Element("SkewHeight").Value);
                Rotation     = float.Parse(xml.Element("Rotation").Value);
                refreshMatrix();

                zIndex    = int.Parse(xml.Element("ZIndex").Value);
                draggable = bool.Parse(xml.Element("Draggable").Value);
                acceleratorSensibility = bool.Parse(xml.Element("AcceleratorSensibility").Value);
                autoInteractionBound   = bool.Parse(xml.Element("AutoInteractionBound").Value);
                InteractionBound       = new RectangleF(float.Parse(xml.Element("InteractionBoundX").Value),
                                                        float.Parse(xml.Element("InteractionBoundY").Value),
                                                        float.Parse(xml.Element("InteractionBoundWidth").Value),
                                                        float.Parse(xml.Element("InteractionBoundHeight").Value));

                puzzle     = bool.Parse(xml.Element("Puzzle").Value);
                PuzzleArea = new RectangleF(TUtil.parseFloatXElement(xml.Element("PuzzleAreaX"), 0),
                                            TUtil.parseFloatXElement(xml.Element("PuzzleAreaY"), 0),
                                            TUtil.parseFloatXElement(xml.Element("PuzzleAreaWidth"), Program.BOOK_WIDTH),
                                            TUtil.parseFloatXElement(xml.Element("PuzzleAreaHeight"), Program.BOOK_HEIGHT));

                return(true);
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                return(false);
            }
        }