コード例 #1
0
 private void SetDayStyles(TableItemStyle style, int styleMask, Unit defaultWidth)
 {
     style.Width           = defaultWidth;
     style.HorizontalAlign = HorizontalAlign.Center;
     if ((styleMask & 16) != 0)
     {
         style.CopyFrom(this.DayStyle);
     }
     if ((styleMask & 1) != 0)
     {
         style.CopyFrom(this.WeekendDayStyle);
     }
     if ((styleMask & 2) != 0)
     {
         style.CopyFrom(this.OtherMonthDayStyle);
     }
     if ((styleMask & 4) != 0)
     {
         style.CopyFrom(this.TodayDayStyle);
     }
     if ((styleMask & 8) != 0)
     {
         style.ForeColor = Color.White;
         style.BackColor = Color.Silver;
         style.CopyFrom(this.SelectedDayStyle);
     }
 }
コード例 #2
0
 protected override void Render(HtmlTextWriter writer)
 {
     if (this.Controls.Count >= 1)
     {
         Table table = (Table)this.Controls[0];
         table.CopyBaseAttributes(this);
         if (base.ControlStyleCreated && !base.ControlStyle.IsEmpty)
         {
             table.ApplyStyle(base.ControlStyle);
         }
         else
         {
             table.GridLines   = GridLines.None;
             table.CellSpacing = 0;
         }
         table.Caption      = this.Caption;
         table.CaptionAlign = this.CaptionAlign;
         foreach (TableRow row in table.Rows)
         {
             Style s = new TableItemStyle();
             s.CopyFrom(_rowStyle);
             if ((s != null) && row.Visible)
             {
                 row.MergeStyle(s);
             }
         }
     }
     base.Render(writer);
 }
コード例 #3
0
ファイル: TableItemStyleTest.cs プロジェクト: raj581/Marvin
        public void CopyFrom_Self()
        {
            TableItemStyle tis = GetTableItemStyle();

            tis.CopyFrom(tis);
            CheckTableStyle(tis);
        }
コード例 #4
0
ファイル: TableItemStyleTest.cs プロジェクト: raj581/Marvin
        public void CopyFrom_Null()
        {
            TableItemStyle tis = GetTableItemStyle();

            tis.CopyFrom(null);
            CheckTableStyle(tis);
        }
コード例 #5
0
ファイル: EventCalendar.cs プロジェクト: zahedbri/mojoportal
        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);
        }
コード例 #6
0
ファイル: TableItemStyleTest.cs プロジェクト: raj581/Marvin
        public void CopyFrom()
        {
            TableItemStyle tis = new TableItemStyle();

            tis.HorizontalAlign = HorizontalAlign.Left;
            tis.VerticalAlign   = VerticalAlign.Top;
            tis.Wrap            = true;

            tis.CopyFrom(GetTableItemStyle());
            CheckTableStyle(tis);
        }
コード例 #7
0
ファイル: EventCalendar.cs プロジェクト: zahedbri/mojoportal
        private void SetDayStyles(TableItemStyle style, int styleMask, Unit defaultWidth)
        {
            // default day styles
            style.Width           = defaultWidth;
            style.HorizontalAlign = HorizontalAlign.Center;

            if ((styleMask & STYLEMASK_DAY) != 0)
            {
                style.CopyFrom(DayStyle);
            }
            if ((styleMask & STYLEMASK_WEEKEND) != 0)
            {
                style.CopyFrom(WeekendDayStyle);
            }
            if ((styleMask & STYLEMASK_OTHERMONTH) != 0)
            {
                style.CopyFrom(OtherMonthDayStyle);
            }
            if ((styleMask & STYLEMASK_TODAY) != 0)
            {
                style.CopyFrom(TodayDayStyle);
            }
        }
