コード例 #1
0
 private void AddImageFromControl(Control ctrl)
 {
     try
     {
         ctrl.Refresh();
         System.Threading.Thread.Sleep(100);
         Bitmap bmp = CScreenCopieur.GetWindowImage(ctrl);
         CHelpExtender.FaireClignoterControl(m_help.Controle);
         string strFichier = "C:\\TMP.BMP";
         bmp.Save(strFichier);
         CResultAErreur result = CHelpData.SourceAide.ReferenceFichier(strFichier, m_help);
         if (!result)
         {
             CFormAlerte.Afficher(result.Erreur.ToString(), EFormAlerteType.Erreur);
             return;
         }
         CRessourceFichier ressource = (CRessourceFichier)result.Data;
         m_listeRessourcesFichier.Add(ressource);
         string strImage = "<img src='File://" + ressource.NomFichierLocal + "'/>";
         m_htmlEditor.InsertHtml(strImage);
     }
     catch
     {
         CFormAlerte.Afficher(I.T("Error while adding an image|30016"), EFormAlerteType.Erreur);
     }
 }
コード例 #2
0
        /// <summary>
        /// Convertit les liens fichiers vers des liens image
        /// </summary>
        private string ConvertImagesFilesToRes()
        {
            string strBody = m_htmlEditor.BodyHtml;

            string[]  strImages     = m_htmlEditor.ImageSrcs;
            Hashtable tableFichiers = new Hashtable();

            foreach (CRessourceFichier ressource in m_listeRessourcesFichier)
            {
                tableFichiers[ressource.NomFichierLocal.ToUpper().Replace('\\', '/')] = ressource;
            }
            foreach (string strImage in strImages)
            {
                if (strImage.Length > 7 && strImage.Substring(0, 7).ToUpper() == "FILE://")
                {
                    string strFile = strImage.Substring(7).ToUpper();
                    while (strFile.Length > 0 && strFile[0] == '/')
                    {
                        strFile = strFile.Substring(1);
                    }
                    CRessourceFichier ressource = (CRessourceFichier)tableFichiers[strFile];
                    if (ressource != null)
                    {
                        strBody = strBody.Replace(strImage, "RES://" + ressource.Cle);
                    }
                }
            }
            return(strBody);
        }
コード例 #3
0
        //-------------------------------------------------------------------
        /// <summary>
        /// Convertit les liens images vers de ressources en liens vers de fichiers locaux
        /// </summary>
        private void ConvertImagesResToFiles( )
        {
            LibereRessourceFichierLocales();
            string strBody = m_htmlEditor.BodyHtml;

            string[] strImages = m_htmlEditor.ImageSrcs;
            foreach (string strImage in strImages)
            {
                if (strImage.Length > 6 && strImage.Substring(0, 6).ToUpper() == "RES://")
                {
                    string            strRes    = strImage.Substring(6);
                    CRessourceFichier ressource = CHelpData.SourceAide.GetRessourceFichier(strRes);
                    if (ressource != null)
                    {
                        strBody = strBody.Replace(strImage, "file://" + ressource.NomFichierLocal.Replace("\\", "/"));
                        m_listeRessourcesFichier.Add(ressource);
                    }
                }
            }
            m_htmlEditor.BodyHtml = strBody;
        }
コード例 #4
0
        //-------------------------------------------------------------
        private void m_btnAddImage_Click(object sender, EventArgs e)
        {
            FileDialog dlg = new OpenFileDialog();

            dlg.Filter = I.T("All images|*.jpg;*.bmp;*.gif;*.tif;*.ico|Bitmap|*.bmp|Jpeg|*.jpg;*.jpeg|Gif|*.gif|Tif|*.tif|Icon|*.ico|All files|*.*|30233");
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(dlg.FileName))
                {
                    CResultAErreur result = CHelpData.SourceAide.ReferenceFichier(dlg.FileName, m_help);
                    if (!result)
                    {
                        CFormAlerte.Afficher(result.Erreur.ToString(), EFormAlerteType.Erreur);
                        return;
                    }
                    CRessourceFichier ressource = (CRessourceFichier)result.Data;
                    m_listeRessourcesFichier.Add(ressource);
                    string strImage = "<img src='File://" + ressource.NomFichierLocal + "'/>";
                    m_htmlEditor.InsertHtml(strImage);
                }
            }
        }
コード例 #5
0
ファイル: WebViewerEx.cs プロジェクト: ykebaili/Timos
        //-----------------------------------------
        private void WebViewerEx_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            HtmlDocument          document = Document;
            HtmlElementCollection images   = document.Images;

            foreach (HtmlElement image in images)
            {
                string strImage = image.GetAttribute("src");
                if (strImage.Length > 6 && strImage.Substring(0, 6).ToUpper() == "RES://")
                {
                    string strRessource = strImage.Substring(6);
                    if (strRessource.Length > 0 && strRessource[strRessource.Length - 1] == '/')
                    {
                        strRessource = strRessource.Substring(0, strRessource.Length - 1);
                    }
                    CRessourceFichier ressource = CHelpData.SourceAide.GetRessourceFichier(strRessource);
                    if (ressource != null)
                    {
                        image.SetAttribute("src", ressource.NomFichierLocal);
                    }
                }
            }
        }
コード例 #6
0
 //-------------------------------------------
 public void LibereRessourceFichierLocale(CRessourceFichier ressource)
 {
     //Ne fait rien, car les ressources locales sont les mêmes que les ressource de l'aide !
 }