本文整理汇总了C#中System.Web.UI.WebControls.Style.MergeWith方法的典型用法代码示例。如果您正苦于以下问题:C# Style.MergeWith方法的具体用法?C# Style.MergeWith怎么用?C# Style.MergeWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Style
的用法示例。
在下文中一共展示了Style.MergeWith方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Style_Merge
public void Style_Merge ()
{
Style s = new Style ();
Style copy = new Style ();
SetSomeValues(s);
copy.ForeColor = Color.Blue;
copy.MergeWith(s);
Assert.AreEqual (Color.Red, copy.BackColor, "Merge1");
Assert.AreEqual (Color.Blue, copy.ForeColor, "Merge2");
// Don't fail here
copy.MergeWith(null);
}
示例2: PushPanelStyle
/// <devdoc>
/// <para>Push style on stack, but do not open it. Used for pending styles, as in the panel and page adapters.</para>
/// </devdoc>
internal void PushPanelStyle(Style style) {
Style stackStyle = new Style();
if (_panelStyleStack.Count == 0) {
stackStyle.CopyFrom(style);
_panelStyleStack.Push(stackStyle);
return;
}
stackStyle.CopyFrom((Style)_panelStyleStack.Peek());
stackStyle.MergeWith(style);
_panelStyleStack.Push(stackStyle);
}
示例3: EnterStyle
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override void EnterStyle(Style style, HtmlTextWriterTag tag) {
// Ignore tag for wml.
if (AnalyzeMode) {
return;
}
// All "block level controls" (controls that render using block level elements in HTML) call enterStyle
// using a div. Here we ensure that a new p is open for these controls to ensure line breaking behavior.
if (tag == HtmlTextWriterTag.Div) {
BeginBlockLevelControl();
}
Style stackStyle = new Style();
stackStyle.CopyFrom(style);
stackStyle.MergeWith(CurrentStyle);
if (_panelStyleStack.Count > 0) {
stackStyle.MergeWith((Style)_panelStyleStack.Peek());
}
_styleStack.Push(stackStyle); // updates CurrentStyle
if (_paragraphOpen) {
OpenCurrentStyleTags();
}
}
示例4: CreateChildControls
protected override void CreateChildControls()
{
LinkButton lnkPrevMon = new LinkButton();
lnkPrevMon.ID = "lnkPrevMon";
lnkPrevMon.Text = this.PrevMonthText;
lnkPrevMon.Click += new EventHandler(this.lnkPrevMon_OnClick);
this._lnkPrevMon = lnkPrevMon;
LinkButton lnkNextMon = new LinkButton();
lnkNextMon.ID = "lnkNextMon";
lnkNextMon.Text = this.NextMonthText;
lnkNextMon.Click += new EventHandler(this.lnkNextMon_OnClick);
this._lnkNextMon = lnkNextMon;
Style hdrTextStyle = new System.Web.UI.WebControls.Style();
hdrTextStyle.MergeWith(this._dayHdrStyle);
hdrTextStyle.BorderStyle = BorderStyle.None;
LinkButton lnkHdrSun = new LinkButton();
lnkHdrSun.ID = "lnkHdrSun";
lnkHdrSun.Text = this.GetDayName(DayOfWeek.Sunday);
lnkHdrSun.ApplyStyle(hdrTextStyle);
lnkHdrSun.CommandName = "ShowDay";
lnkHdrSun.CommandArgument = DayOfWeek.Sunday.ToString();
lnkHdrSun.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrSun = lnkHdrSun;
LinkButton lnkHdrMon = new LinkButton();
lnkHdrMon.ID = "lnkHdrMon";
lnkHdrMon.Text = this.GetDayName(DayOfWeek.Monday);
lnkHdrMon.ApplyStyle(hdrTextStyle);
lnkHdrMon.CommandName = "ShowDay";
lnkHdrMon.CommandArgument = DayOfWeek.Monday.ToString();
lnkHdrMon.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrMon = lnkHdrMon;
LinkButton lnkHdrTue = new LinkButton();
lnkHdrTue.ID = "lnkHdrTue";
lnkHdrTue.Text = this.GetDayName(DayOfWeek.Tuesday);
lnkHdrTue.ApplyStyle(hdrTextStyle);
lnkHdrTue.CommandName = "ShowDay";
lnkHdrTue.CommandArgument = DayOfWeek.Tuesday.ToString();
lnkHdrTue.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrTue = lnkHdrTue;
LinkButton lnkHdrWed = new LinkButton();
lnkHdrWed.ID = "lnkHdrWed";
lnkHdrWed.Text = this.GetDayName(DayOfWeek.Wednesday);
lnkHdrWed.ApplyStyle(hdrTextStyle);
lnkHdrWed.CommandName = "ShowDay";
lnkHdrWed.CommandArgument = DayOfWeek.Wednesday.ToString();
lnkHdrWed.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrWed = lnkHdrWed;
LinkButton lnkHdrThu = new LinkButton();
lnkHdrThu.ID = "lnkHdrThu";
lnkHdrThu.Text = this.GetDayName(DayOfWeek.Thursday);
lnkHdrThu.ApplyStyle(hdrTextStyle);
lnkHdrThu.CommandName = "ShowDay";
lnkHdrThu.CommandArgument = DayOfWeek.Thursday.ToString();
lnkHdrThu.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrThu = lnkHdrThu;
LinkButton lnkHdrFri = new LinkButton();
lnkHdrFri.ID = "lnkHdrFri";
lnkHdrFri.Text = this.GetDayName(DayOfWeek.Friday);
lnkHdrFri.ApplyStyle(hdrTextStyle);
lnkHdrFri.CommandName = "ShowDay";
lnkHdrFri.CommandArgument = DayOfWeek.Friday.ToString();
lnkHdrFri.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrFri = lnkHdrFri;
LinkButton lnkHdrSat = new LinkButton();
lnkHdrSat.ID = "lnkHdrSat";
lnkHdrSat.Text = this.GetDayName(DayOfWeek.Saturday);
lnkHdrSat.ApplyStyle(hdrTextStyle);
lnkHdrSat.CommandName = "ShowDay";
lnkHdrSat.CommandArgument = DayOfWeek.Saturday.ToString();
lnkHdrSat.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrSat = lnkHdrSat;
// Create all link buttons for the days we're going to display.
if (this._lnkDates != null)
this._lnkDates.Clear();
this._lnkDates = new Collections.WebControlCollection();
DateTime curWkStart = this.GetCalFirstDay();
while (curWkStart.Date < this.dtCurMon.AddMonths(1))
{
DateTime curDay = curWkStart;
for (int i = 0; i < 7; i++)
{
LinkButton lnkDate = new LinkButton();
lnkDate.ID = "lnkDate_" + curDay.ToString("yyyyMMdd");
lnkDate.Text = curDay.Day.ToString();
lnkDate.CssClass = "date";
lnkDate.CommandName = "ShowDay";
lnkDate.CommandArgument = curDay.ToString("yyyyMMdd");
lnkDate.Command += new CommandEventHandler(this.lnkDate_OnCommand);
lnkDate.ApplyStyle((curDay.Month == this.dtCurMon.Month) ? this._curMonDateStyle : this._othMonDateStyle);
this._lnkDates.Add(lnkDate, curDay.ToString("yyyMMdd"));
//.........这里部分代码省略.........
示例5: RenderEventRow
protected void RenderEventRow(HtmlTextWriter writer, DateTime rowStart)
{
DateTime rowEnd = rowStart.Date.AddDays(6);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "events");
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
CalendarEvent[] events = this._provider.GetEvents(this.DisplayUserKey, rowStart.Date, rowEnd.Date);
if (events.Length == 0)
{
for (int i = 0; i < 7; i++)
this.RenderEmptyEvent(writer);
}
else
{
Style eventTextStyle = new Style();
eventTextStyle.MergeWith(this._eventStyle);
eventTextStyle.BorderStyle = BorderStyle.None;
List<CalendarEvent> unrenderedEvents = new List<CalendarEvent>(events);
DateTime curDay = rowStart;
while (unrenderedEvents.Count > 0)
{
// Doing the event this way, lets us put multiple events on the same
// row, so long as they don't "interfere" with each other.
CalendarEvent curEv = null;
if (curDay.Date == rowStart.Date)
// Make sure that we only allow events to occured before the
// "current" date if we're on the first cell in the row.
curEv = unrenderedEvents.Where(e => e.EventStartDate.Date <= curDay.Date).FirstOrDefault();
else
curEv = unrenderedEvents.Where(e => e.EventStartDate.Date == curDay.Date).FirstOrDefault();
while (curEv == null && curDay.Date <= rowEnd.Date)
{
this.RenderEmptyEvent(writer);
curDay = curDay.AddDays(1);
curEv = unrenderedEvents.Where(e => e.EventStartDate.Date == curDay.Date).FirstOrDefault();
}
if (curEv == null)
{
// If we still have no current event at this point, end this row,
// start a new one, and let the search start over.
curDay = rowStart;
writer.RenderEndTag(); // TR (event row)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "events");
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
}
else
{
// Now, we write the actual event.
int eventDays = curEv.EventEndDate.Date <= rowEnd.Date
? (int)System.Math.Ceiling(curEv.EventEndDate.Subtract(curDay).TotalDays)
: (int)System.Math.Ceiling(rowEnd.Subtract(curDay).TotalDays) + 1;
if (eventDays > 1)
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, eventDays.ToString());
if (curEv.EventStartDate < rowStart && curEv.EventEndDate > rowEnd)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evMid");
else if (curEv.EventStartDate < rowStart)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evEnd");
else if (curEv.EventEndDate > rowEnd)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evStart");
else
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evFull");
if (this.ControlStyle != null)
{
System.Web.UI.WebControls.Style tdStyle = new Style();
tdStyle.BorderStyle = this.ControlStyle.BorderStyle;
tdStyle.BorderColor = this.ControlStyle.BorderColor;
tdStyle.BorderWidth = this.ControlStyle.BorderWidth;
tdStyle.ForeColor = this.ControlStyle.ForeColor;
tdStyle.BackColor = this.ControlStyle.BackColor;
tdStyle.AddAttributesToRender(writer);
}
writer.RenderBeginTag(HtmlTextWriterTag.Td);
//if (curEv.EventStartDate < rowStart && curEv.EventEndDate > rowEnd)
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evMid");
//else if (curEv.EventStartDate < rowStart)
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evEnd");
//else if (curEv.EventEndDate > rowEnd)
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evStart");
//else
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evFull");
this._eventStyle.AddAttributesToRender(writer);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
LinkButton lnkEvent = new LinkButton();
lnkEvent.ID = "lnkEvent_" + curEv.ProviderEventKey + "_" + curDay.ToString("yyyyMMdd");
lnkEvent.Text = (curEv.EventStartDate.Date == curDay.Date)
? string.Format("{0} {1}", curEv.EventStartDate.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortTimePattern), curEv.Subject)
: string.Format("<< {0}", curEv.Subject);
lnkEvent.ApplyStyle(eventTextStyle);
lnkEvent.CommandName = "ShowEvent";
lnkEvent.CommandArgument = curEv.ProviderEventKey.ToString();
lnkEvent.Command += new CommandEventHandler(this.lnkEvent_Command);
this.Controls.Add(lnkEvent);
lnkEvent.RenderControl(writer);
//.........这里部分代码省略.........
示例6: CreateChildControls
protected override void CreateChildControls()
{
Controls.Clear();
if ((RepeatCount > 0) && (itemTemplate!=null))
{
// Start by outputing the header template (if supplied).
if(headerTemplate != null)
{
SimpleRepeaterItem headerContainer = new SimpleRepeaterItem(0, RepeatCount);
headerTemplate.InstantiateIn(headerContainer);
Controls.Add(headerContainer);
if (headerStyle!=null)
headerContainer.ApplyStyle(headerStyle);
}
// Output the content the specified number of times.
for (int i = 0; i<RepeatCount; i++)
{
SimpleRepeaterItem container = new SimpleRepeaterItem(i+1, RepeatCount);
// Create a style for alternate items.
Style altStyle = new Style();
altStyle.MergeWith(itemStyle);
altStyle.CopyFrom(alternatingItemStyle);
if ((i%2 == 0) && (alternatingItemTemplate != null))
{
// This is an alternating item and there is an alternating template.
alternatingItemTemplate.InstantiateIn(container);
container.ApplyStyle(altStyle);
}
else
{
itemTemplate.InstantiateIn(container);
if (itemStyle != null)
container.ApplyStyle(itemStyle);
}
Controls.Add(container);
}
// Once all of the items have been rendered,
// add the footer template if specified.
if (footerTemplate != null)
{
SimpleRepeaterItem footerContainer = new SimpleRepeaterItem(RepeatCount, RepeatCount);
footerTemplate.InstantiateIn(footerContainer);
Controls.Add(footerContainer);
if (footerStyle != null)
footerContainer.ApplyStyle(footerStyle);
}
}
else
{
// Show an error message.
Controls.Add(new LiteralControl("Specify the record count and an item template"));
}
}