コード例 #8
0
        private void RenderNextMonthNav(HtmlTextWriter writer, DateTime visibleDate, bool buttonsActive)
        {
            var nextPrevFormat = this.NextPrevFormat;
            var nextPrevStyle  = new TableItemStyle();

            nextPrevStyle.Width = Unit.Percentage(15.0);
            nextPrevStyle.CopyFrom(this.NextPrevStyle);

            if (this.IsMinSupportedYearMonth(visibleDate))
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.RenderEndTag();
            }
            else
            {
                string nextMonthText;
                nextPrevStyle.HorizontalAlign = IsRightToLeftCulture ? HorizontalAlign.Right : HorizontalAlign.Left;

                switch (nextPrevFormat)
                {
                case NextPrevFormat.ShortMonth:
                case NextPrevFormat.FullMonth:
                {
                    var month = this.threadCalendar.GetMonth(this.threadCalendar.AddMonths(visibleDate, -1));
                    nextMonthText = this.GetMonthName(month, nextPrevFormat == NextPrevFormat.FullMonth);
                    break;
                }

                default:
                {
                    nextMonthText = this.NextMonthText;
                    break;
                }
                }

                var prevDate      = GetPreviousDate(visibleDate);
                var eventArgument = "V" + prevDate.Subtract(baseDate).Days.ToString(CultureInfo.InvariantCulture);
                this.OnRenderCalendarCell(writer, nextPrevStyle, nextMonthText, null, buttonsActive, eventArgument);
            }
        }
コード例 #9
0
ファイル: BarcodeLabel.cs プロジェクト: fanda-india/prints
        /// <summary>
        /// Prepares our composite controls for rendering by setting
        /// last-minute (ie: non-viewstate tracked) properties.
        /// </summary>
        protected virtual void PrepareControlHierarchy()
        {
            if (Controls.Count > 0)
            {
                // Setup base table control style
                Table table = (Table)Controls[0];
                table.CopyBaseAttributes(this);
                if (ControlStyleCreated && !ControlStyle.IsEmpty)
                {
                    table.ApplyStyle(ControlStyle);
                }
                else
                {
                    table.GridLines   = GridLines.None;
                    table.CellPadding = 10;
                    table.CellSpacing = 0;
                }

                // Setup label controls.
                TableRow labelRowTop    = (TableRow)FindControl("labelRowTop");
                TableRow labelRowBottom = (TableRow)FindControl("labelRowBottom");
                labelRowTop.Visible    = false;
                labelRowBottom.Visible = false;
                if (ShowLabel)
                {
                    // Setup label row style
                    TableItemStyle style = new TableItemStyle();
                    style.CopyFrom(LabelRowStyle);
                    style.HorizontalAlign = LabelHorizontalAlign;

                    // Setup appropriate row
                    if (LabelVerticalAlign == VerticalAlign.Top)
                    {
                        labelRowTop.MergeStyle(style);
                        labelRowTop.Visible = true;

                        TableCell labelCell = (TableCell)FindControl("labelCellTop");
                        labelCell.Text = Text;
                    }
                    else
                    {
                        labelRowBottom.MergeStyle(style);
                        labelRowBottom.Visible = true;

                        TableCell labelCell = (TableCell)FindControl("labelCellBottom");
                        labelCell.Text = Text;
                    }
                }

                // Setup barcode row style
                TableRow barcodeRow = (TableRow)FindControl("barcodeRow");
                barcodeRow.MergeStyle(BarcodeRowStyle);

                // Setup barcode image url
                BarcodeImageUriBuilder builder = new BarcodeImageUriBuilder();
                builder.Text           = Text;
                builder.Scale          = Scale;
                builder.EncodingScheme = BarcodeEncoding;
                builder.BarMinHeight   = BarMinHeight;
                builder.BarMaxHeight   = BarMaxHeight;
                builder.BarMinWidth    = BarMinWidth;
                builder.BarMaxWidth    = BarMaxWidth;
                Image barcodeImage = (Image)FindControl("barcodeImage");
                barcodeImage.ImageUrl = builder.ToString();
            }
        }
