Exemple #1
0
        private void SetSortHeaderAttributes(ASP.GridViewRowEventArgs e)
        {
            bool images = (this.AscImage != String.Empty && this.DescImage != String.Empty);

            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                ASP.TableCell td = e.Row.Cells[i];
                if (td.HasControls())
                {
                    ASP.LinkButton button = td.Controls[0] as ASP.LinkButton;
                    if (button != null)
                    {
                        if (this.SortExpression == button.CommandArgument)
                        {
                            td.ApplyStyle(this.SortedColumnHeaderRowStyle);
                            this.sortColumnIndex = i;
                            if (images)
                            {
                                ImageButton btn = new ImageButton();
                                btn.CommandName     = button.CommandName;
                                btn.CommandArgument = button.CommandArgument;
                                btn.ImageUrl        = (this.SortDirection == ASP.SortDirection.Ascending ? this.AscImage : this.DescImage);
                                td.Controls.Add(new LiteralControl("&nbsp;"));
                                td.Controls.Add(btn);
                                td.Controls.Add(new LiteralControl("&nbsp;"));
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the design time HTML code.
        /// </summary>
        /// <returns>A string containing the HTML to render.</returns>
        public override string GetDesignTimeHtml()
        {
            PagedControl pagerBuilder = (PagedControl)base.Component;

            StringBuilder stringBuilder = new StringBuilder();

            StringWriter   stringWriter = new StringWriter();
            HtmlTextWriter writer       = new HtmlTextWriter(stringWriter);

            // Initialize the structure.
            System.Web.UI.WebControls.Table     pagerPanel               = new System.Web.UI.WebControls.Table();
            System.Web.UI.WebControls.TableRow  pagerPanelRow            = new System.Web.UI.WebControls.TableRow();
            System.Web.UI.WebControls.TableCell pagerPanelInfoCell       = new System.Web.UI.WebControls.TableCell();
            System.Web.UI.WebControls.TableCell pagerPanelNavigationCell = new System.Web.UI.WebControls.TableCell();

            pagerPanelRow.Cells.Add(pagerPanelInfoCell);
            pagerPanelRow.Cells.Add(pagerPanelNavigationCell);

            pagerPanel.Rows.Add(pagerPanelRow);

            // Initialize structure appearance
            pagerPanel.ApplyStyle(pagerBuilder.PagerStyle);
            pagerPanel.Width           = pagerBuilder.Width;
            pagerPanel.Height          = pagerBuilder.Height;
            pagerPanel.HorizontalAlign = pagerBuilder.HorizontalAlign;

            pagerPanel.CellPadding = pagerBuilder.CellPadding;
            pagerPanel.CellSpacing = pagerBuilder.CellSpacing;

            pagerPanelRow.CssClass = pagerBuilder.PanelCssClass;

            //pagerBuilder.InfoPanelStyle.MergeWith(pagerBuilder.PagerStyle);
            //pagerPanelInfoCell.ApplyStyle(pagerBuilder.InfoPanelStyle);
            pagerPanelInfoCell.ApplyStyle(pagerBuilder.PagerStyle);
            pagerPanelInfoCell.HorizontalAlign = pagerBuilder.InfoPanelHorizontalAlign;
            pagerPanelInfoCell.VerticalAlign   = pagerBuilder.InfoPanelVerticalAlign;
            pagerPanelInfoCell.Visible         = !pagerBuilder.InfoPanelDisabled;

            //pagerBuilder.NavPanelStyle.MergeWith(pagerBuilder.PagerStyle);
            //pagerPanelNavigationCell.ApplyStyle(pagerBuilder.NavPanelStyle);
            pagerPanelNavigationCell.ApplyStyle(pagerBuilder.PagerStyle);
            pagerPanelNavigationCell.HorizontalAlign = pagerBuilder.NavPanelHorizontalAlign;
            pagerPanelNavigationCell.VerticalAlign   = pagerBuilder.NavPanelVerticalAlign;

            // Initialize the info panel
            pagerBuilder.BuildInfo(pagerPanelInfoCell, true);

            // Initialize the navigation panel
            pagerBuilder.BuildNavigation(pagerPanelNavigationCell);

            // Add the whole structure to the control collection
            pagerPanel.RenderControl(writer);

            return(stringWriter.ToString());
        }
Exemple #3
0
        // All the .NET API related methods.
        #region DOTNET API
        /// <summary>
        /// Create the child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            //PrintStatus();

            // Initialize the structure.
            System.Web.UI.WebControls.Table     pagerPanel               = new System.Web.UI.WebControls.Table();
            System.Web.UI.WebControls.TableRow  pagerPanelRow            = new System.Web.UI.WebControls.TableRow();
            System.Web.UI.WebControls.TableCell pagerPanelInfoCell       = new System.Web.UI.WebControls.TableCell();
            System.Web.UI.WebControls.TableCell pagerPanelNavigationCell = new System.Web.UI.WebControls.TableCell();

            pagerPanelRow.Cells.Add(pagerPanelInfoCell);
            pagerPanelRow.Cells.Add(pagerPanelNavigationCell);

            pagerPanel.Rows.Add(pagerPanelRow);

            // Initialize structure appearance
            pagerPanel.ApplyStyle(this.PagerStyle);
            pagerPanel.Width           = this.Width;
            pagerPanel.Height          = this.Height;
            pagerPanel.HorizontalAlign = this.HorizontalAlign;

            pagerPanel.CellPadding = CellPadding;
            pagerPanel.CellSpacing = CellSpacing;
            pagerPanel.BorderWidth = BorderWidth;
            pagerPanel.CssClass    = CssClass;

            pagerPanelRow.CssClass = PanelCssClass;

            //this.InfoPanelStyle.MergeWith(this.PagerStyle);
            //pagerPanelInfoCell.ApplyStyle(this.InfoPanelStyle);
            pagerPanelInfoCell.ApplyStyle(this.PagerStyle);
            pagerPanelInfoCell.HorizontalAlign = InfoPanelHorizontalAlign;
            pagerPanelInfoCell.VerticalAlign   = InfoPanelVerticalAlign;
            pagerPanelInfoCell.Visible         = !this.InfoPanelDisabled;

            //this.NavPanelStyle.MergeWith(this.PagerStyle);
            //pagerPanelNavigationCell.ApplyStyle(this.NavPanelStyle);
            pagerPanelNavigationCell.ApplyStyle(this.PagerStyle);
            pagerPanelNavigationCell.HorizontalAlign = NavPanelHorizontalAlign;
            pagerPanelNavigationCell.VerticalAlign   = NavPanelVerticalAlign;
            pagerPanelNavigationCell.Visible         = !this.NavPanelDisabled;

            // Initialize the info panel
            BuildInfo(pagerPanelInfoCell, false);

            // Initialize the navigation panel
            BuildNavigation(pagerPanelNavigationCell);

            // Add the whole structure to the control collection
            this.Controls.Add(pagerPanel);

            //PrintStatus();
        }
Exemple #4
0
        protected override void OnRowCreated(ASP.GridViewRowEventArgs e)
        {
            base.OnRowCreated(e);
            if (e.Row != null)
            {
                switch (e.Row.RowType)
                {
                case ASP.DataControlRowType.Header: this.SetSortHeaderAttributes(e); break;

                case ASP.DataControlRowType.DataRow:
                    if (this.sortColumnIndex > -1)
                    {
                        ASP.TableCell td = e.Row.Cells[this.sortColumnIndex];
                        td.ApplyStyle(this.SortedColumnRowStyle);
                    }
                    break;
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Inserts a grid row. Only cells required for the summary results
        /// will be created (except if GenerateAllCellsOnSummaryRow is true).
        /// The group will be checked for columns with summary
        /// </summary>
        /// <param name="beforeRow"></param>
        /// <param name="g"></param>
        /// <returns></returns>
        private GridViewRow InsertGridRow(GridViewRow beforeRow, GridViewGroup g)
        {
            int colspan;
            TableCell cell;
            TableCell[] tcArray;
            int visibleColumns = this.GetVisibleColumnCount();

            Table tbl = (Table)mGrid.Controls[0];
            int newRowIndex = tbl.Rows.GetRowIndex(beforeRow);
            GridViewRow newRow = new GridViewRow(newRowIndex, newRowIndex, DataControlRowType.DataRow, DataControlRowState.Normal);

            if (g != null && (g.IsSuppressGroup || g.GenerateAllCellsOnSummaryRow))
            {
                // Create all the table cells
                tcArray = new TableCell[visibleColumns];
                for (int i = 0; i < visibleColumns; i++)
                {
                    cell = new TableCell();
                    cell.ApplyStyle(mGrid.Columns[GetRealIndexFromVisibleColumnIndex(i)].ItemStyle);
                    cell.Text = "&nbsp;";
                    tcArray[i] = cell;
                }
            }
            else
            {
                // Create only the required table cells
                colspan = 0;
                List<TableCell> tcc = new List<TableCell>();
                for (int i = 0; i < mGrid.Columns.Count; i++)
                {
                    if (ColumnHasSummary(i, g))
                    {
                        if (colspan > 0)
                        {
                            cell = new TableCell();
                            cell.Text = "&nbsp;";
                            cell.ColumnSpan = colspan;
                            tcc.Add(cell);
                            colspan = 0;
                        }

                        // insert table cell and copy the style
                        cell = new TableCell();
                        cell.ApplyStyle(mGrid.Columns[i].ItemStyle);
                        tcc.Add(cell);
                    }
                    else if (mGrid.Columns[i].Visible)
                    {
                        // A visible column that will have no cell because has
                        // no summary. So we increase the colspan...
                        colspan++;
                    }
                }

                if (colspan > 0)
                {
                    cell = new TableCell();
                    cell.Text = "&nbsp;";
                    cell.ColumnSpan = colspan;
                    tcc.Add(cell);
                    colspan = 0;
                }

                tcArray = new TableCell[tcc.Count];
                tcc.CopyTo(tcArray);
            }

            newRow.Cells.AddRange(tcArray);
            tbl.Controls.AddAt(newRowIndex, newRow);

            return newRow;
        }
			TableRow CreateRow (Control c0, Control c1, Control c2, Style s)
			{
				TableRow row = new TableRow ();
				TableCell cell0 = new TableCell ();
				TableCell cell1 = new TableCell ();

				if (c0 != null) {
					cell0.Controls.Add (c0);
					row.Controls.Add (cell0);
				}

				if (s != null)
					cell0.ApplyStyle (s);

				if ((c1 != null) && (c2 != null)) {
					cell1.Controls.Add (c1);
					cell1.Controls.Add (c2);
					cell0.HorizontalAlign = HorizontalAlign.Right;
					row.Controls.Add (cell1);
				}
				return row;
			}
Exemple #7
0
        //
        // Private methods
        //
        void WriteDayHeader(HtmlTextWriter writer, bool enabled)
        {
            int    i, first;
            string dayName;

            i = first = (int)(DisplayFirstDayOfWeek);
            TableCell cell;


            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            if (SelectionMode == CalendarSelectionMode.DayWeek)
            {
                cell = new TableCell();
                cell.HorizontalAlign = HorizontalAlign.Center;
                cell.ApplyStyle(DayHeaderStyle);

                // Empty Cell
                cell.RenderBeginTag(writer);
                cell.RenderEndTag(writer);
            }
            else
            {
                if (SelectionMode == CalendarSelectionMode.DayWeekMonth)
                {
                    TableCell selector = new TableCell();
                    selector.ApplyStyle(SelectorStyle);
                    selector.HorizontalAlign = HorizontalAlign.Center;

                    DateTime date = new DateTime(DisplayDate.Year, DisplayDate.Month, 1);                      // first date
                    int      days = DateTime.DaysInMonth(DisplayDate.Year, DisplayDate.Month);

                    selector.RenderBeginTag(writer);
                    writer.Write(BuildLink("R" + GetDaysFromZenith(date) + days, SelectMonthText, DayHeaderStyle.ForeColor, enabled));
                    selector.RenderEndTag(writer);
                }
            }

            DateTimeFormatInfo dti = DateInfo;

            while (true)
            {
                DayOfWeek dayOfWeek = (DayOfWeek)i;
                dayName = dti.GetDayName(dayOfWeek);

#if NET_2_0
                if (UseAccessibleHeader)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Abbr, dayName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col", false);
                    cell = new TableHeaderCell();
                }
                else
#endif
                cell = new TableCell();

                cell.HorizontalAlign = HorizontalAlign.Center;
                cell.ApplyStyle(DayHeaderStyle);

                cell.RenderBeginTag(writer);

                switch (DayNameFormat)
                {
                case DayNameFormat.FirstLetter:
                    dayName = dayName.Substring(0, 1);
                    break;

                case DayNameFormat.FirstTwoLetters:
                    dayName = dayName.Substring(0, 2);
                    break;

#if NET_2_0
                case DayNameFormat.Shortest:
                    dayName = dti.GetShortestDayName(dayOfWeek);
                    break;
#endif
                case DayNameFormat.Full:
                    break;

                case DayNameFormat.Short:
                default:
                    dayName = dti.GetAbbreviatedDayName(dayOfWeek);
                    break;
                }

                writer.Write(dayName);
                cell.RenderEndTag(writer);

                if (i >= daysInAWeek - 1)
                {
                    i = 0;
                }
                else
                {
                    i++;
                }
                if (i == first)
                {
                    break;
                }
            }

            writer.RenderEndTag();
        }
        protected override void OnDayRender(TableCell cell, CalendarDay day)
        {
            // _dtSource was already set by the Render method            
            if (_dtSource != null)
            {

                // We have the data source as a DataTable now;                
                // filter the records in the DataTable for the given day;
                // force the date format to be MM/dd/yyyy
                // to ensure compatibility with RowFilter
                // date expression syntax (#date#).
                // Also, take the possibility of time
                // values into account by specifying
                // a date range, to include the full day
                DataView dv = new DataView(_dtSource);
                dv.RowFilter = string.Format(
                   "{0} >= #{1}# and {0} < #{2}#",
                   this.DayField,
                   day.Date.ToString("MM/dd/yyyy"),
                   day.Date.AddDays(1).ToString("MM/dd/yyyy")
                );

                // are there events on this day?
                if (dv.Count > 0)
                {
                    // there are events on this day; if indicated, 
                    // apply the DayWithEventsStyle to the table cell
                    if (this.DayWithEventsStyle != null)
                        cell.ApplyStyle(this.DayWithEventsStyle);

                    // for each event on this day apply the
                    // ItemTemplate, with data bound to the item's row
                    // from the data source
                    if (this.ItemTemplate != null)
                        for (int i = 0; i < dv.Count; i++)
                        {
                            SetupCalendarItem(cell, dv[i].Row, this.ItemTemplate);
                        }

                }
                else
                {
                    // no events this day;
                    if (this.NoEventsTemplate != null)
                        SetupCalendarItem(cell, null, this.NoEventsTemplate);

                }

            }

            // call the base render method too
            base.OnDayRender(cell, day);

        }
 private void RenderErrorMessage(HtmlTextWriter writer) {
     if (_displayErrorMessage) {
         writer.RenderBeginTag(HtmlTextWriterTag.Tr);
         TableCell td = new TableCell();
         td.ApplyStyle(ErrorStyle);
         td.Text = NewConnectionErrorMessage;
         td.RenderControl(writer);
         writer.RenderEndTag();
     }
 }
		private void InitializeCellFooter(TableCell cell, int columnIndex)
		{
			cell.Text = (FooterText.Length > 0 ? FooterText : "&nbsp;");
			if (FooterStyleInternal != null)
				cell.ApplyStyle (FooterStyleInternal);
		}
Exemple #11
0
        public void Init(Control target, Style messageStyle)
        {
            UpdatePanel messageUpdatePanel = target.FindControl("messageUpdatePanel") as UpdatePanel;
            if (null == messageUpdatePanel)
            {
                messageUpdatePanel = new UpdatePanel();
                messageUpdatePanel.ID = "messageUpdatePanel";
                target.Controls.Add(messageUpdatePanel);
                Table messageTable = new Table();
                TableRow messageRow = new TableRow();
                TableCell messageCell = new TableCell();
                messageCell.ApplyStyle(messageStyle);
                _message = new Label();
                messageCell.Controls.Add(this._message);
                messageRow.Cells.Add(messageCell);
                messageTable.Rows.Add(messageRow);
                messageUpdatePanel.ContentTemplateContainer.Controls.Add(messageTable);
            }

            UpdatePanel commandersUpdatePanel = target.FindControl("commandersUpdatePanel") as UpdatePanel;
            if (null == commandersUpdatePanel)
            {
                commandersUpdatePanel = new UpdatePanel();
                commandersUpdatePanel.ID = "commandersUpdatePanel";
                target.Controls.Add(commandersUpdatePanel);
            }

            Panel commandersWrapper = commandersUpdatePanel.FindControl("commandersWrapper") as Panel;
            if (null == commandersWrapper)
            {
                commandersWrapper = new Panel();
                commandersWrapper.ID = "commandersWrapper";
                commandersWrapper.CssClass = "table-responsive";
                commandersUpdatePanel.ContentTemplateContainer.Controls.Add(commandersWrapper);
            }

            _commandersHolder = commandersWrapper.FindControl("commandersHolder");
            if (null == _commandersHolder)
            {
                _commandersHolder = new Table();
                _commandersHolder.ID = "commandersHolder";
                ((Table)_commandersHolder).CssClass = "";
                commandersWrapper.Controls.Add(_commandersHolder);
            }

            _selectorsHolder = target.FindControl("selectorsHolder");
            if (null == _selectorsHolder)
            {
                _selectorsHolder = new Table();
                _selectorsHolder.ID = "selectorsHolder";
                target.Controls.Add(this._selectorsHolder);
            }

            UpdatePanel updatePanel = target.FindControl("containerUpdatePanel") as UpdatePanel;
            if (null == updatePanel)
            {
                updatePanel = new UpdatePanel();
                updatePanel.ID = "containerUpdatePanel";
                target.Controls.Add(updatePanel);
            }

            Panel wrapper = updatePanel.FindControl("containerWrapper") as Panel;
            if (null == wrapper)
            {
                wrapper = new Panel();
                wrapper.ID = "containerWrapper";
                wrapper.CssClass = "table-responsive";
                updatePanel.ContentTemplateContainer.Controls.Add(wrapper);
            }

            Table innerTable = wrapper.FindControl("innerTable") as Table;
            if (null == innerTable)
            {
                innerTable = new Table();
                innerTable.ID = "innerTable";
                innerTable.CssClass = "table table-striped table-hover table-condensed";
                wrapper.Controls.Add(innerTable);
            }

            if (null == this._container)
            {
                _container = innerTable;
            }
        }
Exemple #12
0
		/// <summary>
		/// AddMenu is called recusively, doing a depth-first traversal of the menu hierarchy and building
		/// up the HTML elements from the object model.
		/// </summary>
		/// <param name="menuID">The ID of the parent menu.</param>
		/// <param name="myItems">The collection of menuitems.</param>
		protected virtual void AddMenu(string menuID, MenuItemCollection myItems)
		{
			string image = string.Empty;
			string mouseoverimage = string.Empty;
			string mousedownimage = string.Empty;
			string mouseupimage = string.Empty;
			
			// iterate through the Items
			Table menu = new Table();

			menu.Attributes.Add("id", menuID);
			menu.Attributes.Add("style", "display: none;");
			// The style is overwritten by anthing specifically set in menuitem
			if (this.BackColor != Color.Empty)
				menu.BackColor = this.BackColor;
			if (this.Font != null)
				menu.Font.CopyFrom(this.Font);
			if (this.ForeColor != Color.Empty)
				menu.ForeColor = this.ForeColor;
			if (this.SubMenuCssClass != String.Empty) 
				menu.CssClass = this.SubMenuCssClass;
			else if (this.CssClass != String.Empty) // Use if SubMenuCssClass was blank
				menu.CssClass = this.CssClass;
			if (this.BorderColor != Color.Empty)
				menu.BorderColor = this.BorderColor;
			if (this.BorderStyle != BorderStyle.NotSet)
				menu.BorderStyle = this.BorderStyle;
			if (this.BorderWidth != Unit.Empty)
				menu.BorderWidth = this.BorderWidth;
			menu.CellPadding = ItemPadding;
			menu.CellSpacing = ItemSpacing;
			menu.GridLines = GridLines;
			menu.Style.Add("z-index", curzindex.ToString());
			curzindex += 2;

			BuildOpacity(menu);

			// Iterate through the menuItem's subMenu...
			for (int i = 0; i < myItems.Count; i++)
			{
				MenuItem mi = myItems[i];

				// only render this MenuItem if it is visible and the user has permissions
				if (mi.Visible && UserHasPermission(mi)) 
				{
					TableRow tr = new TableRow();		
					
					TableCell td = new TableCell();
					td.ApplyStyle(this.unselectedMenuItemStyle);
					// The style is overwritten by anything specifically set in menuitem
					if (mi.BackColor != Color.Empty) 
						td.BackColor = mi.BackColor;
					if (mi.Font != null)
						td.Font.CopyFrom(mi.Font);
					if (mi.ForeColor != Color.Empty)
						td.ForeColor = mi.ForeColor;
					if (mi.Height != Unit.Empty)
						td.Height = mi.Height;
					if (mi.Width != Unit.Empty)
						td.Width = mi.Width;
					if (mi.CssClass != String.Empty)
						td.CssClass = mi.CssClass;
					else if	(this.DefaultCssClass != String.Empty)
						td.CssClass = this.DefaultCssClass;
					if (mi.BorderColor != Color.Empty)
						td.BorderColor = mi.BorderColor;
					if (mi.BorderStyle != BorderStyle.NotSet)
						td.BorderStyle = mi.BorderStyle;
					if (mi.BorderWidth != Unit.Empty)
						td.BorderWidth = mi.BorderWidth;
					if (mi.HorizontalAlign != System.Web.UI.WebControls.HorizontalAlign.NotSet)
						td.HorizontalAlign = mi.HorizontalAlign;
					if (mi.VerticalAlign != System.Web.UI.WebControls.VerticalAlign.NotSet)
						td.VerticalAlign = mi.VerticalAlign;
					BuildOpacity(td);
					if (mi.Text != string.Empty)
					{
						//add by johnny start
						if (this.MarginLeftWidth != 0) 
						{
							StringBuilder sb = new StringBuilder();							
							sb.Append("<span style='margin-left:");
							sb.Append(this.MarginLeftWidth);
							sb.Append(";'>");
							sb.Append(mi.Text);
							sb.Append("</span>");
							td.Text = sb.ToString();
						}
						else
						{
							td.Text = mi.Text;
						}
						//end
					}
						
					else if (mi.Image != string.Empty) // Show Image
					{
						System.Web.UI.WebControls.Image cellimage = new System.Web.UI.WebControls.Image();

						cellimage.ImageUrl = mi.Image;
						cellimage.AlternateText = mi.ImageAltText;
						td.Controls.Add(cellimage);

						image = mi.Image;
						mouseoverimage = mi.MouseOverImage;
						mousedownimage = mi.MouseDownImage;
						mouseupimage = mi.MouseUpImage;
					}
					td.Attributes.Add("id", mi.MenuID);

					// Add in the left or right image as needed
					if (mi.LeftImage != String.Empty) 
					{
						System.Web.UI.WebControls.Image leftimage = new System.Web.UI.WebControls.Image();
						System.Web.UI.WebControls.Literal leftliteral = new System.Web.UI.WebControls.Literal();

						leftimage.ImageAlign = mi.LeftImageAlign;
						if (mi.LeftImageRightPadding != Unit.Empty)
							leftimage.Style.Add("margin-right",mi.LeftImageRightPadding.Value.ToString());
						leftimage.ImageUrl = mi.LeftImage;
						td.Controls.Add(leftimage);

						leftliteral.Text = td.Text;
						td.Controls.Add(leftliteral);
					} 
					else if (mi.RightImage != String.Empty) 
					{
						System.Web.UI.WebControls.Image rightimage = new System.Web.UI.WebControls.Image();
						System.Web.UI.WebControls.Literal rightliteral = new System.Web.UI.WebControls.Literal();
						
						rightliteral.Text = td.Text;
						td.Controls.Add(rightliteral);

						rightimage.ImageAlign = mi.RightImageAlign;
						if (mi.RightImageLeftPadding != Unit.Empty)
							rightimage.Style.Add("margin-left",mi.RightImageLeftPadding.Value.ToString());
						rightimage.ImageUrl = mi.RightImage;
						td.Controls.Add(rightimage);
					}

					// Prepare MouseOverCssClass
					string mouseover = String.Empty;

					if (this.DefaultMouseOverCssClass != string.Empty || mi.MouseOverCssClass != string.Empty || this.selectedMenuItemStyle.CssClass != String.Empty)
						mouseover = "this.className='" + GetClass(this.DefaultMouseOverCssClass, mi.MouseOverCssClass, this.selectedMenuItemStyle.CssClass) + "';";

					if (mi.Enabled) // If enabled...
					{
						// Generate OnClick handler
						if (mi.JavascriptCommand != String.Empty) // javascript command
							td.Attributes.Add("onclick", mi.JavascriptCommand + "skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));");
						else if (mi.Url != String.Empty) 
						{
							if (mi.Target != String.Empty)
								td.Attributes.Add("onclick", "javascript:skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));window.open('" + GetURL(mi.ResolveURL, mi.Url) + "','" + mi.Target + "');");
							else if (this.DefaultTarget != String.Empty)
								td.Attributes.Add("onclick", "javascript:skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));window.open('" + GetURL(mi.ResolveURL, mi.Url) + "','" + this.DefaultTarget + "');");
							else
								td.Attributes.Add("onclick", "javascript:skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));location.href='" + GetURL(mi.ResolveURL, mi.Url) + "';");	
						}
						else if (mi.CommandName != String.Empty)  // Must be postback action
							td.Attributes.Add("onclick", Page.GetPostBackClientHyperlink(this, mi.CommandName));
						else if (this.ClickToOpen) // Open submenu on click
							td.Attributes.Add("onclick", "javascript:skm_mousedOverMenu('" + this.ClientID + "',this, document.getElementById('" + menuID + "'), true, '" + mouseoverimage + "');" + GenerateShimCall("true", mi.MenuID + "-subMenu"));
					}

					if (mi.Enabled)
					{
						// Output Tooltip
						if (mi.ToolTip != String.Empty) 
							td.ToolTip = mi.ToolTip;
					}

					// Is this a enabled menuitem?  (as opposed to a Separator or Header)
					if (mi.MenuType == MenuItemType.MenuItem && mi.Enabled) 
					{
						// Output MouseDownCssClass or MouseDownImage
						string mousedown = String.Empty;

						if (this.DefaultMouseDownCssClass != string.Empty || mi.MouseDownCssClass != string.Empty)
							mousedown = "this.className='" + GetClass(this.DefaultMouseDownCssClass, mi.MouseDownCssClass) + "';";

						if (mousedownimage != String.Empty)
							mousedown += "setimage(this, '" + mousedownimage + "');";

						if (mousedown != string.Empty)
							td.Attributes.Add("onmousedown", mousedown);

						// Output MouseUpCssClass or MouseUpImage
						string mouseup = String.Empty;

						if (this.DefaultMouseUpCssClass != string.Empty || mi.MouseUpCssClass != string.Empty)
							mouseup = "this.className='" + GetClass(this.DefaultMouseUpCssClass, mi.MouseUpCssClass) + "';";

						if (mouseupimage != String.Empty)
							mouseup += "setimage(this, '" + mouseupimage + "');";

						if (mouseup != string.Empty)
							td.Attributes.Add("onmouseup", mouseup);

						if (this.ClickToOpen == false) 
						{ 
							td.Attributes.Add("onmouseover", "javascript:skm_mousedOverMenu('" + this.ClientID + "',this, document.getElementById('" + menuID + "'), true, '" + mouseoverimage + "');" + GenerateShimCall("true", mi.MenuID + "-subMenu") + mouseover);
						} 
						else
							td.Attributes.Add("onmouseover", "javascript:skm_mousedOverClickToOpen('" + this.ClientID + "', this, document.getElementById('" + menuID + "'), '" + mouseoverimage + "');"+ mouseover);

						td.Attributes.Add("onmouseout", "javascript:skm_mousedOutMenu('" + this.ClientID + "', this,'" + image + "');" + "this.className='" + GetClass(this.DefaultCssClass, mi.CssClass, this.unselectedMenuItemStyle.CssClass) + "';");
					} 
					else 
					{  // If only a spacer, header or disabled, don't make any style change on mouseover
						td.Attributes.Add("onmouseover", "javascript:skm_mousedOverSpacer('" + this.ClientID + "', this, document.getElementById('" + menuID + "'));");
						td.Attributes.Add("onmouseout", "javascript:skm_mousedOutSpacer('" + this.ClientID + "', this);");
					}

					if (mi.Url != String.Empty || mi.CommandName != String.Empty)
						if (this.Cursor != MouseCursor.Default) 
						{
							if (this.Page.Request.Browser.Browser == "IE")
								td.Style.Add("cursor","hand"); 
							else
								td.Style.Add("cursor","pointer"); 
						}

					tr.Cells.Add(td);
					menu.Rows.Add(tr);

					// (Recursively) Add the subitems for this menu, if needed
					if (mi.SubItems.Count > 0)
					{
						// Create an IFrame (IE5.5 or better) to windowed form elements that might
						// interfere with display of the menu
						if (this.Page.Request.Browser.Browser == "IE" && Convert.ToDouble(this.Page.Request.Browser.Version, enUSCulture) >= 5.5) 
						{
							System.Web.UI.HtmlControls.HtmlGenericControl iframe = new System.Web.UI.HtmlControls.HtmlGenericControl();
							iframe.TagName = "iframe";
							iframe.Attributes.Add("id", "shim" + mi.MenuID + "-subMenu");
							iframe.Attributes.Add("src", IFrameSrc);
							iframe.Attributes.Add("scrolling", "no");
							iframe.Attributes.Add("frameborder", "no");
							iframe.Style.Add("position", "absolute");
							iframe.Style.Add("top", "0px");
							iframe.Style.Add("left", "0px");
							iframe.Style.Add("display", "none");
							BuildOpacity(iframe);
							Controls.Add(iframe);			
						}

						this.subItemsIds.Add(mi.MenuID + "-subMenu");
						AddMenu(mi.MenuID + "-subMenu", mi.SubItems); 
					}
				}
			}

			Controls.Add(menu);
		}
		void WriteDays (HtmlTextWriter writer)
		{
			DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
			DateTime lastDate;
			TableCell selectorCell = null;
			int n;

			// Goes backwards until we find the date of that is begining of the week
			for (n = 0; n < daysInAWeek; n++) {
				if (date.DayOfWeek == DisplayFirstDayOfWeek)
					break;

				date = GetGlobalCalendar().AddDays (date, -1);
			}
			/* if the start date is the first day of the week, we need to shift backward one more week */
			if (n == 0)
				date = GetGlobalCalendar().AddDays (date, -1 * daysInAWeek);

			lastDate = GetGlobalCalendar().AddDays (date, 6 * daysInAWeek); // Always six weeks per months

			while (true) {
				writer.RenderBeginTag (HtmlTextWriterTag.Tr);

				if (HasWeekSelectors (SelectionMode)) {	// Week selector
					if (selectorCell == null) {
						selectorCell = new TableCell ();
						selectorCell.ApplyStyle (SelectorStyle);
						selectorCell.HorizontalAlign = HorizontalAlign.Center;
						selectorCell.Width = Unit.Percentage (GetCellWidth ());
					}

					selectorCell.RenderBeginTag (writer);
					writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, Enabled));
					selectorCell.RenderEndTag (writer);
				}

				for (int i = 0; i < daysInAWeek; i++) {
					WriteDay (date, writer);
					date = GetGlobalCalendar().AddDays (date, 1);
				}

				writer.RenderEndTag ();
				if (date >= lastDate)
					break;
			}
		}
		private void RenderAllDays (HtmlTextWriter writer,
					    DateTime firstDay,
					    DateTime activeDate,
					    CalendarSelectionMode mode,
					    bool isActive,
					    bool isDownLevel)
		{
			TableItemStyle weeksStyle = null;
			TableCell weeksCell = new TableCell ();
			TableItemStyle weekendStyle = WeekendDayStyle;
			TableItemStyle otherMonthStyle = OtherMonthDayStyle;
			Unit size;
			bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
					   mode == CalendarSelectionMode.DayWeekMonth);

			if (isWeekMode) {
				weeksStyle = new TableItemStyle ();
				weeksStyle.Width = Unit.Percentage (12);
				weeksStyle.HorizontalAlign = HorizontalAlign.Center;
				weeksStyle.CopyFrom (SelectorStyle);
				size = Unit.Percentage (12);
			} else {
				size = Unit.Percentage (14);
			}

			TableItemStyle [] styles = new TableItemStyle [32];
			int definedStyles = MASK_SELECTED;
			if (weekendStyle != null && !weekendStyle.IsEmpty)
				definedStyles |= MASK_WEEKEND;
			if (otherMonthStyle != null && !otherMonthStyle.IsEmpty)
				definedStyles |= MASK_OMONTH;
			if (todayDayStyle != null && !todayDayStyle.IsEmpty)
				definedStyles |= MASK_TODAY;
			if (dayStyle != null && !dayStyle.IsEmpty)
				definedStyles |= MASK_DAY;

			int month = globCal.GetMonth (activeDate);
			DateTime currentDay = firstDay;
			int begin = (int) (firstDay - begin_date).TotalDays;
			for (int crr = 0; crr < 6; crr++) {
				writer.Write ("<tr>");
				if (isWeekMode) {
					int week_offset = begin + crr * 7;
					string cellText = GetCalendarLinkText (
								"R" + week_offset + "07",
								SelectWeekText, 
								"Select week " + (crr + 1),
								weeksCell.ForeColor,
								isActive);

					weeksCell.Text = cellText;
					weeksCell.ApplyStyle (weeksStyle);
					RenderCalendarCell (writer, weeksCell, cellText);
				}

				for (int weekDay = 0; weekDay < 7; weekDay++) {
					string dayString = currentDay.Day.ToString ();
					DayOfWeek dow = currentDay.DayOfWeek;
					CalendarDay calDay =
						new CalendarDay (
								currentDay,
								dow == DayOfWeek.Sunday ||
								dow == DayOfWeek.Saturday,
								currentDay == TodaysDate, 
								SelectedDates.Contains (currentDay),
								globCal.GetMonth (currentDay) != month,
								dayString
								);


					int dayStyles = GetMask (calDay) & definedStyles;
					TableItemStyle currentDayStyle = styles [dayStyles];
					if (currentDayStyle == null) {
						currentDayStyle = new TableItemStyle ();
						if ((dayStyles & MASK_DAY) != 0)
							currentDayStyle.CopyFrom (DayStyle);

						if ((dayStyles & MASK_WEEKEND) != 0)
							currentDayStyle.CopyFrom (WeekendDayStyle);

						if ((dayStyles & MASK_TODAY) != 0)
							currentDayStyle.CopyFrom (TodayDayStyle);

						if ((dayStyles & MASK_OMONTH) != 0)
							currentDayStyle.CopyFrom (OtherMonthDayStyle);

						if ((dayStyles & MASK_SELECTED) != 0) {
							currentDayStyle.ForeColor = Color.White;
							currentDayStyle.BackColor = Color.Silver;
							currentDayStyle.CopyFrom (SelectedDayStyle);
						}

						currentDayStyle.Width = size;
						currentDayStyle.HorizontalAlign = HorizontalAlign.Center;
					}

					TableCell dayCell = new TableCell ();
					dayCell.ApplyStyle (currentDayStyle);
					LiteralControl number = new LiteralControl (dayString);
					dayCell.Controls.Add (number);
					calDay.IsSelectable = isActive;
					OnDayRender (dayCell, calDay);
					if (calDay.IsSelectable)
						number.Text = GetCalendarLinkText ((begin + (crr * 7 + weekDay)).ToString (),
									dayString,
									currentDay.ToShortDateString (),
									dayCell.ForeColor,
									isActive);

					dayCell.RenderControl (writer);
					currentDay = globCal.AddDays (currentDay, 1);
				}
				writer.Write("</tr>");
			}
		}
Exemple #15
0
		/// <summary>
		/// BuildMenu builds the top-level menu.  It is called from the OnDataBinding method as well
		/// as from <see cref="CreateChildControls"/>.  It has code to check if the top-level menu should be
		/// laid out horizontally or vertically.
		/// </summary>
		protected virtual void BuildMenu()
		{
			string image = string.Empty;
			string mouseoverimage = string.Empty;
			string mousedownimage = string.Empty;
			string mouseupimage = string.Empty;			

			// iterate through the Items
			Table menu = new Table();
			menu.Attributes.Add("id", this.ClientID);
			menu.MergeStyle(this.ControlStyle);

			menu.CellPadding = ItemPadding;
			menu.CellSpacing = ItemSpacing;
			menu.GridLines = GridLines;

			// Add the Menu control's STYLE properties to the TABLE
			IEnumerator key = this.Style.Keys.GetEnumerator();
			while(key.MoveNext())
			{
				string k = key.Current.ToString();
				menu.Style.Add(k, this.Style[k]);
			}

			menu.Style.Remove("Z-INDEX");		// remove z-index added automatically by grid positioning

			// set the Z-INDEX
			menu.Style.Add("z-index", this.zIndex.ToString());
			curzindex = this.zIndex + 2;

			BuildOpacity(menu);
			
			TableRow tr = null;
			if (Layout == MenuLayout.Horizontal)
				tr = new TableRow();

			// Iterate through the top-level menu's menuitems, and add a <td> tag for each menuItem
			for (int i = 0; i < this.items.Count; i++)
			{
				MenuItem mi = this.items[i];

				//add by johnny start
				if (this.MainSpacingWidth != 0)
				{
					if (i % 2 == 1)
					{
						TableCell tdblank = new TableCell();
						tdblank.Width=this.MainSpacingWidth;
						tdblank.BackColor = Color.Empty;
						tr.Cells.Add(tdblank);
					}
				}
				//end

				// only render this MenuItem if it is visible and the user has permissions
				if (mi.Visible && UserHasPermission(mi)) 
				{ 
					if (Layout == MenuLayout.Vertical)
						tr = new TableRow();

					TableCell td = new TableCell();
					td.ApplyStyle(this.unselectedMenuItemStyle);
					// The style is overwritten by anything specifically set in menuitem
					if (mi.BackColor != Color.Empty) 
						td.BackColor = mi.BackColor;
					if (mi.Font != null)
						td.Font.CopyFrom(mi.Font);
					if (mi.ForeColor != Color.Empty)
						td.ForeColor = mi.ForeColor;
					if (mi.Height != Unit.Empty)
						td.Height = mi.Height;
					if (mi.Width != Unit.Empty)
						td.Width = mi.Width;
					if (mi.CssClass != String.Empty)
						td.CssClass = mi.CssClass;
					else if	(this.DefaultCssClass != String.Empty)
						td.CssClass = this.DefaultCssClass;
					if (mi.BorderColor != Color.Empty)
						td.BorderColor = mi.BorderColor;
					if (mi.BorderStyle != BorderStyle.NotSet)
						td.BorderStyle = mi.BorderStyle;
					if (mi.BorderWidth != Unit.Empty)
						td.BorderWidth = mi.BorderWidth;
					if (mi.HorizontalAlign != System.Web.UI.WebControls.HorizontalAlign.NotSet)
						td.HorizontalAlign = mi.HorizontalAlign;
					if (mi.VerticalAlign != System.Web.UI.WebControls.VerticalAlign.NotSet)
						td.VerticalAlign = mi.VerticalAlign;
					BuildOpacity(td);
					if (mi.Text != string.Empty)
						td.Text = mi.Text;  // Text
					else if (mi.Image != string.Empty) // Show Image
					{
						System.Web.UI.WebControls.Image cellimage = new System.Web.UI.WebControls.Image();

						cellimage.ImageUrl = mi.Image;
						cellimage.AlternateText = mi.ImageAltText;
						td.Controls.Add(cellimage);
						
						image = mi.Image;
						mouseoverimage = mi.MouseOverImage;
						mousedownimage = mi.MouseDownImage;
						mouseupimage = mi.MouseUpImage;
					}
					td.Attributes.Add("id", mi.MenuID);

					// Add in the left or right image as needed
					if (mi.LeftImage != String.Empty) 
					{
						System.Web.UI.WebControls.Image leftimage = new System.Web.UI.WebControls.Image();
						System.Web.UI.WebControls.Literal leftliteral = new System.Web.UI.WebControls.Literal();

						leftimage.ImageAlign = mi.LeftImageAlign;
						if (mi.LeftImageRightPadding != Unit.Empty)
							leftimage.Style.Add("margin-right",mi.LeftImageRightPadding.Value.ToString());
						leftimage.ImageUrl = mi.LeftImage;
						td.Controls.Add(leftimage);

						leftliteral.Text = td.Text;
						td.Controls.Add(leftliteral);
					} 
					else if (mi.RightImage != String.Empty) 
					{
						System.Web.UI.WebControls.Image rightimage = new System.Web.UI.WebControls.Image();
						System.Web.UI.WebControls.Literal rightliteral = new System.Web.UI.WebControls.Literal();
						
						rightliteral.Text = td.Text;
						td.Controls.Add(rightliteral);

						rightimage.ImageAlign = mi.RightImageAlign;
						if (mi.RightImageLeftPadding != Unit.Empty)
							rightimage.Style.Add("margin-left",mi.RightImageLeftPadding.Value.ToString());
						rightimage.ImageUrl = mi.RightImage;
						td.Controls.Add(rightimage);
					}

					// Prepare MouseOverCssClass
					string mouseover = String.Empty;

					if (this.DefaultMouseOverCssClass != string.Empty || mi.MouseOverCssClass != string.Empty || this.selectedMenuItemStyle.CssClass != String.Empty)
						mouseover = "this.className='" + GetClass(this.DefaultMouseOverCssClass, mi.MouseOverCssClass, this.selectedMenuItemStyle.CssClass) + "';";

					if (mi.Enabled) // if enabled...
					{
						// Generate OnClick handler
						if (mi.JavascriptCommand != String.Empty) // javascript command
							td.Attributes.Add("onclick", mi.JavascriptCommand + "skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));");
						else if (mi.Url != String.Empty) 
						{
							if (mi.Target != String.Empty)
								td.Attributes.Add("onclick", "javascript:skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));window.open('" + GetURL(mi.ResolveURL, mi.Url) + "','" + mi.Target + "');");
							else if (this.DefaultTarget != String.Empty)
								td.Attributes.Add("onclick", "javascript:skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));window.open('" + GetURL(mi.ResolveURL, mi.Url) + "','" + this.DefaultTarget + "');");
							else
								td.Attributes.Add("onclick", "javascript:skm_closeSubMenus(document.getElementById('" + this.ClientID + "'));location.href='" + GetURL(mi.ResolveURL, mi.Url) + "';");
						}
						else if (mi.CommandName != String.Empty) // Must be postback action
							td.Attributes.Add("onclick", Page.GetPostBackClientHyperlink(this, mi.CommandName));
						else if (this.ClickToOpen) // Open submenu on click
							if (Layout == MenuLayout.Vertical)
								td.Attributes.Add("onclick", "javascript:skm_mousedOverMenu('" + this.ClientID + "',this, document.getElementById('" + this.ClientID + "'), true, '" + mouseoverimage + "');" + GenerateShimCall("true", mi.MenuID + "-subMenu") + mouseover);
							else
								td.Attributes.Add("onclick", "javascript:skm_mousedOverMenu('" + this.ClientID + "',this, document.getElementById('" + this.ClientID + "'), false, '" + mouseoverimage + "');" + GenerateShimCall("true", mi.MenuID + "-subMenu") + mouseover);
					}

					if (mi.Enabled)
					{
						// Output Tooltip
						if (mi.ToolTip != String.Empty) 
							td.ToolTip = mi.ToolTip;

						// Output MouseDownCssClass or MouseDownImage
						string mousedown = String.Empty;

						if (this.DefaultMouseDownCssClass != string.Empty || mi.MouseDownCssClass != string.Empty)
							mousedown = "this.className='" + GetClass(this.DefaultMouseDownCssClass, mi.MouseDownCssClass) + "';";

						if (mousedownimage != String.Empty)
							mousedown += "setimage(this, '" + mousedownimage + "');";

						if (mousedown != string.Empty)
							td.Attributes.Add("onmousedown", mousedown);

						// Output MouseUpCssClass or MouseUpImage
						string mouseup = String.Empty;

						if (this.DefaultMouseUpCssClass != string.Empty || mi.MouseUpCssClass != string.Empty)
							mouseup = "this.className='" + GetClass(this.DefaultMouseUpCssClass, mi.MouseUpCssClass) + "';";

						if (mouseupimage != String.Empty)
							mouseup += "setimage(this, '" + mouseupimage + "');";

						if (mouseup != string.Empty)
							td.Attributes.Add("onmouseup", mouseup);

						if (this.ClickToOpen == false) 
						{
							if (Layout == MenuLayout.Vertical)
								td.Attributes.Add("onmouseover", "javascript:skm_mousedOverMenu('" + this.ClientID + "',this, document.getElementById('" + this.ClientID + "'), true, '" + mouseoverimage + "');" + GenerateShimCall("true", mi.MenuID + "-subMenu") + mouseover);
							else
								td.Attributes.Add("onmouseover", "javascript:skm_mousedOverMenu('" + this.ClientID + "',this, document.getElementById('" + this.ClientID + "'), false, '" + mouseoverimage + "');" + GenerateShimCall("true", mi.MenuID + "-subMenu") + mouseover);
						} 
						else
							td.Attributes.Add("onmouseover", "javascript:skm_mousedOverClickToOpen('" + this.ClientID + "', this, document.getElementById('" + this.ClientID + "'), '" + mouseoverimage + "');"+ mouseover);
						
						td.Attributes.Add("onmouseout", "javascript:skm_mousedOutMenu('" + this.ClientID +"', this, '" + image + "');" + "this.className='" + GetClass(this.DefaultCssClass, mi.CssClass, this.unselectedMenuItemStyle.CssClass) + "';");
					} 
					else // disabled...
					{
						td.Attributes.Add("onmouseover", "javascript:skm_mousedOverSpacer('" + this.ClientID + "', this, document.getElementById('" + this.ClientID + "'));");
						td.Attributes.Add("onmouseout", "javascript:skm_mousedOutSpacer('" + this.ClientID + "', this);");
					}

					if (mi.Url != String.Empty || mi.CommandName != String.Empty)
						if (this.Cursor != MouseCursor.Default) 
						{
							if (this.Page.Request.Browser.Browser == "IE")
								td.Style.Add("cursor","hand"); 
							else
								td.Style.Add("cursor","pointer"); 
						}

					tr.Cells.Add(td);

					if (Layout == MenuLayout.Vertical)
						menu.Rows.Add(tr);

					// Add the subitems for this menu, if needed
					if (mi.SubItems.Count > 0)
					{
						// Create an IFrame (IE5.5 or better) to windowed form elements that might
						// interfere with display of the menu
						if (this.Page.Request.Browser.Browser == "IE" && Convert.ToDouble(this.Page.Request.Browser.Version, enUSCulture) >= 5.5) 
						{
							System.Web.UI.HtmlControls.HtmlGenericControl iframe = new System.Web.UI.HtmlControls.HtmlGenericControl();
							iframe.TagName = "iframe";
							iframe.Attributes.Add("id", "shim" + mi.MenuID + "-subMenu");
							iframe.Attributes.Add("src", IFrameSrc);
							iframe.Attributes.Add("scrolling", "no");
							iframe.Attributes.Add("frameborder", "no");
							iframe.Style.Add("position", "absolute");
							iframe.Style.Add("top", "0px");
							iframe.Style.Add("left", "0px");
							iframe.Style.Add("display", "none");
							BuildOpacity(iframe);
							Controls.Add(iframe);			
						}

						this.subItemsIds.Add(mi.MenuID + "-subMenu");
						AddMenu(mi.MenuID + "-subMenu", mi.SubItems);
					}
				}
			}

			if (Layout == MenuLayout.Horizontal)
				menu.Rows.Add(tr);

			Controls.Add(menu);
		}
		private void RenderTitle (HtmlTextWriter writer,
					  DateTime visibleDate,
					  CalendarSelectionMode mode,
					  bool isActive)
		{
			writer.Write("<tr>");
			Table innerTable = new Table ();
			TableCell titleCell = new TableCell();
			bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
					   mode == CalendarSelectionMode.DayWeekMonth);

			titleCell.ColumnSpan = (isWeekMode ? 8 : 7);
			titleCell.BackColor = Color.Silver;

			innerTable.GridLines = GridLines.None;
			innerTable.Width = Unit.Percentage (100);
			innerTable.CellSpacing = 0;
			ApplyTitleStyle (innerTable, titleCell, TitleStyle);

			titleCell.RenderBeginTag (writer);
			innerTable.RenderBeginTag (writer);

			writer.Write ("<tr>");
			string prevContent = String.Empty;
			if (ShowNextPrevMonth) {
				TableCell prevCell = new TableCell ();
				prevCell.Width = Unit.Percentage (15);
				prevCell.HorizontalAlign = HorizontalAlign.Left;
				if (NextPrevFormat == NextPrevFormat.CustomText) {
					prevContent = PrevMonthText;
				} else {
					int pMthInt = globCal.GetMonth(globCal.AddMonths (visibleDate, -1));
					if (NextPrevFormat == NextPrevFormat.FullMonth)
						prevContent = infoCal.GetMonthName (pMthInt);
					else
						prevContent = infoCal.GetAbbreviatedMonthName (pMthInt);
				}
				DateTime prev_month = visibleDate.AddMonths (-1);
				int prev_offset = (int) (new DateTime (prev_month.Year,
									  prev_month.Month, 1) - begin_date).TotalDays;
				prevCell.ApplyStyle (NextPrevStyle);
				RenderCalendarCell (writer,
						    prevCell,
						    GetCalendarLinkText ("V" + prev_offset,
							    		 prevContent,
										 "Go to previous month",
									 NextPrevStyle.ForeColor,
									 isActive)
						    );
			}

			TableCell currCell = new TableCell ();
			currCell.Width = Unit.Percentage (70);
			if (TitleStyle.HorizontalAlign == HorizontalAlign.NotSet)
				currCell.HorizontalAlign = HorizontalAlign.Center;
			else
				currCell.HorizontalAlign = TitleStyle.HorizontalAlign;

			currCell.Wrap = TitleStyle.Wrap;
			string currMonthContent = String.Empty;
			if (TitleFormat == TitleFormat.Month) {
				currMonthContent = visibleDate.ToString ("MMMM");
			} else {
				string cmcFmt = infoCal.YearMonthPattern;
				if (cmcFmt.IndexOf (',') >= 0)
					cmcFmt = "MMMM yyyy";

				currMonthContent = visibleDate.ToString (cmcFmt);
			}

			RenderCalendarCell (writer, currCell, currMonthContent);
								 
			string nextContent = String.Empty;
			if (ShowNextPrevMonth) {
				TableCell nextCell = new TableCell ();
				nextCell.Width = Unit.Percentage(15);
				nextCell.HorizontalAlign = HorizontalAlign.Right;
				if (NextPrevFormat == NextPrevFormat.CustomText) {
					nextContent = NextMonthText;
				} else {
					int nMthInt = globCal.GetMonth (globCal.AddMonths (visibleDate, 1));
					if(NextPrevFormat == NextPrevFormat.FullMonth)
						nextContent = infoCal.GetMonthName(nMthInt);
					else
						nextContent = infoCal.GetAbbreviatedMonthName(nMthInt);
				}
				DateTime next_month = visibleDate.AddMonths (1);
				int next_offset = (int) (new DateTime (next_month.Year,
									  next_month.Month, 1) - begin_date).TotalDays;
				nextCell.ApplyStyle(NextPrevStyle);
				RenderCalendarCell (writer,
						    nextCell,
						    GetCalendarLinkText ("V" + next_offset,
									 nextContent,
									 "Go to next month",
									 NextPrevStyle.ForeColor,
									 isActive)
						    );
			}

			writer.Write("</tr>");
			innerTable.RenderEndTag(writer);
			titleCell.RenderEndTag(writer);

			writer.Write("</tr>");
		}
		/// <remarks>
		/// Refers to the second line of the calendar, that contains a link
		/// to select whole month, and weekdays as defined by DayNameFormat
		/// </remarks>
		private void RenderHeader (HtmlTextWriter writer,
					   DateTime firstDay,
					   CalendarSelectionMode mode,
					   bool isActive,
					   bool isDownLevel)
		{
			writer.Write("<tr>");
			bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
					   mode == CalendarSelectionMode.DayWeekMonth);

			TableCell headerCell = new TableCell ();
			headerCell.HorizontalAlign = HorizontalAlign.Center;
			string selMthText = String.Empty;
			if (isWeekMode) {
				if (mode == CalendarSelectionMode.DayWeekMonth) {
					DateTime visDate = GetEffectiveVisibleDate ();
					DateTime sel_month = new DateTime (visDate.Year, visDate.Month, 1);
					int month_offset = (int) (sel_month - begin_date).TotalDays;
					headerCell.ApplyStyle (SelectorStyle);
					selMthText = GetCalendarLinkText ("R" + month_offset +
							globCal.GetDaysInMonth (sel_month.Year,
									sel_month.Month).ToString ("d2"), // maybe there are calendars with less then 10 days in a month
									  SelectMonthText,
									  "Select the whole month",
									  SelectorStyle.ForeColor,
									  isActive);
				} else {
					headerCell.ApplyStyle (DayHeaderStyle);
					selMthText = String.Empty;
				}
				RenderCalendarCell (writer, headerCell, selMthText);
			}

			TableCell dayHeaderCell = new TableCell ();
			dayHeaderCell.HorizontalAlign = HorizontalAlign.Center;
			dayHeaderCell.ApplyStyle (dayHeaderStyle);

			int dayOfWeek = (int) globCal.GetDayOfWeek (firstDay);
			DateTimeFormatInfo currDTInfo = DateTimeFormatInfo.CurrentInfo;
			for(int currDay = dayOfWeek; currDay < dayOfWeek + 7; currDay++) {
				DayOfWeek effDay = (DayOfWeek) Enum.ToObject (typeof (DayOfWeek), currDay % 7);
				string currDayContent;
				switch(DayNameFormat) {
				case DayNameFormat.Full:
					currDayContent = currDTInfo.GetDayName (effDay);
					break;
				case DayNameFormat.FirstLetter:
					currDayContent = currDTInfo.GetDayName (effDay).Substring (0,1);
					break;
				case DayNameFormat.FirstTwoLetters:
					currDayContent = currDTInfo.GetDayName (effDay).Substring (0,2);
					break;
				case DayNameFormat.Short:
					goto default;
				default:
					currDayContent = currDTInfo.GetAbbreviatedDayName (effDay);
					break;
				}

				RenderCalendarHeaderCell (writer, dayHeaderCell, currDayContent, currDTInfo.GetDayName (effDay));
			}
			writer.Write ("</tr>");
		}
        private TableCell CreateDayCell(CalendarDay day)
        {
            //initialize the cellstyles
            if (_cellStyles == null)
            {
                _cellStyles = new TableItemStyle[16];
            }

            //initialize style mask
            if (_definedStyleMask == 0)
            {
                _definedStyleMask = GetDefinedStyleMask();
            }

            int styleMask = STYLEMASK_DAY;
            if (day.IsOtherMonth)
                styleMask |= STYLEMASK_OTHERMONTH;
            if (day.IsToday)
                styleMask |= STYLEMASK_TODAY;
            if (day.IsWeekend)
                styleMask |= STYLEMASK_WEEKEND;
            int dayStyleMask = _definedStyleMask & styleMask;
            // determine the unique portion of the mask for the current calendar,
            // which will strip out the day style bit
            int dayStyleID = dayStyleMask & STYLEMASK_UNIQUE;

            TableItemStyle cellStyle = _cellStyles[dayStyleID];
            if (cellStyle == null)
            {
                cellStyle = new TableItemStyle();
                SetDayStyles(cellStyle, dayStyleMask, Unit.Percentage(14));
                _cellStyles[dayStyleID] = cellStyle;
            }

            TableCell cell = new TableCell();
            cell.ApplyStyle(cellStyle);

            DayNumberDiv div;
            if (dayLinkFormat.Length > 0)
            {
                div = new DayNumberDiv(day, dayLinkFormat);
            }
            else
            {
                div = new DayNumberDiv(day.DayNumberText);
            }
            div.ApplyStyle(DayNumberStyle);
            cell.Controls.Add(div);

            return cell;
        }
		public virtual void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
		{
			switch(itemType)
			{
				case ListItemType.Header : InitializeCellHeader(cell, columnIndex);
				                           break;
				case ListItemType.Footer : InitializeCellFooter(cell, columnIndex);
				                           break;
				default                  : if (ItemStyleInternal != null)
							   	cell.ApplyStyle (ItemStyleInternal);
							   return;
			}
		}
		//
		// Private methods
		//
		void WriteDayHeader (HtmlTextWriter writer)
		{
			int i, first;
			string dayName;
			i = first = (int) (DisplayFirstDayOfWeek);
			TableCell cell;


			writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			if (SelectionMode == CalendarSelectionMode.DayWeek) {
				cell = new TableCell();
				cell.HorizontalAlign = HorizontalAlign.Center;
				cell.ApplyStyle (DayHeaderStyle);

				// Empty Cell
				cell.RenderBeginTag (writer);
				cell.RenderEndTag (writer);
			} else {
				if (SelectionMode == CalendarSelectionMode.DayWeekMonth) {
					TableCell selector = new TableCell ();
					selector.ApplyStyle (SelectorStyle);
					selector.HorizontalAlign = HorizontalAlign.Center;

					DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
					int days =  DateTime.DaysInMonth (DisplayDate.Year, DisplayDate.Month);

					selector.RenderBeginTag (writer);
					writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, Enabled));
					selector.RenderEndTag (writer);
				}
			}

			DateTimeFormatInfo dti = DateInfo;
			while (true) {
				DayOfWeek dayOfWeek = (DayOfWeek) i;
				dayName = dti.GetDayName (dayOfWeek);

#if NET_2_0
				if (UseAccessibleHeader) {
					writer.AddAttribute (HtmlTextWriterAttribute.Abbr, dayName);
					writer.AddAttribute (HtmlTextWriterAttribute.Scope, "col", false);
					cell = new TableHeaderCell();
				}
				else
#endif
					cell = new TableCell();

				cell.HorizontalAlign = HorizontalAlign.Center;
				cell.ApplyStyle (DayHeaderStyle);

				cell.RenderBeginTag (writer);

				switch (DayNameFormat) {
				case DayNameFormat.FirstLetter:
					dayName = dayName.Substring (0, 1);
					break;
				case DayNameFormat.FirstTwoLetters:
					dayName = dayName.Substring (0, 2);
					break;
#if NET_2_0
				case DayNameFormat.Shortest:
					dayName = dti.GetShortestDayName (dayOfWeek);
					break;
#endif
				case DayNameFormat.Full:
					break;
				case DayNameFormat.Short:
				default:
					dayName = dti.GetAbbreviatedDayName (dayOfWeek);
					break;
				}

				writer.Write (dayName);
				cell.RenderEndTag (writer);

				if (i >= daysInAWeek - 1) {
					i = 0;
				}
				else {
					i++;
				}
				if (i == first)
					break;
			}

			writer.RenderEndTag ();
		}
		private void InitializeCellHeader(TableCell cell, int columnIndex)
		{
			WebControl ctrl = null;
			bool       sort = true;
			string     sortExpr = "";
			ImageButton headButton;
			Image       headImage;
			LinkButtonInternal link;

			if(owner != null)
			{
				sort = owner.AllowSorting;
			}
			if(sort)
			{
				sortExpr = SortExpression;
				if(sortExpr.Length == 0)
				{
					sort = false;
				}
			}
			if(HeaderImageUrl.Length > 0)
			{
				if(sort)
				{
					headButton = new ImageButton();
					headButton.ImageUrl = HeaderImageUrl;
					headButton.CommandName = "Sort";
					headButton.CommandArgument = sortExpr;
					headButton.CausesValidation = false;
					ctrl = headButton;
				} else
				{
					headImage = new Image();
					headImage.ImageUrl = HeaderImageUrl;
					ctrl = headImage;
				}
			} else
			{
				if(sort)
				{
					link = new LinkButtonInternal();
					link.Text = HeaderText;
					link.CommandName = "Sort";
					link.CommandArgument = sortExpr;
					link.CausesValidation = false;
					ctrl = link;
				} else
				{
					if(HeaderText.Length > 0)
					{
						cell.Text = HeaderText;
					} else
					{
						cell.Text = "&nbsp;";
					}
				}
			}
			if(ctrl != null)
			{
				cell.Controls.Add(ctrl);
			}
			if (HeaderStyleInternal != null)
				cell.ApplyStyle (HeaderStyleInternal);
		}
        //Creates a title block. No customization is offered, if that's needed then specify the header template.
        Control CreateStaticTitle(DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            //Create a new table for the header controls

            Table titleTable = new Table();
            titleTable.GridLines = GridLines.None;
            titleTable.Width = Unit.Percentage(100);
            titleTable.CellSpacing = 0;

            TableRow titleTableRow = new TableRow();
            titleTable.Rows.Add(titleTableRow);

            TableCell PrevCell = new TableCell();
            titleTableRow.Cells.Add(PrevCell);
            PrevCell.ApplyStyle(nextPrevStyle);
            Button PrevBtn = new Button();
            PrevBtn.CssClass = "buttonlink";
            PrevBtn.Text = "&lt; " + threadCalendar.AddMonths(visibleDate, -1).ToString("MMMM");
            PrevBtn.CommandName = COMMAND_PREVMONTH;
            PrevCell.Controls.Add(PrevBtn);

            TableCell MonthCell = new TableCell();
            titleTableRow.Cells.Add(MonthCell);
            MonthCell.ApplyStyle(titleStyle);
            MonthCell.Text = visibleDate.ToString("MMMM yyyy");

            TableCell NextCell = new TableCell();
            titleTableRow.Cells.Add(NextCell);
            NextCell.ApplyStyle(nextPrevStyle);
            Button NextBtn = new Button();
            NextBtn.CssClass = "buttonlink";
            NextBtn.Text = threadCalendar.AddMonths(visibleDate, +1).ToString("MMMM") + " &gt;";
            NextBtn.CommandName = COMMAND_NEXTMONTH;
            NextCell.Controls.Add(NextBtn);

            return titleTable;
        }
		void WriteDay (DateTime date, HtmlTextWriter writer)
		{			
			TableItemStyle style = new TableItemStyle ();
			TableCell cell = new TableCell ();

			CalendarDay day = new CalendarDay (date,
				IsWeekEnd (date.DayOfWeek),
				date == TodaysDate, SelectedDates.Contains (date),
				GetGlobalCalendar ().GetMonth (DisplayDate) != GetGlobalCalendar ().GetMonth (date),
				date.Day.ToString ());

			day.IsSelectable = SelectionMode != CalendarSelectionMode.None;
			cell.HorizontalAlign = HorizontalAlign.Center;
			cell.Width = Unit.Percentage (GetCellWidth ());

			LiteralControl lit = new LiteralControl (day.DayNumberText);
			cell.Controls.Add (lit);

			OnDayRender (cell, day);
					
			if (dayStyle != null && !dayStyle.IsEmpty) {
				style.CopyFrom (dayStyle);
			}

			if (day.IsWeekend && weekendDayStyle != null && !weekendDayStyle.IsEmpty) {
				style.CopyFrom (weekendDayStyle);
			}

			if (day.IsToday && todayDayStyle != null && !todayDayStyle.IsEmpty) {
				style.CopyFrom (todayDayStyle);
			}

			if (day.IsOtherMonth && otherMonthDayStyle != null && !otherMonthDayStyle.IsEmpty) {
				style.CopyFrom (otherMonthDayStyle);
			}

			if (day.IsSelected && Enabled) {
				style.BackColor = Color.Silver;
				style.ForeColor = Color.White;
				if (selectedDayStyle != null && !selectedDayStyle.IsEmpty) {
					style.CopyFrom (selectedDayStyle);
				}
			}

			cell.ApplyStyle (style);

			lit.Text = BuildLink (GetDaysFromZenith (date).ToString (), day.DayNumberText,
					      cell.ForeColor, day.IsSelectable && Enabled);

			cell.RenderControl (writer);
		}
        private TableRow CreateDayHeader(DateTime firstDay, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            TableRow row = new TableRow();

            DateTimeFormatInfo dtf = DateTimeFormatInfo.CurrentInfo;

            TableItemStyle dayNameStyle = new TableItemStyle();
            dayNameStyle.HorizontalAlign = HorizontalAlign.Center;
            dayNameStyle.CopyFrom(DayHeaderStyle);
            DayNameFormat dayNameFormat = DayNameFormat;

            int numericFirstDay = (int)threadCalendar.GetDayOfWeek(firstDay);
            for (int i = numericFirstDay; i < numericFirstDay + 7; i++)
            {
                string dayName;
                int dayOfWeek = i % 7;
                switch (dayNameFormat)
                {
                    case DayNameFormat.FirstLetter:
                        dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 1);
                        break;
                    case DayNameFormat.FirstTwoLetters:
                        dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 2);
                        break;
                    case DayNameFormat.Full:
                        dayName = dtf.GetDayName((DayOfWeek)dayOfWeek);
                        break;
                    case DayNameFormat.Short:
                        dayName = dtf.GetAbbreviatedDayName((DayOfWeek)dayOfWeek);
                        break;
                    case DayNameFormat.Shortest:
                        dayName = dtf.GetShortestDayName((DayOfWeek)dayOfWeek);
                        break;
                    default:
                        System.Diagnostics.Debug.Assert(false, "Unknown DayNameFormat value!");
                        goto
                    case DayNameFormat.Short;
                }

                TableCell cell = new TableCell();
                cell.ApplyStyle(dayNameStyle);
                cell.Text = dayName;
                row.Cells.Add(cell);

            }
            return row;
        }
		void WriteTitle (HtmlTextWriter writer)
		{
			TableCell cellNextPrev = null;
			TableCell titleCell = new TableCell ();
			Table tableTitle = new Table ();

			writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			titleCell.ColumnSpan = HasWeekSelectors (SelectionMode) ? 8 : 7;

			if (titleStyle != null && !titleStyle.IsEmpty && !titleStyle.BackColor.IsEmpty) {
				titleCell.BackColor = titleStyle.BackColor;
			} else {
				titleCell.BackColor = Color.Silver;
			}

			titleCell.RenderBeginTag (writer);

			// Table
			tableTitle.Width =  Unit.Percentage (100);
			if (titleStyle != null && !titleStyle.IsEmpty) {
				tableTitle.ApplyStyle (titleStyle);
			}

			tableTitle.RenderBeginTag (writer);
			writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			if (ShowNextPrevMonth) { // Previous Table Data
				cellNextPrev = new TableCell ();
				cellNextPrev.ApplyStyle (nextPrevStyle);
				cellNextPrev.Width = Unit.Percentage (15);

				DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, - 1);
				date = GetGlobalCalendar ().AddDays (date, -date.Day + 1);
				cellNextPrev.RenderBeginTag (writer);
				writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, false), cellNextPrev.ForeColor, Enabled));
				cellNextPrev.RenderEndTag (writer);
			}

			// Current Month Table Data
			{
				DateTimeFormatInfo dti = DateInfo;
				string str;
				TableCell cellMonth = new TableCell ();
				cellMonth.Width = Unit.Percentage (70);
				cellMonth.HorizontalAlign = HorizontalAlign.Center;

				cellMonth.RenderBeginTag (writer);

				if (TitleFormat == TitleFormat.MonthYear)
					str = DisplayDate.ToString (dti.YearMonthPattern, dti);
				else
					str = dti.GetMonthName (GetGlobalCalendar ().GetMonth (DisplayDate));

				writer.Write (str);
				cellMonth.RenderEndTag (writer);
			}

			if (ShowNextPrevMonth) { // Next Table Data
				DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, + 1);
				date = GetGlobalCalendar ().AddDays (date, -date.Day + 1);

				cellNextPrev.HorizontalAlign = HorizontalAlign.Right;
				cellNextPrev.RenderBeginTag (writer);
				writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, true), cellNextPrev.ForeColor, Enabled));
				cellNextPrev.RenderEndTag (writer);
			}

			writer.RenderEndTag ();
			tableTitle.RenderEndTag (writer);
			titleCell.RenderEndTag (writer);
			writer.RenderEndTag (); //tr

		}
 private void RenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader)
 {
     Unit unit;
     DateTime time = firstDay;
     TableItemStyle style = null;
     bool flag = this.HasWeekSelectors(selectionMode);
     if (flag)
     {
         style = new TableItemStyle {
             Width = Unit.Percentage(12.0),
             HorizontalAlign = HorizontalAlign.Center
         };
         style.CopyFrom(this.SelectorStyle);
         unit = Unit.Percentage(12.0);
     }
     else
     {
         unit = Unit.Percentage(14.0);
     }
     bool flag2 = !(this.threadCalendar is HebrewCalendar);
     bool flag3 = (base.GetType() != typeof(System.Web.UI.WebControls.Calendar)) || (base.Events[EventDayRender] != null);
     TableItemStyle[] styleArray = new TableItemStyle[0x10];
     int definedStyleMask = this.GetDefinedStyleMask();
     DateTime todaysDate = this.TodaysDate;
     string selectWeekText = this.SelectWeekText;
     bool hasButton = buttonsActive && (selectionMode != CalendarSelectionMode.None);
     int month = this.threadCalendar.GetMonth(visibleDate);
     int days = firstDay.Subtract(baseDate).Days;
     bool flag5 = base.DesignMode && (this.SelectionMode != CalendarSelectionMode.None);
     int num4 = 0;
     if (this.IsMinSupportedYearMonth(visibleDate))
     {
         num4 = ((int) this.threadCalendar.GetDayOfWeek(firstDay)) - this.NumericFirstDayOfWeek();
         if (num4 < 0)
         {
             num4 += 7;
         }
     }
     bool flag6 = false;
     DateTime time3 = this.threadCalendar.AddMonths(this.maxSupportedDate, -1);
     bool flag7 = this.IsMaxSupportedYearMonth(visibleDate) || this.IsTheSameYearMonth(time3, visibleDate);
     for (int i = 0; i < 6; i++)
     {
         if (flag6)
         {
             return;
         }
         writer.Write("<tr>");
         if (flag)
         {
             int num6 = (days * 100) + 7;
             if (num4 > 0)
             {
                 num6 -= num4;
             }
             else if (flag7)
             {
                 int num7 = this.maxSupportedDate.Subtract(time).Days;
                 if (num7 < 6)
                 {
                     num6 -= 6 - num7;
                 }
             }
             string eventArgument = "R" + num6.ToString(CultureInfo.InvariantCulture);
             string title = null;
             if (useAccessibleHeader)
             {
                 int num8 = i + 1;
                 title = System.Web.SR.GetString("Calendar_SelectWeekTitle", new object[] { num8.ToString(CultureInfo.InvariantCulture) });
             }
             this.RenderCalendarCell(writer, style, selectWeekText, title, buttonsActive, eventArgument);
         }
         for (int j = 0; j < 7; j++)
         {
             string str4;
             if (num4 > 0)
             {
                 j += num4;
                 while (num4 > 0)
                 {
                     writer.RenderBeginTag(HtmlTextWriterTag.Td);
                     writer.RenderEndTag();
                     num4--;
                 }
             }
             else if (flag6)
             {
                 while (j < 7)
                 {
                     writer.RenderBeginTag(HtmlTextWriterTag.Td);
                     writer.RenderEndTag();
                     j++;
                 }
                 break;
             }
             int dayOfWeek = (int) this.threadCalendar.GetDayOfWeek(time);
             int dayOfMonth = this.threadCalendar.GetDayOfMonth(time);
             if ((dayOfMonth <= 0x1f) && flag2)
             {
                 str4 = cachedNumbers[dayOfMonth];
             }
             else
             {
                 str4 = time.ToString("dd", CultureInfo.CurrentCulture);
             }
             CalendarDay day = new CalendarDay(time, (dayOfWeek == 0) || (dayOfWeek == 6), time.Equals(todaysDate), (this.selectedDates != null) && this.selectedDates.Contains(time), this.threadCalendar.GetMonth(time) != month, str4);
             int num12 = 0x10;
             if (day.IsSelected)
             {
                 num12 |= 8;
             }
             if (day.IsOtherMonth)
             {
                 num12 |= 2;
             }
             if (day.IsToday)
             {
                 num12 |= 4;
             }
             if (day.IsWeekend)
             {
                 num12 |= 1;
             }
             int styleMask = definedStyleMask & num12;
             int index = styleMask & 15;
             TableItemStyle style2 = styleArray[index];
             if (style2 == null)
             {
                 style2 = new TableItemStyle();
                 this.SetDayStyles(style2, styleMask, unit);
                 styleArray[index] = style2;
             }
             string str5 = null;
             if (useAccessibleHeader)
             {
                 str5 = time.ToString("m", CultureInfo.CurrentCulture);
             }
             if (flag3)
             {
                 TableCell cell = new TableCell();
                 cell.ApplyStyle(style2);
                 LiteralControl child = new LiteralControl(str4);
                 cell.Controls.Add(child);
                 day.IsSelectable = hasButton;
                 this.OnDayRender(cell, day);
                 child.Text = this.GetCalendarButtonText(days.ToString(CultureInfo.InvariantCulture), str4, str5, buttonsActive && day.IsSelectable, cell.ForeColor);
                 cell.RenderControl(writer);
             }
             else
             {
                 if (flag5 && style2.ForeColor.IsEmpty)
                 {
                     style2.ForeColor = this.defaultForeColor;
                 }
                 this.RenderCalendarCell(writer, style2, str4, str5, hasButton, days.ToString(CultureInfo.InvariantCulture));
             }
             if ((flag7 && (time.Month == this.maxSupportedDate.Month)) && (time.Day == this.maxSupportedDate.Day))
             {
                 flag6 = true;
             }
             else
             {
                 time = this.threadCalendar.AddDays(time, 1);
                 days++;
             }
         }
         writer.Write("</tr>");
     }
 }
