public TabStripRenderingTests()
        {
            Mock<TextWriter> textWriter = new Mock<TextWriter>();
            Mock<HtmlTextWriter> writer = new Mock<HtmlTextWriter>(textWriter.Object);

            builder = new Mock<ITabStripHtmlBuilder>();
            builder.Setup(r => r.TabStripTag()).Returns(() =>
            {
                IHtmlNode result = new HtmlElement("div");

                new HtmlElement("ul").AppendTo(result);

                return result;
            });
            builder.Setup(r => r.ItemTag(It.IsAny<TabStripItem>())).Returns(() => new HtmlElement("li"));
            builder.Setup(r => r.ItemContentTag(It.IsAny<TabStripItem>())).Returns(() => new HtmlElement("div"));
            builder.Setup(r => r.ItemInnerTag(It.IsAny<TabStripItem>())).Returns(() => new HtmlElement("a"));

            tabStrip = TabStripTestHelper.CreateTabStrip(writer.Object, builder.Object);
            tabStrip.Name = "TabStrip1";

            tabStrip.Items.Add(new TabStripItem { Text = "TabStripItem1", RouteName = "ProductList" });
            tabStrip.Items.Add(new TabStripItem { Text = "TabStripItem2", RouteName = "ProductList" });
            tabStrip.Items.Add(new TabStripItem { Text = "TabStripItem3", RouteName = "ProductList" });
        }
        public IHtmlNode Create(GridPagerData section)
        {
            var div = new HtmlElement("div")
                .AddClass("t-page-size");

            var dropDown = new HtmlElement("div")
                .AddClass("t-dropdown", "t-header")
                .Css("width","50px")
                .AppendTo(div);

            var wrapper = new HtmlElement("div")
                .AddClass("t-dropdown-wrap", "t-state-default")
                .AppendTo(dropDown);

            new HtmlElement("span")
                .AddClass("t-input")
                .Text(section.PageSize.ToString())
                .AppendTo(wrapper);

            var select = new HtmlElement("span")
                .AddClass("t-select").AppendTo(wrapper);

            new HtmlElement("span")
                .AddClass("t-icon", "t-arrow-down")
                .Text("select")
                .AppendTo(select);

            return div;
        }
        public void NonVoidElement_InnerText_NoChildren()
        {
            HtmlElement expected = new HtmlElement("div")
                .WithInnerText("InnerText");

            Parse(expected, "<div>InnerText</div>");
        }
        public void NonVoidElement_NoInnerText_OneNonVoidChild()
        {
            HtmlElement expected = new HtmlElement("div")
                .WithChild(new HtmlElement("p"));

            Parse(expected, "<div><p></p></div>");
        }
        public IHtmlNode CellTag(DateTime currentDay, DateTime? selectedDate, string urlFormat, bool isOtherMonth)
        {
            IHtmlNode cell = new HtmlElement("td");

            if (isOtherMonth)
            {
                cell.AddClass("t-other-month");
            }
            else if (selectedDate.HasValue && IsInRange(selectedDate.Value) && currentDay.Day == selectedDate.Value.Day)
            {
                cell.AddClass(UIPrimitives.SelectedState);
            }

            if (IsInRange(currentDay))
            {
                var href = GetUrl(currentDay, urlFormat);

                IHtmlNode link = new HtmlElement("a")
                                 .AddClass(UIPrimitives.Link + (href != "#" ? " t-action-link" : string.Empty))
                                 .Attribute("href", href)
                                 .Attribute("title", currentDay.ToLongDateString())
                                 .Text(currentDay.Day.ToString());

                cell.Children.Add(link);
            }
            else
            {
                cell.Html("&nbsp;");
            }

            return cell;
        }
Пример #6
0
 public void Add_ParamsHtmlObject_Empty()
 {
     HtmlElement element = new HtmlElement("parent");
     element.Add(new HtmlObject[0]);
     Assert.Empty(element.Elements());
     Assert.Empty(element.Attributes());
 }
Пример #7
0
        public void Add_HtmlObject(bool isVoid)
        {
            HtmlElement parent = new HtmlElement("parent", isVoid);

            // Atribute
            HtmlAttribute attribute = new HtmlAttribute("attribute");
            parent.Add(attribute);
            Assert.Equal(parent, attribute.Parent);
            Assert.Equal(new HtmlAttribute[] { attribute }, parent.Attributes());

            if (!isVoid)
            {
                // Element
                HtmlElement element = new HtmlElement("element");
                parent.Add(element);
                Assert.Equal(parent, element.Parent);
                Assert.Equal(new HtmlElement[] { element }, parent.Elements());

                // Nodes
                HtmlComment comment = new HtmlComment("comment");
                parent.Add(comment);
                Assert.Equal(parent, comment.Parent);
                Assert.Equal(new HtmlObject[] { element, comment }, parent.Nodes());
            }
        }