コード例 #10
0
        protected virtual void OnRenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive)
        {
            var time            = firstDay;
            var hasWeekSelector = this.HasWeekSelectors(selectionMode);
            var unit            = Unit.Percentage(14.0);

            TableItemStyle selectorStyle = null;

            if (hasWeekSelector)
            {
                selectorStyle = new TableItemStyle
                {
                    Width           = Unit.Percentage(12.0),
                    HorizontalAlign = HorizontalAlign.Center
                };

                selectorStyle.CopyFrom(this.SelectorStyle);
                unit = Unit.Percentage(12.0);
            }

            var hasCustomDayRenderer = base.Events[MonthViewEventDayRender] != null;
            var styleArray           = new TableItemStyle[16];
            var definedStyleMask     = this.GetDefinedStyleMask();
            var todaysDate           = this.TodaysDate;
            var selectWeekText       = this.SelectWeekText;
            var hasButton            = buttonsActive && (selectionMode != CalendarSelectionMode.None);
            var month        = this.threadCalendar.GetMonth(visibleDate);
            var days         = firstDay.Subtract(baseDate).Days;
            var isDesignMode = base.DesignMode && (this.SelectionMode != CalendarSelectionMode.None);

            var firstWeek = 0;

            if (this.IsMinSupportedYearMonth(visibleDate))
            {
                firstWeek = ((int)this.threadCalendar.GetDayOfWeek(firstDay)) - this.NumericFirstDayOfWeek();
                if (firstWeek < 0)
                {
                    firstWeek += 7;
                }
            }

            var isLastSupportedDay = false;
            var firstDate          = this.threadCalendar.AddMonths(this.maxSupportedDate, -1);
            var isFirstWeek        = this.IsMaxSupportedYearMonth(visibleDate) || this.IsTheSameYearMonth(firstDate, visibleDate);

            for (var i = 0; i < 6; i++)
            {
                if (isLastSupportedDay)
                {
                    return;
                }

                writer.Write("<tr>");
                if (hasWeekSelector)
                {
                    var weekNo = (days * 100) + 7;
                    if (firstWeek > 0)
                    {
                        weekNo -= firstWeek;
                    }
                    else if (isFirstWeek)
                    {
                        var dateDiff = this.maxSupportedDate.Subtract(time).Days;
                        if (dateDiff < 6)
                        {
                            weekNo -= 6 - dateDiff;
                        }
                    }

                    var eventArgument = "R" + weekNo.ToString(CultureInfo.InvariantCulture);
                    this.OnRenderCalendarCell(writer, selectorStyle, selectWeekText, null, buttonsActive, eventArgument);
                }

                for (var j = 0; j < 7; j++)
                {
                    if (firstWeek > 0)
                    {
                        j += firstWeek;
                        while (firstWeek > 0)
                        {
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.RenderEndTag();
                            firstWeek--;
                        }
                    }
                    else if (isLastSupportedDay)
                    {
                        while (j < 7)
                        {
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.RenderEndTag();
                            j++;
                        }
                        break;
                    }

                    var dayOfWeek  = (int)this.threadCalendar.GetDayOfWeek(time);
                    var dow        = (DayOfWeek)dayOfWeek;
                    var dayOfMonth = this.threadCalendar.GetDayOfMonth(time);
                    var monthValue = cachedNumbers[dayOfMonth];

                    var day         = new CalendarDay(time, IsWeekEnd(dow), time.Equals(todaysDate), this.SelectedDates != null && this.SelectedDates.Contains(time), this.threadCalendar.GetMonth(time) != month, monthValue);
                    var dayFlag     = GetDayFlag(day);
                    var styleMask   = definedStyleMask & dayFlag;
                    var index       = styleMask & 15;
                    var mergedStyle = styleArray[index];
                    if (mergedStyle == null)
                    {
                        mergedStyle = new TableItemStyle();
                        this.SetDayStyles(mergedStyle, styleMask, unit);
                        styleArray[index] = mergedStyle;
                    }

                    if (hasCustomDayRenderer)
                    {
                        OnRenderCustomDay(buttonsActive, writer, days, monthValue, day, mergedStyle, hasButton);
                    }
                    else
                    {
                        if (isDesignMode && mergedStyle.ForeColor.IsEmpty)
                        {
                            mergedStyle.ForeColor = this.defaultForeColor;
                        }
                        this.OnRenderCalendarCell(writer, mergedStyle, monthValue, null, hasButton, days.ToString(CultureInfo.InvariantCulture), day);
                    }

                    if (isFirstWeek && time.Month == this.maxSupportedDate.Month && time.Day == this.maxSupportedDate.Day)
                    {
                        isLastSupportedDay = true;
                    }
                    else
                    {
                        time = this.threadCalendar.AddDays(time, 1);
                        days++;
                    }
                }
                writer.Write("</tr>");
            }
        }
