GetText() 공개 메소드

public GetText ( ) : string
리턴 string
        /// <summary>
        /// Get the file path from a drag & drop operation info.
        /// Return null if it was not possibile to retrieve a file path (for instance 
        /// if the data format is not handled).
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string GetFilePath(this DragDropInfo info)
        {
            var data = new DataObject(info.Data);

            if (info.Data.GetDataPresent("FileDrop"))
            {
                // The drag and drop operation came from the file system
                var files = data.GetFileDropList();

                if (files != null && files.Count == 1)
                    return files[0];
            }
            else if (info.Data.GetDataPresent("CF_VSSTGPROJECTITEMS"))
                return data.GetText(); // The drag and drop operation came from the VS solution explorer
            else if (info.Data.GetDataPresent("MultiURL"))
                return data.GetText();

            return null;
        }
예제 #2
0
        public static string GetImageFilename(DragDropInfo info)
        {
            DataObject data = new DataObject(info.Data);

            if (info.Data.GetDataPresent("FileDrop"))
            {
                // The drag and drop operation came from the file system
                StringCollection files = data.GetFileDropList();

                if (files != null && files.Count == 1)
                {
                    return files[0];
                }
            }
            else if (info.Data.GetDataPresent("CF_VSSTGPROJECTITEMS"))
            {
                // The drag and drop operation came from the VS solution explorer
                return data.GetText();
            }

            return null;
        }
예제 #3
0
		public void TestText ()
		{
			DataObject d = new DataObject ();

			d.SetText ("yo");

			Assert.AreEqual (false, d.ContainsAudio (), "A1");
			Assert.AreEqual (false, d.ContainsFileDropList (), "A2");
			Assert.AreEqual (false, d.ContainsImage (), "A3");
			Assert.AreEqual (true, d.ContainsText (), "A4");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A5");

			Assert.AreEqual ("yo", d.GetText (), "A6");
			Assert.AreEqual ("yo", d.GetData (DataFormats.StringFormat), "A6-1");
			
			d.SetText ("<html></html>", TextDataFormat.Html);
			Assert.AreEqual (true, d.ContainsText (), "A7");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A8");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Html), "A9");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.Rtf), "A10");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Text), "A11");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.UnicodeText), "A12");

			// directly put a string
			d.SetData ("yo");

			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Text), "A13");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.UnicodeText), "A14");

			Assert.AreEqual ("yo", d.GetData (DataFormats.StringFormat), "A15");
			Assert.AreEqual ("yo", d.GetData (DataFormats.Text), "A16");
			Assert.AreEqual ("yo", d.GetData (DataFormats.UnicodeText), "A17");
		}
예제 #4
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;
        }
예제 #5
0
        public bool LoadDataObject(object Src)
        {
            try
            {
                DataObject d = new DataObject(Src);

                if (d.ContainsImage())
                {
                    if (LoadImage(d.GetImage()))
                        return true;
                }

                if (d.ContainsFileDropList())
                {
                    foreach (string FName in d.GetFileDropList())
                    {
                        try
                        {
                            if (LoadImage(FName))
                                return true;

                        }
                        catch
                        {
                        }
                    }
                }

                if (d.ContainsText())
                {
                    string FName = d.GetText().Trim();

                    if ((FName.IndexOf("http://") == 0) ||
                        (FName.IndexOf("https://") == 0))
                    {
                        if (LoadImageFromUrl(FName))
                            return true;

                    }
                    else
                    {
                        if (File.Exists(FName))
                        {
                            if (LoadImage(FName))
                                return true;
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());

            }
            return false;
        }
예제 #6
0
 void m_docelemevents_elemondragend(object sender, csExWB.HTMLElementEventArgs e)
 {
     /*
      * 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 ((e.EventObj != null) && (e.EventObj.SrcElement != null))
     {
         IHTMLEventObj2 eveobj2 = e.EventObj 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");
 }