public void ResetParameters(HTMLEventType EventType, HTMLEventDispIds DispID, IHTMLEventObj pEvtObj)
 {
     this.Cancel = false;
     this.m_EventDispId = DispID;
     m_pEvtObj = pEvtObj;
     m_EventType = EventType;
 }
示例#2
0
 public void ResetParameters(HTMLEventType EventType, HTMLEventDispIds DispID, IHTMLEventObj pEvtObj)
 {
     this.Cancel        = false;
     this.m_EventDispId = DispID;
     m_pEvtObj          = pEvtObj;
     m_EventType        = EventType;
 }
示例#3
0
        bool IHTMLEventCallBack.HandleHTMLEvent(HTMLEventType EventType, HTMLEventDispIds EventDispId, IHTMLEventObj pEvtObj)
        {
            bool bret = true; //always allow bubbling of events

            try
            {
                if ((EventType == HTMLEventType.HTMLWindowEvent) &&
                    (EventDispId == HTMLEventDispIds.ID_ONUNLOAD))
                {
                    m_elemEvents.DisconnectHtmlEvents();
                    m_winEvents.DisconnectHtmlEvents();
                    this.richTextBox1.AppendText("\r\nWindow Closed!");
                }
                else if (EventType == HTMLEventType.HTMLElementEvent)
                {
                    if ((EventDispId == HTMLEventDispIds.ID_ONCLICK) ||
                        (EventDispId == HTMLEventDispIds.ID_ONKEYUP))
                    {
                        if ((pEvtObj != null) && (pEvtObj.SrcElement != null))
                        {
                            this.richTextBox1.AppendText("\r\nHTML_Document_Event==>tagName =" + pEvtObj.SrcElement.tagName);
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                this.richTextBox1.AppendText("frmHTMLDialogHandler_HandleHTMLEvent\r\n" + ee.ToString());
            }
            return(bret);
        }
 bool IHTMLEventCallBack.HandleHTMLEvent(HTMLEventType EventType, HTMLEventDispIds EventDispId, IHTMLEventObj pEvtObj)
 {
     bool bret = true; //always allow default processing
     if (HTMLEvent != null)
     {
         HtmlEventArg.ResetParameters(EventType, EventDispId, pEvtObj);
         HTMLEvent(this, HtmlEventArg);
         //Not all events are cancellable
         if (HtmlEventArg.Cancel)
             bret = false;
         HtmlEventArg.ResetParameters(HTMLEventType.HTMLEventNone, 0, null);
     }
     return bret;
 }
 public void DeactivateHTMLEvents(HTMLEventType EventType)
 {
     m_WantHTMLEvents = false;
     if (EventType == HTMLEventType.HTMLDocumentEvent)
     {
         m_WantHtmlDocumentEvents = false;
         m_TopLevelHtmlDocumentevents.DisconnectHtmlEvents();
         DisconnectHtmlDocumentEvents();
     }
     else
     {
         m_WantHtmlWindowEvents = false;
         m_TopLevelHtmlWindowEvents.DisconnectHtmlEvents();
         DisconnectHtmlWindowEvnets();
     }
 }
 //For now, only HtmlDocumentEvents and HtmlWindowEvents2 are supported
 public void ActivateHTMLEvents(HTMLEventType EventType, int[] HTMLEventDispIds)
 {
     if (EventType == HTMLEventType.HTMLDocumentEvent)
     {
         m_TopLevelHtmlDocumentevents.InitHTMLEvents(this, HTMLEventDispIds, Iid_Clsids.DIID_HTMLDocumentEvents2);
         m_WantHtmlDocumentEvents = true;
     }
     else if (EventType == HTMLEventType.HTMLWindowEvent)
     {
         m_TopLevelHtmlWindowEvents.InitHTMLEvents(this, HTMLEventDispIds, Iid_Clsids.DIID_HTMLWindowEvents2);
         m_WantHtmlWindowEvents = true;
     }
     else
         return;
     m_WantHTMLEvents = true;
 }
示例#7
0
        bool IHTMLEventCallBack.HandleHTMLEvent(HTMLEventType EventType, HTMLEventDispIds EventDispId, IHTMLEventObj pEvtObj)
        {
            bool bret = true; //always allow bubbling of events except for contextmenu

            if ((EventDispId == HTMLEventDispIds.ID_ONCLICK) ||
                (EventDispId == HTMLEventDispIds.ID_ONKEYUP))
            {
                checkObjectType(pEvtObj);


                resizeLayout(pEvtObj);

                SynchEditButtons();
                if ((pEvtObj != null) && (pEvtObj.SrcElement != null))
                    SynchFont(pEvtObj.SrcElement.tagName);
                else
                    SynchFont(string.Empty); 
                //if ((pEvtObj != null) && (pEvtObj.SrcElement != null))
                //    AllForms.m_frmLog.AppendToLog("HTMLEvent==>pEvtObj.SrcElement.tagName\r\n" + pEvtObj.SrcElement.tagName);
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONCONTEXTMENU)
            {
                bret = false;
                editLinkToolStripMenuItem.Visible = false;
                undoLinkToolStripMenuItem.Visible = false;
                deleteLinkToolStripMenuItem.Visible = false;
                editImageToolStripMenuItem.Visible = false;
                deleteImageToolStripMenuItem.Visible = false;
                editRadioPropertiesToolStripMenuItem.Visible = false;
                editCheckboxPropertiesToolStripMenuItem.Visible = false;
                editTablePropertiesToolStripMenuItem.Visible = false;
                editDatalinkPropertiesToolStripMenuItem.Visible = false;
                editMaplinkPropertiesToolStripMenuItem.Visible = false;
                insertColToolStripMenuItem.Visible = false;
                insertRowToolStripMenuItem.Visible = false;
                deleteRowToolStripMenuItem.Visible = false;
                deleteColToolStripMenuItem.Visible = false;
                editCellPropertiesToolStripMenuItem.Visible = false;

                m_oHTMLCtxMenu = null;

                if (pEvtObj != null)
                {
                    if (pEvtObj.SrcElement != null)
                    {
                        m_oHTMLCtxMenu = pEvtObj.SrcElement;
                        //AllForms.m_frmLog.AppendToLog("HTMLEvent==>epEvtObj.SrcElement.tagName\r\n" + e.m_pEvtObj.SrcElement.tagName);
                        if (pEvtObj.SrcElement.tagName == "A")
                        {
                            editLinkToolStripMenuItem.Visible = true;
                            undoLinkToolStripMenuItem.Visible = true;
                            deleteLinkToolStripMenuItem.Visible = true;
                        }
                        else if (pEvtObj.SrcElement.tagName == "IMG")
                        {
                            editImageToolStripMenuItem.Visible = true;
                            deleteImageToolStripMenuItem.Visible = true;
                        }
                        else if ((pEvtObj.SrcElement.tagName == "TD"))
                        //|| (pEvtObj.SrcElement.tagName == "TABLE"))
                        {
                            editTablePropertiesToolStripMenuItem.Visible = true;
                            insertColToolStripMenuItem.Visible = true;
                            insertRowToolStripMenuItem.Visible = true;
                            deleteRowToolStripMenuItem.Visible = true;
                            deleteColToolStripMenuItem.Visible = true;
                            editCellPropertiesToolStripMenuItem.Visible = true;
                        }
                        else if ((pEvtObj.SrcElement.tagName == "INPUT"))
                        //|| (pEvtObj.SrcElement.tagName == "TABLE"))
                        {

                            //editRadioPropertiesToolStripMenuItem.Visible = true;
                            //editCheckboxPropertiesToolStripMenuItem.Visible = true;
                            string mapKeyName = string.Empty;
                            try
                            {
                                if (pEvtObj.SrcElement.getAttribute("type", 0) != null && !string.IsNullOrEmpty((String)pEvtObj.SrcElement.getAttribute("type", 0)))
                                {
                                    mapKeyName = (String)pEvtObj.SrcElement.getAttribute("type", 0);
                                    if (mapKeyName.Equals("radio"))
                                        editRadioPropertiesToolStripMenuItem.Visible = true;
                                    else if (mapKeyName.Equals("checkbox"))
                                        editCheckboxPropertiesToolStripMenuItem.Visible = true;
                                }
                            }
                            catch (Exception e)
                            {
                                System.Console.Write(e.ToString());
                            }

                        }
                        else if ((pEvtObj.SrcElement.tagName == "DIV"))
                        {
                            //editDatalinkPropertiesToolStripMenuItem.Visible = true;
                            //editMaplinkPropertiesToolStripMenuItem.Visible = true;
                            string mapKeyName = string.Empty;
                            try
                            {
                                if (pEvtObj.SrcElement.getAttribute("mapKeyName", 0) != null && !string.IsNullOrEmpty((String)pEvtObj.SrcElement.getAttribute("mapKeyName", 0)))
                                {
                                    mapKeyName = (String)pEvtObj.SrcElement.getAttribute("mapKeyName", 0);
                                    if (!string.IsNullOrEmpty(mapKeyName))
                                        editDatalinkPropertiesToolStripMenuItem.Visible = true;
                                }
                            }
                            catch (Exception e)
                            {
                                System.Console.Write(e.ToString());
                            }
                            try
                            {
                                string mapSourceId = string.Empty;
                                if (pEvtObj.SrcElement.getAttribute("mapSourceId", 0) != null && !string.IsNullOrEmpty((String)pEvtObj.SrcElement.getAttribute("mapSourceId", 0)))
                                {
                                    mapSourceId = (String)pEvtObj.SrcElement.getAttribute("mapSourceId", 0);
                                    if (!string.IsNullOrEmpty(mapSourceId))
                                        editMaplinkPropertiesToolStripMenuItem.Visible = true;
                                }
                            }
                            catch (Exception e)
                            {
                                System.Console.Write(e.ToString());
                            }
                            

                        }
                        //else if ((pEvtObj.SrcElement.tagName == "P") ||
                        //        (pEvtObj.SrcElement.tagName == "BODY"))
                        //{
                        //}
                    }
                    ctxMnuHTMLEditor.Show(pEvtObj.ScreenX, pEvtObj.ScreenY);
                }
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAG) //fires
            {
                AllForms.m_frmLog.AppendToLog("ID_ONDRAG");
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAGSTART) //fires
            {
                //this is the element that started the drag
                if ((pEvtObj != null) && (pEvtObj.SrcElement != null) ) 
                    AllForms.m_frmLog.AppendToLog("HTMLEvent_ONDRAGSTART==>pEvtObj.SrcElement.tagName\r\n" + pEvtObj.SrcElement.tagName);
                else
                    AllForms.m_frmLog.AppendToLog("ID_ONDRAGSTART");
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAGEND) //fires
            {
                /*
                 * IHTMLEventObj2::dataTransfer
                 * The IHTMLDataTransfer interface retrieved by this method also provides 
                 * access to IDataObject. Call QueryInterface on the IHTMLDataTransfer
                 * interface pointer to obtain an IServiceProvider interface pointer.
                 * Then call IServiceProvider::QueryService, using IID_IDataObject
                 * for the service and interface identifiers, to obtain an IDataObject
                 * interface pointer.
                 * 
                 * IHTMLEventObj2::reason
                 */
                //this is the element which data was dropped on
                
                if ((pEvtObj != null) && (pEvtObj.SrcElement != null))
                {
                    IHTMLEventObj2 eveobj2 = pEvtObj as IHTMLEventObj2;
                    if( (eveobj2 != null) && (eveobj2.dataTransfer != null) )
                    {
                        IfacesEnumsStructsClasses.IServiceProvider pSP = eveobj2.dataTransfer as IfacesEnumsStructsClasses.IServiceProvider;
                        if (pSP != null)
                        {
                            IntPtr pdataobj = IntPtr.Zero;
                            int iret = pSP.QueryService(ref Iid_Clsids.IID_IDataObject, ref Iid_Clsids.IID_IDataObject, out pdataobj);
                            object obj = Marshal.GetObjectForIUnknown(pdataobj);
                            System.Runtime.InteropServices.ComTypes.IDataObject idataobj = obj as System.Runtime.InteropServices.ComTypes.IDataObject;
                            DataObject obja = new DataObject(idataobj);
                            //string[] formats = obja.GetFormats(false);
                            //foreach (string str in formats)
                            //{
                            //    AllForms.m_frmLog.AppendToLog("format ==> " + str);
                            //}
                            AllForms.m_frmLog.AppendToLog("HTMLEvent_ONDRAGEND==> " + obja.GetText(TextDataFormat.Html) );
                        }
                    }
                }
                else
                    AllForms.m_frmLog.AppendToLog("ID_ONDRAGEND");
            }
            //Do not fire
            //else if (EventDispId == HTMLEventDispIds.ID_ONDROP)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDROP");
            //}
            //else if (EventDispId == HTMLEventDispIds.ID_ONDRAGOVER)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDRAGOVER");
            //}
            //else if (EventDispId == HTMLEventDispIds.ID_ONDRAGENTER)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDRAGENTER");
            //}
            //else if (EventDispId == HTMLEventDispIds.ID_ONDRAGLEAVE)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDRAGLEAVE");
            //}

            return bret;
        }
示例#8
0
        bool IHTMLEventCallBack.HandleHTMLEvent(HTMLEventType EventType, HTMLEventDispIds EventDispId, IHTMLEventObj pEvtObj)
        {
            if (_proPanel == null)
            {
                return(false);
            }
            bool          bret    = true;
            IHTMLElement2 element = pEvtObj.SrcElement as IHTMLElement2;

            if ((EventDispId == HTMLEventDispIds.ID_ONMOUSEDOWN))
            {
                #region OnMouseDown
                currentEle = pEvtObj.SrcElement;

                switch (pEvtObj.SrcElement.tagName)
                {
                case "H1":
                case "H2":
                case "H3":
                case "H4":
                case "H5":
                case "H6":
                case "P":
                case "FONT":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel(pEvtObj.SrcElement.tagName));
                    break;
                }

                case "PRE":
                {
                    _proPanel.Controls.Add(AddPanel(pEvtObj.SrcElement.tagName));
                    break;
                }

                case "TD":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("TD"));
                    break;
                }

                case "TABLE":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("TABLE"));
                    break;
                }

                case "IMG":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("IMG"));
                    break;
                }

                case "EMBED":
                case "OBJECT":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("object"));
                    break;
                }

                case "HR":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("HR"));
                    break;
                }

                case "SPAN":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("SPAN"));
                    break;
                }

                case "A":
                {
                    _proPanel.Controls.Add(AddPanel("A"));
                    break;
                }

                case "BODY":
                {
                    phraseb = null;
                    if (_proPanel != null)
                    {
                        _proPanel.Controls.Add(AddPanel("BODY"));
                    }
                } break;
                }
                #endregion
            }
            if ((EventDispId == HTMLEventDispIds.ID_ONCLICK) || (EventDispId == HTMLEventDispIds.ID_ONKEYUP))
            {
                #region OnClick && OnKeyUp
                switch (pEvtObj.SrcElement.tagName)
                {
                case "IMG": break;

                case "OBJECT": break;

                case "TD":    //表格单元格
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("TD"));
                    break;
                }

                case "":
                {
                    _proPanel.Controls.Add(AddPanel(""));
                    break;
                }
                }
                #endregion
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONCONTEXTMENU)
            {
                #region ONContextMenu
                bret = false;

                if (pEvtObj != null)
                {
                    if (pEvtObj.SrcElement != null)
                    {
                        ContextMenuStrip designContextMenuStrip = new DesignPopMenu(pEvtObj.SrcElement.tagName, this);
                        designContextMenuStrip.Show(pEvtObj.ScreenX, pEvtObj.ScreenY);
                    }
                }
                #endregion
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONMOUSEUP)
            {
                switch (pEvtObj.SrcElement.tagName)
                {
                case "BODY":
                {
                    if (_proPanel != null)
                    {
                        _proPanel.Controls.Add(AddPanel("BODY"));        // PropertyPanels.Instance("BODY",m_oHTMLCtxMenu,designWebBrowser,codeTextEditorControl,null,null,null,null));
                    }
                    break;
                }

                case "SPAN":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("SPAN"));
                    break;
                }

                case "A":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("A"));
                    break;
                }

                case "TH":
                case "TD":
                {
                    EleAddBehavior(element);
                    _proPanel.Controls.Add(AddPanel("TD"));
                    break;
                }
                }
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAG)
            {
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAGSTART)
            {
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAGEND)
            {
            }
            return(bret);
        }
 bool IHTMLEventCallBack.HandleHTMLEvent(HTMLEventType EventType, HTMLEventDispIds EventDispId, IHTMLEventObj pEvtObj)
 {
     bool bret = true; //always allow bubbling of events
     try
     {
         if ((EventType == HTMLEventType.HTMLWindowEvent) &&
             (EventDispId == HTMLEventDispIds.ID_ONUNLOAD))
         {
             m_elemEvents.DisconnectHtmlEvents();
             m_winEvents.DisconnectHtmlEvents();
             this.richTextBox1.AppendText("\r\nWindow Closed!");
         }
         else if (EventType == HTMLEventType.HTMLElementEvent)
         {
             if ((EventDispId == HTMLEventDispIds.ID_ONCLICK) ||
                 (EventDispId == HTMLEventDispIds.ID_ONKEYUP))
             {
                 if ((pEvtObj != null) && (pEvtObj.SrcElement != null))
                     this.richTextBox1.AppendText("\r\nHTML_Document_Event==>tagName =" + pEvtObj.SrcElement.tagName);
             }
         }
     }
     catch (Exception ee)
     {
         this.richTextBox1.AppendText("frmHTMLDialogHandler_HandleHTMLEvent\r\n" + ee.ToString());
     }
     return bret;
 }