コード例 #11
0
        protected virtual void OnRenderDayHeader(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive)
        {
            writer.Write("<tr>");
            DateTimeFormatInfo currentInfo = GetDateTimeFormatter();

            if (this.HasWeekSelectors(selectionMode))
            {
                TableItemStyle style = new TableItemStyle();
                style.HorizontalAlign = HorizontalAlign.Center;
                if (selectionMode == CalendarSelectionMode.DayWeekMonth)
                {
                    int days       = visibleDate.Subtract(baseDate).Days;
                    int dayOfMonth = this.threadCalendar.GetDaysInMonth(this.threadCalendar.GetYear(visibleDate), this.threadCalendar.GetMonth(visibleDate), this.threadCalendar.GetEra(visibleDate));
                    if (this.IsMinSupportedYearMonth(visibleDate))
                    {
                        dayOfMonth = (dayOfMonth - this.threadCalendar.GetDayOfMonth(visibleDate)) + 1;
                    }
                    else if (this.IsMaxSupportedYearMonth(visibleDate))
                    {
                        dayOfMonth = this.threadCalendar.GetDayOfMonth(this.maxSupportedDate);
                    }
                    string eventArgument = "R" + (((days * 100) + dayOfMonth)).ToString(CultureInfo.InvariantCulture);
                    style.CopyFrom(this.SelectorStyle);
                    string title = null;

                    this.OnRenderCalendarCell(writer, style, this.SelectMonthText, title, buttonsActive, eventArgument);
                }
                else
                {
                    style.CopyFrom(this.DayHeaderStyle);
                    this.OnRenderCalendarCell(writer, style, string.Empty, null, false, null);
                }
            }

            TableItemStyle weekdayStyle = new TableItemStyle();

            weekdayStyle.HorizontalAlign = HorizontalAlign.Center;
            weekdayStyle.CopyFrom(this.DayHeaderStyle);

            DayNameFormat dayNameFormat = this.DayNameFormat;
            int           firstDay      = this.NumericFirstDayOfWeek();

            for (int i = firstDay; i < (firstDay + 7); i++)
            {
                string dayName;
                int    dayOfWeekNumber = i % 7;

                switch (dayNameFormat)
                {
                case DayNameFormat.Full:
                    dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber);
                    break;

                case DayNameFormat.FirstLetter:
                    dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber).Substring(0, 1);
                    break;

                case DayNameFormat.FirstTwoLetters:
                    dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber).Substring(0, 2);
                    break;

                case DayNameFormat.Shortest:
                    dayName = currentInfo.GetShortestDayName((DayOfWeek)dayOfWeekNumber);
                    break;

                default:
                    dayName = currentInfo.GetAbbreviatedDayName((DayOfWeek)dayOfWeekNumber);
                    break;
                }

                this.OnRenderCalendarCell(writer, weekdayStyle, dayName, null, false, null);
            }
            writer.Write("</tr>");
        }