Exemple #27
0
		public override string GetDesignTimeHtml() 
		{
			StringWriter sw = new StringWriter();
			HtmlTextWriter writer = new HtmlTextWriter(sw);

			Table menu = new Table();				
			menu.CellSpacing = menuInstance.ItemSpacing;
			menu.CellPadding = menuInstance.ItemPadding;
			
			// Display the Menu based on its specified Layout
			if (menuInstance.Layout == MenuLayout.Vertical)
			{
				for (int i = 1; i <= 5; i++)
				{
					TableRow tr = new TableRow();
					TableCell td = new TableCell();
					td.ApplyStyle(menuInstance.UnselectedMenuItemStyle);
					// The style is overwritten by anything specifically set in menuitem
					if (menuInstance.BackColor != Color.Empty) 
						td.BackColor = menuInstance.BackColor;
					if (menuInstance.Font != null)
						td.Font.CopyFrom(menuInstance.Font);
					if (menuInstance.ForeColor != Color.Empty)
						td.ForeColor = menuInstance.ForeColor;
					if (menuInstance.Height != Unit.Empty)
						td.Height = menuInstance.Height;
					if (menuInstance.Width != Unit.Empty)
						td.Width = menuInstance.Width;
					if (menuInstance.CssClass != String.Empty)
						td.CssClass = menuInstance.CssClass;
					else if	(menuInstance.DefaultCssClass != String.Empty)
						td.CssClass = menuInstance.DefaultCssClass;
					if (menuInstance.BorderColor != Color.Empty)
						td.BorderColor = menuInstance.BorderColor;
					if (menuInstance.BorderStyle != BorderStyle.NotSet)
						td.BorderStyle = menuInstance.BorderStyle;
					if (menuInstance.BorderWidth != Unit.Empty)
						td.BorderWidth = menuInstance.BorderWidth;						
					td.Text = "Menu Item " + i.ToString();
					tr.Cells.Add(td);
					menu.Rows.Add(tr);
				}
			}
			else
			{
				TableRow tr = new TableRow();
				for (int i = 1; i <= 5; i++)
				{						
					TableCell td = new TableCell();
					td.ApplyStyle(menuInstance.UnselectedMenuItemStyle);
					// The style is overwritten by anything specifically set in menuitem
					if (menuInstance.BackColor != Color.Empty) 
						td.BackColor = menuInstance.BackColor;
					if (menuInstance.Font != null)
						td.Font.CopyFrom(menuInstance.Font);
					if (menuInstance.ForeColor != Color.Empty)
						td.ForeColor = menuInstance.ForeColor;
					if (menuInstance.Height != Unit.Empty)
						td.Height = menuInstance.Height;
					if (menuInstance.Width != Unit.Empty)
						td.Width = menuInstance.Width;
					if (menuInstance.CssClass != String.Empty)
						td.CssClass = menuInstance.CssClass;
					else if	(menuInstance.DefaultCssClass != String.Empty)
						td.CssClass = menuInstance.DefaultCssClass;
					if (menuInstance.BorderColor != Color.Empty)
						td.BorderColor = menuInstance.BorderColor;
					if (menuInstance.BorderStyle != BorderStyle.NotSet)
						td.BorderStyle = menuInstance.BorderStyle;
					if (menuInstance.BorderWidth != Unit.Empty)
						td.BorderWidth = menuInstance.BorderWidth;
					td.Text = "Menu Item " + i.ToString();
					tr.Cells.Add(td);						
				}
				menu.Rows.Add(tr);
			}

			menu.RenderControl(writer);
			return sw.ToString();
		}
