private List <CustomLinkLabel> GetLinkLabels() { List <CustomLinkLabel> result = new List <CustomLinkLabel>(); if (Links == null) { return(result); } foreach (KeyValuePair <string, Dictionary <string, string> > kvp in Links) { foreach (KeyValuePair <string, string> key in kvp.Value) { LinkType type = (LinkType)Enum.Parse(typeof(LinkType), kvp.Key); string text = key.Value; string formName = !type.Equals(LinkType.Internet) ? key.Value : string.Empty; int popupWidth = type.Equals(LinkType.Popup) ? 900 : 0; int popupHeight = type.Equals(LinkType.Popup) ? 900 : 0; string internetLink = type.Equals(LinkType.Internet) ? key.Value : string.Empty; result.Add(new CustomLinkLabel(type, text, formName, popupWidth, popupHeight, internetLink)); } } return(result); }
/// <summary> /// Returns true if LinkAnnotationParameters instances are equal /// </summary> /// <param name="input">Instance of LinkAnnotationParameters to be compared</param> /// <returns>Boolean</returns> public bool Equals(LinkAnnotationParameters input) { if (input == null) { return(false); } return (( AnnotationLayout == input.AnnotationLayout || (AnnotationLayout != null && AnnotationLayout.Equals(input.AnnotationLayout)) ) && ( LinkType == input.LinkType || LinkType.Equals(input.LinkType) ) && ( LinkPage == input.LinkPage || LinkPage.Equals(input.LinkPage) ) && ( LinkUri == input.LinkUri || (LinkUri != null && LinkUri.Equals(input.LinkUri)) ) && ( ShowBorder == input.ShowBorder || ShowBorder.Equals(input.ShowBorder) ) && ( Color == input.Color || (Color != null && Color.Equals(input.Color)) )); }
/// <summary> /// This function traverses a given directory and finds all its nested directories and /// files. As the function encounters nested directories, it calls a new instance of /// the procedure passing the new found directory as a parameter. Files within the /// directories are nested and tabulated. /// </summary> /// <param name="path">Directory path to traverse.</param> private void parseDirectory(string path) { string[] entry; try { // Retrieve all entry (entry & directories) from the current path entry = Directory.GetFileSystemEntries(path); string contentType; int locDot = 0; // For each entry in the directory... for (int i = 0; i < entry.Length; i++) { // Trim the file path from the file, leaving the filename string filename = entry[i].Replace(path, string.Empty); if (!filename.StartsWith(".")) { // If the current entry is a directory... if (Directory.Exists(entry[i])) { // Find how many entry the subdirectory has and create an objectID name for the subdirectory int subentries = Directory.GetFileSystemEntries(entry[i]).Length; string objectID; if (entry[i].Length > 0) { objectID = entry[i].Replace(physRoot, string.Empty).Replace("\\", "~"); } else { objectID = "~"; } // Define the span that holds the opened/closed directory icon Write("<img id='" + objectID + "_img'"); if (Settings["Collapsed"].ToString().Equals("True")) { Write("src='" + treeImageDIR + "dir.gif'"); } else { Write("src='" + treeImageDIR + "dir_open.gif'"); } Write(" /> <a href=\"javascript:Toggle('" + objectID + "')\" " + // Create a hover tag that contains content details about the subdirectory. "title=\"" + subentries.ToString() + " entries found.\">" + filename + "</a>" + " <br />\n<div id='" + objectID + "' style='"); if (Settings["Collapsed"].ToString().Equals("True")) { Write("display:none;"); } else { Write("display:block;"); } if (!Settings["Indent"].ToString().Equals(string.Empty)) { Write("left:" + Settings["Indent"].ToString() + "; "); } // Call the parseDirectory for the new subdirectory. Write("POSITION: relative;'>\n"); parseDirectory(entry[i] + "\\"); Write("</div>\n"); } else // ...the current entry is a file. { locDot = filename.LastIndexOf(".") + 1; if (locDot > 0) { contentType = filename.Substring(locDot); } else { contentType = "unknown"; } // create a file icon // jminond - switched to use extensions pack if (availExtensions.ContainsKey(contentType)) { Write("<img src='" + baseImageDIR + availExtensions[contentType].ToString() + "' />"); } else { Write("<img src='" + baseImageDIR + "unknown.gif' />"); } Write(" "); if (LinkType.Equals("Network Share")) { Write("<a href='" + entry[i] + "' title='Last Write Time: " + File.GetLastWriteTime(entry[i]).ToString()); Write("' target='_" + Settings["Target"].ToString() + "'>" + filename + "</a>"); } else { // Create the link to the file. LinkButton lb = new LinkButton(); lb.Text = filename; lb.CommandArgument = entry[i]; lb.Click += new EventHandler(Download); myPlaceHolder.Controls.Add(lb); } Write(" <br />\n"); } } } } catch (DirectoryNotFoundException) { Write("<span class='Error'>Error! The directory path you specified does not exist.</span>"); return; } catch (Exception e1) // All other exceptions... { Write("<span class='Error'>" + e1.ToString() + "</span>"); return; } }
/// <summary> /// This function traverses a given directory and finds all its nested directories and /// files. As the function encounters nested directories, it calls a new instance of /// the procedure passing the new found directory as a parameter. Files within the /// directories are nested and tabulated. /// /// </summary> /// <param name="path">Directory path to traverse.</param> private void parseDirectory(string path) { string[] entry; try { // Retrieve all entry (entry & directories) from the current path entry = Directory.GetFileSystemEntries(path); // For each entry in the directory... for (int i = 0; i < entry.Length; i++) { // Trim the file path from the file, leaving the filename string filename = entry[i].Replace(path, string.Empty); // If the current entry is a directory... if (Directory.Exists(entry[i])) { // Find how many entry the subdirectory has and create an objectID name for the subdirectory int subentries = Directory.GetFileSystemEntries(entry[i]).Length; string objectID = entry[i].Replace(Settings["Directory"].ToString(), string.Empty).Replace("\\", "~"); // Define the span that holds the opened/closed directory icon Write("<span id='" + objectID + "Span' style='width=16;font-family:wingdings'>"); if (Settings["Collapsed"].ToString().Equals("True")) { Write("0"); } else { Write("1"); } Write("</span><a href=\"javascript:Toggle('" + objectID + "')\" " + // Create a hover tag that contains content details about the subdirectory. "title=\"" + subentries.ToString() + " entries found.\">" + filename + "</a>" + "<br>\n<span id='" + objectID + "' style='"); if (Settings["Collapsed"].ToString().Equals("True")) { Write("DISPLAY: none; "); } else { Write("DISPLAY: inline; "); } if (!Settings["Indent"].ToString().Equals(string.Empty)) { Write("LEFT: " + Settings["Indent"].ToString() + "; "); } // Call the parseDirectory for the new subdirectory. Write("POSITION: relative;'>\n"); parseDirectory(entry[i] + "\\"); Write("</span>\n"); } else // ...the current entry is a file. { // create a file icon Write("<span style='width=16;font-family:webdings'>�</span>"); if (LinkType.Equals("Network Share")) { Write("<a href='" + entry[i] + "' title='Last Write Time: " + File.GetLastWriteTime(entry[i]).ToString()); Write("' target='_" + Settings["Target"].ToString() + "'>" + filename + "</a>"); } else { // Create the link to the file. LinkButton lb = new LinkButton(); lb.Text = filename; lb.CommandArgument = entry[i]; lb.Click += new EventHandler(Download); myPlaceHolder.Controls.Add(lb); } Write("<br>\n"); } } } /* Unauthorized Access Exception: * * This error thrown when the server does not have rights to read * the current path. Please read the included documentation before * uncommenting the following lines of code. */ // catch (UnauthorizedAccessException) // { // string redirect = Request.Url.PathAndQuery.Replace("/DesktopDefault.aspx", "/WADesktopDefault.aspx"); // Response.Redirect(redirect); // } catch (DirectoryNotFoundException) { Write("<span class='Error'>Error! The directory path you specified does not exist.</span>"); return; } catch (Exception e1) // All other exceptions... { Write("<span class='Error'>" + e1.ToString() + "</span>"); return; } }