protected internal TreeNode buildApplicationsTreeView() { if (this.applications != null && this.applications.Length > 0) { this.storage.OpenConnection(); this.itemsHierarchyTreeView.Nodes.Clear(); TreeNode root = new TreeNode("NetSqlAzMan", "NetSqlAzMan", this.getImageUrl("NetSqlAzMan_16x16.gif")); root.ToolTip = ".NET Sql Authorization Manager"; this.itemsHierarchyTreeView.Nodes.Add(root); TreeNode storeNode = new TreeNode(this.applications[0].Store.Name, this.applications[0].Store.Name, this.getImageUrl("Store_16x16.gif")); root.ChildNodes.Add(storeNode); root.Expand(); storeNode.Expand(); storeNode.ToolTip = this.applications[0].Store.Description; for (int i = 0; i < this.applications.Length; i++) { this.add(storeNode, this.applications[i]); storeNode.Expand(); } this.storage.CloseConnection(); root.Expand(); storeNode.Expand(); return root; } else { return null; } }
public void BindTreeView(IEnumerable<Opcion> optionList, TreeNode parentNode) { var opcions = optionList.Where(x => parentNode == null ? x.ParentID == 0 : x.ParentID == int.Parse(parentNode.Value)); if (_pagemode != BoPage.PageMode.View) { foreach (Opcion opcion in opcions) { var newNode = CreateTreeNode(opcion); if (parentNode == null) { TreeViewPalabrasClaveOpciones.Nodes.Add(newNode); } else { if (opcion.PalabrasClaveOpciones.Where(c => c.KeywordID == _idKeyWord).Count() > 0) { newNode.Checked = true; parentNode.Expand(); } parentNode.ChildNodes.Add(newNode); } BindTreeView(optionList, newNode); } } else { foreach (Opcion opcion in opcions) { if (ExistKeyWord(opcion)) { var newNode = CreateTreeNode(opcion); if (parentNode == null) { TreeViewPalabrasClaveOpciones.Nodes.Add(newNode); } else { if (opcion.PalabrasClaveOpciones.Where(c => c.KeywordID == _idKeyWord).Count() > 0) { newNode.Checked = true; parentNode.Expand(); } if (opcion.PalabrasClaveOpciones.Where(c => c.KeywordID == _idKeyWord).Count() > 0) { parentNode.ChildNodes.Add(newNode); } } BindTreeView(optionList, newNode); } } } }
protected internal void buildApplicationsTreeView() { this.application.Store.Storage.OpenConnection(); this.itemsHierarchyTreeView.Nodes.Clear(); TreeNode root = new TreeNode("NetSqlAzMan", "NetSqlAzMan", this.getImageUrl("NetSqlAzMan_16x16.gif")); root.ToolTip = ".NET Sql Authorization Manager"; this.itemsHierarchyTreeView.Nodes.Add(root); TreeNode storeNode = new TreeNode(this.application.Store.Name, this.application.Store.Name, this.getImageUrl("Store_16x16.gif")); root.ChildNodes.Add(storeNode); root.Expand(); storeNode.Expand(); storeNode.ToolTip = this.application.Store.Description; this.add(storeNode, this.application); storeNode.Expand(); this.application.Store.Storage.CloseConnection(); root.Expand(); storeNode.Expand(); }
private void LadoNorteNew(DataTable dtLadoNorte) { DataRow[] Rows = dtLadoNorte.Select("idSurco IS NULL"); // Get all parents nodes for (int i = 0; i < Rows.Length; i++) { System.Web.UI.WebControls.TreeNode root = new System.Web.UI.WebControls.TreeNode(Rows[i]["Seccion"].ToString(), Rows[i]["idSeccion"].ToString()); root.SelectAction = TreeNodeSelectAction.Expand; root.Expand(); CreateNode(root, dtLadoNorte); trPares.Nodes.Add(root); } }
/// <summary> /// 展开祖父节点 /// </summary> /// <param name="node"></param> public void ExplandParentNode(System.Web.UI.WebControls.TreeNode node) { if (node == null) { return; } while (node.Parent != null) { node = node.Parent; node.Expand(); } }
private void BindTreeViewControl(string idInvernadero) { try { tvInvernadero.Nodes.Clear(); trPares.Nodes.Clear(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@idInvernadero", idInvernadero); DataSet ds = dataaccess.executeStoreProcedureDataSet("procObtieneInvernaderoCostoxActividad", parameters); DataRow[] Rows = ds.Tables[1].Select("idSurco IS NULL"); // Get all parents nodes for (int i = 0; i < Rows.Length; i++) { System.Web.UI.WebControls.TreeNode root = new System.Web.UI.WebControls.TreeNode(Rows[i]["Seccion"].ToString(), Rows[i]["idSeccion"].ToString()); root.SelectAction = TreeNodeSelectAction.Expand; root.Expand(); CreateNode(root, ds.Tables[1]); tvInvernadero.Nodes.Add(root); } if (ds.Tables.Count > 0) { lblInvernadero.Text = ds.Tables[0].Rows[0]["Invernadero"].ToString(); if (((bool)ds.Tables[0].Rows[0]["pasilloMedio"])) { lblPasilloMedio.Text = "SI"; } else { lblPasilloMedio.Text = "NO"; } } if (ds.Tables.Count > 2) { lblNorte.Text = "NORTE"; LadoNorteNew(ds.Tables[2]); Session["dtLadoNorte"] = ds.Tables[2]; } else { lblNorte.Text = ""; } } catch (Exception Ex) { throw Ex; } }
/// <summary> /// Recursively checks for any nodes with a check and expands to that node. /// </summary> /// <param name="node"></param> /// <returns></returns> private bool RecursiveSelectedExpand(TreeNode node) { if (node.ChildNodes.Count == 0 && node.Checked) { return(true); } bool returnVal = false; foreach (TreeNode childNode in node.ChildNodes) { returnVal = (RecursiveSelectedExpand(childNode) || returnVal); } if (returnVal) { node.Expand(); } else { node.Collapse(); } return(returnVal); }
protected void Page_Load(object sender, EventArgs e) { WestgateEntities DatabaseContext = new WestgateEntities(); Repeater1.DataSource = (from row in DatabaseContext.Tags where row.ShowInTabs orderby row.OrderNumber select row).Take(7); Repeater1.DataBind(); if (IsPostBack == false) { TreeNode categoriesNode = new TreeNode("All"); categoriesNode.NavigateUrl = "~/Gallery.aspx"; categoriesNode.Expand(); List<Tag> listTags = (from t in DatabaseContext.Tags orderby t.Name select t).ToList(); foreach (Tag tag in listTags) { TreeNode catNode = new TreeNode(tag.Name, tag.TagId.ToString()); catNode.NavigateUrl = "~/Gallery.aspx?tagId=" + tag.TagId; catNode.CollapseAll(); categoriesNode.ChildNodes.Add(catNode); } tvStructure.Nodes.Add(categoriesNode); } }
protected void Page_Load(object sender, EventArgs e) { WestgateEntities db = new WestgateEntities(); if (IsPostBack == false) { TreeNode categoriesNode = new TreeNode("Tags"); categoriesNode.NavigateUrl = "~/Admin/TagsList.aspx"; categoriesNode.Expand(); List<Tag> listTags = (from t in db.Tags orderby t.Name select t).ToList(); foreach (Tag tag in listTags) { TreeNode catNode = new TreeNode(tag.Name,tag.TagId.ToString()); catNode.NavigateUrl = "~/Admin/EditTag.aspx?tagId=" + tag.TagId; catNode.CollapseAll(); categoriesNode.ChildNodes.Add(catNode); } tvStructure.Nodes.Add(categoriesNode); tvStructure.Nodes.Add(new TreeNode("Add New Image", "Add New Image", "", "~/Admin/AddImageNew.aspx", "")); tvStructure.Nodes.Add(new TreeNode("Gallery", "Gallery", "", "~/Admin/Gallery.aspx", "")); tvStructure.Nodes.Add(new TreeNode("Order Tags", "Order Tags", "", "~/Admin/OrderTags.aspx", "")); } }
void PopulateCategories() { SqlCommand sqlQuery = new SqlCommand( "Select Cat_ID, CatName from TB_Cat_Product"); DataSet resultSet; resultSet = RunQuery(sqlQuery); if (resultSet.Tables.Count > 0) { foreach (DataRow row in resultSet.Tables[0].Rows) { TreeNode NewNode = new TreeNode(row["CatName"].ToString(), row["Cat_ID"].ToString()); //NewNode.PopulateOnDemand = true; if (row["Cat_ID"].ToString().Equals(StrCatID) && !string.IsNullOrEmpty(StrCatID)) { NewNode.Expand(); } else { NewNode.Collapse(); } NewNode.SelectAction = TreeNodeSelectAction.Expand; PopulateSubCategories(NewNode); //node.ChildNodes.Add(NewNode); TreeView1.Nodes.Add(NewNode); } } }
/// <summary> Populates a tree view control with the hierarchical collection of volumes associated with the same title as a digital resource </summary> /// <param name="TreeView1"> Treeview control to populate with the associated volumes </param> protected internal void Build_Tree(TreeView TreeView1) { const int LINE_TO_LONG = 100; // Add the root node TreeNode rootNode = new TreeNode("<span id=\"sbkMviv_TableGroupTitle\">" + briefItem.Behaviors.GroupTitle + "</span>"); if (briefItem.Behaviors.GroupTitle.Length > LINE_TO_LONG) rootNode.Text = "<span id=\"sbkMviv_TableGroupTitle\">" + briefItem.Behaviors.GroupTitle.Substring(0, LINE_TO_LONG) + "...</span>"; rootNode.SelectAction = TreeNodeSelectAction.None; TreeView1.Nodes.Add(rootNode); // Is this a newspaper? bool newspaper = briefItem.Behaviors.GroupType.ToUpper() == "NEWSPAPER"; // Add the first layer of nodes // Hashtable nodeHash = new Hashtable(); string lastNodeText1 = String.Empty; string lastNodeText2 = String.Empty; string lastNodeText3 = String.Empty; string lastNodeText4 = String.Empty; TreeNode lastNode1 = null; TreeNode lastNode2 = null; TreeNode lastNode3 = null; TreeNode lastNode4 = null; TreeNode currentSelectedNode = null; // Compute the base redirect URL string current_vid = currentRequest.VID; currentRequest.VID = "<%VID%>"; string redirect_url = UrlWriterHelper.Redirect_URL(currentRequest, String.Empty); currentRequest.VID = current_vid; // Does this user have special rights on the item? bool specialRights = ((currentUser != null) && ((currentUser.Is_System_Admin) || (currentUser.Is_Internal_User) || (currentUser.Can_Edit_This_Item(briefItem.BibID, briefItem.Type, briefItem.Behaviors.Source_Institution_Aggregation, briefItem.Behaviors.Holding_Location_Aggregation, briefItem.Behaviors.Aggregation_Code_List)))); foreach (Item_Hierarchy_Details thisItem in allVolumes) { // Do not show PRIVATE items in this tree view int access_int = thisItem.IP_Restriction_Mask; bool dark = thisItem.Dark; if (dark) access_int = -1; if ((access_int >= 0) || (specialRights)) { // Set the access string and span name string access_string = String.Empty; string access_span_start = String.Empty; string access_span_end = String.Empty; if (dark) { access_span_start = "<span class=\"sbkMviv_TreeDarkNode\">"; access_string = " ( dark )"; access_span_end = "</span>"; } else { if (access_int < 0) { access_span_start = "<span class=\"sbkMviv_TreePrivateNode\">"; access_string = " ( private )"; access_span_end = "</span>"; } else if (access_int > 0) { access_span_start = "<span class=\"sbkMviv_TreeRestrictedNode\">"; access_string = " ( some restrictions apply )"; access_span_end = "</span>"; } } // Determine the text for all the levels (and nodes) string level1_text = UI_ApplicationCache_Gateway.Translation.Get_Translation(thisItem.Level1_Text, currentRequest.Language); string level2_text = String.Empty; string level3_text = String.Empty; string level4_text = String.Empty; string level5_text = String.Empty; string title = thisItem.Title; if (level1_text.Length == 0) { TreeNode singleNode = new TreeNode(access_span_start + title + access_string + access_span_end); if (title.Length > LINE_TO_LONG) { singleNode.ToolTip = title; title = title.Substring(0, LINE_TO_LONG) + "..."; singleNode.Text = access_span_start + title + access_string + access_span_end; } if (thisItem.ItemID == briefItem.Web.ItemID) { currentSelectedNode = singleNode; singleNode.SelectAction = TreeNodeSelectAction.None; singleNode.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + singleNode.Text + "</span>"; } else { singleNode.NavigateUrl = redirect_url.Replace("<%VID%>", thisItem.VID); } rootNode.ChildNodes.Add(singleNode); } // Look at the first level if (level1_text.Length > 0) { level2_text = UI_ApplicationCache_Gateway.Translation.Get_Translation(thisItem.Level2_Text, currentRequest.Language); if (level2_text.Length == 0) { TreeNode singleNode1 = new TreeNode(access_span_start + level1_text + access_string + access_span_end); if (thisItem.Level1_Text.Length > LINE_TO_LONG) { singleNode1.ToolTip = level1_text; level1_text = level1_text.Substring(0, LINE_TO_LONG) + "..."; singleNode1.Text = access_span_start + level1_text + access_string + access_span_end; } if (thisItem.ItemID == briefItem.Web.ItemID) { currentSelectedNode = singleNode1; singleNode1.SelectAction = TreeNodeSelectAction.None; singleNode1.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + singleNode1.Text + "</span>"; } else { singleNode1.NavigateUrl = redirect_url.Replace("<%VID%>", thisItem.VID); } rootNode.ChildNodes.Add(singleNode1); } else { if ((lastNode1 == null) || (lastNodeText1 != level1_text.ToUpper())) { // Since this is the TOP level, let's look down and see if there are any non-private, non-dark items string nontranslated = thisItem.Level1_Text; bool allPrivate = allVolumes.All(ThisVolume => (thisItem.IP_Restriction_Mask < 0) || (dark) || (String.Compare(ThisVolume.Level1_Text, nontranslated, StringComparison.OrdinalIgnoreCase) != 0) || (thisItem.Level1_Index != ThisVolume.Level1_Index)); lastNode1 = new TreeNode(level1_text); if (level1_text.Length > LINE_TO_LONG) { lastNode1.ToolTip = lastNode1.Text; level1_text = level1_text.Substring(0, LINE_TO_LONG) + "..."; lastNode1.Text = level1_text; } if (allPrivate) { lastNode1.Text = "<span class=\"sbkMviv_TreePrivateNode\">" + level1_text + " ( all private or dark )</span>"; } lastNode1.SelectAction = TreeNodeSelectAction.None; lastNodeText1 = level1_text.ToUpper(); rootNode.ChildNodes.Add(lastNode1); lastNode2 = null; lastNodeText2 = String.Empty; lastNode3 = null; lastNodeText3 = String.Empty; lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the second level if ((level2_text.Length > 0) && (lastNode1 != null)) { level3_text = UI_ApplicationCache_Gateway.Translation.Get_Translation(thisItem.Level3_Text, currentRequest.Language); if (level3_text.Length == 0) { TreeNode singleNode2 = new TreeNode(access_span_start + level2_text + access_string + access_span_end); if (level2_text.Length > LINE_TO_LONG) { singleNode2.ToolTip = level2_text; level2_text = level2_text.Substring(0, LINE_TO_LONG) + "..."; singleNode2.Text = access_span_start + level2_text + access_string + access_span_end; } if (thisItem.ItemID == briefItem.Web.ItemID) { currentSelectedNode = singleNode2; singleNode2.SelectAction = TreeNodeSelectAction.None; singleNode2.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level2_text + access_string + "</span>"; } else { singleNode2.NavigateUrl = redirect_url.Replace("<%VID%>", thisItem.VID); } lastNode1.ChildNodes.Add(singleNode2); } else { if ((lastNode2 == null) || (lastNodeText2 != level2_text.ToUpper())) { lastNode2 = new TreeNode(level2_text); if (level2_text.Length > LINE_TO_LONG) { lastNode2.ToolTip = lastNode2.Text; lastNode2.Text = level2_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode2.SelectAction = TreeNodeSelectAction.None; lastNodeText2 = level2_text.ToUpper(); lastNode1.ChildNodes.Add(lastNode2); lastNode3 = null; lastNodeText3 = String.Empty; lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the third level if ((level3_text.Length > 0) && (lastNode2 != null)) { level4_text = UI_ApplicationCache_Gateway.Translation.Get_Translation(thisItem.Level4_Text, currentRequest.Language); if (level4_text.Length == 0) { TreeNode singleNode3 = new TreeNode(access_span_start + level3_text + access_string + access_span_end); if (level3_text.Length > LINE_TO_LONG) { singleNode3.ToolTip = level3_text; level3_text = level3_text.Substring(0, LINE_TO_LONG) + "..."; singleNode3.Text = access_span_start + level3_text + access_string + access_span_end; } if (newspaper) { level3_text = access_span_start + level2_text + " " + level3_text + ", " + level1_text + access_string + access_span_end; singleNode3.Text = level3_text; } if (thisItem.ItemID == briefItem.Web.ItemID) { currentSelectedNode = singleNode3; singleNode3.SelectAction = TreeNodeSelectAction.None; singleNode3.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level3_text + access_string + "</span>"; } else { singleNode3.NavigateUrl = redirect_url.Replace("<%VID%>", thisItem.VID); } lastNode2.ChildNodes.Add(singleNode3); } else { if ((lastNode3 == null) || (lastNodeText3 != level3_text.ToUpper())) { lastNode3 = new TreeNode(level3_text); if (level3_text.Length > LINE_TO_LONG) { lastNode3.ToolTip = lastNode3.Text; lastNode3.Text = level3_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode3.SelectAction = TreeNodeSelectAction.None; lastNodeText3 = level3_text.ToUpper(); lastNode2.ChildNodes.Add(lastNode3); lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the fourth level if ((level4_text.Length > 0) && (lastNode3 != null)) { UI_ApplicationCache_Gateway.Translation.Get_Translation(thisItem.Level5_Text, currentRequest.Language); if (level5_text.Length == 0) { TreeNode singleNode4 = new TreeNode(access_span_start + level4_text + access_string + access_span_end); if (level4_text.Length > LINE_TO_LONG) { singleNode4.ToolTip = level4_text; level4_text = level4_text.Substring(0, LINE_TO_LONG) + "..."; singleNode4.Text = access_span_start + level4_text + access_string + access_span_end; } if (thisItem.ItemID == briefItem.Web.ItemID) { currentSelectedNode = singleNode4; singleNode4.SelectAction = TreeNodeSelectAction.None; singleNode4.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level4_text + access_string + "</span>"; } else { singleNode4.NavigateUrl = redirect_url.Replace("<%VID%>", thisItem.VID); } lastNode3.ChildNodes.Add(singleNode4); } else { if ((lastNode4 == null) || (lastNodeText4 != level4_text.ToUpper())) { lastNode4 = new TreeNode(level4_text); if (level4_text.Length > LINE_TO_LONG) { lastNode4.ToolTip = lastNode4.Text; lastNode4.Text = level4_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode4.SelectAction = TreeNodeSelectAction.None; lastNodeText4 = level4_text.ToUpper(); lastNode3.ChildNodes.Add(lastNode4); } } } // Look at the fifth level if ((level5_text.Length > 0) && (lastNode4 != null)) { TreeNode lastNode5 = new TreeNode(access_span_start + level5_text + access_string + access_span_end); if (level5_text.Length > LINE_TO_LONG) { lastNode5.ToolTip = level5_text; level5_text = level5_text.Substring(0, LINE_TO_LONG) + "..."; lastNode5.Text = access_span_start + level5_text + access_string + access_span_end; } if (thisItem.ItemID == briefItem.Web.ItemID) { currentSelectedNode = lastNode5; lastNode5.SelectAction = TreeNodeSelectAction.None; lastNode5.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level5_text + access_string + "</span>"; } else { lastNode5.NavigateUrl = redirect_url.Replace("<%VID%>", thisItem.VID); } lastNode4.ChildNodes.Add(lastNode5); } } } rootNode.CollapseAll(); rootNode.Expand(); if (currentSelectedNode == null) return; while ((currentSelectedNode != rootNode) && (currentSelectedNode != null)) { currentSelectedNode.Expand(); currentSelectedNode = currentSelectedNode.Parent; } }
private void ShowSiteCollection(IEnumerable<SPSite> sites) { foreach (SPSite site in sites) { using (site) { var rootWeb = site.RootWeb; var node = new TreeNode(rootWeb.Title, rootWeb.Url); if (rootWeb.Url == currentWeb.Url) { node.Selected = true; } if (rootWeb.Webs.Count > 0) { ShowWebCollection( rootWeb.Webs, (title, url, rootNode) => { var childNode = new TreeNode(title, new Uri(new Uri(site.Url), url).ToString()); if (currentWeb.Url.Contains(url)) { childNode.Selected = true; childNode.Expand(); } rootNode.ChildNodes.Add(childNode); return childNode; }, node); } siteCollectionTree.Nodes.Add(node); } } }
private void add(TreeNode parent, IAzManApplication app) { TreeNode node = new TreeNode(app.Name, app.Name, this.getImageUrl("Application_16x16.gif")); node.ToolTip = app.Description; parent.ChildNodes.Add(node); node.Expand(); foreach (IAzManItem item in app.Items.Values) { if (item.ItemType == ItemType.Role) { if (item.ItemsWhereIAmAMember.Count == 0) this.AddRole(node, item, node); } } foreach (IAzManItem item in app.Items.Values) { if (item.ItemType == ItemType.Task) { if (item.ItemsWhereIAmAMember.Count == 0) this.AddTask(node, item, node); } } if (app.Store.Storage.Mode == NetSqlAzManMode.Developer) { foreach (IAzManItem item in app.Items.Values) { if (item.ItemType == ItemType.Operation) { if (item.ItemsWhereIAmAMember.Count == 0) this.AddOperation(node, item, node); } } } node.Collapse(); }
/// <summary> Add controls directly to the form in the main control area placeholder </summary> /// <param name="MainPlaceHolder"> Main place holder to which all main controls are added </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> The <see cref="PagedResults_HtmlSubwriter"/> class is instantiated and adds controls to the placeholder here </remarks> public override void Add_Controls(PlaceHolder MainPlaceHolder, Custom_Tracer Tracer) { Tracer.Add_Trace("Folder_Mgmt_MySobekViewer.Add_Controls", String.Empty); // If this is submitted items, don't show the folders string redirect_url = String.Empty; if ( properFolderName != "Submitted Items") { // Determine the redirect RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "XXXXXXXXXXXXXXXXXX"; Result_Display_Type_Enum currentDisplayType = RequestSpecificValues.Current_Mode.Result_Display_Type; RequestSpecificValues.Current_Mode.Result_Display_Type = Result_Display_Type_Enum.Bookshelf; redirect_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Saved_Searches; string saved_search_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; RequestSpecificValues.Current_Mode.Home_Type = Home_Type_Enum.Personalized; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; string personalized_home = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Folder_Management; RequestSpecificValues.Current_Mode.My_Sobek_SubMode = properFolderName; RequestSpecificValues.Current_Mode.Result_Display_Type = currentDisplayType; // Build the tree view object and tree view nodes now TreeView treeView1 = new TreeView { CssClass = "tree", EnableClientScript = true, PopulateNodesFromClient = false, ShowLines = false }; treeView1.NodeStyle.NodeSpacing = new Unit(2); treeView1.NodeStyle.CssClass = "TreeNode"; // Add the root my bookshelves node TreeNode rootNode = new TreeNode { Text = " <a title=\"Manage my library\" href=\"" + redirect_url.Replace("XXXXXXXXXXXXXXXXXX", String.Empty) + "\">My Library (Manage my bookshelves)</a>", ImageUrl = Static_Resources_Gateway.Bookshelf_Img, SelectAction = TreeNodeSelectAction.None }; treeView1.Nodes.Add(rootNode); // Add the personalized home page TreeNode homeNode = new TreeNode { Text = " <a title=\"View my collections home page\" href=\"" + personalized_home + "\">My Collections Home</a>", SelectAction = TreeNodeSelectAction.None, ImageUrl = Static_Resources_Gateway.Home_Folder_Gif }; rootNode.ChildNodes.Add(homeNode); // Add the saved searches node TreeNode savedSearchesNode = new TreeNode { Text =" <a title=\"View my saved searches\" href=\"" + saved_search_url + "\">My Saved Searches</a>", SelectAction = TreeNodeSelectAction.None, ImageUrl = Static_Resources_Gateway.Saved_Searches_Img }; rootNode.ChildNodes.Add(savedSearchesNode); // StringBuilder literalBuilder = new StringBuilder(); List<TreeNode> selectedNodes = new List<TreeNode>(); foreach (User_Folder thisFolder in RequestSpecificValues.Current_User.Folders) { if (thisFolder.Folder_Name != "Submitted Items") { TreeNode folderNode = new TreeNode { Text =" <a href=\"" + redirect_url.Replace("XXXXXXXXXXXXXXXXXX", thisFolder.Folder_Name_Encoded) + "\">" + thisFolder.Folder_Name + "</a>" }; if (thisFolder.Folder_Name == properFolderName) { selectedNodes.Add(folderNode); if (thisFolder.IsPublic) { folderNode.ImageUrl = Static_Resources_Gateway.Open_Folder_Public_Jpg; folderNode.ImageToolTip = "Public folder"; } else { folderNode.ImageUrl = Static_Resources_Gateway.Open_Folder_Jpg; } folderNode.Text = " <span class=\"Selected_TreeNode_Text\">" + thisFolder.Folder_Name + "</span>"; folderNode.SelectAction = TreeNodeSelectAction.None; } else { if (thisFolder.IsPublic) { folderNode.ImageUrl = Static_Resources_Gateway.Closed_Folder_Public_Jpg; folderNode.ImageToolTip = "Public folder"; } else { folderNode.ImageUrl = Static_Resources_Gateway.Closed_Folder_Jpg; } folderNode.Text = " <a href=\"" + redirect_url.Replace("XXXXXXXXXXXXXXXXXX", thisFolder.Folder_Name_Encoded) + "\">" + thisFolder.Folder_Name + "</a>"; } rootNode.ChildNodes.Add(folderNode); // Add all the children nodes as well add_children_nodes(folderNode, thisFolder, properFolderName, redirect_url, selectedNodes); } } // Collapse the treeview treeView1.CollapseAll(); if (selectedNodes.Count > 0) { TreeNode selectedNodeExpander = selectedNodes[0]; while (selectedNodeExpander.Parent != null) { (selectedNodeExpander.Parent).Expand(); selectedNodeExpander = selectedNodeExpander.Parent; } } else { rootNode.Expand(); } MainPlaceHolder.Controls.Add(treeView1); } if (RequestSpecificValues.Current_Mode.My_Sobek_SubMode.Length > 0) { if ( RequestSpecificValues.Results_Statistics.Total_Titles == 0) { Literal literal = new Literal(); string folder_name = RequestSpecificValues.Current_User.Folder_Name(RequestSpecificValues.Current_Mode.My_Sobek_SubMode); RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; if (folder_name.Length == 0) { UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } if (properFolderName != "Submitted Items") literal.Text = "<br /><br /><h1>" + folder_name + "</h1><br /><br /><div class=\"SobekHomeText\" ><center><b>This bookshelf is currently empty</b></center><br /><br /><br /></div></div>"; else literal.Text = "<h1>" + folder_name + "</h1><br /><br /><div class=\"SobekHomeText\" ><center><b>This bookshelf is currently empty</b></center><br /><br /><br /></div></div>"; MainPlaceHolder.Controls.Add(literal); } else { writeResult = new PagedResults_HtmlSubwriter(RequestSpecificValues, RequestSpecificValues.Results_Statistics, RequestSpecificValues.Paged_Results) { Browse_Title = properFolderName, Outer_Form_Name = "itemNavForm" }; if (properFolderName != "Submitted Items") writeResult.Include_Bookshelf_View = true; // Add some space and then the view type selection box StringBuilder view_type_selection_builder = new StringBuilder( 2000); if (properFolderName != "Submitted Items") view_type_selection_builder.AppendLine("<br /><br />"); StringWriter writer = new StringWriter(view_type_selection_builder); writeResult.Write_HTML(writer, Tracer); Literal view_type_selection_literal = new Literal {Text = view_type_selection_builder.ToString()}; MainPlaceHolder.Controls.Add(view_type_selection_literal); // Now, add the results controls as well writeResult.Add_Controls(MainPlaceHolder, Tracer); // Close the div Literal final_literal = new Literal {Text = "<br />\n"}; MainPlaceHolder.Controls.Add(final_literal); } //if (( pagedResults != null ) && ( pagedResults.Count > 0)) //{ // Literal literal = new Literal(); // literal.Text = "<div class=\"sbkPrsw_ResultsNavBar\">" + Environment.NewLine + " " + writeResult.Buttons + Environment.NewLine + " " + writeResult.Showing_Text + Environment.NewLine + "</div>" + Environment.NewLine + "<br />" + Environment.NewLine; // MainPlaceHolder.Controls.Add(literal); //} } else { // Add the folder management piece here StringBuilder bookshelfManageBuilder = new StringBuilder(); bookshelfManageBuilder.AppendLine("<br /><br />\n<h1>Manage My Bookshelves</h1>\n<div class=\"SobekHomeText\" >"); bookshelfManageBuilder.AppendLine(" <blockquote>"); bookshelfManageBuilder.AppendLine(" <table width=\"630px\">"); bookshelfManageBuilder.AppendLine(" <tr valign=\"middle\">"); bookshelfManageBuilder.AppendLine(" <td align=\"left\" width=\"30px\"><a href=\"?\" id=\"new_bookshelf_link\" name=\"new_bookshelf_link\" onclick=\"return open_new_bookshelf_folder();\" title=\"Click to add a new bookshelf\" ><img title=\"Click to add a new bookshelf\" src=\"" + Static_Resources_Gateway.New_Folder_Jpg + "\" /></a><td>"); bookshelfManageBuilder.AppendLine(" <td align=\"left\"><a href=\"?\" id=\"new_bookshelf_link\" name=\"new_bookshelf_link\" onclick=\"return open_new_bookshelf_folder();\" title=\"Click to add a new bookshelf\" >Add New Bookshelf</a><td>"); bookshelfManageBuilder.AppendLine(" <td align=\"right\" width=\"40px\"><a href=\"?\" id=\"refresh_bookshelf_link\" name=\"refresh_bookshelf_link\" onclick=\"return refresh_bookshelves();\" title=\"Refresh bookshelf list\" ><img title=\"Refresh bookshelf list\" src=\"" + Static_Resources_Gateway.Refresh_Folder_Jpg + "\" /></a><td>"); bookshelfManageBuilder.AppendLine(" <td align=\"left\" width=\"150px\"><a href=\"?\" id=\"refresh_bookshelf_link\" name=\"refresh_bookshelf_link\" onclick=\"return refresh_bookshelves();\" title=\"Refresh bookshelf list\" >Refresh Bookshelves</a><td>"); bookshelfManageBuilder.AppendLine(" </tr>"); bookshelfManageBuilder.AppendLine(" </table>"); bookshelfManageBuilder.AppendLine(" <br /><br />"); bookshelfManageBuilder.AppendLine(" <table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">"); bookshelfManageBuilder.AppendLine(" <tr align=\"left\" bgcolor=\"#0022a7\" >"); bookshelfManageBuilder.AppendLine(" <th width=\"210px\" align=\"left\"><span style=\"color: White\"> ACTIONS</span></th>"); bookshelfManageBuilder.AppendLine(" <th width=\"40px\" align=\"left\"> </th>"); bookshelfManageBuilder.AppendLine(" <th width=\"380px\" align=\"left\"><span style=\"color: White\">BOOKSHELF NAME</span></th>"); bookshelfManageBuilder.AppendLine(" </tr>"); bookshelfManageBuilder.AppendLine(" <tr><td bgcolor=\"#e7e7e7\" colspan=\"3\"></td></tr>"); // Write the data for each interface int folder_number = 1; foreach ( User_Folder thisFolder in RequestSpecificValues.Current_User.All_Folders ) { if (thisFolder.Folder_Name != "Submitted Items") { // Build the action links bookshelfManageBuilder.AppendLine(" <tr align=\"left\" valign=\"center\" >"); bookshelfManageBuilder.Append(" <td class=\"SobekFolderActionLink\" >( "); if (thisFolder.Child_Count == 0) { if (RequestSpecificValues.Current_User.All_Folders.Count == 1) { bookshelfManageBuilder.Append("<a title=\"Click to delete this bookshelf\" id=\"DELETE_" + folder_number + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"alert('You cannot delete your last bookshelf');return false;\">delete</a> | "); } else { bookshelfManageBuilder.Append("<a title=\"Click to delete this bookshelf\" id=\"DELETE_" + folder_number + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return delete_folder('" + thisFolder.Folder_ID + "');\">delete</a> | "); } } else { bookshelfManageBuilder.Append("<a title=\"Click to delete this bookshelf\" id=\"DELETE_" + folder_number + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"alert('You cannot delete bookshelves which contain other bookshelves');return false;\">delete</a> | "); } if (thisFolder.IsPublic) { bookshelfManageBuilder.Append("<a title=\"Make this bookshelf private\" id=\"PUBLIC_" + folder_number + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return change_folder_visibility('" + thisFolder.Folder_Name_Encoded + "', 'private');\">make private</a> | "); } else { bookshelfManageBuilder.Append("<a title=\"Make this bookshelf public\" id=\"PUBLIC_" + folder_number + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return change_folder_visibility('" + thisFolder.Folder_Name_Encoded + "', 'public');\">make public</a> | "); } bookshelfManageBuilder.AppendLine("<a title=\"Click to manage this bookshelf\" href=\"" + redirect_url.Replace("XXXXXXXXXXXXXXXXXX", thisFolder.Folder_Name_Encoded) + "\">manage</a> )</td>"); if (thisFolder.IsPublic) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Public_Folder; RequestSpecificValues.Current_Mode.FolderID = thisFolder.Folder_ID; bookshelfManageBuilder.AppendLine(" <td><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\"><img title=\"Public folder\" src=\"" + Static_Resources_Gateway.Closed_Folder_Public_Jpg + "\" /><a/></td>"); bookshelfManageBuilder.AppendLine(" <td><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + thisFolder.Folder_Name + "</a></td>"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; } else { bookshelfManageBuilder.AppendLine(" <td><img title=\"Private folder\" src=\"" + Static_Resources_Gateway.Closed_Folder_Jpg + "\" /></td>"); bookshelfManageBuilder.AppendLine(" <td>" + thisFolder.Folder_Name + "</td>"); } bookshelfManageBuilder.AppendLine(" </tr>"); bookshelfManageBuilder.AppendLine(" <tr><td bgcolor=\"#e7e7e7\" colspan=\"3\"></td></tr>"); // Increment the folder number folder_number++; } } bookshelfManageBuilder.AppendLine(" </table>"); bookshelfManageBuilder.AppendLine(" </blockquote>"); bookshelfManageBuilder.AppendLine("</div>"); // Add this as a literal Literal mgmtLiteral = new Literal {Text = bookshelfManageBuilder.ToString()}; MainPlaceHolder.Controls.Add(mgmtLiteral); } }
private TreeNode[] recurseSOATree(SOA soa) { string strCPU = null; string strWCF = null; string strASPNET = null; if (soa.ConnectedSOAs == null || soa.ConnectedSOAs.Count == 0) return null; TreeNode[] returnNodes = new TreeNode[soa.ConnectedSOAs.Count]; for (int i = 0; i < soa.ConnectedSOAs.Count; i++) { int imageIndex = 0; if (soa.ConnectedSOAs[i].Status.Equals(ConfigSettings.MESSAGE_CIRCULAR_REF_TERMINAL)) imageIndex = 3; else if (soa.ConnectedSOAs[i].Status.Equals(ConfigSettings.MESSAGE_OFFLINE)) imageIndex = 1; string rootName = "<span><Font color='#84BDEC'>" + soa.ConnectedSOAs[i].SOAName + "</font></span>"; TreeNode root = new TreeNode(rootName, imageIndex.ToString(), imageList[imageIndex]); root.ToolTip = "Connected Service Domain"; root.Expand(); imageIndex = 0; int offset = 0; string prefix = ""; string deployment = ""; string display=""; if (soa.ConnectedSOAs[i].MyVirtualHost != null) { if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes != null && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes.Count > 0 && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0] != null) { if (soa.ConnectedSOAs[i].MyVirtualHost.Status == ConfigSettings.MESSAGE_OFFLINE) offset = 0; else { if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0].RuntimePlatform!=null && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0].RuntimePlatform.ToLower().Contains("azure")) { offset = 1; prefix = "Azure Platform Cloud Deployed "; } else if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0].RuntimePlatform != null && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0].RuntimePlatform.ToLower().Contains("hyper")) { offset = 2; prefix = "On-premise Deployed (Hyper-V) "; } else { offset = 0; prefix = "On-premise Deployed "; } } } if (soa.ConnectedSOAs[i].MyVirtualHost.Status == ConfigSettings.MESSAGE_ONLINE) imageIndex = 4 + offset; else if (soa.ConnectedSOAs[i].MyVirtualHost.Status == ConfigSettings.MESSAGE_OFFLINE) imageIndex = 7 + offset; else if (soa.ConnectedSOAs[i].MyVirtualHost.Status == ConfigSettings.MESSAGE_SOME_NODES_DOWN) imageIndex = 10 + offset; TreeNode myVHost = new TreeNode(prefix + soa.ConnectedSOAs[i].MyVirtualHost.VHostName, imageIndex.ToString(), imageList[imageIndex]); myVHost.Expand(); TreeNode[] clusterNodes = new TreeNode[soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes.Count]; for (int h = 0; h < soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes.Count; h++) { TreeNode primaryEPs = new TreeNode("", "23", imageList[23]); primaryEPs.ToolTip = "Primary Endpoints are those defined by the business application developer to service business requests via their custom business logic."; primaryEPs.Collapse(); TreeNode configEPs = new TreeNode("", "22", imageList[22]); configEPs.ToolTip = "Configuration Service Endpoints are infrastructure endpoints available for the Configuration Service itself, for example an endpoint to which ConfigWeb connects."; configEPs.Collapse(); // TreeNode dcEPs = new TreeNode("", "24", imageList[24]); // dcEPs.Collapse(); TreeNode[] endPointNodesPrimary = new TreeNode[soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints.Count]; TreeNode[] endPointNodesConfig = new TreeNode[soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints.Count]; // TreeNode[] endPointNodesDC = new TreeNode[soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].DCServiceListenEndpoints.Count]; for (int j = 0; j < soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints.Count; j++) { string NAT = ""; string NAT2 = ""; int endPointImageIndex = 0; switch (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints[j].Status) { case ConfigSettings.MESSAGE_ONLINE: { endPointImageIndex = 25; break; } case ConfigSettings.MESSAGE_OFFLINE: { endPointImageIndex = 26; break; } case ConfigSettings.MESSAGE_UNKNOWN: { endPointImageIndex = 27; break; } } if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints[j].LoadBalanceType.Equals(1)) { NAT = "<span style=\"color:#FFFFFF\"> --> {" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints[j].LoadBalanceAddress + "}</span>"; NAT2 = "<span style=\"color:#FFFFFF\"> --> {NAT Load-Balanced}</span>"; } TreeNode endpointnode = null; if (CheckBoxEndpointDetail.Checked) { endpointnode = new TreeNode("<span style=\"color:#848483;\">" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints[j].RemoteAddress + "</span>" + NAT, endPointImageIndex.ToString(), imageList[endPointImageIndex]); } else { endpointnode = new TreeNode("<span style=\"color:#848483;\">" +soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints[j].ServiceFriendlyName + "</span>" + NAT2, endPointImageIndex.ToString(), imageList[endPointImageIndex]); } endpointnode.ToolTip = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints[j].Exception; endPointNodesPrimary[j] = endpointnode; } for (int j = 0; j < soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints.Count; j++) { string NAT = ""; string NAT2 = ""; int endPointImageIndex = 0; switch (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints[j].Status) { case ConfigSettings.MESSAGE_ONLINE: { endPointImageIndex = 25; break; } case ConfigSettings.MESSAGE_OFFLINE: { endPointImageIndex = 26; break; } case ConfigSettings.MESSAGE_UNKNOWN: { endPointImageIndex = 27; break; } } if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints[j].LoadBalanceType.Equals(1)) { NAT = "<span style=\"color:#FFFFFF\"> --> {" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints[j].LoadBalanceAddress + "}</span>"; NAT2 = "<span style=\"color:#FFFFFF\"> --> {NAT Load-Balanced}</span>"; } TreeNode endpointnode = null; if (CheckBoxEndpointDetail.Checked) { endpointnode = new TreeNode("<span style=\"color:#848483;\">" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints[j].RemoteAddress + "</span>" + NAT, endPointImageIndex.ToString(), imageList[endPointImageIndex]); } else { endpointnode = new TreeNode("<span style=\"color:#848483;\">" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints[j].ServiceFriendlyName + "</span>" + NAT2, endPointImageIndex.ToString(), imageList[endPointImageIndex]); } endpointnode.ToolTip = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ConfigServiceListenEndpoints[j].Exception; endPointNodesConfig[j] = endpointnode; } /* for (int j = 0; j < soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].DCServiceListenEndpoints.Count; j++) { int endPointImageIndex = 0; switch (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].DCServiceListenEndpoints[j].Status) { case ConfigSettings.MESSAGE_ONLINE: { endPointImageIndex = 25; break; } case ConfigSettings.MESSAGE_OFFLINE: { endPointImageIndex = 26; break; } case ConfigSettings.MESSAGE_UNKNOWN: { endPointImageIndex = 27; break; } } TreeNode endpointnode = null; if (CheckBoxEndpointDetail.Checked) { endpointnode = new TreeNode("<span style=\"color:#848483;\">"+ soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].DCServiceListenEndpoints[j].RemoteAddress+ "</span>", endPointImageIndex.ToString(), imageList[endPointImageIndex]); } else { endpointnode = new TreeNode("<span style=\"color:#848483;\">" +soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].DCServiceListenEndpoints[j].ServiceFriendlyName + "</span>", endPointImageIndex.ToString(), imageList[endPointImageIndex]); } endpointnode.ToolTip = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].DCServiceListenEndpoints[j].Exception; endPointNodesDC[j] = endpointnode; } for (int k = 0; k < endPointNodesDC.Length; k++) { dcEPs.ChildNodes.Add(endPointNodesDC[k]); } * */ for (int k = 0; k < endPointNodesConfig.Length; k++) { configEPs.ChildNodes.Add(endPointNodesConfig[k]); } for (int k = 0; k < endPointNodesPrimary.Length; k++) { primaryEPs.ChildNodes.Add(endPointNodesPrimary[k]); } int nodeimageIndex = 0; offset = 0; if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].RuntimePlatform != null) { if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].RuntimePlatform.ToLower().Contains("azure")) { offset = 1; deployment = "Windows Azure"; } else if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].RuntimePlatform.ToLower().Contains("hyper")) { offset = 2; deployment = "On-Premise/Private Cloud (Hyper-V)"; } else { offset = 0; deployment = "On-Premise/Private Cloud"; } } else { offset = 0; } switch (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].Status) { case ConfigSettings.MESSAGE_ONLINE: { nodeimageIndex = 13 + offset; break; } case ConfigSettings.MESSAGE_OFFLINE: { nodeimageIndex = 16 + offset; break; } case ConfigSettings.MESSAGE_UNKNOWN: { nodeimageIndex = 19 + offset; break; } case ConfigSettings.MESSAGE_SOME_NODES_DOWN: { nodeimageIndex = 50 + offset; break; } } TreeNode node = null; string vhostname = null; string azureRoleInstanceID = ""; if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].AzureRoleInstanceID!=null && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].AzureRoleInstanceID!="") azureRoleInstanceID = "<span style=\"font-size:.85em;\"> {" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].AzureRoleInstanceID + "}</span>"; if (CheckBoxEndpointDetail.Checked) { vhostname = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].Address + azureRoleInstanceID; } else { vhostname = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].NodeServiceName + azureRoleInstanceID; } if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].CPU != -1f) strCPU = System.Math.Round(soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].CPU).ToString(); else strCPU = "*"; if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ASPNETReqPerSec != -1f) strASPNET = System.Math.Round(soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].ASPNETReqPerSec).ToString(); else strASPNET = "*"; if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].WCFReqPerSec != -1f) strWCF = System.Math.Round(soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].WCFReqPerSec).ToString(); else strWCF = "*"; string runtime; if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].OSVersionString == null) runtime = ""; else runtime = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].RuntimePlatform + ": OS v " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].OSVersionString; if (CheckBoxNoDetail.Checked) { display = "<span style=\"padding-left:10px;color:#848483;\">" + vhostname + "</span>"; } else { display = "<table align=\"right\" width='1675px' style='color:#848483;border:0px;table-layout:fixed;border-collpase:collapse'>" + "<col width=\"775\"/><col width=\"200\"/><col width=\"200\"/><col width=\"200\"/><col width=\"300\"/> <tr>" + "<td style=\"width:770;padding-left:10px;\">" + vhostname + "</td>" + "<td style=\"width:200;font-size:.9em\">ASP.NET Request/Sec: <span style=\"Color:#6B8EAA;\">" + strASPNET + "</td></span>" + "<td style=\"width:200;font-size:.9em\">WCF Requests/Sec: <span style=\"Color:#6B8EAA;\">" + strWCF + "</td></span>" + "<td style=\"width:200;font-size:.9em\">Current CPU : <span style=\"Color:#6B8EAA;\">" + strCPU + "%</span></td>" + "<td style=\"width:300;font-size:.9em\">Runtime Platform: " + runtime + "</td></tr></table>"; } node = new TreeNode(display, nodeimageIndex.ToString(), imageList[nodeimageIndex]); if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].Exception == "Online" && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData != null && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData.Count > 0) if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints.Count > 0 || soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].RequestsPerDay > 0) { if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].PrimaryListenEndpoints.Count > 0) node.ToolTip = "Active Since: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].ActiveSince.ToString() + "\nTotal Primary Business Service Requests Since Active: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].TotalRequests.ToString() + "\nPrimary Business Service Requests per Day: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].RequestsPerDay.ToString(); else node.ToolTip = "Active Since: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].ActiveSince.ToString() + "\nTotal Measured Page Requests Since Active: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].TotalRequests.ToString() + "\nMeasured Page Requests per Day: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].RequestsPerDay.ToString(); } else node.ToolTip = "Active Since: " + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].EndPointData[0].ActiveSince.ToString(); else node.ToolTip = soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[h].Exception; node.Collapse(); // node.ChildNodes.Add(dcEPs); node.ChildNodes.Add(configEPs); node.ChildNodes.Add(primaryEPs); clusterNodes[h] = node; } if (soa.ConnectedSOAs[i].MyVirtualHost.AvgCPU != -1f) strCPU = System.Math.Round(soa.ConnectedSOAs[i].MyVirtualHost.AvgCPU).ToString(); else strCPU = "*"; if (soa.ConnectedSOAs[i].MyVirtualHost.TotalASPNETRecPerSec != -1f) strASPNET = System.Math.Round(soa.ConnectedSOAs[i].MyVirtualHost.TotalASPNETRecPerSec).ToString(); else strASPNET = "*"; if (soa.ConnectedSOAs[i].MyVirtualHost.TotalWCFRecPerSec != -1f) strWCF = System.Math.Round(soa.ConnectedSOAs[i].MyVirtualHost.TotalWCFRecPerSec).ToString(); else strWCF = "*"; string display2 = ""; if (CheckBoxNoDetail.Checked) { display2 = "<span style=\"color:#FFFFFF;padding-left:10px\">" + soa.ConnectedSOAs[i].MyVirtualHost.VHostName + " (Node Count=" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes.Count.ToString() + ")</span>"; } else { display2 = "<table align=\"right\" width=\"1700px\" style=\"color:#FFFFFF;border:0px;table-layout:fixed;border-collapse:collapse\">" + "<col width=\"800\"/><col width=\"200\"/><col width=\"200\"/><col width=\"200\"/><col width=\"300\"/><tr>" + "<td style=\"width:800;padding-left:10px;border:0px\">" + soa.ConnectedSOAs[i].MyVirtualHost.VHostName + " (Node Count=" + soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes.Count.ToString() + ")</td>" + "<td style=\"width:200;font-size:.9em\">ASP.NET Request/Sec: <span style=\"Color:#6B8EAA;font-weight:bold;\">" + strASPNET + "</span></td>" + "<td style=\"width:200;font-size:.9em\">WCF Requests/Sec: <span style=\"Color:#6B8EAA;font-weight:bold;\">" + strWCF + "</td></span>" + "<td style=\"width:200;font-size:.9em\">Avg. Node CPU: <span style=\"Color:#6B8EAA;font-weight:bold;\">" + strCPU + "%</td></span>" + "<td style=\"width:300;font-size:.9em\">Deployment: " + deployment + "</td></tr></table>"; } myVHost.Text = display2; for (int c = 0; c < clusterNodes.Length; c++) { myVHost.ChildNodes.Add(clusterNodes[c]); } TreeNode myDatabases = getMyDatabases(soa.ConnectedSOAs[i]); TreeNode myDistributedCaches = getMyDistributedCaches(soa.ConnectedSOAs[i]); root.ChildNodes.Add(myDatabases); root.ChildNodes.Add(myDistributedCaches); string prefix2 = "Service Domain "; if (deployment.ToLower().Contains("azure")) prefix2 = "Windows Azure Service Domain "; else if (deployment.ToLower().Contains("hyper-v")) prefix2 = "Windows Server Hyper-V Service Domain "; if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes != null && soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes.Count > 0) { if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0].PrimaryListenEndpoints.Count > 0 || soa.ConnectedSOAs[i].MyVirtualHost.RequestsPerDay > 0) { if (soa.ConnectedSOAs[i].MyVirtualHost.ServiceNodes[0].PrimaryListenEndpoints.Count>0) myVHost.ToolTip = prefix2 + "\nTotal Primary Business Service Requests Since Active: " + soa.ConnectedSOAs[i].MyVirtualHost.TotalRequests.ToString() + "\nPrimary Business Service Requests per Day: " + soa.ConnectedSOAs[i].MyVirtualHost.RequestsPerDay.ToString(); else myVHost.ToolTip = prefix2 + "\nTotal Measured Page Requests Since Active: " + soa.ConnectedSOAs[i].MyVirtualHost.TotalRequests.ToString() + "\nPrimary Measured Page Requests per Day: " + soa.ConnectedSOAs[i].MyVirtualHost.RequestsPerDay.ToString(); } else myVHost.ToolTip = prefix2; } root.ChildNodes.Add(myVHost); if (soa.ConnectedSOAs[i].ConnectedSOAs != null && soa.ConnectedSOAs[i].ConnectedSOAs.Count > 0) { TreeNode[] csnodes = recurseSOATree(soa.ConnectedSOAs[i]); for (int k = 0; k < csnodes.Length; k++) { root.ChildNodes[2].ChildNodes.Add(csnodes[k]); } } } returnNodes[i] = root; } return returnNodes; }
private void ExpandToRoot(TreeNode node) { if (node != null) { node.Expand(); if (node.Parent != null) { ExpandToRoot(node.Parent); } } }
private void makeChild(TreeNode currentNode, BSI__Clinic_Service service) { using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities()) { TreeNode newNode = new TreeNode(service.Service_Name, service.Id.ToString()); if (service.Is_Part == true && searchMode == true) { return; } currentNode.ChildNodes.Add(newNode); if (managementMode == false) { if (SharedClass.IsUserAdminOrOperator(SharedClass.CurrentUser) != true) { var employeeService = mc.BSI__Employee_Service_Set.Where(o => o.Service_Id == service.Id && o.Employee_Id == SharedClass.CurrentUser).ToList(); if (employeeService.Count() != 0) { if (service.Is_Part == true) { newNode.SelectAction = TreeNodeSelectAction.None; if ( selectedService != null && selectedService == currentNode.Value ) { newNode.ShowCheckBox = true; } else { newNode.ShowCheckBox = false; } } else { newNode.SelectAction = TreeNodeSelectAction.Select; newNode.Expand(); var parent = newNode.Parent; while (parent != null) { parent.Expand(); parent = parent.Parent; } } } else { newNode.SelectAction = TreeNodeSelectAction.None; } } else { if (service.Is_Part == true) { newNode.SelectAction = TreeNodeSelectAction.None; if ( selectedService != null && selectedService == currentNode.Value ) { newNode.ShowCheckBox = true; } else { newNode.ShowCheckBox = false; } } else { newNode.SelectAction = TreeNodeSelectAction.Select; } isExpanded = false; } } else { newNode.SelectAction = TreeNodeSelectAction.Select; } foreach (var child in mc.BSI__Clinic_Services.Where(o => o.Parent_Id == service.Id).ToList()) { makeChild(newNode, child); } } }
void CreateTreeNodes() { NavigationTree = new TreeView(); NavigationTree.ID = "NavigationTree"; NavigationTree.ShowLines = this.ShowLines; NavigationTree.ExpandDepth = _ExpandDepth; try { SPList list = base.GetCurrentSPList(); if (list == null) return; SPView view = base.CurrentView; SPFolder rootFolder = list.RootFolder; string pageUrl = Page.Request.RawUrl; if (pageUrl.IndexOf("?") != -1) pageUrl = pageUrl.Split('?')[0]; pageUrl += "?RootFolder="; string currentUrl = Page.Request.QueryString["RootFolder"]; string webUrl = base.GetCurrentSPWeb().ServerRelativeUrl; if (!webUrl.EndsWith("/")) webUrl += "/"; //root TreeNode rootNode = new TreeNode(); rootNode.ImageUrl = "/_layouts/images/folder.gif"; rootNode.Expand(); rootNode.Text = list.Title; rootNode.NavigateUrl = ""; NavigationTree.Nodes.Add(rootNode); if (EnableCallback) { string serverCallJs = Page.ClientScript.GetCallbackEventReference(this, "args", "TreeListViewWebPart_Callback", "context", "TreeListViewWebPart_Callback", true); pageUrl = getCurrentPageName(pageUrl); string clientBackJs = "function TreeListViewWebPart_Callback(rvalue, context){document.getElementById('" + this.ClientID + "__FolderContent').innerHTML=rvalue;}\n"; //encodeURIComponent��moss����js���� string serverCallJsWrap = "function TreeListViewWebPart_LoadFolderContent( page , folder ){ theForm.action= page + encodeURIComponent(folder);" + "var args = '';var context='';document.getElementById('" + this.ClientID + "__FolderContent').innerHTML='Loading...';" + serverCallJs + " ;}\n"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", serverCallJsWrap + clientBackJs, true); rootNode.NavigateUrl = String.Format("javascript:TreeListViewWebPart_LoadFolderContent('{0}','{1}')", pageUrl, (webUrl + rootFolder.Url)); buildAsyncSub(pageUrl, webUrl, rootFolder, rootNode.ChildNodes); } else { rootNode.NavigateUrl = pageUrl + Page.Server.UrlEncode(webUrl + rootFolder.Url); this.buildSub(pageUrl, webUrl, currentUrl, rootFolder, rootNode.ChildNodes); } this.Controls.Add(NavigationTree); } catch (Exception ex) { base.RegisterError(ex); } }
protected void tree_TreeNodePopulate(object sender, TreeNodeEventArgs e) { if (e.Node.Value.StartsWith("-")) { int itemTypeId = Utils.ParseInt(e.Node.Value.Substring(1), 0); string[] items = ES.Services.Import.GetImportableItems(PanelSecurity.PackageId, itemTypeId); foreach (string item in items) { TreeNode node = new TreeNode(); node.Text = item; node.Value = itemTypeId.ToString() + "|" + item; node.ShowCheckBox = true; node.SelectAction = TreeNodeSelectAction.None; e.Node.ChildNodes.Add(node); } } if (e.Node.Value.StartsWith("+")) { int itemTypeId = Utils.ParseInt(e.Node.Value.Substring(1), 0); string[] items = ES.Services.Import.GetImportableItems(PanelSecurity.PackageId, itemTypeId * -1); switch (itemTypeId) { case 100: TreeNode headerNode = new TreeNode(); headerNode.Text = GetSharedLocalizedString("ServiceItemType.HostHeader"); headerNode.Value = "+" + itemTypeId.ToString(); headerNode.ShowCheckBox = true; headerNode.SelectAction = TreeNodeSelectAction.None; e.Node.ChildNodes.Add(headerNode); foreach (string item in items) { string[] objectData = item.Split('|'); TreeNode userNode = null; foreach (TreeNode n in headerNode.ChildNodes) { if (n.Value == "+" + itemTypeId.ToString() + "|" + objectData[1]) { userNode = n; break; } } if (userNode == null) { userNode = new TreeNode(); userNode.Text = objectData[0]; userNode.Value = "+" + itemTypeId.ToString() + "|" + objectData[1]; userNode.ShowCheckBox = true; userNode.SelectAction = TreeNodeSelectAction.None; headerNode.ChildNodes.Add(userNode); } TreeNode siteNode = new TreeNode(); siteNode.Text = objectData[3]; siteNode.Value = "+" + itemTypeId.ToString() + "|" + item; siteNode.ShowCheckBox = true; userNode.SelectAction = TreeNodeSelectAction.None; userNode.ChildNodes.Add(siteNode); } headerNode.Expand(); break; } } }
public void List(WebLegend tree, ServerLayer l = null, TreeNode parent = null) { if (l == null) { TreeNode tn = new TreeNode(_layer.Title); tn.ShowCheckBox = true; tn.Checked = _layer.visible; tn.Expand(); if (_layer.Style != null) { if (_layer.Style.Count() > 0) { if (_layer.Style[0].LegendUrl.OnlineResource.OnlineResource != "") { tn.ImageUrl = _layer.Style[0].LegendUrl.OnlineResource.OnlineResource; } } List(tree, _layer, tn); } tree.Nodes.Add(tn); } else { //foreach (WmsServerLayer cl in l.ChildLayers) for (int i = l.ChildLayers.Count() - 1; i >= 0; i--) { ServerLayer cl = l.ChildLayers[i]; TreeNode tn = new TreeNode(cl.Title);// + " " + cl.Name); tn.ShowCheckBox = true; tn.Checked = cl.visible; List(tree, cl, tn); tn.Expand(); parent.ChildNodes.Add(tn); } } }
/// <summary> Populates a tree view control with the hierarchical collection of volumes associated with the same title as a digital resource </summary> /// <param name="TreeView1"> Treeview control to populate with the associated volumes </param> /// <param name="Volumes"> Source datatable with all affiliated volumes </param> protected internal void Build_Tree(TreeView TreeView1, DataTable Volumes) { const int LINE_TO_LONG = 100; // Add the root node TreeNode rootNode = new TreeNode("<span id=\"sbkMviv_TableGroupTitle\">" + CurrentItem.Behaviors.GroupTitle + "</span>"); if (CurrentItem.Behaviors.GroupTitle.Length > LINE_TO_LONG) rootNode.Text = "<span id=\"sbkMviv_TableGroupTitle\">" + CurrentItem.Behaviors.GroupTitle.Substring(0, LINE_TO_LONG) + "...</span>"; rootNode.SelectAction = TreeNodeSelectAction.None; TreeView1.Nodes.Add(rootNode); // Is this a newspaper? bool newspaper = CurrentItem.Behaviors.GroupType.ToUpper() == "NEWSPAPER"; // Add the first layer of nodes // Hashtable nodeHash = new Hashtable(); string lastNodeText1 = String.Empty; string lastNodeText2 = String.Empty; string lastNodeText3 = String.Empty; string lastNodeText4 = String.Empty; TreeNode lastNode1 = null; TreeNode lastNode2 = null; TreeNode lastNode3 = null; TreeNode lastNode4 = null; TreeNode currentSelectedNode = null; // Compute the base redirect URL string current_vid = CurrentMode.VID; CurrentMode.VID = "<%VID%>"; string redirect_url = UrlWriterHelper.Redirect_URL(CurrentMode, String.Empty); CurrentMode.VID = current_vid; // Get the data columns for quick access DataColumn level1_text_column = Volumes.Columns[2]; DataColumn level2_text_column = Volumes.Columns[4]; DataColumn level3_text_column = Volumes.Columns[6]; DataColumn level4_text_column = Volumes.Columns[8]; DataColumn level5_text_column = Volumes.Columns[10]; DataColumn vid_column = Volumes.Columns[13]; DataColumn title_column = Volumes.Columns[1]; DataColumn itemid_column = Volumes.Columns[0]; DataColumn visibility_column = Volumes.Columns[14]; DataColumn dark_column = Volumes.Columns[16]; //DataColumn level1_index_column = Volumes.Columns[3]; //DataColumn level2_index_column = Volumes.Columns[5]; //DataColumn level3_index_column = Volumes.Columns[7]; //DataColumn level4_index_column = Volumes.Columns[9]; //DataColumn level5_index_column = Volumes.Columns[11]; // Does this user have special rights on the item? bool specialRights = ((CurrentUser != null) && ((CurrentUser.Is_System_Admin) || (CurrentUser.Is_Internal_User) || (CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Bib_Info.SobekCM_Type_String, CurrentItem.Bib_Info.Source.Code, CurrentItem.Bib_Info.HoldingCode, CurrentItem.Behaviors.Aggregation_Code_List)))); foreach (DataRow thisItem in Volumes.Rows) { // Do not show PRIVATE items in this tree view int access_int = Convert.ToInt32(thisItem[visibility_column]); bool dark = Convert.ToBoolean(thisItem[dark_column]); if (dark) access_int = -1; if (( access_int >= 0) || (specialRights)) { // Set the access string and span name string access_string = String.Empty; string access_span_start = String.Empty; string access_span_end = String.Empty; if (dark) { access_span_start = "<span class=\"sbkMviv_TreeDarkNode\">"; access_string = " ( dark )"; access_span_end = "</span>"; } else { if (access_int < 0) { access_span_start = "<span class=\"sbkMviv_TreePrivateNode\">"; access_string = " ( private )"; access_span_end = "</span>"; } else if (access_int > 0) { access_span_start = "<span class=\"sbkMviv_TreeRestrictedNode\">"; access_string = " ( some restrictions apply )"; access_span_end = "</span>"; } } // Determine the text for all the levels (and nodes) string level1_text = translator.Get_Translation(thisItem[level1_text_column].ToString(), CurrentMode.Language); string level2_text = String.Empty; string level3_text = String.Empty; string level4_text = String.Empty; string level5_text = String.Empty; string title = thisItem[title_column].ToString(); string vid = thisItem[vid_column].ToString(); int itemid = Convert.ToInt32(thisItem[itemid_column]); if (level1_text.Length == 0) { TreeNode singleNode = new TreeNode(access_span_start + title + access_string + access_span_end); if (title.Length > LINE_TO_LONG) { singleNode.ToolTip = title; title = title.Substring(0, LINE_TO_LONG) + "..."; singleNode.Text = access_span_start + title + access_string + access_span_end; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode; singleNode.SelectAction = TreeNodeSelectAction.None; singleNode.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + singleNode.Text + "</span>"; } else { singleNode.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } rootNode.ChildNodes.Add(singleNode); } // Look at the first level if (level1_text.Length > 0) { level2_text = translator.Get_Translation(thisItem[level2_text_column].ToString(), CurrentMode.Language); if (level2_text.Length == 0) { TreeNode singleNode1 = new TreeNode(access_span_start + level1_text + access_string + access_span_end); if (thisItem[level1_text_column].ToString().Length > LINE_TO_LONG) { singleNode1.ToolTip = level1_text; level1_text = level1_text.Substring(0, LINE_TO_LONG) + "..."; singleNode1.Text = access_span_start + level1_text + access_string + access_span_end; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode1; singleNode1.SelectAction = TreeNodeSelectAction.None; singleNode1.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + singleNode1.Text + "</span>"; } else { singleNode1.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } rootNode.ChildNodes.Add(singleNode1); } else { if ((lastNode1 == null) || (lastNodeText1 != level1_text.ToUpper())) { // Since this is the TOP level, let's look down and see if there are any non-private, non-dark items string nontranslated = thisItem[level1_text_column].ToString(); int index = Convert.ToInt32(thisItem["Level1_Index"]); DataRow[] test = Volumes.Select("(IP_Restriction_Mask >= 0 ) and ( Dark = 'false') and ( " + level1_text_column.ColumnName + "='" + nontranslated + "') and ( Level1_Index=" + index + ")"); bool allPrivate = test.Length == 0; lastNode1 = new TreeNode(level1_text); if (level1_text.Length > LINE_TO_LONG) { lastNode1.ToolTip = lastNode1.Text; level1_text = level1_text.Substring(0, LINE_TO_LONG) + "..."; lastNode1.Text = level1_text; } if (allPrivate) { lastNode1.Text = "<span class=\"sbkMviv_TreePrivateNode\">" + level1_text + " ( all private or dark )</span>"; } lastNode1.SelectAction = TreeNodeSelectAction.None; lastNodeText1 = level1_text.ToUpper(); rootNode.ChildNodes.Add(lastNode1); lastNode2 = null; lastNodeText2 = String.Empty; lastNode3 = null; lastNodeText3 = String.Empty; lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the second level if ((level2_text.Length > 0) && (lastNode1 != null)) { level3_text = translator.Get_Translation(thisItem[level3_text_column].ToString(), CurrentMode.Language); if (level3_text.Length == 0) { TreeNode singleNode2 = new TreeNode( access_span_start + level2_text + access_string + access_span_end ); if (level2_text.Length > LINE_TO_LONG) { singleNode2.ToolTip = level2_text; level2_text = level2_text.Substring(0, LINE_TO_LONG) + "..."; singleNode2.Text = access_span_start + level2_text + access_string + access_span_end; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode2; singleNode2.SelectAction = TreeNodeSelectAction.None; singleNode2.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level2_text + access_string + "</span>"; } else { singleNode2.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode1.ChildNodes.Add(singleNode2); } else { if ((lastNode2 == null) || (lastNodeText2 != level2_text.ToUpper())) { lastNode2 = new TreeNode(level2_text); if (level2_text.Length > LINE_TO_LONG) { lastNode2.ToolTip = lastNode2.Text; lastNode2.Text = level2_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode2.SelectAction = TreeNodeSelectAction.None; lastNodeText2 = level2_text.ToUpper(); lastNode1.ChildNodes.Add(lastNode2); lastNode3 = null; lastNodeText3 = String.Empty; lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the third level if ((level3_text.Length > 0) && (lastNode2 != null)) { level4_text = translator.Get_Translation(thisItem[level4_text_column].ToString(), CurrentMode.Language); if (level4_text.Length == 0) { TreeNode singleNode3 = new TreeNode(access_span_start + level3_text + access_string + access_span_end); if (level3_text.Length > LINE_TO_LONG) { singleNode3.ToolTip = level3_text; level3_text = level3_text.Substring(0, LINE_TO_LONG) + "..."; singleNode3.Text = access_span_start + level3_text + access_string + access_span_end; } if (newspaper) { level3_text = access_span_start + level2_text + " " + level3_text + ", " + level1_text + access_string + access_span_end; singleNode3.Text = level3_text; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode3; singleNode3.SelectAction = TreeNodeSelectAction.None; singleNode3.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level3_text + access_string + "</span>"; } else { singleNode3.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode2.ChildNodes.Add(singleNode3); } else { if ((lastNode3 == null) || (lastNodeText3 != level3_text.ToUpper())) { lastNode3 = new TreeNode(level3_text); if (level3_text.Length > LINE_TO_LONG) { lastNode3.ToolTip = lastNode3.Text; lastNode3.Text = level3_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode3.SelectAction = TreeNodeSelectAction.None; lastNodeText3 = level3_text.ToUpper(); lastNode2.ChildNodes.Add(lastNode3); lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the fourth level if ((level4_text.Length > 0) && (lastNode3 != null)) { translator.Get_Translation(thisItem[level5_text_column].ToString(), CurrentMode.Language); if (level5_text.Length == 0) { TreeNode singleNode4 = new TreeNode(access_span_start + level4_text + access_string + access_span_end); if (level4_text.Length > LINE_TO_LONG) { singleNode4.ToolTip = level4_text; level4_text = level4_text.Substring(0, LINE_TO_LONG) + "..."; singleNode4.Text = access_span_start + level4_text + access_string + access_span_end; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode4; singleNode4.SelectAction = TreeNodeSelectAction.None; singleNode4.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level4_text + access_string + "</span>"; } else { singleNode4.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode3.ChildNodes.Add(singleNode4); } else { if ((lastNode4 == null) || (lastNodeText4 != level4_text.ToUpper())) { lastNode4 = new TreeNode(level4_text); if (level4_text.Length > LINE_TO_LONG) { lastNode4.ToolTip = lastNode4.Text; lastNode4.Text = level4_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode4.SelectAction = TreeNodeSelectAction.None; lastNodeText4 = level4_text.ToUpper(); lastNode3.ChildNodes.Add(lastNode4); } } } // Look at the fifth level if ((level5_text.Length > 0) && (lastNode4 != null)) { TreeNode lastNode5 = new TreeNode(access_span_start + level5_text + access_string + access_span_end ); if (level5_text.Length > LINE_TO_LONG) { lastNode5.ToolTip = level5_text; level5_text = level5_text.Substring(0, LINE_TO_LONG) + "..."; lastNode5.Text = access_span_start + level5_text + access_string + access_span_end; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = lastNode5; lastNode5.SelectAction = TreeNodeSelectAction.None; lastNode5.Text = "<span id=\"sbkMviv_TreeSelectedNode\">" + level5_text + access_string + "</span>"; } else { lastNode5.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode4.ChildNodes.Add(lastNode5); } } } rootNode.CollapseAll(); rootNode.Expand(); if (currentSelectedNode == null) return; while ((currentSelectedNode != rootNode) && ( currentSelectedNode != null )) { currentSelectedNode.Expand(); currentSelectedNode = currentSelectedNode.Parent; } }
/// <summary> /// Invoked when new tree node is created. /// </summary> /// <param name="itemData">Category data.</param> /// <param name="defaultNode">Default node.</param> protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode) { defaultNode.Selected = false; defaultNode.SelectAction = TreeNodeSelectAction.None; defaultNode.NavigateUrl = ""; if (itemData != null) { CategoryInfo category = new CategoryInfo(itemData); var catLevel = category.CategoryLevel; if ((StartingCategoryObj != null) && (category.CategoryIDPath.StartsWithCSafe(StartingCategoryObj.CategoryIDPath))) { catLevel -= StartingCategoryObj.CategoryLevel - 1; } string cssClass = GetCssClass(catLevel); string caption = category.CategoryDisplayName; if (String.IsNullOrEmpty(caption)) { caption = category.CategoryName; } // Get target URL string url = GetUrl(category); caption = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(caption)); StringBuilder attrs = new StringBuilder(); // Append target attribute if (!string.IsNullOrEmpty(CategoriesPageTarget)) { attrs.Append(" target=\"").Append(CategoriesPageTarget).Append("\""); } // Append title attribute if (RenderLinkTitle) { attrs.Append(" title=\"").Append(caption).Append("\""); } // Append CSS class if (!string.IsNullOrEmpty(cssClass)) { attrs.Append(" class=\"" + cssClass + "\""); } // Append before/after texts caption = (CategoryContentBefore ?? "") + caption; caption += CategoryContentAfter ?? ""; if (category.IsGlobal && !category.CategoryIsPersonal) { caption += " <sup>" + GetString("general.global") + "</sup>"; } // Set caption defaultNode.Text = defaultNode.Text.Replace("##NODECUSTOMNAME##", caption); defaultNode.Text = defaultNode.Text.Replace("##NODECODENAME##", HTMLHelper.HTMLEncode(category.CategoryName)); defaultNode.Text = defaultNode.Text.Replace("##PARENTID##", category.CategoryParentID.ToString()); defaultNode.Text = defaultNode.Text.Replace("##ID##", category.CategoryID.ToString()); defaultNode.Text = defaultNode.Text.Replace("##BEFORENAME##", string.Format("<a href=\"{0}\" {1}>", HTMLHelper.EncodeForHtmlAttribute(url), attrs)); defaultNode.Text = defaultNode.Text.Replace("##AFTERNAME##", "</a>"); // Expand node if all nodes are to be expanded if (ExpandAll) { defaultNode.Expand(); } else { // Check if selected category exists if (Category != null) { if ((Category.CategoryID != category.CategoryID) || RenderSubItems) { // Expand whole path to selected category string strId = category.CategoryID.ToString().PadLeft(CategoryInfoProvider.CategoryIDLength, '0'); if (Category.CategoryIDPath.Contains(strId)) { defaultNode.Expand(); } } } } return defaultNode; } return null; }
private void Create_TreeView_From_Collections(TreeView treeView1) { // Save the current home type TreeNode rootNode = new TreeNode("Collection Hierarchy") {SelectAction = TreeNodeSelectAction.None}; treeView1.Nodes.Add(rootNode); // Step through each node under this SortedList<string, TreeNode> sorted_node_list = new SortedList<string, TreeNode>(); foreach (Item_Aggregation_Related_Aggregations childAggr in Hierarchy_Object.Children) { if ((!childAggr.Hidden) && ( childAggr.Active )) { // Set the aggregation value, for the redirect URL currentMode.Aggregation = childAggr.Code.ToLower(); // Set some default interfaces if (currentMode.Aggregation == "dloc1") currentMode.Skin = "dloc"; if (currentMode.Aggregation == "edlg") currentMode.Skin = "edl"; // Create this tree node TreeNode childNode = new TreeNode("<a href=\"" + currentMode.Redirect_URL() + "\"><abbr title=\"" + childAggr.Description + "\">" + childAggr.Name + "</abbr></a>"); if (currentMode.Internal_User) { childNode.Text = string.Format("<a href=\"{0}\"><abbr title=\"{1}\">{2} ( {3} )</abbr></a>", currentMode.Redirect_URL(), childAggr.Description, childAggr.Name, childAggr.Code); } childNode.SelectAction = TreeNodeSelectAction.None; childNode.NavigateUrl = currentMode.Redirect_URL(); // Add to the sorted list if ((childAggr.Name.Length > 4) && (childAggr.Name.IndexOf("The ") == 0 )) sorted_node_list.Add(childAggr.Name.Substring(4).ToUpper(), childNode); else sorted_node_list.Add(childAggr.Name.ToUpper(), childNode); // Check the children nodes recursively add_children_to_tree(childAggr, childNode); currentMode.Skin = String.Empty; } } // Now add the sorted nodes to the tree foreach( TreeNode childNode in sorted_node_list.Values ) { rootNode.ChildNodes.Add(childNode); } currentMode.Aggregation = String.Empty; if ((currentMode.Home_Type == Home_Type_Enum.Tree_Expanded) || ( currentMode.Is_Robot )) { treeView1.ExpandAll(); } else { treeView1.CollapseAll(); rootNode.Expand(); } }
private void BindData(bool isNewItem = false) { ICategorySchemeMutableObject cs = GetCategorySchemeFromSession(); if (cs == null) return; SetGeneralTab(cs.ImmutableInstance); LocalizedUtils localUtils = new LocalizedUtils(Utils.LocalizedCulture); EntityMapper eMapper = new EntityMapper(Utils.LocalizedLanguage); TreeView1.Nodes.Clear(); IList<Category> lCategorySchemeItem = new List<Category>(); TreeNode rootNode = new TreeNode(string.Format("[ {0} ] {1}", cs.Id, localUtils.GetNameableName(cs.ImmutableInstance))); rootNode.Value = cs.Id; foreach (ICategoryObject category in cs.ImmutableInstance.Items) { //TreeNode node = new TreeNode( string.Format( "{0} - {1} - {2}", category.Id, localUtils.GetNameableName( category ), localUtils.GetNameableDescription( category ) ) ); TreeNode node = new TreeNode(string.Format("[ {0} ] {1}", category.Id, localUtils.GetNameableName(category))); node.Value = category.Id; node.SelectAction = TreeNodeSelectAction.Select; CreateTreeWithRecursion(category, node); rootNode.ChildNodes.Add(node); lCategorySchemeItem.Add(new Category(category.Id, localUtils.GetNameableName(category), localUtils.GetNameableDescription(category), (category.IdentifiableParent != null) ? category.IdentifiableParent.Id : string.Empty)); } TreeView1.Nodes.Add(rootNode); rootNode.Expand(); }
/// <summary> Add the sitemap tree-view control, if there is a site map included in this object </summary> /// <param name="placeHolder"> Main place holder ( "mainPlaceHolder" ) in the itemNavForm form, widely used throughout the application</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public void Add_Controls(PlaceHolder placeHolder, Custom_Tracer Tracer) { if ((siteMap == null) || (currentMode.Is_Robot)) return; Tracer.Add_Trace("Web_Content_HtmlSubwriter.Add_Controls", "Adding site map tree nav view"); // Create the treeview TreeView treeView1 = new TreeView { CssClass = "SobekSiteMapTreeView", ExpandDepth = 0, NodeIndent = 15, ShowLines = true, EnableClientScript = true, PopulateNodesFromClient = true }; // Set some tree view properties treeView1.TreeNodePopulate += treeView1_TreeNodePopulate; // Determine the base URL string base_url = currentMode.Base_URL; if (currentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn) { base_url = base_url + "l/"; } // Find the selected node int selected_node = siteMap.Selected_NodeValue(currentMode.Info_Browse_Mode); foreach (SobekCM_SiteMap_Node rootSiteMapNode in siteMap.RootNodes) { // Add the sitemaps root node first TreeNode rootNode = new TreeNode { SelectAction = TreeNodeSelectAction.None, Text = string.Format("<a href='{0}{1}' title='{2}'>{3}</a>", base_url, rootSiteMapNode.URL, rootSiteMapNode.Description, rootSiteMapNode.Title) }; treeView1.Nodes.Add(rootNode); // Was this node currently selected? if (rootSiteMapNode.URL == currentMode.Info_Browse_Mode) { rootNode.Text = string.Format("<span Title='{0}'>{1}</span>", rootSiteMapNode.Description, rootSiteMapNode.Title); rootNode.Expand(); } // Now add all the children recursively add_child_nodes(rootNode, rootSiteMapNode, base_url, selected_node); } // Always expand the top node //rootNode.Expand(); // Add the tree to the view placeHolder.Controls.Add(treeView1); }
private void showNode(TreeNode treeNode) { treeNode.Select(); while (treeNode.Parent != null) { treeNode = treeNode.Parent; treeNode.Expand(); } }
//int CompareFolder(SPFolder f1, SPFolder f2) //{ // return f1.Name.CompareTo(f2.Name); //} //�����ļ����� void buildSub(string pageUrl, string webUrl , string currentFolderUrl , SPFolder root, TreeNodeCollection nodes) { if (root.SubFolders.Count == 0) return; IList<SPFolder> sortedFolders = this.GetSortedSubFolders(root); foreach (SPFolder f in sortedFolders ) { //if ( f.Name.ToLower() == "forms") continue; if (IsHiddenFolder(f)) continue; string folderUrl = webUrl + f.Url; TreeNode n = new TreeNode(); // string url = webUrl + pageUrl + "?RootFolder=" + folderUrl ;// + Page.Server.UrlEncode(folderUrl); // n.NavigateUrl = "javascript:SubmitFormPost( '"+pageUrl+"' + encodeURIComponent('" + f.Url + "') );"; //EnterFolder and SubmitFormPost��ϵͳjs n.NavigateUrl = pageUrl + Page.Server.UrlEncode(folderUrl); //n.Expanded = Expanded ; n.ImageUrl = "/_layouts/images/folder.gif"; nodes.Add(n); if (String.Compare(currentFolderUrl, folderUrl, true) == 0) //չ�����и� { n.Expand(); TreeNode temp = n.Parent; while (temp != null) { temp.Expand(); temp = temp.Parent; } n.Select(); //n.Text = "<b>" + f.Name + "</b>(" + f.Files.Count + ")"; n.Text = "<b>" + f.Name + "</b>"; } else { //n.Collapse(); n.Text = f.Name ; } //n.Text = "<a href='"+url+"' onclick=\"javascript:EnterFolder('" + url + "');return false;\">" + n.Text + "<a>"; buildSub(pageUrl, webUrl , currentFolderUrl , f, n.ChildNodes); } }
/// <summary> Populates a tree view control with the hierarchical collection of volumes associated with the same title as a digital resource </summary> /// <param name="treeView1"> Treeview control to populate with the associated volumes </param> /// <param name="Volumes"> Source datatable with all affiliated volumes </param> protected internal void Build_Tree(TreeView treeView1, DataTable Volumes) { const int LINE_TO_LONG = 100; // Add the root node TreeNode rootNode = new TreeNode("<b>" + CurrentItem.Behaviors.GroupTitle + "</b>"); if (CurrentItem.Behaviors.GroupTitle.Length > LINE_TO_LONG) rootNode.Text = "<b>" + CurrentItem.Behaviors.GroupTitle.Substring(0, LINE_TO_LONG) + "...</b>"; rootNode.SelectAction = TreeNodeSelectAction.None; treeView1.Nodes.Add(rootNode); // Is this a newspaper? bool newspaper = false; if (CurrentItem.Behaviors.GroupType.ToUpper() == "NEWSPAPER") { newspaper = true; } // Add the first layer of nodes // Hashtable nodeHash = new Hashtable(); string lastNodeText1 = String.Empty; string lastNodeText2 = String.Empty; string lastNodeText3 = String.Empty; string lastNodeText4 = String.Empty; TreeNode lastNode1 = null; TreeNode lastNode2 = null; TreeNode lastNode3 = null; TreeNode lastNode4 = null; TreeNode currentSelectedNode = null; // Compute the base redirect URL string current_vid = CurrentMode.VID; CurrentMode.VID = "<%VID%>"; string redirect_url = CurrentMode.Redirect_URL(String.Empty); CurrentMode.VID = current_vid; // Get the data columns for quick access DataColumn level1_text_column = Volumes.Columns[2]; DataColumn level2_text_column = Volumes.Columns[4]; DataColumn level3_text_column = Volumes.Columns[6]; DataColumn level4_text_column = Volumes.Columns[8]; DataColumn level5_text_column = Volumes.Columns[10]; DataColumn vid_column = Volumes.Columns[13]; DataColumn title_column = Volumes.Columns[1]; DataColumn itemid_column = Volumes.Columns[0]; DataColumn visibility_column = Volumes.Columns[14]; //DataColumn level1_index_column = Volumes.Columns[3]; //DataColumn level2_index_column = Volumes.Columns[5]; //DataColumn level3_index_column = Volumes.Columns[7]; //DataColumn level4_index_column = Volumes.Columns[9]; //DataColumn level5_index_column = Volumes.Columns[11]; foreach (DataRow thisItem in Volumes.Rows) { // Do not show PRIVATE items in this tree view if (Convert.ToInt16(thisItem[visibility_column]) >= 0) { string level1_text = translator.Get_Translation(thisItem[level1_text_column].ToString(), CurrentMode.Language); string level2_text = String.Empty; string level3_text = String.Empty; string level4_text = String.Empty; string level5_text = String.Empty; string title = thisItem[title_column].ToString(); string vid = thisItem[vid_column].ToString(); int itemid = Convert.ToInt32(thisItem[itemid_column]); if (level1_text.Length == 0) { TreeNode singleNode = new TreeNode(title); if (title.Length > LINE_TO_LONG) singleNode.Text = title.Substring(0, LINE_TO_LONG) + "..."; if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode; singleNode.SelectAction = TreeNodeSelectAction.None; singleNode.Text = "<i>" + singleNode.Text + "</i>"; } else { singleNode.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } rootNode.ChildNodes.Add(singleNode); } // Look at the first level if (level1_text.Length > 0) { level2_text = translator.Get_Translation(thisItem[level2_text_column].ToString(), CurrentMode.Language); if (level2_text.Length == 0) { TreeNode singleNode1 = new TreeNode(level1_text); if (thisItem[level1_text_column].ToString().Length > LINE_TO_LONG) { singleNode1.ToolTip = singleNode1.Text; singleNode1.Text = level1_text.Substring(0, LINE_TO_LONG) + "..."; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode1; singleNode1.SelectAction = TreeNodeSelectAction.None; singleNode1.Text = "<i>" + singleNode1.Text + "</i>"; } else { singleNode1.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } rootNode.ChildNodes.Add(singleNode1); } else { if ((lastNode1 == null) || (lastNodeText1 != level1_text.ToUpper())) { lastNode1 = new TreeNode(level1_text); if (level1_text.Length > LINE_TO_LONG) { lastNode1.ToolTip = lastNode1.Text; lastNode1.Text = level1_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode1.SelectAction = TreeNodeSelectAction.None; lastNodeText1 = level1_text.ToUpper(); rootNode.ChildNodes.Add(lastNode1); lastNode2 = null; lastNodeText2 = String.Empty; lastNode3 = null; lastNodeText3 = String.Empty; lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the second level if ((level2_text.Length > 0) && (lastNode1 != null)) { level3_text = translator.Get_Translation(thisItem[level3_text_column].ToString(), CurrentMode.Language); if (level3_text.Length == 0) { TreeNode singleNode2 = new TreeNode(level2_text); if (level2_text.Length > LINE_TO_LONG) { singleNode2.ToolTip = singleNode2.Text; singleNode2.Text = level2_text.Substring(0, LINE_TO_LONG) + "..."; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode2; singleNode2.SelectAction = TreeNodeSelectAction.None; singleNode2.Text = "<i>" + singleNode2.Text + "</i>"; } else { singleNode2.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode1.ChildNodes.Add(singleNode2); } else { if ((lastNode2 == null) || (lastNodeText2 != level2_text.ToUpper())) { lastNode2 = new TreeNode(level2_text); if (level2_text.Length > LINE_TO_LONG) { lastNode2.ToolTip = lastNode2.Text; lastNode2.Text = level2_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode2.SelectAction = TreeNodeSelectAction.None; lastNodeText2 = level2_text.ToUpper(); lastNode1.ChildNodes.Add(lastNode2); lastNode3 = null; lastNodeText3 = String.Empty; lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the third level if ((level3_text.Length > 0) && (lastNode2 != null)) { level4_text = translator.Get_Translation(thisItem[level4_text_column].ToString(), CurrentMode.Language); if (level4_text.Length == 0) { TreeNode singleNode3 = new TreeNode(level3_text); if (level3_text.Length > LINE_TO_LONG) { singleNode3.ToolTip = singleNode3.Text; singleNode3.Text = level3_text.Substring(0, LINE_TO_LONG) + "..."; } if (newspaper) { singleNode3.Text = level2_text + " " + level3_text + ", " + level1_text; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode3; singleNode3.SelectAction = TreeNodeSelectAction.None; singleNode3.Text = "<i>" + singleNode3.Text + "</i>"; } else { singleNode3.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode2.ChildNodes.Add(singleNode3); } else { if ((lastNode3 == null) || (lastNodeText3 != level3_text.ToUpper())) { lastNode3 = new TreeNode(level3_text); if (level3_text.Length > LINE_TO_LONG) { lastNode3.ToolTip = lastNode3.Text; lastNode3.Text = level3_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode3.SelectAction = TreeNodeSelectAction.None; lastNodeText3 = level3_text.ToUpper(); lastNode2.ChildNodes.Add(lastNode3); lastNode4 = null; lastNodeText4 = String.Empty; } } } // Look at the fourth level if ((level4_text.Length > 0) && (lastNode3 != null)) { translator.Get_Translation(thisItem[level5_text_column].ToString(), CurrentMode.Language); if (level5_text.Length == 0) { TreeNode singleNode4 = new TreeNode(level4_text); if (level4_text.Length > LINE_TO_LONG) { singleNode4.ToolTip = singleNode4.Text; singleNode4.Text = level4_text.Substring(0, LINE_TO_LONG) + "..."; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = singleNode4; singleNode4.SelectAction = TreeNodeSelectAction.None; singleNode4.Text = "<i>" + singleNode4.Text + "</i>"; } else { singleNode4.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode3.ChildNodes.Add(singleNode4); } else { if ((lastNode4 == null) || (lastNodeText4 != level4_text.ToUpper())) { lastNode4 = new TreeNode(level4_text); if (level4_text.Length > LINE_TO_LONG) { lastNode4.ToolTip = lastNode4.Text; lastNode4.Text = level4_text.Substring(0, LINE_TO_LONG) + "..."; } lastNode4.SelectAction = TreeNodeSelectAction.None; lastNodeText4 = level4_text.ToUpper(); lastNode3.ChildNodes.Add(lastNode4); } } } // Look at the fifth level if ((level5_text.Length > 0) && (lastNode4 != null)) { TreeNode lastNode5 = new TreeNode(level5_text); if (level5_text.Length > LINE_TO_LONG) { lastNode5.ToolTip = lastNode5.Text; lastNode5.Text = level5_text.Substring(0, LINE_TO_LONG) + "..."; } if (itemid == CurrentItem.Web.ItemID) { currentSelectedNode = lastNode5; lastNode5.SelectAction = TreeNodeSelectAction.None; lastNode5.Text = "<i>" + lastNode5.Text + "</i>"; } else { lastNode5.NavigateUrl = redirect_url.Replace("<%VID%>", vid); } lastNode4.ChildNodes.Add(lastNode5); } } } rootNode.CollapseAll(); rootNode.Expand(); if (currentSelectedNode == null) return; while ((currentSelectedNode != rootNode) && ( currentSelectedNode != null )) { currentSelectedNode.Expand(); currentSelectedNode = currentSelectedNode.Parent; } }
void HandleSelectEvent (TreeNode node) { switch (node.SelectAction) { case TreeNodeSelectAction.Select: node.Select (); break; case TreeNodeSelectAction.Expand: node.Expand (); break; case TreeNodeSelectAction.SelectExpand: node.Select (); node.Expand (); break; } }
/// <summary> /// Invoked when new tree node is created. /// </summary> /// <param name="itemData">Category data.</param> /// <param name="defaultNode">Default node.</param> protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode) { defaultNode.Selected = false; defaultNode.SelectAction = TreeNodeSelectAction.None; defaultNode.NavigateUrl = ""; if (itemData != null) { CategoryInfo category = new CategoryInfo(itemData); var catLevel = category.CategoryLevel; if ((StartingCategoryObj != null) && (category.CategoryIDPath.StartsWithCSafe(StartingCategoryObj.CategoryIDPath))) { catLevel -= StartingCategoryObj.CategoryLevel - 1; } string cssClass = GetCssClass(catLevel); string caption = category.CategoryDisplayName; if (String.IsNullOrEmpty(caption)) { caption = category.CategoryName; } // Get target URL string url = GetUrl(category); caption = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(caption)); StringBuilder attrs = new StringBuilder(); // Append target attribute if (!string.IsNullOrEmpty(CategoriesPageTarget)) { attrs.Append(" target=\"").Append(CategoriesPageTarget).Append("\""); } // Append title attribute if (RenderLinkTitle) { attrs.Append(" title=\"").Append(caption).Append("\""); } // Append CSS class if (!string.IsNullOrEmpty(cssClass)) { attrs.Append(" class=\"" + cssClass + "\""); } // Append before/after texts caption = (CategoryContentBefore ?? "") + caption; caption += CategoryContentAfter ?? ""; if (category.IsGlobal && !category.CategoryIsPersonal) { caption += " <sup>" + GetString("general.global") + "</sup>"; } // Set caption defaultNode.Text = defaultNode.Text.Replace("##NODECUSTOMNAME##", caption); defaultNode.Text = defaultNode.Text.Replace("##NODECODENAME##", HTMLHelper.HTMLEncode(category.CategoryName)); defaultNode.Text = defaultNode.Text.Replace("##PARENTID##", category.CategoryParentID.ToString()); defaultNode.Text = defaultNode.Text.Replace("##ID##", category.CategoryID.ToString()); defaultNode.Text = defaultNode.Text.Replace("##BEFORENAME##", string.Format("<a href=\"{0}\" {1}>", URLHelper.EncodeQueryString(url), attrs)); defaultNode.Text = defaultNode.Text.Replace("##AFTERNAME##", "</a>"); // Expand node if all nodes are to be expanded if (ExpandAll) { defaultNode.Expand(); } else { // Check if selected category exists if (Category != null) { if ((Category.CategoryID != category.CategoryID) || RenderSubItems) { // Expand whole path to selected category string strId = category.CategoryID.ToString().PadLeft(CategoryInfoProvider.CategoryIDLength, '0'); if (Category.CategoryIDPath.Contains(strId)) { defaultNode.Expand(); } } } } return(defaultNode); } return(null); }
private void add_child_nodes(TreeNode treeNode, SobekCM_SiteMap_Node siteNode, string base_url, int selected_node ) { // Only do anything if there are child nodes defined if (siteNode.Child_Nodes_Count > 0) { // Step through each child node ReadOnlyCollection<SobekCM_SiteMap_Node> childNodes = siteNode.Child_Nodes; int child_node_counter = 0; while ( child_node_counter < childNodes.Count ) { // Get this child node SobekCM_SiteMap_Node childNode = childNodes[child_node_counter]; // Add this child node to the tree view TreeNode childTreeNode = new TreeNode { SelectAction = TreeNodeSelectAction.None, Value = childNode.NodeValue.ToString() }; if (childNode.URL.Length > 0) { childTreeNode.Text = string.Format("<a href='{0}' title='{1}'>{2}</a>", base_url + childNode.URL, childNode.Description, childNode.Title); } else { childTreeNode.Text = string.Format("<span Title='{0}' class='SobekSiteMapNoLink' >{1}</span>", childNode.Description, childNode.Title); childTreeNode.SelectAction = TreeNodeSelectAction.Expand; } treeNode.ChildNodes.Add(childTreeNode); if (childNode.Child_Nodes_Count > 0) { // Determine if the selected node is in the child nodes... if ((childNode.NodeValue < selected_node) && ((child_node_counter + 1 == childNodes.Count) || (childNodes[child_node_counter + 1].NodeValue > selected_node))) { // Recurse through any children add_child_nodes(childTreeNode, childNode, base_url, selected_node); } else { childTreeNode.PopulateOnDemand = true; } } // Was this node currently selected? if (childNode.NodeValue == selected_node ) { childTreeNode.Text = string.Format("<span Title='{0}'>{1}</span>", childNode.Description, childNode.Title); childTreeNode.Expand(); // Create the breadcrumbs now StringBuilder breadcrumbBuilder = new StringBuilder(); breadcrumbBuilder.Append(childTreeNode.Text); // Add each parent next, if they have a URL and also expand each parent TreeNode selectedNodeExpander = childTreeNode; while (selectedNodeExpander.Parent != null) { // expand this node (selectedNodeExpander.Parent).Expand(); // add to breadcrumb, if a link if (selectedNodeExpander.Parent.SelectAction == TreeNodeSelectAction.None) { string text = selectedNodeExpander.Parent.Text.Replace(" Namespace</a>","</a>").Replace(" Sub-Namespace</a>","</a>"); breadcrumbBuilder.Insert(0, text + " <img src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/breadcrumbimg.gif\" alt=\">\" /><img src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/breadcrumbimg.gif\" alt=\">\" /> "); } // step up another level selectedNodeExpander = selectedNodeExpander.Parent; } breadcrumbs = breadcrumbBuilder.ToString(); } child_node_counter++; } } }
protected void Page_Load( object sender, EventArgs e ) { Response.Cache.SetCacheability( HttpCacheability.NoCache ); ScriptsManager.RegisterJQuery(Page); if( !IsPostBack ) { TreeNode root = new TreeNode( "Библиотека документов", "0" ); root.SelectAction = TreeNodeSelectAction.SelectExpand; root.ImageUrl = "~/Controls/FileManager/root.gif"; _treeView.Nodes.Add( root ); using (var dc = new DCFactory<CmsDataContext>()) { AddChildren( root, dc.DataContext.Folders.Where( f => f.ParentID == null ).OrderBy( f => f.FolderName ).ToArray() ); } _treeView.CollapseAll(); root.Expand(); root.Select(); } }