Exemple #1
0
 public static HTMLElement InvisibleScroll(this HTMLElement element)
 {
     EnableInvisibleScroll(element);
     return(element);
 }
 protected ButtonBase(HTMLElement element) : base(element)
 {
 }
Exemple #3
0
 /// <summary>
 /// Returns the DOM element into which child components are to be rendered,
 /// or null if the container hasn't been rendered yet.
 /// </summary>
 /// <param name="element">Root element of the container whose content element</param>
 ///     is to be returned.
 /// <returns>Element to contain child elements (null if none).</returns>
 public HTMLElement getContentElement(HTMLElement element)
 {
     return(element);
 }
Exemple #4
0
        /// <summary>
        /// width and height - doesn't properly (=slowly) check if element is part of DOM (is attached)
        /// </summary>
        public static Dimensions2D GetOrComputeClientDimensionsOf(this HTMLElement self, HTMLElement ownedBy = null)
        {
            if (self.ClientHeight > 0 || self.ClientWidth > 0)
            {
                return(new Dimensions2D(self.ClientWidth, self.ClientHeight));
            }

            ownedBy = ownedBy ?? self;

            var oldVis = ownedBy.Style.Visibility;
            var oldPos = ownedBy.Style.Position;

            ownedBy.Style.Visibility = Visibility.Hidden;
            ownedBy.Style.Position   = Position.Absolute;

            Document.Body.AppendChild(ownedBy);
            var result = new Dimensions2D(self.ClientWidth, self.ClientHeight);

            Document.Body.RemoveChild(ownedBy);

            ownedBy.Style.Visibility = oldVis;
            ownedBy.Style.Position   = oldPos;

            return(result);
        }
