Click here to Skip to main content
15,897,518 members
Articles / Web Development / ASP.NET

OneNote on iPhone and Palm Pré using Windows Azure

Rate me:
Please Sign up or sign in to vote.
4.96/5 (39 votes)
25 Dec 2009CPOL12 min read 80.7K   322   53  
Learn how to synchronize your OneNote notebooks on Windows Azure and access it from your iPhone or your Palm Pré.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Rino.iphone
{
    /// <summary>
    /// Class for an iPhone list.
    /// </summary>
    public partial class iPhoneList : System.Web.UI.UserControl
    {
        /// <summary>
        /// Class for an item in the list.
        /// </summary>
        private class ListItem
        {
            public string text;
            public string color;
            public string link;
        }

        /// <summary>
        /// This list is selected as the current selected list
        /// </summary>
        public bool selected { get; set; }

        /// <summary>
        /// List title
        /// </summary>
        public string title { get; set; }


        /// <summary>
        /// Content of the list
        /// </summary>
        private List<ListItem> Items;


        /// <summary>
        /// Constructor
        /// </summary>
        public iPhoneList()
        {
            Items = new List<ListItem>();
        }

        /// <summary>
        /// Load event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
        }


        /// <summary>
        /// Render the control.
        /// </summary>
        /// <param name="writer">Html writer to use to render</param>
        protected override void Render(HtmlTextWriter writer)
        {
            // Write header
            writer.Write("<ul id='" + ID + "' title='" + HttpUtility.HtmlEncode(title) + "'");
            if (selected)
                writer.Write(" selected='true'");
            writer.Write(">");

            // Write content
            foreach (ListItem item in Items)
            {
                // Add line and color
                writer.Write("<li");
                if (item.color != null)
                    writer.Write(" style='background:" + item.color + "'");
                writer.Write(">");

                // Add link and text
                if (item.link != null)
                    writer.Write("<a href='" + item.link + "'>");
                writer.Write(HttpUtility.HtmlEncode(item.text));
                if (item.link != null)
                    writer.Write("</a>");

                // Close line
                writer.Write("</li>");
            }

            // Write footer
            writer.Write("</ul>");
        }


        /// <summary>
        /// Add a new item in the list.
        /// </summary>
        /// <param name="itext">item text</param>
        public void AddItem(string itext)
        {
            AddItem(itext, null, null);
        }


        /// <summary>
        /// Add a new item in the list.
        /// </summary>
        /// <param name="itext">item text</param>
        /// <param name="icolor">item color</param>
        public void AddItem(string itext, string icolor)
        {
            AddItem(itext, icolor, null);
        }


        /// <summary>
        /// Add a new item in the list.
        /// </summary>
        /// <param name="itext">item text</param>
        /// <param name="icolor">item color</param>
        /// <param name="ilink">item link</param>
        public void AddItem(string itext, string icolor, string ilink)
        {
            Items.Add(new ListItem() { text = itext, color = icolor, link = ilink });
        }
    }
}

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
Architect C2S
France France
Lionel is a software architect at C2S, a software company based in France and subsidiary of the Bouygues group.
Lionel is also the author of Liogo, an open-source Logo compiler for .NET.
Lionel is a contributor of DotNetGuru and Dr.Dobb's Journal.
Lionel is President and co-founder of OLPC France.

Comments and Discussions