Ejemplo n.º 1
0
        UnPackAsync(BrowserForm form)
        {
            string S;

            pForm = form;

            S = await form.ExecJSAsync($"(function() {{ return document.styleSheets[{parentIndex}].cssRules[{index}].cssText}})();");

            cssText = S;
            S       = await form.ExecJSAsync($"(function() {{ return document.styleSheets[{parentIndex}].cssRules[{index}].selectorText}})();");

            selectorText = S;
        }
Ejemplo n.º 2
0
        internal async Task ExecuteAsync(BrowserForm pForm)
        {
            string CMD = $"document.styleSheets[{Rule.parentIndex}].cssRules[{Rule.index}].style.";

            CMD += Edit;
            Debug.Print(CMD);
            string S = await pForm.ExecJSAsync(CMD);

            Debug.Print(S);
        }
Ejemplo n.º 3
0
        public async void UnPackAsync(BrowserForm form)
        {
            int    NumStyles = 0;
            string S;

            S = await form.ExecJSAsync($"(function() {{ return document.styleSheets[{index}].cssRules.length}})();");

            NumStyles = Int32.Parse(S);
            if (NumStyles > 0)
            {
                S = await form.ExecJSAsync($"(function() {{ return document.styleSheets[{index}].href}})();");

                href     = S;
                cssRules = new StyleSheetRule[NumStyles];
                Debug.Print(S);
                for (int j = 0; j < NumStyles; j++)
                {
                    cssRules[j] = new StyleSheetRule(index, j);
                    await cssRules[j].UnPackAsync(form);
                }
            }
        }
Ejemplo n.º 4
0
        private async void LoadCssTimer_TickAsync(object sender, EventArgs e)
        {
            if (jsHandler.Click)
            {
                // User has clicked on an element in the browser, so handler class is signalling us
                int X = jsHandler.X;
                int Y = jsHandler.Y;
                jsHandler.Click = false;

                StylesList.Items.Clear();
                Debug.Print($"Click at ({jsHandler.X},{jsHandler.Y})");

                string S = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y}).length }})();");

                string N;
                string ClassNames;
                int    NumElements = Int32.Parse(S);
                for (int i = 0; i < NumElements; i++)
                {
                    //                    S = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y})[{i}].attributes }})();");
                    N = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y})[{i}].nodeName }})();");

                    ClassNames = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y})[{i}].className }})();");

                    bool bFoundOne = false;
                    foreach (string ClassName in ClassNames.Split(' '))
                    {
                        foreach (StyleSheet SS in browserForm.StyleSheets)
                        {
                            if (!(SS.cssRules is null))
                            {
                                StyleSheetRule SSR = SS.FindRuleByClass(ClassName);
                                if (!(SSR is null))
                                {
                                    StylesList.Items.Add(SSR);
                                    bFoundOne = true;
                                }
                            }
                        }
                    }
                    if (!bFoundOne)
                    {
                        StylesList.Items.Add($"[{i}]<{N}> {ClassNames}");
                    }

                    //            var x = event.clientX, y = event.clientY,
                    //    elementMouseIsOver = document.elementsFromPoint(x, y);

                    /*
                     * if (! (browserForm is null))
                     * {
                     *  if (browserForm.unPacked)
                     *  {
                     *      loadCssTimer.Enabled = false;
                     *      listBox1.Items.Clear();
                     *
                     *      foreach(StyleSheet S in browserForm.StyleSheets)
                     *      {
                     *          if (!(S.cssRules is null))
                     *          {
                     *              foreach (StyleSheetRule SSR in S.cssRules)
                     *              {
                     *                  if (!(SSR.selectorText is null))
                     *                      listBox1.Items.Add("" + S.index + "," + SSR.index + "," + SSR.selectorText);
                     *              }
                     *          }
                     *      } */
                }
            }
        }