コード例 #12
0
        protected virtual void PrepareControlHierarchyForRendering()
        {
            ControlCollection controls = Controls;

            if (controls.Count != 1)
            {
                return;
            }

            Table outerTable = (Table)controls[0];

            outerTable.CopyBaseAttributes(this);
            if (ControlStyleCreated)
            {
                outerTable.ApplyStyle(ControlStyle);
            }
            else
            {
                // Because we didn't create a ControlStyle yet, the settings
                // for the default style of the control need to be applied
                // to the child table control directly.
                outerTable.CellSpacing = 0;
            }

            TableRowCollection rows     = outerTable.Rows;
            TableCell          bodyCell = null;

            if (_headerTemplate != null)
            {
                TableRow headerRow = rows[0];
                if (ShowHeader)
                {
                    if (_headerStyle != null)
                    {
                        headerRow.Cells[0].MergeStyle(_headerStyle);
                    }
                }
                else
                {
                    headerRow.Visible = false;
                }

                bodyCell = rows[1].Cells[0];
            }
            if (_footerTemplate != null)
            {
                TableRow footerRow = rows[rows.Count - 1];
                if (ShowFooter)
                {
                    if (_footerStyle != null)
                    {
                        footerRow.Cells[0].MergeStyle(_footerStyle);
                    }
                }
                else
                {
                    footerRow.Visible = false;
                }
            }

            if (bodyCell == null)
            {
                bodyCell = rows[0].Cells[0];
            }

            ListViewPanel viewPanel = (ListViewPanel)bodyCell.Controls[0];

            if (_viewStyle != null)
            {
                viewPanel.ApplyStyle(_viewStyle);

                if (ShowScrollBars)
                {
                    viewPanel.Style["overflow"]   = "scroll";
                    viewPanel.Style["overflow-x"] = "auto";
                    viewPanel.Style["overflow-y"] = "auto";
                }
            }

            ListViewTable bodyTable = (ListViewTable)viewPanel.Controls[0];

            bodyTable.Columns = Columns;

            foreach (ListViewItem item in _items)
            {
                TableItemStyle   style          = _itemStyle;
                TableItemStyle   compositeStyle = null;
                ListViewItemType itemType       = item.ItemType;

                if (((itemType & ListViewItemType.EditItem) != 0) && (_editItemStyle != null))
                {
                    if (style != null)
                    {
                        compositeStyle = new TableItemStyle();
                        compositeStyle.CopyFrom(style);
                        compositeStyle.CopyFrom(_editItemStyle);
                    }
                    else
                    {
                        style = _editItemStyle;
                    }
                }
                if (((itemType & ListViewItemType.SelectedItem) != 0) && (_selectedItemStyle != null))
                {
                    if (compositeStyle != null)
                    {
                        compositeStyle.CopyFrom(_selectedItemStyle);
                    }
                    else if (style != null)
                    {
                        compositeStyle = new TableItemStyle();
                        compositeStyle.CopyFrom(style);
                        compositeStyle.CopyFrom(_selectedItemStyle);
                    }
                    else
                    {
                        style = _selectedItemStyle;
                    }
                }

                if (compositeStyle != null)
                {
                    item.MergeStyle(compositeStyle);
                }
                else if (style != null)
                {
                    item.MergeStyle(style);
                }

                if (_renderClickSelectScript)
                {
                    if ((itemType & ListViewItemType.SelectedItem) == 0)
                    {
                        item.Attributes["onclick"] = Page.GetPostBackEventReference(this, "S" + item.ItemIndex);
                        item.Style["cursor"]       = "hand";
                    }
                }
            }
        }
コード例 #13
0
        private void PrepareControlHierarchy()
        {
            if (HasControls() == false)
            {
                return;
            }

            Debug.Assert(Controls[0] is Table);
            Table table = (Table)Controls[0];

            table.CopyBaseAttributes(this);
            if (ControlStyleCreated)
            {
                table.ApplyStyle(ControlStyle);
            }

            // The composite alternating item style; do just one
            // merge style on the actual item.
            Style altItemStyle = null;

            if (alternatingItemStyle != null)
            {
                altItemStyle = new TableItemStyle();
                altItemStyle.CopyFrom(itemStyle);
                altItemStyle.CopyFrom(alternatingItemStyle);
            }
            else
            {
                altItemStyle = itemStyle;
            }

            int rowCount = table.Rows.Count;

            for (int i = 0; i < rowCount; i++)
            {
                TemplatedListItem item           = (TemplatedListItem)table.Rows[i];
                Style             compositeStyle = null;

                switch (item.ItemType)
                {
                case ListItemType.Item:
                    compositeStyle = itemStyle;
                    break;

                case ListItemType.AlternatingItem:
                    compositeStyle = altItemStyle;
                    break;

                case ListItemType.SelectedItem:
                {
                    compositeStyle = new TableItemStyle();

                    if (item.ItemIndex % 2 != 0)
                    {
                        compositeStyle.CopyFrom(altItemStyle);
                    }
                    else
                    {
                        compositeStyle.CopyFrom(itemStyle);
                    }
                    compositeStyle.CopyFrom(selectedItemStyle);
                }
                break;
                }

                if (compositeStyle != null)
                {
                    item.MergeStyle(compositeStyle);
                }
            }
        }