Exemple #28
0
        protected override void OnDayRender(TableCell cell, System.Web.UI.WebControls.CalendarDay day)
        {
            // _dtSource was already set by the Render method
            //if (_dtSource != null)
            if (dv != null)
            {

                // We have the data source as a DataTable now;
                // filter the records in the DataTable for the given day;
                // force the date format to be MM/dd/yyyy
                // to ensure compatibility with RowFilter
                // date expression syntax (#date#).
                // Also, take the possibility of time
                // values into account by specifying
                // a date range, to include the full day
                //DataView dv = new DataView(_dtSource);

                // ANTS profiler says this takes a long time and is called 42 times in rendering
                // 0.148
                //dv.RowFilter = string.Format(
                //    "{0} >= #{1}# and {0} < #{2}#",
                //    this.DayField,
                //    day.Date.ToString("MM/dd/yyyy"),
                //    day.Date.AddDays(1).ToString("MM/dd/yyyy")
                //    );

                if (_dtSource.Rows.Count > 0)
                {
                    // 0.0343
                    dv.RowFilter = GetDayFilter(day, DayField);

                    // are there events on this day?
                    if (dv.Count > 0)
                    {
                        // there are events on this day; if indicated,
                        // apply the DayWithEventsStyle to the table cell
                        if (day.Date == this.SelectedDate)
                        {
                            if (this._currentDayStyle != null)
                            {

                                cell.ApplyStyle(this._currentDayStyle);
                            }

                        }
                        else
                        {
                            if (this.DayWithEventsStyle != null)
                                cell.ApplyStyle(this.DayWithEventsStyle);
                        }

                        // for each event on this day apply the
                        // ItemTemplate, with data bound to the item's row
                        // from the data source
                        if (this.ItemTemplate != null)
                            for (int i = 0; i < dv.Count; i++)
                            {
                                SetupCalendarItem(cell, dv[i].Row, this.ItemTemplate);
                            }

                    }
                    else
                    {
                        // no events this day;
                        if (day.Date == this.SelectedDate)
                        {
                            if (this._currentDayStyle != null)
                            {

                                cell.ApplyStyle(this._currentDayStyle);
                            }
                        }
                        else
                        {
                            if (this.NoEventsTemplate != null)
                                SetupCalendarItem(cell, null, this.NoEventsTemplate);
                        }

                    }
                }
                else
                {
                    // no events
                    if (day.Date == this.SelectedDate)
                    {
                        if (this._currentDayStyle != null)
                        {

                            cell.ApplyStyle(this._currentDayStyle);
                        }
                    }
                    else
                    {
                        if (this.NoEventsTemplate != null)
                            SetupCalendarItem(cell, null, this.NoEventsTemplate);
                    }

                }

            }

            // call the base render method too
            // under windows commenting this has no effect on result
            base.OnDayRender(cell, day);
        }
 private void RenderErrorMessage(HtmlTextWriter writer)
 {
     if (this._displayErrorMessage)
     {
         writer.RenderBeginTag(HtmlTextWriterTag.Tr);
         TableCell cell = new TableCell();
         cell.ApplyStyle(base.ErrorStyle);
         cell.Text = this.NewConnectionErrorMessage;
         cell.RenderControl(writer);
         writer.RenderEndTag();
     }
 }
