public static Node GetNodeBeforePosition(int pos, ComplexNode parent) { Node node = null; SortedNodeList <Node> children = GetChildren(parent); int start = 0; if (children.Any()) { start = children[0].Start; } if (start < pos) { int i = FindInsertIndex(children, pos) - 1; if (i >= 0) { node = children[i]; if (node is ComplexNode complexNode) { // Recurse to find the deepest node node = GetNodeBeforePosition(pos, complexNode); } } } return(node); }
protected override void WriteInner(System.Xml.XmlWriter writer) { var anchorContainer = new ComplexNode(); anchorContainer.Classes.Add("anchor"); var anchor = new ComplexNode("a"); anchor.Attributes.Add("href", "FileDownload/DownloadFile?fileName=" + _downloadFilePath); var img = new SimpleNode("img", string.Empty); img.Attributes.Add("src", _imagePath); anchor.ChildNodes.Add(img); var span = new SimpleNode("span", _downloadText); anchor.ChildNodes.Add(span); anchorContainer.ChildNodes.Add(anchor); ChildNodes.Add(anchorContainer); base.WriteInner(writer); }
private Node GetNextSibling(ArrayElementNode arrayElementNode) { ComplexNode parent = arrayElementNode.Parent as ComplexNode; SortedNodeList <Node> children = JsonHelpers.GetChildren(parent); return(parent != null?GetNextChild(arrayElementNode, children) : null); }
protected override void WriteInner(System.Xml.XmlWriter writer) { var anchor = new ComplexNode("a"); if ((_code == Guide.MvScopeMeasurement) || (_code == Guide.MvScopeCoverage) || (_code == Guide.MvScopePeriods) || (_code == Guide.MvScopeTimePeriodMapping)) { anchor.Attributes.Add("href", "FileDownload/DownloadFile?filename=Scope_Definition.xlsx"); } else if ((_code == Guide.MvExchangeRateDollar) || (_code == Guide.MvExchangeRateEuro) || (_code == Guide.MvExchangeRateMRFactor)) { anchor.Attributes.Add("href", "FileDownload/DownloadFile?filename=Exchange_Rates.xlsx"); } else { anchor.Attributes.Add("href", "javascript:CommandCenter.widgetExportClicked('xlsx','" + _widgetName + "');"); } var image = new SimpleNode("img", string.Empty); image.Attributes.Add("alt", "Export to Excel"); image.Attributes.Add("src", "Content/Images/xlsx.png"); anchor.ChildNodes.Add(image); ChildNodes.Add(anchor); base.WriteInner(writer); }
protected override NodeBase CreateInternal(object data) { var style = new Dictionary <string, string> { { "height", "20px" }, { "width", "15px" }, { "align", "center" } }; var complexNode = new ComplexNode("td") { Styles = { { "width", "20px" } } }; if (string.IsNullOrEmpty(data.ToString())) { complexNode.ChildNodes.Add(new SimpleNode("div", string.Empty) { Styles = style, }); } else { complexNode.ChildNodes.Add(new SimpleNode("img", "") { Styles = style, Attributes = { { "src", "Content/Images/" + data.ToString() + ".gif" }, } }); } return(complexNode); }
protected override void CreateSingleRow(TRowData row, ComplexNode tbody) { var tableRow = new ComplexNode("tr"); GenerateColumn(row, tableRow); tbody.ChildNodes.Add(tableRow); }
protected virtual void CreateSingleRow(XElement row, ComplexNode tbody) { var tableRow = new ComplexNode("tr"); GenerateColumn(row, tableRow); tbody.ChildNodes.Add(tableRow); }
protected override NodeBase CreateInternal(object data) { var values = data as List <string>; var complexNode = new ComplexNode("td"); //complexNode.ChildNodes.Add(new SimpleNode("span", values != null ? Convert.ToString(RecordCount) : "") { Classes = new List<string>() { "rank-div" } }); string colorValue = ""; if (values[1].ToUpper().Contains("TOTAL")) { colorValue = ColorListDataSource.ColorOfTotal.Replace("#", ""); } else if (UncheckedItem != null && UncheckedItem.Contains(values[1])) { colorValue = ""; if (RecordCount != 0) { complexNode.ChildNodes.Add(new SimpleNode("span", values != null ? Convert.ToString(RecordCount) : "") { Classes = new List <string>() { "rank-div" } }); } } else { colorValue = _colorSource.GetNextColor(); if (RecordCount != 0) { complexNode.ChildNodes.Add(new SimpleNode("span", values != null ? Convert.ToString(RecordCount) : "") { Classes = new List <string>() { "rank-div" } }); } } complexNode.ChildNodes.Add(new SimpleNode("span", string.Empty) { Classes = new List <string>() { "color-div" }, Styles = new Dictionary <string, string>() { { "background-color", "#" + colorValue } } }); RecordCount++; return(complexNode); }
public override INode Create(object value) { var cell = new ComplexNode("td"); cell.Classes.Add("col-" + ColumnPosition); cell.ChildNodes.Add(GetNumeric(value)); AddHoverAction(cell); return(cell); }
protected override void GenerateColumn(XElement row, ComplexNode tableRow) { int columnPosition = 0; for (int i = 0; i < row.Elements("col").Count(); i++) { var column = row.Elements("col").ElementAt(i); var cell = new GuideBodyLeftBlueTextCellFactory("td", column.Value, columnPosition); tableRow.ChildNodes.Add(cell); columnPosition++; } }
protected override void WriteInner(System.Xml.XmlWriter writer) { ChildNodes.Add(ExportNode); var scrollableTableContainer = new ComplexNode(); scrollableTableContainer.Classes.Add("table-responsive"); scrollableTableContainer.ChildNodes.Add(TableNode); ChildNodes.Add(scrollableTableContainer); base.WriteInner(writer); }
protected override void WriteInner(System.Xml.XmlWriter writer) { var tBody = new ComplexNode("tbody"); foreach (var rowData in Input) { CreateSingleRow(rowData, tBody); } ChildNodes.Add(GetHeader(Input.First())); ChildNodes.Add(tBody); base.WriteInner(writer); }
public List <string> VisitComplexNode(ComplexNode node, object input) { var result = new List <string>(); foreach (var childNode in node.Nodes) { childNode.Accept(this, input).ForEach(x => { if (!result.Contains(x)) { result.Add(x); } }); } return(result); }
protected override void WriteInner(System.Xml.XmlWriter writer) { var anchorContainer = new ComplexNode(); anchorContainer.Classes.Add("anchor"); var anchorPpt = CreateAchor(OverViewImage, OverViewFilePath, OverViewDownlaodText); var anchorPdf = CreateAchor(PannelChangeImage, PannelChangeFilePath, PannelChangeDownlaodText); anchorContainer.ChildNodes.Add(anchorPpt); anchorContainer.ChildNodes.Add(anchorPdf); ChildNodes.Add(anchorContainer); base.WriteInner(writer); }
protected override void WriteInner(System.Xml.XmlWriter writer) { var tBody = new ComplexNode("tbody"); foreach (var r in Input.Elements("row")) { CreateSingleRow(r, tBody); } ChildNodes.Add(GetHeader(Input.Element("row"))); ChildNodes.Add(tBody); Classes.Add(Class); base.WriteInner(writer); }
protected override void WriteInner(System.Xml.XmlWriter writer) { var container = new ComplexNode(); container.Classes.Add("image-container"); var img = new SimpleNode("img", string.Empty); img.Attributes.Add("src", _imagePath); img.Styles.Add("width", "100%"); container.ChildNodes.Add(img); ChildNodes.Add(container); base.WriteInner(writer); }
protected override void GenerateColumn(XElement row, ComplexNode tableRow) { int columnPosition = 0; for (int i = 0; i < row.Elements("col").Count() - 1; i++) { var column = row.Elements("col").ElementAt(i); if (i == 1) { var geoParent = row.Elements("col").ElementAt(i - 1); var countryClass = string.Empty; var text = row.Elements("col").ElementAt(i).Value; if (string.IsNullOrEmpty(text)) { countryClass = " cluster"; } else { countryClass = " country"; } var cell = new GuideBodyCellLeftGrayCountryFactory("td", column.Value, geoParent.Value, columnPosition + countryClass); tableRow.ChildNodes.Add(cell); columnPosition++; } if (i == 5) { var cell = new GuideBodyCellCrossBgGrayTextFactory("td", column.Value, columnPosition); tableRow.ChildNodes.Add(cell); columnPosition++; } else if (i == 2 || i == 3 || i == 4 || i == 5 || i == 6) { var cell = new GuideBodyCellLeftGrayFactory("td", column.Value, columnPosition); tableRow.ChildNodes.Add(cell); columnPosition++; } else if (i >= 7) { var cell = new GuideBodyCellCrossTextFactory("td", column.Value, columnPosition); tableRow.ChildNodes.Add(cell); columnPosition++; } } }
public ComplexNode Clone() { //Double it!! ComplexNode loop = this; while (loop != null) { ComplexNode loop_next = loop.Next; ComplexNode cn = new ComplexNode(loop.Data); loop.Next = cn; cn.Next = loop_next; loop = loop_next; } //Copy the sibling loop = this; while (loop != null) { ComplexNode loop_sibling = loop.Sibiling; if (loop_sibling != null) { loop.Next.Sibiling = loop_sibling.Next; } loop = loop.Next.Next; } //Split the Double Loop loop = this; ComplexNode head = loop.Next; while (loop != null) { ComplexNode loop_next = loop.Next.Next; if (loop_next == null) { break; } loop.Next.Next = loop_next.Next; loop.Next = loop_next; loop = loop_next; } loop.Next = null; return(head); }
private ComplexNode CreateAchor(string imagePath, string filePath, string text) { var anchor = new ComplexNode("a"); anchor.Attributes.Add("href", "FileDownload/DownloadFile?fileName=" + filePath); var img = new SimpleNode("img", string.Empty); img.Attributes.Add("src", @"Content/Images/help/" + imagePath); anchor.ChildNodes.Add(img); var span = new SimpleNode("span", text); anchor.ChildNodes.Add(span); return(anchor); }
// pitfalls: (i) remember to set the null pointer of the last node // (ii) not every node has a sibling public static ComplexNode clone(ComplexNode start) { if (start == null || start.next == null) { return(start); } // 1. copy every nodes with next pointer and value ComplexNode head = start; while (start != null) { ComplexNode copy = new ComplexNode(start.value, start.next); start.next = copy; start = copy.next; } // 2. set all the sibling pointers start = head; while (start != null) { ComplexNode copy = start.next; if (start.sibling != null) { copy.sibling = start.sibling.next; } start = copy.next; } // 3. seperate the whole list into two lists start = head; ComplexNode clone = null; while (start.next.next != null) { ComplexNode copy = start.next; if (clone == null) { clone = copy; } start.next = copy.next; copy.next = copy.next.next; start = start.next; } start.next = null; // set the pointer of last node return(clone); }
public ComplexNode Clone() { //Double it!! ComplexNode loop = this; while (loop != null) { ComplexNode loop_next = loop.Next; ComplexNode cn = new ComplexNode(loop.Data); loop.Next = cn; cn.Next = loop_next; loop = loop_next; } //Copy the sibling loop = this; while (loop != null) { ComplexNode loop_sibling = loop.Sibiling; if (loop_sibling != null) { loop.Next.Sibiling = loop_sibling.Next; } loop = loop.Next.Next; } //Split the Double Loop loop = this; ComplexNode head = loop.Next; while (loop != null) { ComplexNode loop_next = loop.Next.Next; if (loop_next == null) { break; } loop.Next.Next = loop_next.Next; loop.Next = loop_next; loop = loop_next; } loop.Next = null; return head; }
public static void printList(ComplexNode start) { ComplexNode head = start; while (start != null) { Console.Write(start.value + " "); start = start.next; } Console.WriteLine(); while (head != null) { if (head.sibling != null) { Console.WriteLine(head.value + " -> " + head.sibling.value); } head = head.next; } }
public ComplexNode FlattenLinkedList(ComplexNode node) { if (node == null) { return(node); } last = node; var next = node.next; node.next = FlattenLinkedList(node.down); if (next != null) { last.next = FlattenLinkedList(next); } return(node); }
protected override void GenerateColumn(XElement row, ComplexNode tableRow) { int columnPosition = 0; for (int i = 0; i < row.Elements("col").Count(); i++) { var column = row.Elements("col").ElementAt(i); if (i >= 0 && i <= 1) { var cell = new GuideBodyCellLeftGrayFactory("td", column.Value, columnPosition); tableRow.ChildNodes.Add(cell); columnPosition++; } else if (i >= 2) { var cell = new GuideBodyCellCrossTextFactory("td", column.Value, columnPosition); tableRow.ChildNodes.Add(cell); columnPosition++; } } }
protected override void GenerateColumn(UserViewModel row, ComplexNode tableRow) { var cell = new GuideBodyLeftBlueTextCellFactory("td", row.FirstName, 0); tableRow.ChildNodes.Add(cell); cell = new GuideBodyLeftBlueTextCellFactory("td", row.LastName, 1); tableRow.ChildNodes.Add(cell); cell = new GuideBodyLeftBlueTextCellFactory("td", row.Position, 2); tableRow.ChildNodes.Add(cell); cell = new GuideBodyLeftBlueTextCellFactory("td", row.Email, 3); tableRow.ChildNodes.Add(cell); cell = new GuideBodyLeftBlueTextCellFactory("td", row.Org, 4); tableRow.ChildNodes.Add(cell); cell = new GuideBodyLeftBlueTextCellFactory("td", row.GeoCode, 5); tableRow.ChildNodes.Add(cell); }
protected override NodeBase CreateInternal(string data) { var cell = new ComplexNode(_nodeName); var checkBox = new SimpleNode("input", "") { Attributes = new Dictionary <string, string>() { { "type", "checkbox" }, { "checked", "checked" }, { "series-name", data }, { "onClick", "customTable.ChartUpdate('" + ParamName + "')" } } }; if (!string.IsNullOrEmpty(UncheckedItem) && UncheckedItem.ToUpper().Contains(data.ToUpper())) { checkBox.Attributes.Remove("checked"); } cell.ChildNodes.Add(checkBox); return(cell); }
protected override NodeBase CreateInternal(object colValues) { string data = null; var values = colValues as List <string>; if (values == null || string.IsNullOrEmpty(values[0])) { return new SimpleNode("td", string.Empty) { Classes = new List <string>() { "col-" + colId.ToString() }, Attributes = new Dictionary <string, string>() { { "column-index", colId.ToString() } } } } ; if (TextFormat != null) { data = TextFormat.Format(values[0]); } var complexNode = new ComplexNode("td"); complexNode.Attributes.Add("column-index", colId.ToString()); complexNode.ChildNodes.Add(new SimpleNode("span", data)); complexNode.ChildNodes.Add(new SimpleNode("img", "") { Attributes = { { "src", "Content/Images/" + values[1] + ".gif" }, } }); return(complexNode); } }
public HoverHeaderTableFactory(string hoverItem, string periodType, string measureText) : base("th") { var companyNode = new SimpleNode("div", hoverItem.ToLower() == "all"?"Selected Market":hoverItem); companyNode.Classes.Add("snapshot-hover-compnay"); ChildNodes.Add(companyNode); var yearAndMeasureNode = new ComplexNode(); yearAndMeasureNode.Classes.Add("snapshot-hover-head"); //var yearNode = new SimpleNode("span", periodType); //yearNode.Classes.Add("snapshot-hover-year"); //yearAndMeasureNode.ChildNodes.Add(yearNode); var measureNode = new SimpleNode("div", ": " + periodType + " - " + measureText); measureNode.Classes.Add("snapshot-hover-measure"); ChildNodes.Add(measureNode); //ChildNodes.Add(yearAndMeasureNode); }
public override INode Create(object value) { var cell = new ComplexNode("td"); cell.Classes.Add("col-" + ColumnPosition); var values = value as List <string>; cell.ChildNodes.Add(GetNumeric(value)); if (value != null && values != null && values.Count > 1) { if (values[0] != "--") { cell.ChildNodes.Add(GetIndicator(value)); cell.Classes.Add("has-indicator"); } } AddHoverAction(cell); return(cell); }
public static void Test() { /* --------- | | | A - B - C - D - E | | | | | ----|---- | | | | ------------- */ ComplexNode E = new ComplexNode(5); ComplexNode D = new ComplexNode(4, E); ComplexNode C = new ComplexNode(3, D); ComplexNode B = new ComplexNode(2, C); ComplexNode A = new ComplexNode(1, B); A.sibling = C; D.sibling = B; B.sibling = E; printList(A); ComplexNode clonedList = clone(A); printList(clonedList); }
// pitfalls: (i) remember to set the null pointer of the last node // (ii) not every node has a sibling public static ComplexNode clone(ComplexNode start) { if (start == null || start.next == null) return start; // 1. copy every nodes with next pointer and value ComplexNode head = start; while (start != null) { ComplexNode copy = new ComplexNode(start.value, start.next); start.next = copy; start = copy.next; } // 2. set all the sibling pointers start = head; while (start != null) { ComplexNode copy = start.next; if (start.sibling != null) copy.sibling = start.sibling.next; start = copy.next; } // 3. seperate the whole list into two lists start = head; ComplexNode clone = null; while (start.next.next != null) { ComplexNode copy = start.next; if (clone == null) clone = copy; start.next = copy.next; copy.next = copy.next.next; start = start.next; } start.next = null; // set the pointer of last node return clone; }
public static void Test() { /* --------- | | A - B - C - D - E | | | | ----|---- | | | ------------- */ ComplexNode E = new ComplexNode(5); ComplexNode D = new ComplexNode(4, E); ComplexNode C = new ComplexNode(3, D); ComplexNode B = new ComplexNode(2, C); ComplexNode A = new ComplexNode(1, B); A.sibling = C; D.sibling = B; B.sibling = E; printList(A); ComplexNode clonedList = clone(A); printList(clonedList); }
protected virtual void AddHoverAction(ComplexNode complexNode) { ; }
public ComplexNode(int value, ComplexNode next) { this.value = value; this.next = next; }