Пример #8
0
        public static UserErrorTypes Parse(HtmlElement root)
        {
            var content = root.FindFirst("div", (e) => e.Attributes["class"] == "tip-content");
            
            if (content == null)
                throw new InvalidDataException();
            else
            {
                var divs = content.Descendants("div");
                string msg = null;
                var errType = UserErrorTypes.ErrorWithMsg;
                int count = divs.Count();
                if (count == 1)
                {
                    var span = divs.First().Element();
                    if (span != null)
                        msg = span.InnerHtml;
                }
                else if (count >1)
                {
                    msg = divs.ElementAt(1).PlainText();
                }

                if (msg.Contains("您没有权限"))
                    errType = UserErrorTypes.NotAuthorized;
                else if (msg.Contains("网站已经关闭"))
                    errType = UserErrorTypes.SiteClosed;
                if (msg != null)
                    throw new S1UserException(msg, errType);
            }
            return UserErrorTypes.Unknown;
        }
        public IHtmlNode Create(GridPagerData section)
        {
            var span = new HtmlElement("span")
                .AddClass("k-pager-sizes", "k-label");

            var select = new HtmlElement("select")
                .AppendTo(span);

            foreach (var pageSize in section.PageSizes)
            {
                var pageSizeText = pageSize.ToString().ToLowerInvariant();
                var pageSizeValue = pageSizeText;

                if (pageSizeText == "all")
                {
                    pageSizeText = section.Messages.AllPages;
                }

                new HtmlElement("option").Attribute("value", pageSizeValue).Text(pageSizeText).AppendTo(select);
            }

            new LiteralNode(section.Messages.ItemsPerPage).AppendTo(span);

            return span;
        }
        public void ReplaceAll_SameElementInContent_ThrowsInvalidOperationException()
        {
            HtmlElement parent = new HtmlElement("parent");

            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAll(new HtmlObject[] { parent }));
            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAll((IEnumerable<HtmlObject>)new HtmlObject[] { parent }));
        }
        public void ReplaceAll_NullContent_ThrowsArgumentNullException()
        {
            HtmlElement parent = new HtmlElement("parent");

            Assert.Throws<ArgumentNullException>("content", () => parent.ReplaceAll(null));
            Assert.Throws<ArgumentNullException>("content", () => parent.ReplaceAll((IEnumerable<HtmlObject>)null));
        }
Пример #12
0
 public static void SerializeIgnoringFormatting(HtmlElement element, string expected)
 {
     expected = expected.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);
     Assert.Equal(expected, element.ToString());
     Assert.Equal(expected, element.Serialize());
     Assert.Equal(expected.Replace(Environment.NewLine, ""), element.Serialize(HtmlSerializeOptions.NoFormatting));
 }
 public void ReplaceAll_ContentNotNodeOrAttribute_ThrowsArgumentException()
 {
     HtmlElement parent = new HtmlElement("parent");
     
     Assert.Throws<ArgumentException>("content", () => parent.ReplaceAll(new HtmlObject[] { new CustomHtmlObject() }));
     Assert.Throws<ArgumentException>("content", () => parent.ReplaceAll((IEnumerable<HtmlObject>)new HtmlObject[] { new CustomHtmlObject() }));
 }
Пример #14
0
        public IHtmlNode CreateTextArea()
        {
            var content = new HtmlElement("textarea")
                            .Attributes(new
                            {
                                cols = "20",
                                rows = "5",
                                name = editor.Name,
                                id = editor.Id + "-value"
                            })
                            .Attributes(editor.GetUnobtrusiveValidationAttributes())
                            .PrependClass(UIPrimitives.Content, UIPrimitives.Editor.RawContent);

            var value = editor.GetValue<string>(editor.Value);

            if (!string.IsNullOrEmpty(value))
            {
                content.Text(value);
            }
            else if (editor.Content != null)
            {
                editor.Template.Apply(content);
            }
            else if (editor.Template.InlineTemplate != null)
            {
                content.Text(editor.Template.InlineTemplate(null).ToString());
            }

            return content;
        }
