Пример #1
0
        public MathTeXPackage(MathTeXPackage source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source",
                                                "The source cannot be null (or Nothing)");
            }

            _use    = source._use;
            _option = source._option;
        }
Пример #2
0
        public MathTeXPackage Clone()
        {
            MathTeXPackage package = new MathTeXPackage(this);

            if (_use != null)
            {
                package._use = String.Copy(_use);
            }
            if (_option != null)
            {
                package._option = String.Copy(_option);
            }

            return(package);
        }
Пример #3
0
        public override void Update(XPathNavigator configuration)
        {
            base.Update(configuration);

            IList <MathTeXPackage> listPackages = this.Packages;

            if (listPackages != null && listPackages.Count > 0)
            {
                int itemCount = listPackages.Count;

                for (int i = 0; i < itemCount; i++)
                {
                    MathTeXPackage package = listPackages[i];

                    package.ToString(_displayedBuilder);
                }
            }

            IList <MathTeXCommand> listCommands = this.Commands;

            if (listCommands != null && listCommands.Count > 0)
            {
                int itemCount = listCommands.Count;

                for (int i = 0; i < itemCount; i++)
                {
                    MathTeXCommand command = listCommands[i];

                    command.ToString(_displayedBuilder);
                }
            }

            _inlineBuilder.AppendLine("\\begin{document}");
            _inlineBuilder.AppendLine("\\pagestyle{empty}");

            _displayedBuilder.AppendLine("\\begin{document}");
            _displayedBuilder.AppendLine("\\pagestyle{empty}");
        }
Пример #4
0
        public virtual void Update(XPathNavigator configuration)
        {
            if (configuration == null)
            {
                return;
            }

            //<packages>
            //  <package use="amstext" />
            //  <package use="amsbsy, amscd" />
            //  <package use="noamsfonts" option="psamsfonts" />
            //</packages>
            XPathNodeIterator iterator = configuration.Select("packages/package");

            if (iterator != null && iterator.Count > 0)
            {
                _listPackages = new List <MathTeXPackage>(iterator.Count);

                foreach (XPathNavigator navigator in iterator)
                {
                    string attribute = navigator.GetAttribute("use",
                                                              String.Empty);
                    if (String.IsNullOrEmpty(attribute) == false)
                    {
                        MathTeXPackage package = new MathTeXPackage(attribute,
                                                                    navigator.GetAttribute("options", String.Empty));

                        if (package.IsValid)
                        {
                            _listPackages.Add(package);
                        }
                    }
                }

                this.WriteMessage(MessageLevel.Info,
                                  String.Format("Loaded {0} LaTeX packages", _listPackages.Count));
            }

            //<commands>
            //    <!-- For testing an example
            //    <command name="" value="" />-->
            //    <command name="\quot" value="" arguments="2" />
            //    <command name="\exn" value="" arguments="1" />
            //</commands>
            iterator = configuration.Select("commands/command");
            if (iterator != null && iterator.Count > 0)
            {
                _listCommands = new List <MathTeXCommand>(iterator.Count);

                foreach (XPathNavigator navigator in iterator)
                {
                    string attribute = navigator.GetAttribute("name",
                                                              String.Empty);
                    if (String.IsNullOrEmpty(attribute) == false)
                    {
                        MathTeXCommand command = new MathTeXCommand(attribute,
                                                                    navigator.GetAttribute("value", String.Empty),
                                                                    navigator.GetAttribute("arguments", String.Empty));

                        if (command.IsValid)
                        {
                            _listCommands.Add(command);
                        }
                    }
                }

                this.WriteMessage(MessageLevel.Info,
                                  String.Format("Loaded {0} LaTeX commands", _listCommands.Count));
            }
        }