Exemple #5
0
        public Layout(PlotSettings settings)
        {
            var plotter = new TinyPlotter(settings);

            var exprInput = new HTMLInputElement { Type = InputType.Text };
            exprInput.Value = "sin(3x)";

            var evalInput = new HTMLInputElement { Type = InputType.Text };
            evalInput.Value = "plus(5^2, sin(div(pi, 2)))";

            var variableInput = new HTMLInputElement { Type = InputType.Text };
            variableInput.Value = "x";

            var deltaXInput = new HTMLInputElement { Type = InputType.Text };
            deltaXInput.Value = "0.005";

            var xminInput = new HTMLInputElement { Type = InputType.Text };
            xminInput.Value = settings.Viewport.XMin.ToString();

            var xmaxInput = new HTMLInputElement { Type = InputType.Text };
            xmaxInput.Value = settings.Viewport.XMax.ToString();

            var yminInput = new HTMLInputElement { Type = InputType.Text };
            yminInput.Value = settings.Viewport.YMin.ToString();

            var ymaxInput = new HTMLInputElement { Type = InputType.Text };
            ymaxInput.Value = settings.Viewport.YMax.ToString();

            var resultDiv = new HTMLDivElement();
            resultDiv.Style.FontSize = "18px";
            resultDiv.Style.MaxWidth = "300px";

            var btnPlot = new HTMLButtonElement
            {
                InnerHTML = "Plot with derivative",
                OnClick = ev =>
                {
                    Func<HTMLInputElement, bool> IsNaN = x => double.IsNaN(Script.ParseFloat(x.Value));

                    var isNotValid = exprInput.Value == ""
                                  || variableInput.Value == ""
                                  || IsNaN(deltaXInput)
                                  || IsNaN(xminInput)
                                  || IsNaN(xmaxInput)
                                  || IsNaN(yminInput)
                                  || IsNaN(ymaxInput);

                    if (isNotValid)
                    {
                        Write("<h1 style='color:red'>Input is not valid!</h1>", resultDiv);
                        return;
                    }

                    var result = Parser.TryParseInput(exprInput.Value);
                    if (result.WasSuccessful)
                    {
                        // set the settings
                        plotter.Settings.StepX = Script.ParseFloat(deltaXInput.Value);
                        plotter.Settings.Viewport.XMin = Script.ParseFloat(xminInput.Value);
                        plotter.Settings.Viewport.XMax = Script.ParseFloat(xmaxInput.Value);
                        plotter.Settings.Viewport.YMin = Script.ParseFloat(yminInput.Value);
                        plotter.Settings.Viewport.YMax = Script.ParseFloat(ymaxInput.Value);

                        resultDiv.InnerHTML = "";
                        var f = result.Value;
                        var df = Expr.Differentiate(f, variableInput.Value);

                        var fLambda = Expr.Lambdify(f, variableInput.Value);
                        var dfLambda = Expr.Lambdify(df, variableInput.Value);
                        var curveColor = RandomColor();

                        plotter.Settings.Curves.Clear();
                        plotter.Settings.Curves.Add(new Curve { Map = fLambda, Color = curveColor });
                        plotter.Settings.Curves.Add(new Curve { Map = dfLambda, Color = Grayscale(curveColor) });
                        plotter.Draw();

                        var rgbCurveColor = RGB(curveColor);
                        var rgbGrayColor = RGB(Grayscale(curveColor));

                        var msgParsed = "<strong style='color:" + rgbCurveColor + "'>" + f.ToString() + "</strong>";
                        var derivative = "<strong style='color:" + rgbGrayColor + "'>" + df.ToString() + "</strong>";
                        Write("<hr /> Parsed: <br />" + msgParsed + "<br /> Derivative: <br /> " + derivative + "<hr />", resultDiv);
                    }
                    else
                    {
                        var error = string.Join("<br />", result.Expectations);
                        Write("<h1 style='color:red'>" + error + "</h1>", resultDiv);
                    }

                }
            };

            var btnEvaluate = new HTMLButtonElement
            {
                InnerHTML = "Evaluate",
                OnClick = ev =>
                {
                    if (evalInput.Value == "")
                    {
                        Write("<h1 style='color:red'>Input is not valid!</h1>", resultDiv);
                        return;
                    }

                    var result = Parser.TryParseInput(evalInput.Value);
                    if (result.WasSuccessful)
                    {
                        resultDiv.InnerHTML = "";
                        var expression = result.Value;
                        var eval = Expr.Evaluate(expression);

                        Write("<h4 style='color:green'>" +
                                "Parsed: " + expression.ToString() + "<br />" +
                                "Answer: " + eval.ToString()
                            + "</h4>", resultDiv);
                    }
                    else
                    {
                        var error = string.Join("<br />", result.Expectations);
                        Write("<h1 style='color:red'>" + error + "</h1>", resultDiv);
                    }

                }
            };

            var slider = new HTMLInputElement { Type = InputType.Range };

            btnEvaluate.Style.Width = "90%";
            btnEvaluate.Style.Margin = "5px";
            btnEvaluate.Style.Height = "40px";
            btnPlot.Style.Margin = "5px";
            btnPlot.Style.Height = "40px";
            btnPlot.Style.Width = "90%";

            var layout = Table(
                    Row(Table(
                            Row(Label("Expression"), exprInput),
                            Row(Label("Variable"), variableInput),
                            Row(Label("XAxis step"), deltaXInput),
                            Row(Label("XMin"), xminInput),
                            Row(Label("XMax"), xmaxInput),
                            Row(Label("YMin"), yminInput),
                            Row(Label("YMax"), ymaxInput),
                            Row(btnPlot, 2),
                            Row(new HTMLHRElement(), 2),
                            Row(Label("Expression"), evalInput),
                            Row(btnEvaluate, 2),
                            Row(resultDiv, 2)),
                        Table(
                            Row(plotter.Canvas)))
                );

            this.container = layout;
        }
 /// <summary>
 /// Checks the tag exclusion list to see if this click should be ignored ...
 /// </summary>
 public bool isValidHandleChild(HTMLElement node){return false;}
Exemple #7
0
 public void RemoveChild (HTMLElement element)
 {
 }
Exemple #8
0
 public static IView <HTMLElement> AsIview(this HTMLElement self)
 {
     return(new AdaptAsIview(self));
 }