Пример #15
0
        protected override IHtmlNode BuildCore()
        {
            var root = CreateEditor();

            var toolbarRow = new HtmlElement("tr").AppendTo(root);

            if (editor.DefaultToolGroup.Tools.Any())
            {
                CreateToolBar().AppendTo(new HtmlElement("td").AddClass("t-editor-toolbar-wrap").AppendTo(toolbarRow));
            }

            var editableCell = new HtmlElement("td")
                .AddClass("t-editable-area")
                .ToggleClass("input-validation-error", !editor.IsValid())
                .AppendTo(new HtmlElement("tr").AppendTo(root));

            var textarea = CreateTextArea();
            textarea.AppendTo(editableCell);

            var script = new HtmlElement("script")
                            .Attribute("type", "text/javascript")
                            .Html("document.getElementById('" + textarea.Attribute("id") + "').style.display='none'");

            script.AppendTo(editableCell);

            return root;
        }
Пример #16
0
        public IHtmlNode CreateTextbox()
        {
            var content = new HtmlElement("input")
                .Attribute("id", textbox.Id);

            return content;
        }
Пример #17
0
        protected virtual IHtmlNode CreatePane(MobileSplitViewPane pane)
        {
            var dom = new HtmlElement("div")
                        .Attribute("id", pane.Id)
                        .Attribute("data-role", "pane")
                        .Attributes(pane.HtmlAttributes);

            if (pane.Content.HasValue())
            {
                pane.Content.Apply(dom);
            }

            foreach (var item in pane.ToJson())
            {
                if (item.Value.GetType() == typeof(bool))
                {
                    dom.Attribute("data-" + item.Key, item.Value.ToString().ToLower());
                }
                else
                {
                    dom.Attribute("data-" + item.Key, item.Value.ToString());
                }
            }

            AddEventAttributes(dom, pane.Events);

            return dom;
        }
Пример #18
0
        private IHtmlNode CreateWrapper(Action<IHtmlNode> appendContent)
        {
            var toolbar = new HtmlElement("div").AddClass(UIPrimitives.ToolBar, UIPrimitives.Grid.ToolBar);

            appendContent(toolbar);

            return toolbar;
        }
Пример #19
0
        public IHtmlNode CreateForm()
        {
            var form = new HtmlElement("form")
                        .Attribute("method", "post")
                        .Attributes(htmlAttributes);

            return form;
        }
        public IHtmlNode CreateSections(GridPagerData section)
        {
            var div = new HtmlElement("div")
                .AddClass("t-pager", UIPrimitives.ResetStyle);

            pagingSectionsBuilder.CreateSections(section).AppendTo(div);
            return div;
        }
        public IHtmlNode Create(IGridUrlBuilder urlBuilder, int currentPage, int pageCount)
        {
            var numericDiv = new HtmlElement("div").AddClass("t-numeric");

            AppendContent(urlBuilder, numericDiv, pageCount, currentPage);

            return numericDiv;
        }
Пример #22
0
 public void Applying_when_html_is_set_sets_html_of_the_node()
 {
     var template = new HtmlTemplate<object>();
     template.Html = "<strong>foo</strong>";
     var node = new HtmlElement("div");
     template.Apply(null, node);
     Assert.Equal(template.Html, node.InnerHtml);
 }
        public void Apply(IHtmlNode parent)
        {
            var span = new HtmlElement("span");

            span.Attributes(button.ImageHtmlAttributes).AddClass(UIPrimitives.Icon, button.SpriteCssClass);

            span.AppendTo(parent);
        }
Пример #24
0
 public void Applying_when_code_block_is_set_sets_template_of_the_node()
 {
     var template = new HtmlTemplate<object>();
     template.CodeBlockTemplate = delegate { };
     var node = new HtmlElement("div");
     template.Apply(null, node);
     Assert.NotNull(node.Template());
 }