Exemple #30
0
			public static TableRow CreateRow(Control c1, Control c2, Style s1, Style s2, bool twoCells)
			{
				TableRow row = new TableRow ();
				TableCell cell1 = new TableCell ();

				cell1.Controls.Add (c1);
				if (s1 != null)
					cell1.ApplyStyle (s1);

				row.Cells.Add (cell1);

				if (c2 != null) {
					TableCell cell2 = new TableCell ();
					cell2.Controls.Add (c2);

					if (s2 != null)
						cell2.ApplyStyle (s2);

					row.Cells.Add (cell2);

					cell1.HorizontalAlign = HorizontalAlign.Right;
					cell2.HorizontalAlign = HorizontalAlign.Left;
				}
				else {
					cell1.HorizontalAlign = HorizontalAlign.Center;
					if (twoCells)
						cell1.ColumnSpan = 2;
				}
				
				return row;
			}
        private void DisplayPageSizeSelector(GridViewRow dgItem)
        {
            TableCell pagerCell;
            TableRow pagerRow;

            int j = 0;
            System.Web.UI.WebControls.DropDownList cboPageSize = new DropDownList();
            cboPageSize.AutoPostBack = true;

            ((DropDownList)(cboPageSize)).SelectedIndexChanged += new EventHandler(this.cboPageSize_SelectedIndexChanged);

            // -- limit the max page size to a 250 records
            j = this.RecordsCount + _pageSelectorPageSizeInterval;
            for (int i = _pageSelectorPageSizeInterval; i <= ((j > 250) ? 250 : j); )
            {
                cboPageSize.Items.Add(i.ToString());
                i += _pageSelectorPageSizeInterval;
            }

            if (cboPageSize.Items.FindByText(this.PageSize.ToString()) != null)
            {
                cboPageSize.Items.FindByText(this.PageSize.ToString()).Selected = true;
            }

            pagerRow = dgItem;
            pagerCell = ((TableCell)(pagerRow.Controls[0]));
            TableRow pagerTableRow = ((Table)pagerCell.Controls[0]).Rows[0];
            TableCell cell = new TableCell();
            cell.Text = string.Format("{0}: ", ShowPageText );
            cell.Wrap = false;
            cell.ApplyStyle(this.PagerStyle);
            pagerTableRow.Cells.AddAt(0, cell);

            cell = new TableCell();
            cell.Text = string.Format("&nbsp; ({1}: {0})", RecordsCount, TotalRecordsText);
            cell.Wrap = false;
            cell.ApplyStyle(this.PagerStyle);
            pagerTableRow.Cells.Add(cell);

            cell = new TableCell();
            cell.Width = Unit.Percentage(100);
            cell.ApplyStyle(this.PagerStyle);
            pagerTableRow.Cells.Add(cell);

            if (AllowExportToExcel) 
            {
            	cell = new TableCell();
            	cell.Controls.Add(ExcelButton());
                cell.Wrap = false;
                cell.ApplyStyle(this.PagerStyle);
            	pagerTableRow.Cells.Add(cell);
            }

            cell = new TableCell();
            cell.Text = string.Format("{0}: ", RecordsPerPageText);
            cell.Wrap = false;
            cell.ApplyStyle(this.PagerStyle);
            cell.HorizontalAlign = HorizontalAlign.Right;
            pagerTableRow.Cells.Add(cell);

            cell = new TableCell();
            cell.Controls.Add(cboPageSize);
            cell.HorizontalAlign = HorizontalAlign.Right;
            cell.ApplyStyle(this.PagerStyle);
            pagerTableRow.Cells.Add(cell);
        }
			TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1)
			{
				TableRow row = new TableRow ();
				TableCell cell0 = new TableCell ();
				TableCell cell1 = new TableCell ();

				cell0.Controls.Add (c0);
				row.Controls.Add (cell0);

				if ((c1 != null) && (c2 != null)) {
					cell1.Controls.Add (c1);
					cell1.Controls.Add (c2);
					cell0.HorizontalAlign = HorizontalAlign.Right;

					if (s0 != null)
						cell0.ApplyStyle (s0);
					if (s1 != null)
						cell1.ApplyStyle (s1);

					row.Controls.Add (cell1);
				}
				else {
					cell0.ColumnSpan = 2;
					cell0.HorizontalAlign = HorizontalAlign.Center;
					if (s0 != null)
						cell0.ApplyStyle (s0);
				}
				return row;
			}