Exemple #9
0
        public static void Main()
        {
            AddJquery(Document.Head);
            AddBootstrap(Document.Head);
            AddHighcharts(Document.Head);
            AddChartsRender(Document.Head);

            var divContainer = new HTMLDivElement()
            {
                ClassName = "container-fluid"
            };

            Document.Body.AppendChild(divContainer);

            AddDivAsRow(divContainer, "medianRatingByCountry");
            AddDivAsRow(divContainer, "countByCountry");
            AddDivAsRow(divContainer, "medianRatingByBrewery");
            AddDivAsRow(divContainer, "countByBrewery");
            AddDivAsRow(divContainer, "medianRatingByStyle");
            AddDivAsRow(divContainer, "countByStyle");
            AddDivAsRow(divContainer, "countByServingType");
            AddDivAsRow(divContainer, "medianRatingByFlavorProfile");
            AddDivAsRow(divContainer, "countByFlavorProfile");
            AddDivAsRow(divContainer, "medianAbvByDayOfWeek");
            divContainer.AppendChild(new HTMLHRElement());
            AddDivAsRow(divContainer, "additionalStats");

            var row = new HTMLDivElement {
                ClassName = "row"
            };

            divContainer.AppendChild(row);
            var col = new HTMLDivElement {
                ClassName = "mx-auto"
            };

            row.AppendChild(col);
            var formGroup = new HTMLDivElement {
                ClassName = "form-group"
            };

            col.AppendChild(formGroup);
            var input = new HTMLInputElement {
                Type = InputType.File, Accept = ".json"
            };

            formGroup.AppendChild(input);
            var small = new HTMLElement("small")
            {
                ClassList = { "form-text", "text-muted" }
            };

            formGroup.AppendChild(small);

            var button = new HTMLButtonElement
            {
                InnerHTML = "Process",
                ClassList = { "btn", "btn-primary" },
                OnClick   = (clickEvent) =>
                {
                    if (input.Files.Length > 0 && input.Files[0] != null)
                    {
                        var reader = new FileReader();
                        reader.OnLoad = loadEvent =>
                        {
                            var rawDataString = reader.Result.ToString();

                            var data = JsonConvert.DeserializeObject <IList <Checkin> >(rawDataString);

                            var dataAnalyzer = new DataAnalyzer();

                            var medianRating = dataAnalyzer.GetMedian(data.Where(c => c.RatingScore.HasValue).Select(c => c.RatingScore.Value));
                            var medianAbv    = dataAnalyzer.GetMedian(data.Where(c => c.BeerAbv.HasValue).Select(c => c.BeerAbv.Value));
                            var medianIbu    = dataAnalyzer.GetMedian(data.Where(c => c.BeerIbu.HasValue).Select(c => c.BeerIbu.Value));

                            var dataByFlavorProfile = data.Aggregate(new List <Checkin>(), (checkins, checkin) =>
                            {
                                if (!string.IsNullOrWhiteSpace(checkin.FlavorProfiles))
                                {
                                    var flavorProfiles = checkin.FlavorProfiles.Split(',');
                                    foreach (var flavorProfile in flavorProfiles)
                                    {
                                        var checkinCopy            = checkin.DeepCopy();
                                        checkinCopy.FlavorProfiles = flavorProfile;
                                        checkins.Add(checkinCopy);
                                    }
                                }
                                return(checkins);
                            });

                            var statsByCountry       = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.BreweryCountry)), checkin => checkin.BreweryCountry, checkin => checkin.RatingScore);
                            var statsByBrewery       = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.BreweryName)), checkin => checkin.BreweryName, checkin => checkin.RatingScore);
                            var statsByStyle         = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.BeerType)), checkin => checkin.BeerType, checkin => checkin.RatingScore);
                            var statsByServingType   = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.ServingType)), checkin => checkin.ServingType, checkin => checkin.RatingScore);
                            var statsByFlavorProfile = dataAnalyzer.GetStatistics(dataByFlavorProfile, checkin => checkin.FlavorProfiles, checkin => checkin.RatingScore);
                            var statsByDayOfWeek     = dataAnalyzer.GetStatistics(data, checkin => checkin.CreatedAt.DayOfWeek, checkin => checkin.BeerAbv);

                            var medianRatingByCountry = statsByCountry.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByCountry        = statsByCountry.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianRatingByBrewery = statsByBrewery.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByBrewery        = statsByBrewery.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianRatingByStyle = statsByStyle.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByStyle        = statsByStyle.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var countByServingType = statsByServingType.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianRatingByFlavorProfile = statsByFlavorProfile.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByFlavorProfile        = statsByFlavorProfile.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianAbvByDayOfWeek = statsByDayOfWeek.OrderBy(item => item.Key).Select(item => new { name = item.Key.ToString(), y = Math.Round(item.Median, 2) }).ToList();
                            var countByDayOfWeek     = statsByDayOfWeek.OrderBy(item => item.Key).Select(item => new { name = item.Key.ToString(), y = item.Count }).ToList();

                            Document.GetElementById("additionalStats").AppendChild(new HTMLParagraphElement()
                            {
                                ClassName = "text-center",
                                InnerHTML = $"<b>{nameof(medianRating)}: {medianRating}, {nameof(medianAbv)}: {medianAbv}, {nameof(medianIbu)}: {medianIbu}</b>",
                            });

                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByCountry), nameof(countByCountry), medianRatingByCountry.ToArray(), countByCountry.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByCountry), countByCountry.ToArray());
                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByBrewery), nameof(countByBrewery), medianRatingByBrewery.ToArray(), countByBrewery.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByBrewery), countByBrewery.ToArray());
                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByStyle), nameof(countByStyle), medianRatingByStyle.ToArray(), countByStyle.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByStyle), countByStyle.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByServingType), countByServingType.ToArray());
                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByFlavorProfile), nameof(countByFlavorProfile), medianRatingByFlavorProfile.ToArray(), countByFlavorProfile.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByFlavorProfile), countByFlavorProfile.ToArray());
                            Script.Call("renderValueAndCountColumnChart", nameof(medianAbvByDayOfWeek), nameof(countByDayOfWeek), medianAbvByDayOfWeek.ToArray(), countByDayOfWeek.ToArray());
                        };
                        reader.ReadAsText(input.Files[0]);
                    }
                }
            };

            col.AppendChild(button);
        }
