public void PasteElement(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
 {
     if (copycheck)
     {
         var    clipboarddata = System.Windows.Clipboard.GetText();
         IFrame frame         = MainWindowBrowser.GetMainFrame();
         frame.ExecuteJavaScriptAsync(String.Format("pasteAllElements(`{0}`)", clipboarddata));
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Please select an element to paste", "Element Selection Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
        public void DeleteElement(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
        {
            IFrame deleteFrame = MainWindowBrowser.GetMainFrame();

            deleteFrame.ExecuteJavaScriptAsync("deleteAllElements()");
        }
        public void SelectAllElements(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
        {
            IFrame selectFrame = MainWindowBrowser.GetMainFrame();

            selectFrame.ExecuteJavaScriptAsync("selectAllElements()");
        }
        public void CopyElement(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
        {
            IFrame copyFrame = MainWindowBrowser.GetMainFrame();

            copyFrame.ExecuteJavaScriptAsync("copyAllElements()");
        }
Esempio n. 5
0
        public void OpenProject(winForms.RichTextBox htmlTextBox, winForms.RichTextBox csstextBox, MenuItem SaveProject, CefSharp.Wpf.ChromiumWebBrowser mwb)
        {
            if (SaveProject.IsEnabled == true)
            {
                MessageBoxResult msgBoxRes = MessageBox.Show("Do you want to save content or not?", "Save File", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (msgBoxRes == MessageBoxResult.Yes)
                {
                    Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
                    sfd.DefaultExt = ".html";
                    sfd.Filter     = "HTML File (.html)|*.html";
                    if (sfd.ShowDialog() == true && sfd.FileName.Length > 0)
                    {
                        File.WriteAllText(sfd.FileName, htmlTextBox.Text);
                        savepath = sfd.FileName.ToString();
                        save     = true;
                    }

                    //Open the respective css file
                    sfd.DefaultExt = ".css";
                    sfd.Filter     = "CSS File (.css)|*.css";
                    if (sfd.ShowDialog() == true && sfd.FileName.Length > 0)
                    {
                        File.WriteAllText(sfd.FileName, csstextBox.Text);
                        csssavepath = sfd.FileName.ToString();
                        save        = true;
                    }
                }
            }
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.DefaultExt = ".html";
            ofd.Filter     = "HTML File (.html)|*.html|ALL Files (.)|*.*";
            if (ofd.ShowDialog() == true && ofd.CheckFileExists)
            {
                StreamReader sr1 = new StreamReader(ofd.FileName, Encoding.Default);
                htmlTextBox.Text = sr1.ReadToEnd();
                save             = true;
                savepath         = ofd.FileName.ToString();
            }

            ofd.Title      = "Open CSS file";
            ofd.DefaultExt = ".css";
            ofd.Filter     = "CSS File (.css)|*.css|ALL Files (.)|*.*";
            if (ofd.ShowDialog() == true && ofd.CheckFileExists)
            {
                StreamReader sr1 = new StreamReader(ofd.FileName, Encoding.Default);
                csstextBox.Text = sr1.ReadToEnd();
                save            = true;
                csssavepath     = ofd.FileName.ToString();
            }


            //validation
            //stop single line grammercheck firing
            MainWindow.htmlfire = false;
            MainWindow.fire     = false;
            //creating objects to simulate validation
            htmltextBoxClass htb = new htmltextBoxClass();
            csstextBoxClass  ctb = new csstextBoxClass();


            //Overriding Paste Functionality
            //Showing busy work with mouse
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            try
            {
                htb.ValidateTags(htmlTextBox);
                ctb.clipboardGrammerCheck(csstextBox);

                this.mw.Dispatcher.Invoke(() =>
                {
                    Regex singlelinepattern = new Regex(@"\s*?(\r\n|\n|\r)\s*");
                    String htmlH            = htmlTextBox.Text;
                    String singleLineString = singlelinepattern.Replace(htmlH, "");
                    //winForms.MessageBox.Show(singleLineString);
                    IFrame frame = mwb.GetMainFrame();
                    frame.ExecuteJavaScriptAsync(String.Format("testFunc(`{0}`)", htmlH));
                });
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
            MainWindow.htmlfire = true;
            MainWindow.fire     = true;


            SaveProject.IsEnabled = false;
            save = true;
        }
Esempio n. 6
0
        private void updateCSSstring(winForms.RichTextBox cssTextBox, String idname, String propertyName, string propertyValue)
        {
            //check if element selected
            if (DragnDrop.idHolder.Equals("noidsfound"))
            {
                winForms.MessageBox.Show("Please select an element to change css!", "Element Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                String Line = "";
                propertyName = propertyName + ":";
                int length = cssTextBox.Text.Length;
                int index  = 0;
                int found  = -1;
                found = cssTextBox.Find("#" + idname, index, length, winForms.RichTextBoxFinds.WholeWord);
                int startLine = cssTextBox.GetLineFromCharIndex(found);

                index = cssTextBox.Text.IndexOf("#" + idname, index) + 1;


                if (found == -1)
                {
                    cssTextBox.Text += "\n#" + idname + "{\n\t" + propertyName + " " + propertyValue + ";\n}";
                }
                if (found != -1)
                {
                    int endLine = cssTextBox.GetLineFromCharIndex(cssTextBox.Find("}", found, length, winForms.RichTextBoxFinds.MatchCase));

                    //Finding is current style exists
                    String lineText      = "";
                    bool   propertyFound = false;
                    for (int i = startLine; i < endLine; i++)
                    {
                        lineText = cssTextBox.Lines[i];

                        if (propertyName.Equals("color:") && (lineText.Contains("border-color") || lineText.Contains("background-color")))
                        {
                            continue;
                        }
                        else if (lineText.Contains(propertyName))
                        {
                            propertyFound = true;

                            //replacing number in between
                            String startMarker = propertyName;
                            String endMarker   = ";";

                            /*Regex x = new Regex("("+startMarker+")(.*?)("+endMarker+")");
                             * string repl = paddingvalue+"";
                             * string Result = x.Replace(lineText, "$1" + repl + "$3");*/


                            int    start  = lineText.IndexOf(startMarker) + startMarker.Length;
                            int    end    = lineText.IndexOf(endMarker);
                            string result = lineText.Substring(start, end - start);
                            lineText = lineText.Replace(result, " " + propertyValue);

                            changeLine(cssTextBox, i, lineText);
                            break;
                        }
                    }

                    //if property not found then add a new line and add property
                    if (!propertyFound)
                    {
                        String propertyname = propertyName;
                        changeLine(cssTextBox, endLine - 1, cssTextBox.Lines[endLine - 1] + "\n\t" + propertyname + " " + propertyValue + ";");
                    }
                }
                Line = idname + " " + propertyName + " " + propertyValue;
                IFrame cssStringFrame = mwb.GetMainFrame();
                cssStringFrame.ExecuteJavaScriptAsync(String.Format("cssStringFunc(`{0}`)", Line));
            }
        }