Пример #25
0
        public void Applying_when_inline_template_sets_html_of_the_node()
        {
            var template = new HtmlTemplate<object>();
            template.InlineTemplate = (value) => value;
            var node = new HtmlElement("div");
            template.Apply("foo", node);

            Assert.Equal("<div>foo</div>", node.ToString());
        }
        public void ReplaceAll_IEnumerableHtmlObject_AttributeToVoidElement()
        {
            HtmlElement parent = new HtmlElement("parent", isVoid: true);
            parent.Add(new HtmlAttribute("attribute"));

            HtmlAttribute[] attributes = new HtmlAttribute[] { new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2") };
            parent.ReplaceAll((IEnumerable<HtmlObject>)attributes);
            Assert.Equal(attributes, parent.Attributes());
        }
Пример #27
0
        protected IHtmlNode CreateContainer()
        {
            var th = new HtmlElement("th")
                    .Attribute("scope", "col")
                    .Attributes(htmlAttributes)
                    .PrependClass(UIPrimitives.Header);

            return th;
        }
Пример #28
0
 private static HtmlElement GetRowContainer( HtmlElement rootElement )
 {
     HtmlElementFindParams findParams1 = new HtmlElementFindParams();
     findParams1.TagName = "div";
     findParams1.Attributes.Add( "class", "wgreylinebottom" );
     findParams1.Index = 0;
     
     return rootElement.ChildElements.Find( findParams1 );
 }
        public void ReplaceAll_DuplicateElementInContents_ThrowsInvalidOperationException()
        {
            HtmlElement parent = new HtmlElement("parent");
            HtmlElement element = new HtmlElement("element");
            parent.Add(element);

            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAll(new HtmlObject[] { element }));
            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAll((IEnumerable<HtmlObject>)new HtmlObject[] { element }));
        }
        public void ReplaceAll_DuplicateAttributeInContents_ThrowsInvalidOperationException()
        {
            HtmlElement parent = new HtmlElement("parent");
            HtmlAttribute attribute = new HtmlAttribute("attribute");
            parent.Add(attribute);

            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAll(new HtmlObject[] { attribute }));
            Assert.Throws<InvalidOperationException>(() => parent.ReplaceAll((IEnumerable<HtmlObject>)new HtmlObject[] { attribute }));
        }
 public static HtmlElement focus(this HtmlElement htmlElement)
 {
     htmlElement.Focus();
     return(htmlElement);
 }
 public static string attribute(this HtmlElement htmlElement, string name)
 {
     return(htmlElement.GetAttribute(name));
 }
 public static string value(this HtmlElement htmlElement)
 {
     return(htmlElement.attribute("value"));
 }
        //actions

        public static HtmlElement createElement(this WebBrowser browser, string tagName, HtmlElement targetElement)
        {
            var newElement = browser.createElement(tagName);

            targetElement.appendChild(newElement);
            return(newElement);
        }
