Click here to Skip to main content
15,881,882 members
Articles / Desktop Programming / Windows Forms

An Alpha Channel Composited Windows Form with Designer Support

Rate me:
Please Sign up or sign in to vote.
4.96/5 (124 votes)
5 Oct 2009CPOL8 min read 322.7K   48.8K   279  
An alpha channel composited form for image based Window frames
<%@ Page Language="C#" EnableViewState="False" %>

<script runat="server">
//=============================================================================
// System  : Sandcastle Help File Builder
// File    : FillNode.aspx
// Author  : Eric Woodruff  (Eric@EWoodruff.us)
// Updated : 06/21/2007
// Note    : Copyright 2007, Eric Woodruff, All rights reserved
// Compiler: Microsoft C#
//
// This file contains the code used to dynamically load a parent node with its
// child table of content nodes when first expanded.
//
// This file may be freely used for any purpose including commercial
// applications PROVIDING that this notice and the author's name and all
// copyright notices remain intact.  In addition, altered source versions of
// this file must be clearly marked as such.
//
// This code is provided "as is" with no warranty either express or implied.
// The author accepts no liability for any damage or loss of business that
// this product may cause.
//
// Version     Date     Who  Comments
// ============================================================================
// 1.5.0.0  06/21/2007  EFW  Created the code
//=============================================================================

protected override void Render(HtmlTextWriter writer)
{
    StringBuilder sb = new StringBuilder(10240);
    string id, url, target, title;

    XmlDocument toc = new XmlDocument();
    toc.Load(Server.MapPath("WebTOC.xml"));

    // The ID to use should be passed in the query string
    XmlNode root = toc.SelectSingleNode("//HelpTOCNode[@Id='" +
        this.Request.QueryString["Id"] + "']");

    if(root == null)
    {
        writer.Write("<b>TOC node not found!</b>");
        return;
    }

    foreach(XmlNode node in root.ChildNodes)
    {
        if(node.ChildNodes.Count != 0)
        {
            // Write out a parent TOC entry
            if(node.Attributes["Url"] == null)
            {
                id = node.Attributes["Id"].Value;
                title = node.Attributes["Title"].Value;
                url = "#";
                target = String.Empty;
            }
            else
            {
                id = node.Attributes["Id"].Value;
                title = node.Attributes["Title"].Value;
                url = node.Attributes["Url"].Value;
                target = " target=\"TopicContent\"";
            }

            sb.AppendFormat("<div class=\"TreeNode\">\r\n" +
                "<img class=\"TreeNodeImg\" " +
                "onclick=\"javascript: Toggle(this);\" " +
                "src=\"Collapsed.gif\"/><a class=\"UnselectedNode\" " +
                "onclick=\"javascript: return Expand(this);\" " +
                "href=\"{0}\"{1}>{2}</a>\r\n" +
                "<div id=\"{3}\" class=\"Hidden\"></div>\r\n</div>\r\n",
                url, target, HttpUtility.HtmlEncode(title), id);
        }
        else
        {
            title = node.Attributes["Title"].Value;
            url = node.Attributes["Url"].Value;

            // Write out a TOC entry that has no children
            sb.AppendFormat("<div class=\"TreeItem\">\r\n" +
                "<img src=\"Item.gif\"/>" +
                "<a class=\"UnselectedNode\" " +
                "onclick=\"javascript: return SelectNode(this);\" " +
                "href=\"{0}\" target=\"TopicContent\">{1}</a>\r\n" +
                "</div>\r\n", url, HttpUtility.HtmlEncode(title));
        }
    }

    writer.Write(sb.ToString());
}
</script>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
Jeff Anderson has been a computer graphics software developer for over twenty years.

He is a co-founder of Braid Art Labs and a developer of Braid's GroBoto 3D software. Jeff also dabbles in shareware with an expanded version of the AlphaForm control and other programs here.

Comments and Discussions