コード例 #1
0
ファイル: EdxNode.cs プロジェクト: polytronicgr/netrix
        /// <summary>
        /// Inserts new child at spec'd index.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="index"></param>
        public void InsertChild(EdxNode node, int index)
        {
            // sanity check
            if (index > ChildNodes.Count)
            {
                Util.Err("insertChild: can't insert past end of array.");
                return;
            }

            // resolve forw/back pointers
            if (index != 0)
            {
                ((EdxNode)ChildNodes[index - 1]).NextSibling = node;
                node.PreviousSibling = ChildNodes[index - 1] as EdxNode;
            }
            else
            {
                node.PreviousSibling = null;
            }

            if (index < ChildNodes.Count)
            {
                ((EdxNode)ChildNodes[index]).PreviousSibling = node;
                node.NextSibling = ChildNodes[index] as EdxNode;
            }
            else
            {
                node.NextSibling = null;
            }

            // insert into array
            ChildNodes.Insert(index, node);
        }
コード例 #2
0
ファイル: Region.cs プロジェクト: polytronicgr/netrix
 /// <summary>
 /// Constructor for region class.
 /// </summary>
 /// <param name="editor"></param>
 /// <param name="p"></param>
 /// <param name="sTemp"></param>
 /// <param name="sPath"></param>
 /// <param name="sOptions"></param>
 /// <param name="index"></param>
 public Region(IHtmlEditor editor, EdxNode p, string sTemp, string sPath, string sOptions, int index) : base(editor, p, sTemp, sPath, sOptions, index)
 {
     base.parent = p;
     // init class vars
     this.saveBackground  = Color.Empty;
     this.viewState       = null;
     this.displayLinkNode = null;
 }
コード例 #3
0
        internal static EdxNode GetEdxFromElement(Interop.IHTMLElement element)
        {
            object[] attr = new object[1];
            element.GetAttribute("__eobj", 0, attr);
            EdxNode edx = attr[0] as EdxNode;

            return(edx);
        }
コード例 #4
0
ファイル: EdxNode.cs プロジェクト: polytronicgr/netrix
        /// <summary>
        /// Returns true if the node is a child of the spec'd parent.
        /// </summary>
        /// <param name="par"></param>
        public bool IsChildOf(EdxNode par)
        {
            EdxNode e = this;

            while (e != null && e != par)
            {
                e = e.parent;
            }
            return(e == par);
        }
コード例 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="editor"></param>
 /// <param name="p"></param>
 /// <param name="sTemp"></param>
 /// <param name="sPath"></param>
 /// <param name="sOptions"></param>
 /// <param name="index"></param>
 public Widget(IHtmlEditor editor, EdxNode p, string sTemp, string sPath, string sOptions, int index) : base(editor, p, sTemp, sPath, sOptions, index)
 {
     resAssPath = this.GetType().Assembly.GetName().FullName;
     // init class vars
     this.type = sTemp;
     string[] a = this.type.Substring(7).Split('.');             // widget:icon or widget:icon.add
     this.widgetType = (Widget.WidgetType)Enum.Parse(typeof(Widget.WidgetType), a[0], true);
     if (a.Length > 1)
     {
         this.widgetSubType = a[1];
     }
     else
     {
         this.widgetSubType = null;
     }
 }
コード例 #6
0
ファイル: EdxNode.cs プロジェクト: polytronicgr/netrix
 /// <summary>
 /// Removes the specific child from the child list.
 /// </summary>
 /// <param name="node"></param>
 public EdxNode RemoveChild(EdxNode node)
 {
     for (int i = 0; i < ChildNodes.Count; i++)
     {
         if (ChildNodes[i] == node)
         {
             if (node.PreviousSibling != null)
             {
                 node.PreviousSibling.NextSibling = node.NextSibling;
             }
             if (node.NextSibling != null)
             {
                 node.NextSibling.PreviousSibling = node.PreviousSibling;
             }
             //ChildNodes.splice( i, 1 );
             return(node);
         }
     }
     Util.Err("Child node not found in childNode list");
     return(null);
 }
コード例 #7
0
ファイル: EdxNode.cs プロジェクト: polytronicgr/netrix
 /// <summary>
 /// Constructor for base edxnode.
 /// Passed parent edxnode, template name, edxpath, and an optional index within the parent node list to insert at.
 /// </summary>
 /// <param name="editor"></param>
 /// <param name="p"></param>
 /// <param name="sTemplate"></param>
 /// <param name="sPath"></param>
 /// <param name="sOptions"></param>
 /// <param name="index"></param>
 public EdxNode(IHtmlEditor editor, EdxNode p, string sTemplate, string sPath, string sOptions, int index)
 {
     this.editor = editor;
     this.editor.ReadyStateComplete += new EventHandler(editor_ReadyStateComplete);
     if (sTemplate == null)
     {
         throw new Exception("");
     }
     // capture tree info
     if (p == null)
     {
         // we must be root
         this.parent = null;
         this.root   = this as Root;
     }
     else
     {
         this.parent = p;
         this.root   = p.root;
         this.index  = index;
         this.id     = this.root.AssignID(this);
         if (index == -1 /* undefined */)
         {
             p.AppendChild(this);
         }
         else
         {
             p.InsertChild(this, index);
         }
     }
     this.edxtemplate = sTemplate;
     this.edxpath     = sPath;
     this.oTemplate   = null;
     this.oEditNode   = null;
     this.childNodes  = new List <EdxNode>(); // TODO: EdxNode[] ?
     this.ProcessOptions(sOptions);
 }