Exemple #33
0
        protected void CreateControlHierarchy()
        {
            //code = new StringBuilder();
              //      code.AppendLine("<script>");
              //      code.AppendLine("function EnableServiceName() {");
              //      code.AppendLine("var msg= 'Are you sure you want to modify the Web Service Name?" + modifyMessage +"';");
              //      code.AppendLine("if (confirm(msg)) document.getElementById('selfReg_btnModifyService').disabled = false;");
              //      code.AppendLine("else{ document.getElementById('txtServiceName').value = document.getElementById('bakServiceName').value;}}</script>");
              //      code.AppendLine();
              //      code.AppendLine("<script>function EnableCodeBase() {");
              //      code.AppendLine("var msg= 'Are you sure you want to modify the CodeBase for this service?" + modifyMessage + "';");
              //      code.AppendLine("if (confirm(msg))document.getElementById('btnModifyService').disabled = false;");
              //      code.AppendLine("else{document.getElementById('txtCodebaseUrl').value = document.getElementById('bakCodebase').value;}}");
              //      code.AppendLine();
              //      code.AppendLine("function EnableServiceUrl() {");
              //      code.AppendLine("var msg= 'Are you sure you want to modify the Web Service URL?" + modifyMessage + "';");
              //      code.AppendLine("if (confirm(msg))document.getElementById('btnModifyService').disabled = false;");
              //      code.AppendLine("else{document.getElementById('txtWebServiceUrl').value = document.getElementById('bakServiceUrl').value;}}");
              //      code.AppendLine();
              //      code.AppendLine("function ConfirmRetire() {");
              //      code.AppendLine("var msg= 'Are you sure you want to retire this WebService.\\nIf you proceed all references to this site will be retired';");
              //      code.AppendLine("var state = confirm(msg);return state;}");
              //      code.AppendLine("</script>");
              //      Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OnNameChange", code.ToString());
            pageintro = new HtmlGenericControl("div");
            pageintro.ID ="pageintro";
            lblTitle = new Label();
            lblTitle.Text = "Self Registration for " +  AgentType;
            lblTitle.ID = "lblTitle";
            lblTitle.Visible = true;
            lblResponse = new Label();
            lblResponse.ID = "lblResponse";
            lblResponse.Text = Response;
            lblResponse.Visible = ResponseVisible;

            lblIntroduction = new Label();
            lblIntroduction.ID = "lblIntroduction";
            lblIntroduction.Text = Intro;
            lblIntroduction.Visible = true;
            lblServiceType = new Label();
            lblServiceType.ID = "lblServiceType";
            lblServiceType.Text = AgentType;
            HtmlGenericControl h1 = new HtmlGenericControl("h2");
            h1.Controls.Add(lblTitle);
            pageintro.Controls.Add(h1);

            HtmlGenericControl p = new HtmlGenericControl("p");
            p.Controls.Add(lblIntroduction);
            pageintro.Controls.Add(p);
            if (ResponseVisible)
            {
                p = new HtmlGenericControl("p");
                p.Controls.Add(lblResponse);
                pageintro.Controls.Add(p);
            }
            Controls.Add(pageintro);

            pagecontent = new HtmlGenericControl("div");
            pagecontent.ID = "pagecontent";

            //frmRegister = new HtmlForm();
            //frmRegister.Method = "post";
            //frmRegister.Target = "";
            //frmRegister.Name = "RegisterSelf";
            //frmRegister.ID = "frmRegister";

            tblMain = new Table();
            tblMain.CssClass = "simpleform";
            tblMain.Width = width;

            Literal spacer = new Literal();
            spacer.Text = "&nbsp;&nbsp;";
            Style s1 = new Style();
            s1.Width = labelWidth;
            s1.Height = onePX;
            s1.ForeColor = ForeColor;
            Style s2 = new Style();
            s2.Width = guidWidth;
            s2.ForeColor = BorderColor;

            Style s3 = new Style();
            s3.Width = buttonColumnWidth;
            s3.ForeColor = ForeColor;
            Style s4 = new Style();
            s4.Width = dataWidth;

            Style txtAreaStyle = new Style();
            //txtAreaStyle.Height = txtBoxHeight;
            txtAreaStyle.Width = dataWidth;
            txtAreaStyle.BorderColor = BorderColor;

            Style txtBoxStyle = new Style();
            txtBoxStyle.Height = txtBoxHeight;
            txtBoxStyle.Width = dataWidth;
            txtBoxStyle.BorderColor = BorderColor;

            Style txtGuidStyle = new Style();
            txtGuidStyle.Height = txtBoxHeight;
            txtGuidStyle.Width = guidWidth;
            txtGuidStyle.BorderColor = BorderColor;

            TableRow row;
            TableHeaderCell th;
            TableCell td;
            TableCell td2;
            //Label lbl;
            //Create the first row
            row = new TableRow();
            th = new TableHeaderCell();
            th.ApplyStyle(s1);
            td = new TableCell();
            td.ApplyStyle(s2);
            td2 = new TableCell();
            td2.ApplyStyle(s3);
            row.Cells.Add(th);
            row.Cells.Add(td);
            row.Cells.Add(td2);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            th.ColumnSpan = 3;
            th.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
            th.Text = "Required Credential Information";
            row.Cells.Add(th);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblServiceName = new Label();
            lblServiceName.ID = "lblServiceName";
            lblServiceName.Text = "Service Name";
            th.Controls.Add(lblServiceName);
            td = new TableCell();
            td.ColumnSpan = 2;
            txtServiceName = new TextBox();
            txtServiceName.ID = "txtServiceName";
            txtServiceName.ApplyStyle(txtBoxStyle);
            txtServiceName.Text = AgentName;
            td.Controls.Add(txtServiceName);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblServiceGuid = new Label();
            lblServiceGuid.ID = "lblServiceGuid";
            lblServiceGuid.Text = "Service GUID";
            th.Controls.Add(lblServiceGuid);

            td = new TableCell();
            td.ColumnSpan = 1;
            txtServiceGuid = new TextBox();
            txtServiceGuid.ID = "txtServiceGuid";
            txtServiceGuid.ApplyStyle(txtGuidStyle);
            txtServiceGuid.Text = AgentGuid;
            td.Controls.Add(txtServiceGuid);
            td2 = new TableCell();
            td2.ApplyStyle(s3);
            btnGuid = new Button();
            btnGuid.Text = "Create GUID";
            btnGuid.ID = "btnGuid";
            btnGuid.Click += btnGuid_Click;
            btnGuid.Enabled = false;
            td2.Controls.Add(btnGuid);
            row.Cells.Add(th);
            row.Cells.Add(td);
            row.Cells.Add(td2);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblCodebaseUrl = new Label();
            lblCodebaseUrl.ID = "lblCodebaseUrl";
            lblCodebaseUrl.Text = "Codebase URL";
            th.Controls.Add(lblCodebaseUrl);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtCodebaseUrl = new TextBox();
            txtCodebaseUrl.ID = "txtCodebaseUrl";
            txtCodebaseUrl.ApplyStyle(txtBoxStyle);
            txtCodebaseUrl.Text = CodebaseUrl;
            td.Controls.Add(txtCodebaseUrl);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblServiceUrl = new Label();
            lblServiceUrl.ID = "lblServiceUrl";
            lblServiceUrl.Text = "Web Service URL";
            th.Controls.Add(lblServiceUrl);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtServiceUrl = new TextBox();
            txtServiceUrl.ID = "txtServiceUrl";
            txtServiceUrl.ApplyStyle(txtBoxStyle);
            txtServiceUrl.Text = WebServiceUrl;
            td.Controls.Add(txtServiceUrl);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            trDomainSB = new TableRow();
            trDomainSB.ID = "trDomainSB";
            th = new TableHeaderCell();
            lblDomainServer = new Label();
            lblDomainServer.ID = "lblDomainServer";
            lblDomainServer.Text = "Domain ServiceBroker";
            th.Controls.Add(lblDomainServer);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtDomainServer = new TextBox();
            txtDomainServer.ApplyStyle(txtBoxStyle);
            txtDomainServer.Text = DomainServer;
            td.Controls.Add(txtDomainServer);
            trDomainSB.Cells.Add(th);
            trDomainSB.Cells.Add(td);
            tblMain.Rows.Add(trDomainSB);

            trDomainSB.Visible = (AgentType == ProcessAgentType.SERVICE_BROKER || AgentType == ProcessAgentType.BATCH_SERVICE_BROKER) ? false :true;

            trRowPasskey = new TableRow();
            th = new TableHeaderCell();
            lblOutPassKey = new Label();
            lblOutPassKey.ID = "lblOutPassKey";
            lblOutPassKey.Text = "Install Credential Passkey";
            th.Controls.Add(lblOutPassKey);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtOutPasskey = new TextBox();
            txtOutPasskey.ApplyStyle(txtBoxStyle);
            txtOutPasskey.Text = ConfigurationManager.AppSettings["defaultPasskey"];
            td.Controls.Add(txtOutPasskey);
            td2 = new TableCell();
            td2.ApplyStyle(s3);
            trRowPasskey.Cells.Add(th);
            trRowPasskey.Cells.Add(td);
            tblMain.Rows.Add(trRowPasskey);

            row = new TableRow();
            th = new TableHeaderCell();
            th.ColumnSpan = 3;
            th.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
            th.Text = "Optional Information";
            row.Cells.Add(th);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblDescription = new Label();
            lblDescription.ID = "lblDescription";
            lblDescription.Text = "Description";
            th.Controls.Add(lblDescription);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtDescription = new TextBox();
            txtDescription.TextMode = TextBoxMode.MultiLine;
            txtDescription.Columns = 50;
            txtDescription.Rows = 4;

            txtDescription.Wrap = true;
            txtDescription.ApplyStyle(txtAreaStyle);
            txtDescription.Text = Description;
            td.Controls.Add(txtDescription);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblInfoUrl = new Label();
            lblInfoUrl.ID = "lblInfoUrl";
            lblInfoUrl.Text = "Information URL";
            th.Controls.Add(lblInfoUrl);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtInfoUrl = new TextBox();
            txtInfoUrl.ApplyStyle(txtBoxStyle);
            txtInfoUrl.Text = InfoUrl;
            td.Controls.Add(txtInfoUrl);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblContactInfo = new Label();
            lblContactInfo.ID = "lblContactInfo";
            lblContactInfo.Text = "Contact Email";
            th.Controls.Add(lblContactInfo);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtContactInfo = new TextBox();
            txtContactInfo.ApplyStyle(txtBoxStyle);
            txtContactInfo.Text = ContactEmail;
            td.Controls.Add(txtContactInfo);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblBugEmail = new Label();
            lblBugEmail.ID = "lblBugEmail";
            lblBugEmail.Text = "Bug Email";
            th.Controls.Add(lblBugEmail);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtBugEmail = new TextBox();
            txtBugEmail.ApplyStyle(txtBoxStyle);
            txtBugEmail.Text = BugEmail;
            td.Controls.Add(txtBugEmail);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            lblLocation = new Label();
            lblLocation.ID = "lblLocation";
            lblLocation.Text = "Location";
            th.Controls.Add(lblLocation);

            td = new TableCell();
            td.ColumnSpan = 2;
            txtLocation = new TextBox();
            txtLocation.ApplyStyle(txtBoxStyle);
            txtLocation.Text = Location;
            td.Controls.Add(txtLocation);
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            row = new TableRow();
            th = new TableHeaderCell();
            th.ColumnSpan = 2;

            btnSave = new Button();
            btnSave.ID = "btnSave";
            btnSave.Text = "Save Service";
            btnSave.CommandName = "Save";
            btnSave.Click += btnSave_Click;
            btnSave.Enabled = false;
            th.Controls.Add(btnSave);

            btnModify = new Button();
            btnModify.ID = "btnModify";
            btnModify.Text = "Modify Service";
            btnModify.CommandName = "Modify";
            btnModify.Click += btnModify_Click;
            btnModify.OnClientClick = "javascript:return confirm('Are you sure you want to modify this WebService?\\n If you proceed all references to this site will be modified.');";
            btnModify.Enabled = false;
            th.Controls.Add(btnModify);
            th.Controls.Add(spacer);

            btnRefresh = new Button();
            btnRefresh.Text = "Refresh";
            btnRefresh.CommandName="Refresh";
            btnRefresh.ID= "btnRefresh";
            btnRefresh.Click += btnRefresh_Click;
            th.Controls.Add(btnRefresh);
            th.Controls.Add(spacer);

            btnClear = new Button();
            btnClear.Text = "Clear";
            btnClear.CommandName="Clear";
            btnClear.ID="btnClear";
            btnClear.Click += btnClear_Click;
            btnClear.OnClientClick = "javascript:return confirm('Are you sure you want to clear the page?\\n Are you really sure');";
            th.Controls.Add(btnClear);

            th.Controls.Add(spacer);
            btnRetire = new Button();
            btnRetire.ID = "btnRetire";
            btnRetire.Text = "Retire";
            btnRetire.CommandName="Retire";
            btnRetire.Click += btnRetire_Click;
            btnRetire.OnClientClick="javascript:return confirm('Are you sure you want to retire this WebService?\\nIf you proceed all references to this site will be retired');";

            th.Controls.Add(btnRetire);
            td = new TableCell();
            row.Cells.Add(th);
            row.Cells.Add(td);
            tblMain.Rows.Add(row);

            pagecontent.Controls.Add(tblMain);
            hdnServiceGuid = new HiddenField();
            hdnServiceGuid.ID = "bakServiceGuid";
            pagecontent.Controls.Add(hdnServiceGuid);
            hdnServiceName = new HiddenField();
            hdnServiceName.ID = "bakServiceName";
            pagecontent.Controls.Add(hdnServiceName);
            hdnServiceUrl = new HiddenField();
            hdnServiceUrl.ID = "bakServiceUrl";
            pagecontent.Controls.Add(hdnServiceUrl);
            hdnCodebaseUrl = new HiddenField();
            hdnCodebaseUrl.ID = "bakCodebaseUrl";
            pagecontent.Controls.Add(hdnCodebaseUrl);
            //pagecontent.Controls.Add(frmRegister);
            Controls.Add(pagecontent);

            ChildControlsCreated = true;
            SetFormMode(HasDomain);
        }
			TableRow CreateRow (Control c0, Style s0, HorizontalAlign align)
			{
				TableRow row = new TableRow ();
				TableCell cell0 = new TableCell ();

				cell0.Controls.Add (c0);
				cell0.HorizontalAlign = align;
				if (s0 != null)
					cell0.ApplyStyle (s0);

				row.Controls.Add (cell0);
				return row;
			}
			TableCell CreateCell (Control c0, Control c1, Style s)
			{
				TableCell cell = new TableCell ();
				if (s != null)
					cell.ApplyStyle (s);

				cell.Controls.Add (c0);
				if (c1 != null)
					cell.Controls.Add (c1);

				return cell;
			}
