public void Save()
 {
     try
     {
         if (this.templateElements != null)
         {
             object[] pvars = new object[1];
             for (int i = 0; i < this.templateNames.Length; i++)
             {
                 if (this.templateElements[i] != null)
                 {
                     System.Design.NativeMethods.IHTMLElement element = (System.Design.NativeMethods.IHTMLElement) this.templateElements[i];
                     element.GetAttribute("contentEditable", 0, pvars);
                     if (((pvars[0] != null) && (pvars[0] is string)) && (string.Compare((string)pvars[0], "true", StringComparison.OrdinalIgnoreCase) == 0))
                     {
                         string innerHTML = element.GetInnerHTML();
                         this.owner.SetTemplateContent(this, this.templateNames[i], innerHTML);
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
 private void ReleaseParentElement()
 {
     this.htmlElemParent      = null;
     this.htmlElemFrame       = null;
     this.htmlElemContent     = null;
     this.htmlElemControlName = null;
     this.templateElements    = null;
     this.fVisible            = false;
 }
 public TemplateEditingFrame(TemplatedControlDesigner owner, string frameName, string[] templateNames, Style controlStyle, Style[] templateStyles)
 {
     this.owner = owner;
     this.frameName = frameName;
     this.controlStyle = controlStyle;
     this.templateStyles = templateStyles;
     this.verb = null;
     this.templateNames = (string[]) templateNames.Clone();
     if (owner.BehaviorInternal != null)
     {
         System.Design.NativeMethods.IHTMLElement designTimeElementView = (System.Design.NativeMethods.IHTMLElement) ((IControlDesignerBehavior) owner.BehaviorInternal).DesignTimeElementView;
         this.htmlElemParent = designTimeElementView;
     }
     this.htmlElemControlName = null;
 }
 public TemplateEditingFrame(TemplatedControlDesigner owner, string frameName, string[] templateNames, Style controlStyle, Style[] templateStyles)
 {
     this.owner          = owner;
     this.frameName      = frameName;
     this.controlStyle   = controlStyle;
     this.templateStyles = templateStyles;
     this.verb           = null;
     this.templateNames  = (string[])templateNames.Clone();
     if (owner.BehaviorInternal != null)
     {
         System.Design.NativeMethods.IHTMLElement designTimeElementView = (System.Design.NativeMethods.IHTMLElement)((IControlDesignerBehavior)owner.BehaviorInternal).DesignTimeElementView;
         this.htmlElemParent = designTimeElementView;
     }
     this.htmlElemControlName = null;
 }
 public void Open()
 {
     System.Design.NativeMethods.IHTMLElement designTimeElementView = (System.Design.NativeMethods.IHTMLElement)((IControlDesignerBehavior)this.owner.BehaviorInternal).DesignTimeElementView;
     if (this.htmlElemParent != designTimeElementView)
     {
         this.ReleaseParentElement();
         this.htmlElemParent = designTimeElementView;
     }
     this.Initialize();
     try
     {
         for (int i = 0; i < this.templateNames.Length; i++)
         {
             if (this.templateElements[i] != null)
             {
                 bool allowEditing = true;
                 System.Design.NativeMethods.IHTMLElement element2 = (System.Design.NativeMethods.IHTMLElement) this.templateElements[i];
                 string p = this.owner.GetTemplateContent(this, this.templateNames[i], out allowEditing);
                 element2.SetAttribute("contentEditable", allowEditing, 0);
                 if (p != null)
                 {
                     p = "<body contentEditable=true>" + p + "</body>";
                     element2.SetInnerHTML(p);
                 }
             }
         }
         if (this.htmlElemControlName != null)
         {
             this.htmlElemControlName.SetInnerText(this.owner.Component.Site.Name);
         }
     }
     catch (Exception)
     {
     }
     this.ShowInternal(true);
 }
        public string GetContainingTemplateName(Control control)
        {
            string str = string.Empty;
            HtmlControlDesigner designer = (HtmlControlDesigner)this.designerHost.GetDesigner(control);

            if (designer != null)
            {
                System.Design.NativeMethods.IHTMLElement designTimeElement = (System.Design.NativeMethods.IHTMLElement)designer.BehaviorInternal.DesignTimeElement;
                if (designTimeElement == null)
                {
                    return(str);
                }
                object[] pvars = new object[1];
                for (System.Design.NativeMethods.IHTMLElement element3 = designTimeElement.GetParentElement(); element3 != null; element3 = element3.GetParentElement())
                {
                    element3.GetAttribute("templatename", 0, pvars);
                    if ((pvars[0] != null) && (pvars[0].GetType() == typeof(string)))
                    {
                        return(pvars[0].ToString());
                    }
                }
            }
            return(str);
        }
 private void ReleaseParentElement()
 {
     this.htmlElemParent = null;
     this.htmlElemFrame = null;
     this.htmlElemContent = null;
     this.htmlElemControlName = null;
     this.templateElements = null;
     this.fVisible = false;
 }
 private void Initialize()
 {
     if (this.htmlElemFrame == null)
     {
         try
         {
             object obj2;
             this.htmlElemFrame = this.htmlElemParent.GetDocument().CreateElement("SPAN");
             this.htmlElemFrame.SetInnerHTML(this.Content);
             System.Design.NativeMethods.IHTMLDOMNode htmlElemFrame = (System.Design.NativeMethods.IHTMLDOMNode) this.htmlElemFrame;
             if (htmlElemFrame != null)
             {
                 this.htmlElemContent = (System.Design.NativeMethods.IHTMLElement) htmlElemFrame.GetFirstChild();
             }
             System.Design.NativeMethods.IHTMLElement3 element = (System.Design.NativeMethods.IHTMLElement3) this.htmlElemFrame;
             if (element != null)
             {
                 element.SetContentEditable("false");
             }
             this.templateElements = new object[this.templateNames.Length];
             object index = 0;
             System.Design.NativeMethods.IHTMLElementCollection all = (System.Design.NativeMethods.IHTMLElementCollection) this.htmlElemFrame.GetAll();
             for (int i = 0; i < this.templateNames.Length; i++)
             {
                 try
                 {
                     obj2 = this.templateNames[i];
                     System.Design.NativeMethods.IHTMLElement element2 = all.Item(obj2, index);
                     element2.SetAttribute("templatename", obj2, 0);
                     string p = "<DIV contentEditable=\"true\" style=\"padding:1;height:100%;width:100%\"></DIV>";
                     element2.SetInnerHTML(p);
                     System.Design.NativeMethods.IHTMLDOMNode node2 = (System.Design.NativeMethods.IHTMLDOMNode) element2;
                     if (node2 != null)
                     {
                         this.templateElements[i] = node2.GetFirstChild();
                     }
                 }
                 catch (Exception)
                 {
                     this.templateElements[i] = null;
                 }
             }
             obj2 = "idControlName";
             this.htmlElemControlName = all.Item(obj2, index);
             obj2 = "idFrameName";
             object obj4 = all.Item(obj2, index);
             if (obj4 != null)
             {
                 ((System.Design.NativeMethods.IHTMLElement) obj4).SetInnerText(this.frameName);
             }
             System.Design.NativeMethods.IHTMLDOMNode htmlElemParent = (System.Design.NativeMethods.IHTMLDOMNode) this.htmlElemParent;
             if (htmlElemParent != null)
             {
                 htmlElemParent.AppendChild(htmlElemFrame);
             }
         }
         catch (Exception)
         {
         }
     }
 }
 public void Open()
 {
     System.Design.NativeMethods.IHTMLElement designTimeElementView = (System.Design.NativeMethods.IHTMLElement) ((IControlDesignerBehavior) this.owner.BehaviorInternal).DesignTimeElementView;
     if (this.htmlElemParent != designTimeElementView)
     {
         this.ReleaseParentElement();
         this.htmlElemParent = designTimeElementView;
     }
     this.Initialize();
     try
     {
         for (int i = 0; i < this.templateNames.Length; i++)
         {
             if (this.templateElements[i] != null)
             {
                 bool allowEditing = true;
                 System.Design.NativeMethods.IHTMLElement element2 = (System.Design.NativeMethods.IHTMLElement) this.templateElements[i];
                 string p = this.owner.GetTemplateContent(this, this.templateNames[i], out allowEditing);
                 element2.SetAttribute("contentEditable", allowEditing, 0);
                 if (p != null)
                 {
                     p = "<body contentEditable=true>" + p + "</body>";
                     element2.SetInnerHTML(p);
                 }
             }
         }
         if (this.htmlElemControlName != null)
         {
             this.htmlElemControlName.SetInnerText(this.owner.Component.Site.Name);
         }
     }
     catch (Exception)
     {
     }
     this.ShowInternal(true);
 }
 private void Initialize()
 {
     if (this.htmlElemFrame == null)
     {
         try
         {
             object obj2;
             this.htmlElemFrame = this.htmlElemParent.GetDocument().CreateElement("SPAN");
             this.htmlElemFrame.SetInnerHTML(this.Content);
             System.Design.NativeMethods.IHTMLDOMNode htmlElemFrame = (System.Design.NativeMethods.IHTMLDOMNode) this.htmlElemFrame;
             if (htmlElemFrame != null)
             {
                 this.htmlElemContent = (System.Design.NativeMethods.IHTMLElement)htmlElemFrame.GetFirstChild();
             }
             System.Design.NativeMethods.IHTMLElement3 element = (System.Design.NativeMethods.IHTMLElement3) this.htmlElemFrame;
             if (element != null)
             {
                 element.SetContentEditable("false");
             }
             this.templateElements = new object[this.templateNames.Length];
             object index = 0;
             System.Design.NativeMethods.IHTMLElementCollection all = (System.Design.NativeMethods.IHTMLElementCollection) this.htmlElemFrame.GetAll();
             for (int i = 0; i < this.templateNames.Length; i++)
             {
                 try
                 {
                     obj2 = this.templateNames[i];
                     System.Design.NativeMethods.IHTMLElement element2 = all.Item(obj2, index);
                     element2.SetAttribute("templatename", obj2, 0);
                     string p = "<DIV contentEditable=\"true\" style=\"padding:1;height:100%;width:100%\"></DIV>";
                     element2.SetInnerHTML(p);
                     System.Design.NativeMethods.IHTMLDOMNode node2 = (System.Design.NativeMethods.IHTMLDOMNode)element2;
                     if (node2 != null)
                     {
                         this.templateElements[i] = node2.GetFirstChild();
                     }
                 }
                 catch (Exception)
                 {
                     this.templateElements[i] = null;
                 }
             }
             obj2 = "idControlName";
             this.htmlElemControlName = all.Item(obj2, index);
             obj2 = "idFrameName";
             object obj4 = all.Item(obj2, index);
             if (obj4 != null)
             {
                 ((System.Design.NativeMethods.IHTMLElement)obj4).SetInnerText(this.frameName);
             }
             System.Design.NativeMethods.IHTMLDOMNode htmlElemParent = (System.Design.NativeMethods.IHTMLDOMNode) this.htmlElemParent;
             if (htmlElemParent != null)
             {
                 htmlElemParent.AppendChild(htmlElemFrame);
             }
         }
         catch (Exception)
         {
         }
     }
 }