コード例 #1
0
        /// <summary>
        /// Finds the node with specified name.
        /// </summary>
        /// <param name="name">The name of node to find.</param>
        /// <returns>The node with specified name, if found; the new node otherwise.</returns>
        /// <remarks>
        /// This method adds the node with specified name to the child nodes if it cannot find the node.
        /// </remarks>
        public XmlItem FindItem(string name)
        {
            XmlItem result = null;
            int     i      = Find(name);

            if (i == -1)
            {
                result      = Add();
                result.Name = name;
            }
            else
            {
                result = Items[i];
            }
            return(result);
        }
コード例 #2
0
 public void Save(XmlItem rootItem)
 {
     foreach (BlobItem item in list)
     {
         XmlItem xi = rootItem.Add();
         xi.Name = "item";
         xi.SetProp("Stream", Converter.ToXml(item.Stream));
         if (!String.IsNullOrEmpty(item.Source))
         {
             xi.SetProp("Source", Converter.ToXml(item.Source));
         }
         if (TempFile != null)
         {
             item.Dispose();
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Replaces the specified locale string with the new value.
        /// </summary>
        /// <param name="id">Comma-separated path to the existing locale string.</param>
        /// <param name="value">The new string.</param>
        /// <remarks>
        /// Use this method if you want to replace some existing locale value with the new one.
        /// </remarks>
        /// <example>
        /// <code>
        /// Res.Set("Messages,SaveChanges", "My text that will appear when you close the designer");
        /// </code>
        /// </example>
        public static void Set(string id, string value)
        {
            if (!FLocaleLoaded)
            {
                LoadBuiltinLocale();
            }

            string[] categories = id.Split(new char[] { ',' });
            XmlItem  xi         = FLocale.Root;

            foreach (string category in categories)
            {
                xi = xi.FindItem(category);
            }

            xi.SetProp("Text", value);
        }
コード例 #4
0
ファイル: Res.cs プロジェクト: frontlook-admin/FastReport
        private static string Get(string id, XmlDocument locale)
        {
            string[] categories = id.Split(new char[] { ',' });
            XmlItem  xi         = locale.Root;

            foreach (string category in categories)
            {
                int i = xi.Find(category);
                if (i == -1)
                {
                    return(null);
                }
                xi = xi[i];
            }

            return(xi.GetProp("Text"));
        }
コード例 #5
0
ファイル: Xml.cs プロジェクト: zixing131/LAEACC
        private void WriteItem(XmlItem item, int level)
        {
            string s;

            // start
            if (!FAutoIndent)
            {
                s = "<" + item.Name;
            }
            else
            {
                s = Dup(level) + "<" + item.Name;
            }

            // text
            if (item.Text != "")
            {
                if (item.Text.StartsWith(" "))
                {
                    s += item.Text;
                }
                else
                {
                    s += " " + item.Text;
                }
            }

            // end
            if (item.Count == 0 && item.Value == "")
            {
                s += "/>";
            }
            else
            {
                s += ">";
            }

            // value
            if (item.Count == 0 && item.Value != "")
            {
                s += item.Value + "</" + item.Name + ">";
            }

            WriteLn(s);
        }
コード例 #6
0
ファイル: Config.cs プロジェクト: satem02/FastReport
        private static void RestoreUIOptions()
        {
            RestoreRightToLeft();

            XmlItem xi = Root.FindItem("UIOptions");
            string  disableHotkeysStringValue = xi.GetProp("DisableHotkeys");

            if (!String.IsNullOrEmpty(disableHotkeysStringValue))
            {
                disableHotkeys = disableHotkeysStringValue.ToLower() != "false";
            }
            string disableBacklightStringValue = xi.GetProp("DisableBacklight");

            if (!String.IsNullOrEmpty(disableBacklightStringValue))
            {
                disableBacklight = disableBacklightStringValue.ToLower() != "false";
            }
        }
コード例 #7
0
        private bool DoRead(XmlItem rootItem)
        {
            ItemState itemState = ReadItem(rootItem);

            lastName = rootItem.Name;

            if (itemState == ItemState.End)
            {
                return(true);
            }
            else if (itemState == ItemState.Complete)
            {
                return(false);
            }

            if (ReadValue(rootItem))
            {
                return(false);
            }

            bool done = false;

            do
            {
                XmlItem childItem = new XmlItem();
                done = DoRead(childItem);
                if (!done)
                {
                    rootItem.AddItem(childItem);
                }
                else
                {
                    childItem.Dispose();
                }
            }while (!done);

            if (lastName != "" && String.Compare(lastName, rootItem.Name, true) != 0)
            {
                RaiseException();
            }

            return(false);
        }
コード例 #8
0
        private static void LoadPlugins()
        {
            // main assembly initializer
            ProcessAssembly(typeof(Config).Assembly);

            XmlItem pluginsItem = Root.FindItem("Plugins");

            for (int i = 0; i < pluginsItem.Count; i++)
            {
                XmlItem item       = pluginsItem[i];
                string  pluginName = item.GetProp("Name");

                try
                {
                    ProcessAssembly(Assembly.LoadFrom(pluginName));
                }
                catch
                {
                }
            }
        }
コード例 #9
0
        public static void CreateFunctionsTree(Report report, ObjectInfo rootItem, XmlItem rootNode)
        {
            foreach (ObjectInfo item in rootItem.Items)
            {
                string     text = String.Empty;
                string     desc = String.Empty;
                MethodInfo func = item.Function;
                if (func != null)
                {
                    text = func.Name;
                    // if this is an overridden function, show its parameters
                    if (rootItem.Name == text)
                    {
                        text = report.CodeHelper.GetMethodSignature(func, false);
                    }
                    desc = GetFunctionDescription(report, func);
                }
                else
                {
                    // it's a category
                    text = Res.TryGet(item.Text);
                }
                XmlItem node = rootNode.Add();
                node.SetProp("Name", text);
                if (!String.IsNullOrEmpty(desc))
                {
                    node.SetProp("Description", desc);
                }

                if (item.Items.Count > 0)
                {
                    node.Name = "Functions";
                    CreateFunctionsTree(report, item, node);
                }
                else
                {
                    node.Name = "Function";
                }
            }
        }
コード例 #10
0
ファイル: Config.cs プロジェクト: frontlook-admin/FastReport
        private static void RestoreCompilerSettings()
        {
            XmlItem xi = Root.FindItem("CompilerSettings");

            CompilerSettings.Placeholder = xi.GetProp("Placeholder");

            string exceptionBehaviour = xi.GetProp("ExceptionBehaviour");

            if (!String.IsNullOrEmpty(exceptionBehaviour))
            {
                try
                {
                    CompilerSettings.ExceptionBehaviour =
                        (CompilerExceptionBehaviour)Converter.FromString(typeof(CompilerExceptionBehaviour),
                                                                         exceptionBehaviour);
                }
                catch
                {
                    CompilerSettings.ExceptionBehaviour = CompilerExceptionBehaviour.Default;
                }
            }
        }
コード例 #11
0
        // we need this to prevent form.Load event to be fired *after* the form is displayed.
        // Used in the StandardDesignerForm.Load event
        internal static bool RestoreFormState(Form form, bool ignoreWindowState)
        {
            XmlItem xi = FDoc.Root.FindItem("Forms").FindItem(form.Name);

            if (!ignoreWindowState)
            {
                form.WindowState = xi.GetProp("Maximized") == "1" ? FormWindowState.Maximized : FormWindowState.Normal;
            }
            string left   = xi.GetProp("Left");
            string top    = xi.GetProp("Top");
            string width  = xi.GetProp("Width");
            string height = xi.GetProp("Height");

            if (left != "" && top != "")
            {
                form.Location = new Point(int.Parse(left), int.Parse(top));
            }
            if (width != "" && height != "")
            {
                form.Size = new Size(int.Parse(width), int.Parse(height));
            }
            return(xi.GetProp("Maximized") == "1");
        }
コード例 #12
0
        /// <summary>
        /// Reads the specified object.
        /// </summary>
        /// <param name="obj">The object to read.</param>
        /// <remarks>
        /// The object must implement the <see cref="IFRSerializable"/> interface. This method
        /// invokes the <b>Deserialize</b> method of the object.
        /// </remarks>
        /// <example>This example demonstrates the use of <b>ReadProperties</b>, <b>ReadChildren</b>,
        /// <b>NextItem</b>, <b>Read</b> methods.
        /// <code>
        /// public void Deserialize(FRReader reader)
        /// {
        ///   // read simple properties like "Text", complex properties like "Border.Lines"
        ///   reader.ReadProperties(this);
        ///
        ///   // moves the current reader item
        ///   while (reader.NextItem())
        ///   {
        ///     // read the "Styles" collection
        ///     if (String.Compare(reader.ItemName, "Styles", true) == 0)
        ///       reader.Read(Styles);
        ///     else if (reader.ReadChildren)
        ///     {
        ///       // if read of children is enabled, read them
        ///       Base obj = reader.Read();
        ///       if (obj != null)
        ///          obj.Parent = this;
        ///     }
        ///   }
        /// }
        /// </code>
        /// </example>
        public void Read(IFRSerializable obj)
        {
            XmlItem saveCurItem = curItem;
            XmlItem saveCurRoot = curRoot;

            XmlProperty[] saveProps = props;
            try
            {
                if (curItem == null)
                {
                    curItem = root;
                }
                curRoot = curItem;
                GetProps();
                obj.Deserialize(this);
            }
            finally
            {
                curItem = saveCurItem;
                curRoot = saveCurRoot;
                props   = saveProps;
            }
        }
コード例 #13
0
        /// <summary>
        /// Reads the specified object.
        /// </summary>
        /// <param name="obj">The object to read.</param>
        /// <remarks>
        /// The object must implement the <see cref="IFRSerializable"/> interface. This method
        /// invokes the <b>Deserialize</b> method of the object.
        /// </remarks>
        /// <example>This example demonstrates the use of <b>ReadProperties</b>, <b>ReadChildren</b>,
        /// <b>NextItem</b>, <b>Read</b> methods.
        /// <code>
        /// public void Deserialize(FRReader reader)
        /// {
        ///   // read simple properties like "Text", complex properties like "Border.Lines"
        ///   reader.ReadProperties(this);
        ///
        ///   // moves the current reader item
        ///   while (reader.NextItem())
        ///   {
        ///     // read the "Styles" collection
        ///     if (String.Compare(reader.ItemName, "Styles", true) == 0)
        ///       reader.Read(Styles);
        ///     else if (reader.ReadChildren)
        ///     {
        ///       // if read of children is enabled, read them
        ///       Base obj = reader.Read();
        ///       if (obj != null)
        ///          obj.Parent = this;
        ///     }
        ///   }
        /// }
        /// </code>
        /// </example>
        public void Read(IFRSerializable obj)
        {
            XmlItem         saveCurItem = FCurItem;
            XmlItem         saveCurRoot = FCurRoot;
            List <PropInfo> saveProps   = FProps;

            try
            {
                if (FCurItem == null)
                {
                    FCurItem = FRoot;
                }
                FCurRoot = FCurItem;
                GetProps();
                obj.Deserialize(this);
            }
            finally
            {
                FCurItem = saveCurItem;
                FCurRoot = saveCurRoot;
                FProps   = saveProps;
            }
        }
コード例 #14
0
        private static string Get(string id, XmlDocument locale)
        {
            string[] categories = id.Split(new char[] { ',' });
            XmlItem  xi         = locale.Root;

            foreach (string category in categories)
            {
                int i = xi.Find(category);
                if (i == -1)
                {
                    return(id + " " + FBadResult);
                }
                xi = xi[i];
            }

            string result = xi.GetProp("Text");

            if (result == "")
            {
                result = id + " " + FBadResult;
            }
            return(result);
        }
コード例 #15
0
        private void WriteItem(XmlItem item, int level)
        {
            FastString sb = new FastString();


            // start
            if (autoIndent)
            {
                sb.Append(Dup(level));
            }
            sb.Append("<");
            sb.Append(item.Name);

            // text

            item.WriteProps(sb);

            // end
            if (item.Count == 0 && item.Value == "")
            {
                sb.Append("/>");
            }
            else
            {
                sb.Append(">");
            }

            // value
            if (item.Count == 0 && item.Value != "")
            {
                sb.Append(Converter.ToXml(item.Value, false));
                sb.Append("</");
                sb.Append(item.Name);
                sb.Append(">");
            }
            WriteLn(sb.ToString());
        }
コード例 #16
0
ファイル: ExportsOptions.cs プロジェクト: yajunsun/FastReport
        private void SaveMenuTree(XmlItem xi, List <ExportsTreeNode> nodes)
        {
            xi.Items.Clear();

            foreach (ExportsTreeNode node in nodes)
            {
                XmlItem newItem = new XmlItem();
                newItem.Name = node.Name;
                if (node.ExportType != null)
                {
                    newItem.SetProp("ExportType", node.ExportType.FullName);
                }
                if (node.ImageIndex != -1)
                {
                    newItem.SetProp("Icon", node.ImageIndex.ToString());
                }
                newItem.SetProp("Enabled", node.Enabled.ToString());
                xi.Items.Add(newItem);
                if (node.Nodes.Count != 0)
                {
                    SaveMenuTree(newItem, node.Nodes);
                }
            }
        }
コード例 #17
0
        private bool ReadValue(XmlItem item)
        {
            FastString builder;

            if (Config.IsStringOptimization)
            {
                builder = new FastStringWithPool(stringPool);
            }
            else
            {
                builder = new FastString();
            }
            ReadState state          = ReadState.FindLeft;
            string    lastName       = "</" + this.lastName + ">";
            int       lastNameLength = lastName.Length;

            do
            {
                int c = reader.Read();
                if (c == -1)
                {
                    RaiseException();
                }

                builder.Append((char)c);
                if (state == ReadState.FindLeft)
                {
                    if (c == '<')
                    {
                        symbolInBuffer = '<';
                        return(false);
                    }
                    else if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
                    {
                        state = ReadState.FindCloseItem;
                    }
                }
                else if (state == ReadState.FindCloseItem)
                {
                    if (builder.Length >= lastNameLength)
                    {
                        bool match = true;
                        for (int j = 0; j < lastNameLength; j++)
                        {
                            if (builder[builder.Length - lastNameLength + j] != lastName[j])
                            {
                                match = false;
                                break;
                            }
                        }

                        if (match)
                        {
                            builder.Length -= lastNameLength;
                            item.Value      = Converter.FromXml(builder.ToString());
                            return(true);
                        }
                    }
                }
            }while (true);
        }
コード例 #18
0
        private ItemState ReadItem(XmlItem item)
        {
            FastString builder;

            if (Config.IsStringOptimization)
            {
                builder = new FastStringWithPool(stringPool);
            }
            else
            {
                builder = new FastString();
            }
            ReadState state   = ReadState.FindLeft;
            int       comment = 0;
            int       i       = 0;
            //string tempAttrName = null;
            //int lc = -1;
            int c = -1;

            // find <
            c = readNextSymbol();
            while (c != -1)
            {
                if (c == '<')
                {
                    break;
                }
                c = readNextSymbol();
            }

            //while not end
            while (state != ReadState.Done && c != -1)
            {
                // find name or comment;
                c = readNextSymbol();
                i = 0;
                while (c != -1)
                {
                    if (i <= comment)
                    {
                        switch (comment)
                        {
                        case 0: if (c == '!')
                            {
                                comment++;
                            }
                            break;

                        case 1: if (c == '-')
                            {
                                comment++;
                            }
                            break;

                        case 2: if (c == '-')
                            {
                                state = ReadState.FindComment;
                            }
                            break;

                        default: comment = -1; break;
                        }
                        if (state == ReadState.FindComment)
                        {
                            break;
                        }
                    }
                    i++;
                    switch (c)
                    {
                    case '>': state = ReadState.Done; break;      //Found name

                    case ' ': state = ReadState.FindRight; break; //Found name

                    case '<': RaiseException(); break;

                    default: builder.Append((char)c); break;
                    }
                    if (state != ReadState.FindLeft)
                    {
                        break;
                    }
                    c = readNextSymbol();
                }
                switch (state)
                {
                case ReadState.FindComment:
                    comment = 0;
                    while (c != -1)
                    {
                        c = readNextSymbol();
                        if (comment > 1)
                        {
                            if (c == '>')
                            {
                                state = ReadState.FindLeft;
                                break;
                            }
                        }
                        else
                        {
                            if (c == '-')
                            {
                                comment++;
                            }
                            else
                            {
                                comment = 0;
                            }
                        }
                    }
                    comment        = 0;
                    builder.Length = 0;
                    while (c != -1)
                    {
                        if (c == '<')
                        {
                            break;
                        }
                        c = readNextSymbol();
                    }
                    break;

                case ReadState.Done:
                    string result = builder.ToString();
                    if (result[0] == '/')
                    {
                        item.Name = result.Substring(1);
                        return(ItemState.End);
                    }
                    if (result[result.Length - 1] == '/')
                    {
                        item.Name = result.Substring(0, result.Length - 1);
                        return(ItemState.Complete);
                    }
                    item.Name = result;
                    return(ItemState.Begin);

                case ReadState.FindRight:
                    if (builder[0] == '/')
                    {
                        builder.Remove(0, 1);
                        item.Name = builder.ToString();
                        return(ItemState.End);
                    }
                    item.Name      = builder.ToString();
                    builder.Length = 0;
                    while (c != -1 && c != '>')
                    {
                        c = readNextSymbol();
                        while (c != -1)
                        {
                            if (c == ' ')
                            {
                                builder.Length = 0;
                                c = readNextSymbol();
                                continue;
                            }
                            if (c == '=' || c == '>')
                            {
                                break;
                            }
                            builder.Append((char)c);
                            c = readNextSymbol();
                        }
                        if (c == '>')
                        {
                            if (builder.Length > 0 && builder[builder.Length - 1] == '/')
                            {
                                return(ItemState.Complete);
                            }
                            return(ItemState.Begin);
                        }
                        c = readNextSymbol();
                        if (c != '"')
                        {
                            continue;
                        }
                        string attrName = builder.ToString();
                        builder.Length = 0;
                        while (c != -1)
                        {
                            c = readNextSymbol();
                            if (c == '"')
                            {
                                break;
                            }
                            builder.Append((char)c);
                        }
                        item.SetProp(attrName, Converter.FromXml(builder.ToString()));
                        builder.Length = 0;
                    }
                    break;
                }
            }


            //just for errors
            return(ItemState.Begin);
        }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <b>XmlDocument</b> class with default settings.
 /// </summary>
 public XmlDocument()
 {
     root        = new XmlItem();
     writeHeader = true;
 }
コード例 #20
0
 /// <summary>
 /// Gets the index of specified node in the child nodes list.
 /// </summary>
 /// <param name="item">The node to find.</param>
 /// <returns>Zero-based index of node, if found; <b>-1</b> otherwise.</returns>
 public int IndexOf(XmlItem item)
 {
     return(Items.IndexOf(item));
 }
コード例 #21
0
ファイル: Xml.cs プロジェクト: zixing131/LAEACC
 public void Write(XmlItem rootItem)
 {
     WriteHeader();
     DoWrite(rootItem, 0);
     FWriter.Flush();
 }
コード例 #22
0
 /// <summary>
 /// Inserts a specified node to this node.
 /// </summary>
 /// <param name="index">Position to insert.</param>
 /// <param name="item">Node to insert.</param>
 public void InsertItem(int index, XmlItem item)
 {
     AddItem(item);
     Items.RemoveAt(Count - 1);
     Items.Insert(index, item);
 }
コード例 #23
0
 /// <summary>
 /// Initializes a new instance of the <b>FRReader</b> class with specified report and xml item with
 /// contents to read.
 /// </summary>
 /// <param name="report">Reference to a report.</param>
 /// <param name="root">Xml item with contents to read.</param>
 public FRReader(Report report, XmlItem root) : this(report)
 {
     this.root = root;
 }
コード例 #24
0
        private static void SaveUIStyle()
        {
            XmlItem xi = Root.FindItem("UIStyle");

            xi.SetProp("Style", Converter.ToString(UIStyle));
        }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <b>FRWriter</b> class with specified xml item that will
 /// receive writer's output.
 /// </summary>
 /// <param name="root">The xml item that will receive writer's output.</param>
 public FRWriter(XmlItem root) : this()
 {
     FRoot = root;
 }
コード例 #26
0
        private static void SaveUIOptions()
        {
            XmlItem xi = Root.FindItem("UIOptions");

            xi.SetProp("DisableHotkeys", Converter.ToString(DisableHotkeys));
        }
コード例 #27
0
ファイル: Xml.cs プロジェクト: zixing131/LAEACC
        private ItemState ReadItem(XmlItem item)
        {
            FBuilder.Length = 0;
            ReadState state   = ReadState.FindLeft;
            int       comment = 0;
            int       i       = 0;

            do
            {
                int c = FSymbolInBuffer == -1 ? FReader.Read() : FSymbolInBuffer;
                FSymbolInBuffer = -1;
                if (c == -1)
                {
                    RaiseException();
                }

                if (state == ReadState.FindLeft)
                {
                    if (c == '<')
                    {
                        state = ReadState.FindRight;
                    }
                    else if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
                    {
                        RaiseException();
                    }
                }
                else if (state == ReadState.FindRight)
                {
                    if (c == '>')
                    {
                        state = ReadState.Done;
                        break;
                    }
                    else if (c == '<')
                    {
                        RaiseException();
                    }
                    else
                    {
                        FBuilder.Append((char)c);
                        i++;
                        if (i == 3 && FBuilder[0] == '!' && FBuilder[1] == '-' && FBuilder[2] == '-')
                        {
                            state           = ReadState.FindComment;
                            comment         = 0;
                            i               = 0;
                            FBuilder.Length = 0;
                        }
                    }
                }
                else if (state == ReadState.FindComment)
                {
                    if (comment == 2)
                    {
                        if (c == '>')
                        {
                            state = ReadState.FindLeft;
                        }
                    }
                    else
                    {
                        if (c == '-')
                        {
                            comment++;
                        }
                        else
                        {
                            comment = 0;
                        }
                    }
                }
            }while (true);

            if (FBuilder[FBuilder.Length - 1] == ' ')
            {
                FBuilder.Length--;
            }

            string    itemText  = FBuilder.ToString();
            ItemState itemState = ItemState.Begin;

            if (itemText.StartsWith("/"))
            {
                itemText  = itemText.Substring(1);
                itemState = ItemState.End;
            }
            else if (itemText.EndsWith("/"))
            {
                itemText  = itemText.Substring(0, itemText.Length - 1);
                itemState = ItemState.Complete;
            }

            item.Name = itemText;
            item.Text = "";

            i = itemText.IndexOf(" ");
            if (i != -1)
            {
                item.Name = itemText.Substring(0, i);
                item.Text = itemText.Substring(i + 1);
            }

            return(itemState);
        }
コード例 #28
0
 /// <summary>
 /// Adds a specified node to this node.
 /// </summary>
 /// <param name="item">The node to add.</param>
 public void AddItem(XmlItem item)
 {
     item.Parent = this;
 }
コード例 #29
0
 public void Read(XmlItem item)
 {
     ReadHeader();
     DoRead(item);
 }
コード例 #30
0
 internal void Read(IFRSerializable obj, XmlItem Root)
 {
     curItem = Root;
     Read(obj);
 }