Exemple #10
0
 public static void AppendAllChildren(this HTMLElement self, params HTMLElement[] items) =>
 items.ForEach(x => self.AppendChild(x));
Exemple #11
0
 public static void AppendAllChildren(this HTMLElement self, IEnumerable <HTMLElement> items) =>
 items.ForEach(x => self.AppendChild(x));
Exemple #12
0
 public static bool HasFocus(this HTMLElement self)
 {
     return(self == Document.ActiveElement);
 }
Exemple #13
0
 public static List <HTMLElement> GetSiblings(this HTMLElement self) =>
 (self.ParentElement == null) ? new List <HTMLElement>() : self.ParentElement.Children.Where(x => x != self).ToList();
Exemple #14
0
 public static IEnumerable <HTMLElement> ChildElements(this HTMLElement self)
 {
     return(self.ChildNodes
            .Where(x => x.NodeType == NodeType.Element)
            .Select(x => (HTMLElement)x));
 }
Exemple #15
0
 /// <summary>
 /// Adds an element to the collection of option elements for this select element.
 /// <param name="element">An item to add to the collection of options.</param>
 /// </summary>
 public virtual extern void Add(HTMLElement element);
Exemple #16
0
 public static void AppendChild(this HTMLElement c, Control b)
 {
     c.appendChild <Node>(b);
 }
Exemple #17
0
 /// <summary>
 /// Adds an element to the collection of option elements for this select element.
 /// <param name="element">An item to add to the collection of options.</param>
 /// <param name="beforeIndex">An index of an item that the new item should be inserted before. If the index does not exist, the new element is appended to the end of the collection.</param>
 /// </summary>
 public virtual extern void Add(HTMLElement element, int beforeIndex);
Exemple #18
0
 public static void AppendChild(this HTMLElement c, Node b)
 {
     c.appendChild(b);
 }
 /// <summary>
 /// Returns the template node the passed child belongs to, or null if it doesn't belong to one. ...
 /// </summary>
 public HTMLElement findItemByChild(HTMLElement node){return null;}
Exemple #20
0
 public static void SetBoundsFull(this HTMLElement c)
 {
     c.SetBounds(0, 0, "100%", "100%");
 }