Exemple #36
0
        /// <summary>
        /// 将此控件呈现给指定的输出参数,并使用指定的数据初始化控件。
        /// </summary>
        /// <param name="writer"> 接收控件内容的 HtmlTextWriter 编写器 </param>
        /// <param name="MenuXML">菜单文件名。</param>
        public void RenderControl(HtmlTextWriter writer, string MenuXML)
        {
            Thinksea.WebControls.Menu2.Menu menuConnection = new Thinksea.WebControls.Menu2.Menu(MenuXML); // 菜单数据库联接。

            string OutMenuHtmlText =                                                                       // 输出菜单 HTML 文本。
                                     @"<script type='text/javascript' id='clientEventHandlersJS'>
<!--
function Thinksea_WebControls_Menu2_menuChange_" + this.ID + @"(obj,menu)
{
	var controls = document.getElementById('"     + this.ID + @"').all;
	for (var i=0; i < controls.length; i++)
	{
		if( controls[i].id == menu )
		{
			menu = controls[i];
		}
	}
	if(menu.style.display=='')
	{"    ;

            if (this.MenuTitleCollapseStyle != null)
            {
                if (this.MenuTitleCollapseStyle.CssClass != null && this.MenuTitleCollapseStyle.CssClass != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.className='"         + this.MenuTitleCollapseStyle.CssClass + @"';";
                }
                string styleStr = this.StyleToCssString(this.MenuTitleCollapseStyle);
                if (styleStr != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.style.cssText='"         + styleStr + @"';";
                }
            }
            OutMenuHtmlText += @"
		menu.style.display='none';
	}else{"    ;
            if (this.MenuTitleStyle != null)
            {
                if (this.MenuTitleStyle.CssClass != null && this.MenuTitleStyle.CssClass != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.className='"         + this.MenuTitleStyle.CssClass + @"';";
                }
                string styleStr = this.StyleToCssString(this.MenuTitleStyle);
                if (styleStr != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.style.cssText='"         + styleStr + @"';";
                }
            }
            OutMenuHtmlText += @"
		menu.style.display='';
	}
}
//-->
		</script>"        ;

            System.Web.UI.WebControls.Panel MenuPanel = new System.Web.UI.WebControls.Panel();
            MenuPanel.ID = this.ID;
            if (this.Style["Z-INDEX"] != null)
            {
                MenuPanel.Style["Z-INDEX"] = this.Style["Z-INDEX"];
            }
            if (this.Style["POSITION"] != null)
            {
                MenuPanel.Style["POSITION"] = this.Style["POSITION"];
            }
            if (this.Style["LEFT"] != null)
            {
                MenuPanel.Style["LEFT"] = this.Style["LEFT"];
            }
            if (this.Style["TOP"] != null)
            {
                MenuPanel.Style["TOP"] = this.Style["TOP"];
            }
            MenuPanel.ApplyStyle(this.ControlStyle);
            MenuPanel.Enabled = this.Enabled;
            MenuPanel.Visible = this.Visible;

            int menuGroupCount = 0;       //菜单组数量
            int menuItemCount;            //菜单组中菜单项数量

            Thinksea.WebControls.Menu2.MenuGroup [] mgis = menuConnection.GetMenuGroup( );
            foreach (Thinksea.WebControls.Menu2.MenuGroup tmpmgis in mgis)
            {
                Thinksea.WebControls.Menu2.MenuItem [] miis = menuConnection.GetMenuItemOfMenuGroupIDWithAccessFilter(tmpmgis.ID, this.Powers);
                if (miis.Length > 0)
                {
                    menuItemCount = 0;

                    #region 菜单集合。
                    System.Web.UI.WebControls.Table MenuGroup = new System.Web.UI.WebControls.Table();
                    MenuGroup.Width       = new System.Web.UI.WebControls.Unit("100%");
                    MenuGroup.CellSpacing = 0;
                    MenuGroup.CellPadding = 0;

                    #region 菜单组标题
                    System.Web.UI.WebControls.TableRow MenuGroupTitleRow = new System.Web.UI.WebControls.TableRow();
                    MenuGroupTitleRow.Style["CURSOR"] = "hand";
                    #region
                    System.Web.UI.WebControls.TableCell MenuGroupTitleCell = new System.Web.UI.WebControls.TableCell();
                    if (tmpmgis.Expand)
                    {
                        MenuGroupTitleCell.ApplyStyle(this.MenuTitleStyle);
                    }
                    else
                    {
                        MenuGroupTitleCell.ApplyStyle(this.MenuTitleCollapseStyle);
                    }
                    MenuGroupTitleCell.Attributes["onclick"] = "Thinksea_WebControls_Menu2_menuChange_" + this.ID + "(this,'" + tmpmgis.ID.Replace("\"", "\\\"") + "');";

                    #region 填充菜单组标题
                    System.Web.UI.WebControls.Label TitleText = new System.Web.UI.WebControls.Label();
                    TitleText.ApplyStyle(this.MenuTitleOnMouseOutStyle);
                    if (this.MenuTitleOnMouseOverStyle != null)
                    {
                        string styleStr = this.StyleToCssString(this.MenuTitleOnMouseOverStyle);
                        if (styleStr != "")
                        {
                            TitleText.Attributes["onmouseover"] = "this.style.cssText='" + styleStr + "';";
                        }
                        else
                        {
                            if (this.MenuTitleOnMouseOverStyle.CssClass != null && this.MenuTitleOnMouseOverStyle.CssClass != "")
                            {
                                TitleText.Attributes["onmouseover"] = "this.className='" + this.MenuTitleOnMouseOverStyle.CssClass + "';";
                            }
                        }
                    }
                    if (this.MenuTitleOnMouseOutStyle != null)
                    {
                        string styleStr = this.StyleToCssString(this.MenuTitleOnMouseOutStyle);
                        if (styleStr != "")
                        {
                            TitleText.Attributes["onmouseout"] = "this.style.cssText='" + styleStr + "';";
                        }
                        else
                        {
                            if (this.MenuTitleOnMouseOutStyle.CssClass != null && this.MenuTitleOnMouseOutStyle.CssClass != "")
                            {
                                TitleText.Attributes["onmouseout"] = "this.className='" + this.MenuTitleOnMouseOutStyle.CssClass + "';";
                            }
                        }
                    }
                    TitleText.Text = tmpmgis.Text;

                    MenuGroupTitleCell.Controls.Add(TitleText);
                    #endregion

                    MenuGroupTitleRow.Cells.Add(MenuGroupTitleCell);
                    #endregion
                    MenuGroup.Rows.Add(MenuGroupTitleRow);
                    #endregion

                    #region 菜单项集合。
                    System.Web.UI.WebControls.TableRow MenuGroupRow = new System.Web.UI.WebControls.TableRow();
                    #region
                    System.Web.UI.WebControls.TableCell MenuGroupCell = new System.Web.UI.WebControls.TableCell();

                    #region
                    System.Web.UI.WebControls.Panel MenuGroupPanel = new System.Web.UI.WebControls.Panel();
                    MenuGroupPanel.ApplyStyle(this.MenuGroupStyle);
                    MenuGroupPanel.ID = tmpmgis.ID;
                    if (!tmpmgis.Expand)
                    {
                        MenuGroupPanel.Style["DISPLAY"] = "none";
                    }

                    #region 填充菜单项
                    int CellMaxCount = this.MaxColumn;    //用来控制每行最多显示的菜单项数量
                    int CellIndex    = 0;                 //当前显示的菜单项行索引。用来辅助CellMaxCount完成控制每行显示的菜单项数量
                    foreach (Thinksea.WebControls.Menu2.MenuItem tmpmiis in miis)
                    {
                        #region 插入菜单项分隔符
                        if (this.ShowMenuItemSeparator && CellIndex > 0)
                        {
                            System.Web.UI.WebControls.Label menuItemSeparator = new System.Web.UI.WebControls.Label();
                            menuItemSeparator.ApplyStyle(this.MenuItemSeparatorStyle);
                            MenuGroupPanel.Controls.Add(menuItemSeparator);
                        }
                        #endregion

                        #region 菜单项
                        System.Web.UI.WebControls.HyperLink MenuItem = new System.Web.UI.WebControls.HyperLink();
                        MenuItem.ApplyStyle(this.MenuItemStyle);
                        MenuItem.ID   = tmpmiis.ID;
                        MenuItem.Text = tmpmiis.Text;
                        if (this.Enabled)
                        {
                            if (tmpmiis.URL.Length == 0)
                            {
                                MenuItem.NavigateUrl = "javascript:" + this.Page.ClientScript.GetPostBackEventReference(this, "ItemID_" + tmpmiis.ID);
                            }
                            else
                            {
                                MenuItem.Target      = tmpmiis.Target;
                                MenuItem.NavigateUrl = tmpmiis.URL;
                            }
                            if (this.ItemDataBound != null)
                            {
                                this.ItemDataBound(this, new Thinksea.WebControls.Menu2.ItemEventArgs(MenuItem, tmpmiis));
                            }
                        }

                        MenuGroupPanel.Controls.Add(MenuItem);
                        #endregion

                        menuItemCount++;
                        CellIndex++;
                        if (CellIndex >= CellMaxCount)
                        {
                            CellIndex = 0;
                            System.Web.UI.WebControls.Literal MenuItemSplit = new System.Web.UI.WebControls.Literal();
                            MenuItemSplit.Text = "<br>";
                            MenuGroupPanel.Controls.Add(MenuItemSplit);
                        }
                    }
                    #endregion

                    MenuGroupCell.Controls.Add(MenuGroupPanel);
                    #endregion

                    MenuGroupRow.Cells.Add(MenuGroupCell);
                    #endregion
                    MenuGroup.Rows.Add(MenuGroupRow);
                    #endregion

                    if (menuItemCount > 0)
                    {
                        if (this.ShowMenuGroupSeparator && menuGroupCount > 0)
                        {
                            System.Web.UI.WebControls.Panel menuGroupSeparator = new System.Web.UI.WebControls.Panel();
                            menuGroupSeparator.ApplyStyle(this.MenuGroupSeparatorStyle);
                            MenuPanel.Controls.Add(menuGroupSeparator);
                        }
                        MenuPanel.Controls.Add(MenuGroup);
                        menuGroupCount++;
                    }
                    #endregion
                }
            }
            writer.Write(OutMenuHtmlText);
            MenuPanel.RenderControl(writer);
        }