Sunday 18 November 2012

web editor in windows form


        private void frmPrdouctVariant_Load(object sender, EventArgs e)
        {
            _objMdiMalta = (mdiAMalta)this.MdiParent;

            ClearProductDetails();
            wbFullDescription.Navigate(Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", string.Empty) + "\\tinymce\\examples\\HtmlEditor.html");

        }
        public string HtmlFullDescription
        {
            get
            {
                string content = string.Empty;
                if (wbFullDescription.Document != null)
                {
                    object html = wbFullDescription.Document.InvokeScript("GetContent");
                    content = html as string;
                }
                return content;
            }
            set
            {
                if (wbFullDescription.Document != null)
                {
                    wbFullDescription.Document.InvokeScript("SetContent", new object[] { value });
                    // wbFullDescription.DocumentText = wbFullDescription.DocumentText.Replace("@@content@@", value);
                }
            }
        }

      public void CreateHtmlEditor(String strContent)
        {
            // String strFilePath = AppDomain.CurrentDomain.BaseDirectory + "tinymce\\examples\\index.html";
            String strBasePath = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", string.Empty);
            String strFilePath = strBasePath + "\\tinymce\\examples\\index.html";
            if (File.Exists(strFilePath))
            {
                String strFileContent = File.ReadAllText(strFilePath);

                strFileContent = strFileContent.Replace("@@content@@", strContent);
                if (File.Exists(strBasePath + "\\tinymce\\examples\\HtmlEditor.html"))
                {
                    File.Delete(strBasePath + "\\tinymce\\examples\\HtmlEditor.html");
                }
                File.WriteAllText(strBasePath + "\\tinymce\\examples\\HtmlEditor.html", strFileContent);
            }
        }

No comments:

Post a Comment