Exemple #21
0
 /// <summary>
 /// Highlight a given item in the DataView. ...
 /// </summary>
 public object highlightItem(HTMLElement item){return null;}
Exemple #22
0
 public static void SetSize(this HTMLElement c, Union <string, int, float> width, Union <string, int, float> height)
 {
     c.style.width  = width.ToHtmlValue();
     c.style.height = height.ToHtmlValue();
 }
 public ResultContext(HTMLElement element, BindingContext bindingContext)
 {
     Element        = element;
     BindingContext = bindingContext;
 }
Exemple #24
0
 public static void SetLocation(this HTMLElement c, Union <string, int, float> left, Union <string, int, float> top)
 {
     c.style.left = left.ToHtmlValue();
     c.style.top  = top.ToHtmlValue();
 }
Exemple #25
0
 public void AppendTo(HTMLElement el)
 {
     el.AppendChild(this.container);
 }
Exemple #26
0
        public override void CreateElement(ElementId elementId, string tagName)
        {
            HTMLElement element = Document.CreateElement(tagName);

            Map.Add(elementId, element);
        }
Exemple #27
0
        private static bool ExecuteTest(TestDetails testItemDetails, bool showDetailedInformation, HTMLElement appendSuccessesTo, HTMLElement appendFailuresTo)
        {
            try
            {
                var testItem = TestItemInstanceCreator.GetInstance(testItemDetails.FullName);
                var decoder  = GetTypedMessagePackSerializerDeserializeCall(testItem.DeserialiseAs, testItem.DecodeOptions);
                if (testItemDetails.ExpectedError is null)
                {
                    var clone          = decoder(testItemDetails.Serialised);
                    var expectedResult = (testItemDetails.AlternateResultJson is null) ? testItem.Value : DeserialiseAlternateResultJson(testItemDetails.AlternateResultJson);
                    if (ObjectComparer.AreEqual(expectedResult, clone, out var messageIfNotEqual))
                    {
                        RenderSuccess($"Expected and received: {JsonSerialiserForComparison.ToJson(expectedResult)}");
                        return(true);
                    }
                    RenderFailure(messageIfNotEqual);
                    return(false);
                }
                else
                {
                    try
                    {
                        decoder(testItemDetails.Serialised);
                        RenderFailure("No exception was thrown but expected: " + testItemDetails.ExpectedError.ExceptionType.FullName);
                        return(false);
                    }
                    catch (Exception deserialisationException)
                    {
                        if (deserialisationException.GetType() != testItemDetails.ExpectedError.ExceptionType)
                        {
                            var additionalInfo = $"Expected exception {testItemDetails.ExpectedError.ExceptionType.FullName} but {deserialisationException.GetType().FullName} was thrown";
                            if (showDetailedInformation)
                            {
                                additionalInfo += "\n\n" + deserialisationException.ToString();
                            }
                            RenderFailure(additionalInfo);
                            return(false);
                        }
                        if (deserialisationException.Message != testItemDetails.ExpectedError.Message)
                        {
                            var additionalInfo = $"Expected exception message \"{testItemDetails.ExpectedError.Message}\" but received \"{deserialisationException.Message}\"";
                            if (showDetailedInformation)
                            {
                                additionalInfo += "\n\n" + deserialisationException.ToString();
                            }
                            RenderFailure(additionalInfo);
                            return(false);
                        }
                        RenderSuccess($"Expected and received error: {deserialisationException.Message}");
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                RenderFailure(e.Message, e.ToString());
            }
            return(false);

            void RenderSuccess(string extendedAdditionalInfo)
            {
                appendSuccessesTo.appendChild(
                    GetMessage(testItemDetails.DisplayName, hrefIfTextShouldLink: GetHrefForFilteringToTest(testItemDetails.DisplayName), isSuccess: true, additionalInfo: showDetailedInformation ? extendedAdditionalInfo : null)
                    );
            }

            void RenderFailure(string summary, string extendedAdditionalInfo = null)
            {
                appendFailuresTo.appendChild(
                    GetMessage(testItemDetails.DisplayName, hrefIfTextShouldLink: GetHrefForFilteringToTest(testItemDetails.DisplayName), isSuccess: false, additionalInfo: showDetailedInformation ? (extendedAdditionalInfo ?? summary) : summary)
                    );
            }
        }
Exemple #28
0
 public extern void Add(ElementId i, HTMLElement element);
Exemple #29
0
 /// <summary>
 /// Inspects the element, and creates an instance of {@link goog.ui.Control} or
 /// an appropriate subclass best suited to decorate it.  Returns the control (or
 /// null if no suitable class was found).  This default implementation uses the
 /// element's CSS class to find the appropriate control class to instantiate.
 /// May be overridden in subclasses.
 /// </summary>
 /// <param name="element">Element to decorate.</param>
 /// <returns>A new control suitable to decorate the element
 ///      (null if none).</returns>
 public goog.ui.Control getDecoratorForChild(HTMLElement element)
 {
     return((goog.ui.Control)(
                goog.ui.registry.getDecorator(element)));
 }
Exemple #30
0
 private string DistroGump_GFAddHTMLLocalized(string gump_name, HTMLElement elem)
 {
     //TODO: What about allowing Hue to be placed in HTML when using cliloc?
     if (elem.ShowScrollbar || elem.ShowBackground)
         return String.Format("GFAddHTMLLocalized({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7});", gump_name, elem.X, elem.Y, elem.Width, elem.Height, elem.CliLocID, BoolToString(elem.ShowBackground), BoolToString(elem.ShowScrollbar));
     else 
         return String.Format("GFAddHTMLLocalized({0}, {1}, {2}, {3}, {4}, {5});", gump_name, elem.X, elem.Y, elem.Width, elem.Height, elem.CliLocID);
 }
Exemple #31
0
 public static HTMLElement RemoveInvisibleScroll(this HTMLElement element)
 {
     DisableInvisibleScroll(element);
     return(element);
 }
Exemple #32
0
        private string DistroGump_GFHTMLArea(string gump_name, HTMLElement elem)
        {
            string text = (bGetDefaultText) ? "HtmlElement" : "";

            if (elem.HTML != null)
                if (elem.HTML != String.Empty)
                    text = elem.HTML;

            if (elem.ShowScrollbar || elem.ShowBackground)
                return String.Format("GFHTMLArea({0}, {1}, {2}, {3}, {4}, \"{5}\", {6}, {7});", gump_name, elem.X, elem.Y, elem.Width, elem.Height, text, BoolToString(elem.ShowBackground), BoolToString(elem.ShowScrollbar));
            else
                return String.Format("GFHTMLArea({0}, {1}, {2}, {3}, {4}, \"{5}\");", gump_name, elem.X, elem.Y, elem.Width, elem.Height, text);
        }
Exemple #33
0
 /// <summary>
 /// Adds an element to the collection of option elements for this select element.
 /// <param name="element">An item to add to the collection of options.</param>
 /// <param name="beforeElement">An item that the new item should be inserted before. If this parameter is null, the new element is appended to the end of the collection.</param>
 /// </summary>
 public virtual extern void Add(HTMLElement element, HTMLElement beforeElement);
Exemple #34
0
        string Gump_WriteHTMLGump(HTMLElement elem, ref List<string> texts) {
            int textid = texts.Count;

            string text = String.Concat("HtmlGump id.", textid);

            if (elem.HTML != null) {
                text = (elem.HTML == String.Empty) ? text : elem.HTML;
            }

            texts.Add(text);
            
            return String.Format("htmlgump {0} {1} {2} {3} {4} {5} {6}", elem.X, elem.Y, elem.Width, elem.Height, textid, BoolToString(elem.ShowBackground), BoolToString(elem.ShowScrollbar));    
        }
Exemple #35
0
 /// <summary>
 /// Moves the proxy to a different position in the DOM. ...
 /// </summary>
 public object moveProxy(HTMLElement parentNode, HTMLElement before = null)
 {
     return(null);
 }
Exemple #36
0
 string Gump_WriteXMFHtmlGump(HTMLElement elem)
 {
     return String.Format("xmfhtmlgump {0} {1} {2} {3} {4} {5} {6}", elem.X, elem.Y, elem.Width, elem.Height, elem.CliLocID, BoolToString(elem.ShowBackground), BoolToString(elem.ShowScrollbar));
 }
 /// <summary>
 /// Moves the proxy to a different position in the DOM. ...
 /// </summary>
 public object moveProxy(HTMLElement parentNode, HTMLElement before=null){return null;}
Exemple #38
0
 /// <summary>
 /// Set the image to be used for dragging if a custom one is desired.
 /// </summary>
 /// <param name="img">An image Element element to use for the drag feedback image.</param>
 /// <param name="xOffset">A long indicating the horizontal offset within the image.</param>
 /// <param name="yOffset">A long indicating the vertical offset within the image.</param>
 public extern void SetDragImage(HTMLElement img, int xOffset, int yOffset);
Exemple #39
0
		public void AppendChild (HTMLElement element)
		{
		}
 private static void CreatePage(HTMLElement page, Action <HTMLElement> renderingAction) => renderingAction(page);
Exemple #41
0
 /// <summary>
 /// Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child e...
 /// </summary>
 public Ext.core.Element createChild(object config, HTMLElement insertBefore=null, bool returnDom=false){return null;}
Exemple #42
0
        public Dragger()
        {
            var document = HTMLPage.Document;

            HTMLElement dragged = null;

            // events fired on the draggable target */
            document.OnDrag += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) =>
            {
                //Console.WriteLine("dragged");
            };

            document.OnDragStart += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                Console.WriteLine("Drag Start");
                dragged = ((DragEvent)args.EventObject).Target.As <HTMLElement>();
                dragged.SetStyleAttribute("opacity", ".5");
            };


            document.OnDragEnd += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                ((DragEvent)args.EventObject).Target.As <HTMLElement>().SetStyleAttribute("opacity", null);
            };

            document.OnDragLeave += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                ((DragEvent)args.EventObject).Target.As <HTMLElement>().RemoveStyleAttribute("opacity");
            };


            //Events fired on the drop targets
            document.OnDragOver += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                args.PreventDefault();
                args.StopPropagation();
                var target = ((DragEvent)args.EventObject).Target.As <HTMLElement>();
                if (target.ClassName == "dropzone")
                {
                    // A DropEffect must be set
                    ((DragEvent)args.EventObject).DataTransfer.DropEffect = DropEffect.Link;
                }
                else
                {
                    // A DropEffect must be set
                    ((DragEvent)args.EventObject).DataTransfer.DropEffect = DropEffect.None;
                }
            };

            document.OnDragEnter += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                var target = ((DragEvent)args.EventObject).Target.As <HTMLElement>();
                if (target.ClassName == "dropzone")
                {
                    target.SetStyleAttribute("background", "purple");
                }
            };

            document.OnDragLeave += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                var target = ((DragEvent)args.EventObject).Target.As <HTMLElement>();
                if (target.ClassName == "dropzone")
                {
                    target.SetStyleAttribute("background", "");
                }
            };

            document.OnDrop += (Mono.WebAssembly.JSObject sender, DOMEventArgs args) => {
                args.PreventDefault();
                args.StopPropagation();

                var target = ((DragEvent)args.EventObject).Target.As <HTMLElement>();
                if (target.ClassName == "dropzone")
                {
                    target.SetStyleAttribute("background", "");
                    dragged.ParentNode.RemoveChild(dragged);
                    target.AppendChild(dragged);
                }
            };
        }
Exemple #43
0
 private HTMLTableRowElement Row(HTMLElement el, int colspan)
 {
     var row = new HTMLTableRowElement();
     var td = new HTMLTableDataCellElement();
     td.SetAttribute("colspan", colspan.ToString());
     td.AppendChild(el);
     row.AppendChild(td);
     return row;
 }
Exemple #44
0
 /// <summary>
 /// traverse using depth first way UNTIL first matching element is found. If nothing found null is returned
 /// </summary>
 public static HTMLElement TraverseUntilFirst(this HTMLElement self, Func <HTMLElement, bool> visitor, string purposeNameOrNull = null)
 {
     return(self.TraverseUntilFirst(x => x.IsTraversable(purposeNameOrNull), visitor));
 }