Пример #35
0
        private bool processAction(string action)
        {
            bool cancelNavigation = false;

            try
            {
                switch (action)
                {
                case ReportExecution.ActionExecuteReport:
                    cancelNavigation = true;
                    _reportDone      = false;
                    if (webBrowser.Document != null)
                    {
                        _report.InputRestrictions.Clear();
                        if (HeaderForm != null)
                        {
                            foreach (HtmlElement element in HeaderForm.All)
                            {
                                if (element.Id != null)
                                {
                                    _report.InputRestrictions.Add(element.Id, element.TagName.ToLower() == "option" ? element.GetAttribute("selected") : element.GetAttribute("value"));
                                    Debug.WriteLine("{0} {1} {2} {3}", element.Id, element.Name, element.GetAttribute("value"), element.GetAttribute("selected"));
                                }
                            }
                        }
                    }
                    Execute();
                    break;

                case ReportExecution.ActionRefreshReport:
                    if (_report.IsExecuting)
                    {
                        cancelNavigation = true;
                        HtmlElement message = webBrowser.Document.All[ReportExecution.HtmlId_processing_message];
                        if (message != null)
                        {
                            message.SetAttribute("innerHTML", _report.ExecutionHeader);
                        }
                        HtmlElement messages = webBrowser.Document.All[ReportExecution.HtmlId_execution_messages];
                        if (messages != null)
                        {
                            messages.SetAttribute("innerHTML", Helper.ToHtml(_report.ExecutionMessages));
                        }
                    }
                    else if (!_reportDone)
                    {
                        cancelNavigation = true;
                        _reportDone      = true;
                        _url             = "file:///" + _report.HTMLDisplayFilePath;
                        webBrowser.Navigate(_url);
                    }
                    break;

                case ReportExecution.ActionCancelReport:
                    _execution.Report.LogMessage(_report.Translate("Cancelling report..."));
                    cancelNavigation = true;
                    _report.Cancel   = true;
                    break;

                case ReportExecution.ActionUpdateViewParameter:
                    cancelNavigation = true;
                    _report.UpdateViewParameter(GetFormValue(ReportExecution.HtmlId_parameter_view_id), GetFormValue(ReportExecution.HtmlId_parameter_view_name), GetFormValue(ReportExecution.HtmlId_parameter_view_value));
                    break;

                case ReportExecution.ActionViewHtmlResult:
                    string resultPath = _execution.GenerateHTMLResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionViewPrintResult:
                    resultPath = _execution.GeneratePrintResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionViewPDFResult:
                    resultPath = _execution.GeneratePDFResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionViewExcelResult:
                    resultPath = _execution.GenerateExcelResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                cancelNavigation = true;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(cancelNavigation);
        }
Пример #36
0
        private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            HtmlDocument document =
                this.webBrowser1.Document;

            if (document == null)
            {
                return;
            }
            //e.Cancel = true;
            HtmlElement e_ = document.ActiveElement;
            //e_ is submit input or anchor
            bool process_ = false;

            while (true)
            {
                if (e_ == null)
                {
                    break;
                }
                Console.WriteLine(e_.TagName + "%%");
                if ("FORM".Equals(e_.TagName) || "A".Equals(e_.TagName))
                {
                    process_ = true;
                    break;
                }
                e_ = e_.Parent;
            }
            if (document.ActiveElement != null)
            {
                Console.WriteLine("end with: " + document.ActiveElement.TagName);
            }

            if (!process_)
            {
                Console.WriteLine(this.webBrowser1.DocumentText);
                return;
            }
            //
            htmlText = "<html><head><style>.excuse{color:blue;}</style></head><body><a href=\"hurlement2\">Hello 2!!</a><br/>";
            //retrieve data by e_.GetElementsByTagName("INPUT");
            HtmlElementCollection c_ = e_.GetElementsByTagName("INPUT");

            foreach (HtmlElement element_ in c_)
            {
                if (element_.GetAttribute("name").Equals("prenom"))
                {
                    htmlText += element_.GetAttribute("value") + "<br/>";
                }
            }
            //retrieve href by GetAttribute
            htmlText += e_.GetAttribute("href");
            htmlText += "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAIAAABLMMCEAAAAEUlEQVR42mN4K6OCiRgGgSgAfEs5nifMv08AAAAASUVORK5CYII=\"/>";
            htmlText += "<form action=\"theatre\" name=\"mar\" method=\"post\"><input name=\"prenom\"/><input name=\"validate\" type=\"submit\" value=\"OK\"/></form>";
            htmlText += "<br/>";
            htmlText += "<span class=\"excuse\">Tarot</span><br/>";
            htmlText += "<a href=\"chien\">here</a>";
            htmlText += "</body></html>";//

            this.webBrowser1.Navigate("about:blank");
            HtmlDocument doc = this.webBrowser1.Document;

            doc.Write(string.Empty);
            Console.WriteLine("HERE");
            this.webBrowser1.DocumentText = htmlText;
            //mshtml.IHTMLDocument2 h_;
            //h_ = this.webBrowser1.Document.DomDocument as mshtml.IHTMLDocument2;
            //h_.body.innerHTML = htmlText;
            //Console.WriteLine();
            //this.webBrowser1.Document.DomDocument.GetType();
            //webBrowser1.DocumentText = htmlText;
            //webBrowser1.Invalidate();
        }
Пример #37
0
 public SvgRootEventPortal(HtmlElement elementNode)
 {
     _elementNode = elementNode;
 }
        private void btnAcept_Click(object sender, EventArgs e)
        {
            HtmlElement   txtDepartureDate   = wbContent.Document.GetElementById("txtDepartureDate");
            HtmlElement   txtDeparture       = wbContent.Document.GetElementById("txtDeparture");
            HtmlElement   txtArrival         = wbContent.Document.GetElementById("txtArrival");
            HtmlElement   ckbSabre           = wbContent.Document.GetElementById("ckbSabre");
            HtmlElement   ckbInterjet        = wbContent.Document.GetElementById("ckbInterjet");
            HtmlElement   ckbVolaris         = wbContent.Document.GetElementById("ckbVolaris");
            HtmlElement   txtStartHour       = wbContent.Document.GetElementById("txtStartHour");
            HtmlElement   txtFinalHour       = wbContent.Document.GetElementById("txtFinalHour");
            HtmlElement   ckbIndFlights      = wbContent.Document.GetElementById("ckbIndFlights");
            HtmlElement   ckbSharedCodes     = wbContent.Document.GetElementById("ckbSharedCodes");
            HtmlElement   ckbShowWeekly      = wbContent.Document.GetElementById("ckbShowWeekly");
            HtmlElement   ckbIncludeAircraft = wbContent.Document.GetElementById("ckbIncludeAircraft");
            HtmlElement   txtAirlineInclude1 = wbContent.Document.GetElementById("txtAirlineInclude1");
            HtmlElement   txtAirlineInclude2 = wbContent.Document.GetElementById("txtAirlineInclude2");
            HtmlElement   txtAirlineInclude3 = wbContent.Document.GetElementById("txtAirlineInclude3");
            HtmlElement   txtAirlineExclude1 = wbContent.Document.GetElementById("txtAirlineExclude1");
            HtmlElement   txtAirlineExclude2 = wbContent.Document.GetElementById("txtAirlineExclude2");
            HtmlElement   txtAirlineExclude3 = wbContent.Document.GetElementById("txtAirlineExclude3");
            List <string> airlines           = new List <string>();

            if (!string.IsNullOrEmpty(txtDepartureDate.GetAttribute("Value")) && !string.IsNullOrEmpty(txtArrival.GetAttribute("Value")) && !string.IsNullOrEmpty(txtDeparture.GetAttribute("Value")))
            {
                if (bool.Parse(ckbSabre.GetAttribute("Checked")))
                {
                    airlines.Add("HC");
                }
                if (bool.Parse(ckbVolaris.GetAttribute("Checked")))
                {
                    airlines.Add("Y4");
                }
                if (bool.Parse(ckbInterjet.GetAttribute("Checked")))
                {
                    airlines.Add("4O");
                }


                bool isExcludeFlights = false;

                if (string.IsNullOrEmpty(txtAirlineInclude1.GetAttribute("Value")) && string.IsNullOrEmpty(txtAirlineInclude2.GetAttribute("Value")) && string.IsNullOrEmpty(txtAirlineInclude3.GetAttribute("Value")))
                {
                    airlines.Add(txtAirlineExclude1.GetAttribute("Value").ToUpper());
                    airlines.Add(txtAirlineExclude2.GetAttribute("Value").ToUpper());
                    airlines.Add(txtAirlineExclude3.GetAttribute("Value").ToUpper());
                    isExcludeFlights = true;
                }
                else
                {
                    airlines.Add(txtAirlineInclude1.GetAttribute("Value").ToUpper());
                    airlines.Add(txtAirlineInclude2.GetAttribute("Value").ToUpper());
                    airlines.Add(txtAirlineInclude3.GetAttribute("Value").ToUpper());
                }
                ClipboardService service   = new ClipboardService();
                string           startHour = string.Empty;
                if (!string.IsNullOrEmpty(txtStartHour.GetAttribute("Value")))
                {
                    switch (txtStartHour.GetAttribute("Value").Length)
                    {
                    case 1:
                        startHour = string.Concat("00:0", txtStartHour.GetAttribute("Value"));
                        break;

                    case 2:
                        startHour = string.Concat("00:", txtStartHour.GetAttribute("Value"));
                        break;

                    case 3:
                        startHour = string.Concat("0", txtStartHour.GetAttribute("Value")[0], ":", txtStartHour.GetAttribute("Value").Substring(1, 2));
                        break;

                    case 4:
                        startHour = string.Concat(txtStartHour.GetAttribute("Value").Substring(0, 2), ":", txtStartHour.GetAttribute("Value").Substring(2, 2));
                        break;
                    }
                }
                string finalHour = string.Empty;
                if (!string.IsNullOrEmpty(txtFinalHour.GetAttribute("Value")))
                {
                    switch (txtFinalHour.GetAttribute("Value").Length)
                    {
                    case 1:
                        finalHour = string.Concat("00:0", txtFinalHour.GetAttribute("Value"));
                        break;

                    case 2:
                        finalHour = string.Concat("00:", txtFinalHour.GetAttribute("Value"));
                        break;

                    case 3:
                        finalHour = string.Concat("0", txtFinalHour.GetAttribute("Value")[0], ":", txtFinalHour.GetAttribute("Value").Substring(1, 2));
                        break;

                    case 4:
                        finalHour = string.Concat(txtFinalHour.GetAttribute("Value").Substring(0, 2), ":", txtFinalHour.GetAttribute("Value").Substring(2, 2));
                        break;
                    }
                }

                DateTime departureDate = new DateTime();

                if (txtDepartureDate.GetAttribute("Value").ToUpper().Equals("29FEB"))
                {
                    if (DateTime.Today <= new DateTime(DateTime.Today.Year, 2, 28))
                    {
                        departureDate = DateTime.ParseExact(txtDepartureDate.GetAttribute("Value"), "ddMMM", new System.Globalization.CultureInfo("en-US"));
                    }
                    else
                    {
                        departureDate = DateTime.ParseExact(string.Concat(txtDepartureDate.GetAttribute("Value"), DateTime.Today.AddYears(1).Year.ToString("0000")), "ddMMMyyyy", new System.Globalization.CultureInfo("en-US"));
                    }
                }
                else
                {
                    departureDate = DateTime.ParseExact(txtDepartureDate.GetAttribute("Value"), "ddMMM", new System.Globalization.CultureInfo("en-US"));
                }

                ClipboardServices.Schedule schedule = service.CopyReport(txtDeparture.GetAttribute("Value").ToUpper(), txtArrival.GetAttribute("Value").ToUpper(), departureDate < DateTime.Today ? departureDate.AddYears(1) : departureDate, bool.Parse(ckbIndFlights.GetAttribute("Checked")), bool.Parse(ckbSharedCodes.GetAttribute("Checked")), bool.Parse(ckbShowWeekly.GetAttribute("Checked")), bool.Parse(ckbIncludeAircraft.GetAttribute("Checked")), isExcludeFlights, startHour, finalHour, airlines);
                if (schedule.Trips.Count == 0)
                {
                    MessageBox.Show("No se encontrarón resultados con los datos proporcionados.", "Sin resultados", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    ClipboardServices.File file = service.CopyReport(schedule);

                    try
                    {
                        DataObject obj = new DataObject();
                        obj.SetData(DataFormats.Html, new System.IO.MemoryStream(
                                        file.Buffer));
                        Clipboard.SetDataObject(obj, true);
                        if (MessageBox.Show("Se ha copiado el reporte a tu portapapeles.", "Reporte copiado", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                        {
                            Form frm = Application.OpenForms["frmSchedule"];
                            if (frm != null)
                            {
                                CloseForm(frm);
                            }
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Ocurrio un problema al copiar el reporte al portapapeles.", "Reporte no copiado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(txtDepartureDate.GetAttribute("Value")))
                {
                    MessageBox.Show("Es necesario que introduzca la fecha.", "Datos faltantes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (string.IsNullOrEmpty(txtArrival.GetAttribute("Value")))
                {
                    MessageBox.Show("Es necesario que introduzca el destino.", "Datos Faltantes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (string.IsNullOrEmpty(txtDeparture.GetAttribute("Value")))
                {
                    MessageBox.Show("Es necesario que introduzca el origen.", "Datos Faltantes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        void wbContent_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlElement btnAcept = wbContent.Document.GetElementById("btnAcept");

            btnAcept.AttachEventHandler("onclick", btnAcept_Click);
        }
 public static HtmlElement appendChild(this HtmlElement htmlElement, HtmlElement newElement)
 {
     htmlElement.AppendChild(newElement);
     return(htmlElement);
 }
 public static HtmlElement value(this HtmlElement htmlElement, string value)
 {
     return(htmlElement.attribute("value", value));
 }
 public static string outerHtml(this HtmlElement htmlElement)
 {
     return(htmlElement.OuterHtml);
 }
 public static List <HtmlElement> all(this HtmlElement htmlElement, string tagName)
 {
     return(htmlElement.GetElementsByTagName(tagName).toList());
 }
 public static HtmlElement attribute(this HtmlElement htmlElement, string name, string value)
 {
     htmlElement.SetAttribute(name, value);
     return(htmlElement);
 }
 public static List <HtmlElement> all(this HtmlElement htmlElement)
 {
     return(htmlElement.All.toList());
 }
Пример #46
0
 private bool GotClass(HtmlElement ele, string className)
 {
     return(ele.GetAttribute("className") == className);
 }
 public static HtmlElement raiseEvent(this HtmlElement htmlElement, string name)
 {
     htmlElement.RaiseEvent(name);
     return(htmlElement);
 }
 public static HtmlElement invokeMember(this HtmlElement htmlElement, string member)
 {
     htmlElement.InvokeMember(member);
     return(htmlElement);
 }
 public static string outerText(this HtmlElement htmlElement)
 {
     return(htmlElement.OuterText);
 }
 public static string            html(this HtmlElement htmlElement)
 {
     return(htmlElement.outerHtml());
 }
 public static string innerHtml(this HtmlElement htmlElement)
 {
     return(htmlElement.InnerHtml);
 }
 public static string innerText(this HtmlElement htmlElement)
 {
     return(htmlElement.InnerText);
 }
Пример #53
0
 public JsWorkerApi(HtmlElement element, object options)
     : base(element, options)
 {
 }
 public static HtmlElement scrollIntoView(this HtmlElement htmlElement)
 {
     htmlElement.ScrollIntoView(true); //alignWithTop = true
     return(htmlElement);
 }
Пример #55
0
 /// <summary>
 /// Set up bindings on a single node without binding any of its descendents.
 /// </summary>
 /// <param name="node">The node to bind to.</param>
 /// <param name="bindings">An optional dictionary of bindings, pass null to let Knockout gather them from the element.</param>
 /// <param name="viewModel">The view model instance.</param>
 /// <param name="bindingAttributeName">The name of the attribute which has the binding definitions.</param>
 public static void applyBindingsToNode(HtmlElement node, JsObject bindings, object viewModel, JsString bindingAttributeName)
 {
 }
 //events
 public static HtmlElement click(this HtmlElement htmlElement)
 {
     return(htmlElement.invokeMember("Click"));
 }
Пример #57
0
        //Validates the form, returns true if it is valid, false otherwise.

        public bool element(HtmlElement element)
        {
            return(false);
        }
Пример #58
0
 /// <summary>
 /// Invoked whenever an observable associated with this binding changes.
 /// </summary>
 /// <param name="element">The element involved in this binding.</param>
 /// <param name="valueAccessor">A function which returns the model property that is involved in this binding.</param>
 /// <param name="allBindingsAccessor">A function which returns all the model properties bound to this element.</param>
 /// <param name="viewModel">The view model instance involved in this binding.</param>
 public virtual void update(HtmlElement element, JsFunc <object> valueAccessor, JsFunc <JsObject> allBindingsAccessor, object viewModel)
 {
 }
Пример #59
0
        private void LoginWebBrowserNavigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (loginWebBrowser.Visible)
            {
                var fb = new FacebookClient();

                FacebookOAuthResult oauthResult;
                if (fb.TryParseOAuthCallbackUrl(e.Url, out oauthResult))
                {
                    if (oauthResult.IsSuccess)
                    {
                        _accessToken = oauthResult.AccessToken;
                        _authorized  = true;
                    }
                    else
                    {
                        _accessToken = "";
                        _authorized  = false;
                    }

                    if (_authorized)
                    {
                        fb = new FacebookClient(_accessToken);

                        dynamic result = fb.Get("me");
                        _currentName       = result.name;
                        _currentEmail      = result.email;
                        userNameLabel.Text = string.Format("Facebook User: {0}", _currentName);

                        RestoreXml();

                        UpdateListView();

                        updateBackgroundWorker.RunWorkerAsync();
                    }
                    else
                    {
                        MessageBox.Show("Couldn't log into Facebook!", "Login unsuccessful", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }

                    fileToolStripMenuItem.Enabled = true;
                    loginWebBrowser.Visible       = false;

                    return;
                }
            }

            if (_loggingOut)
            {
                if (loginWebBrowser.Document != null)
                {
                    HtmlElement logoutForm = loginWebBrowser.Document.GetElementById("logout_form");

                    if (logoutForm != null)
                    {
                        loginWebBrowser.Document.InvokeScript("execScript", new Object[] { "document.getElementById('logout_form').submit();", "JavaScript" });
                    }
                }

                if (e.Url.AbsoluteUri.StartsWith(@"https://www.facebook.com/index.php") || e.Url.AbsoluteUri.StartsWith(@"http://www.facebook.com/index.php"))
                {
                    if (_closeAfterUpdateAndLogout)
                    {
                        Close();
                    }
                    else
                    {
                        userNameLabel.Text = "Facebook User: ---";
                        totalLabel.Text    = "";

                        _loggingOut  = false;
                        _accessToken = "";
                        _authorized  = false;
                        _currentName = "";

                        fileToolStripMenuItem.Enabled = false;
                        loginWebBrowser.Navigate(_loginUrl);
                    }
                }
            }

            if (e.Url.AbsoluteUri.Equals(_loginUrl))
            {
                loginWebBrowser.Visible = true;
            }
        }
Пример #60
0
 /// <summary>
 /// Set up bindings on a single node without binding any of its descendents.
 /// </summary>
 /// <param name="node">The node to bind to.</param>
 /// <param name="bindings">An optional dictionary of bindings, pass null to let Knockout gather them from the element.</param>
 /// <param name="viewModel">The view model instance.</param>
 public static void applyBindingsToNode(HtmlElement node, JsObject bindings, object viewModel)
 {
 }