コード例 #8
0
        /// <summary>
        /// Attempts to find a field to the left of the spec'd one. Depth-first tree traversal.
        /// </summary>
        /// <param name="cur"></param>
        /// <param name="bUp"></param>
        /// <returns></returns>
        public static EdxNode TraverseLeft(EdxNode cur, bool bUp)
        {
            EdxNode en;

            // catch root
            if (cur == null)
            {
                return(null);
            }

            if (bUp)
            {
                // look left first
                en = cur.PreviousSibling;
                if (en == null)
                {
                    return(Util.TraverseLeft(cur.parent, true));
                }
            }
            else
            {
                // look down first
                if (cur.ChildNodes.Count == 0)
                {
                    return(Util.TraverseLeft(cur, true));
                }
                en = cur.ChildNodes[cur.ChildNodes.Count - 1];
            }
            if (en is Field)
            {
                return(en);
            }
            else
            {
                return(TraverseLeft(en, false));
            }
        }
コード例 #9
0
        /// <summary>
        /// Attempts to find a field to the right of the spec'd one. Depth-first tree traversal.
        /// </summary>
        /// <param name="cur"></param>
        /// <param name="bUp"></param>
        public static EdxNode TraverseRight(EdxNode cur, bool bUp)
        {
            EdxNode en;

            // catch root
            if (cur == null)
            {
                return(null);
            }

            if (bUp)
            {
                // look right first
                en = (EdxNode)cur.NextSibling;
                if (en == null)
                {
                    return(Util.TraverseRight(cur.parent, true));
                }
            }
            else
            {
                // look down first
                if (cur.ChildNodes.Count == 0)
                {
                    return(Util.TraverseRight(cur, true));
                }
                en = cur.ChildNodes[0] as EdxNode;
            }
            if (en is Field)
            {
                return(en);
            }
            else
            {
                return(TraverseRight(en, false));
            }
        }
コード例 #10
0
ファイル: EdxNode.cs プロジェクト: polytronicgr/netrix
 /// <summary>
 /// Maintain a list of all edxnode children in order.
 /// </summary>
 /// <param name="node"></param>
 public void AppendChild(EdxNode node)
 {
     this.InsertChild(node, this.ChildNodes.Count);
 }
コード例 #11
0
 /// <summary>
 /// Constructor for container class.
 /// </summary>
 /// <param name="editor"></param>
 /// <param name="p"></param>
 /// <param name="sTemp"></param>
 /// <param name="sPath"></param>
 /// <param name="sOptions"></param>
 /// <param name="index"></param>
 public Container(IHtmlEditor editor, EdxNode p, string sTemp, string sPath, string sOptions, int index) : base(editor, p, sTemp, sPath, sOptions, index)
 {
     // init class vars
     this.bEmpty  = true;
     this.edxnode = p;
 }
コード例 #12
0
ファイル: Region.cs プロジェクト: polytronicgr/netrix
        /// <summary>
        /// Creates region's XHTML.
        /// </summary>
        /// <param name="oFrag"></param>
        /// <returns></returns>
        public override XmlNode XHTML(XmlNode oFrag)
        {
            XmlNode oHtml;

            View v = EdxDocument.GetEdxDocument.GetView();

            // find our edit node
            XmlNode editnode = GetXmlNode();

            // see if we're display-linked to an attribute
            if (this.displayLink != null)
            {
                XmlNode n = editnode.SelectSingleNode("@" + displayLink);
                if (n != null)
                {
                    viewState       = n.Value;
                    displayLinkNode = n;
                    root.WatchChanges(n, this);
                }
            }
            XmlNode templateNode = GetTemplate();

            // reached root
            if (templateNode == null)
            {
                return(null);
            }
            //
            if (viewState == null)
            {
                if (templateNode != null)
                {
                    viewState = v.GetTemplateDefaultDisplayName(templateNode);
                }
            }
            oHtml = v.GetTemplateHtmlByName(templateNode, viewState);
            if (oHtml == null)
            {
                Util.Err("Error: no HTML template for " + viewState);
                return(null);
            }

            // clone the template node
            XmlNode oXml = oHtml.CloneNode(true);

            // find the children
            XmlNodeList children = oXml.SelectNodes("//*[@edxtemplate != '']");

            // loop through all children which represent EdxNodes
            foreach (XmlNode child in children)
            {
                string  sTemplate = Util.GetXmlAttribute(child, "edxtemplate");
                string  sPath     = Util.GetXmlAttribute(child, "edxpath");
                string  sOptions  = Util.GetXmlAttribute(child, "edxoptions");
                EdxNode obj       = null;
                // look for multiple elements
                if (sPath == null)
                {
                    // probably a widget
                    obj = Factory(editor, sTemplate, sPath, sOptions, -1);
                    // associate the edx with the working xml data object
                    obj.Associate(hobj, child);
                    obj.XHTML(child);
                }
                else
                {
                    XmlNodeList multiNodes = hobj.SelectNodes(sPath, EdxDocument.GetEdxDocument.XmlnsFrag);
                    foreach (XmlNode hobjSub in multiNodes)
                    {
                        obj = Factory(editor, sTemplate, sPath, sOptions, -1);
                        // associate the edx with the working xml data object
                        obj.Associate(hobjSub, child);
                        obj.XHTML(child);
                    }
                }
            }

            // if parent provided, append children
            if (oFrag != null && oXml != null && oFrag.OwnerDocument != null)
            {
                for (int i = 0; i < oXml.ChildNodes.Count; i++)
                {
                    XmlNode oTmp = oXml.ChildNodes[i].CloneNode(true);
                    oFrag.AppendChild(oTmp);
                }
            }

            // done, return the XML fragment
            return(oXml);
        }