/// <summary> /// Render do controlo /// </summary> /// <param name="writer"></param> protected override void Render(HtmlTextWriter writer) { base.CssClass = "OWCheckBoxList"; RepeatInfo info1 = new RepeatInfo(); Style style1 = base.ControlStyleCreated ? base.ControlStyle : null; short num1 = this.TabIndex; bool flag1 = false; this.controlToRepeat.TabIndex = num1; if (num1 != 0) { if (!this.ViewState.IsItemDirty("TabIndex")) { flag1 = true; } this.TabIndex = 0; } info1.RepeatColumns = this.RepeatColumns; info1.RepeatDirection = this.RepeatDirection; info1.RepeatLayout = this.RepeatLayout; info1.RenderRepeater(writer, this, style1, this); if (num1 != 0) { this.TabIndex = num1; } if (flag1) { this.ViewState.SetItemDirty("TabIndex", false); } }
public void Is_serializable() { var repeatInfo = new RepeatInfo(DateTime.Now, DatePeriod.Daily); var json = JsonSerializer.Serialize(repeatInfo); Assert.IsNotNullOrEmpty(json); Console.WriteLine(json); }
/// <summary> /// 将控件呈现给指定的 HTML 编写器。 /// </summary> /// <param name="writer">接收控件内容的 <see cref="HtmlTextWriter"/> 对象。</param> protected override void Render(HtmlTextWriter writer) { if (!this.IsShowUnchecked) { DeleteUnChecked(); } if (this.Items.Count <= 0) { return; } RepeatInfo info = new RepeatInfo(); info.RepeatColumns = this.RepeatColumns; info.RepeatDirection = this.RepeatDirection; if (!base.DesignMode && !this.Context.Request.Browser.Tables) { info.RepeatLayout = RepeatLayout.Flow; } else { info.RepeatLayout = this.RepeatLayout; } Style controlStyle = base.ControlStyleCreated ? base.ControlStyle : null; info.RenderRepeater(writer, this, controlStyle, this); }
/// <summary> /// 连击 /// </summary> /// <param name="key"></param> /// <param name="clickCount"></param> /// <returns></returns> public static bool RepeatKey(KeyCode key, int clickCount) { float dicKey = (float)key + ((clickCount - 0.05f)) / 2; // 强行制造一个浮点Key if (!repeatInfoDic.ContainsKey(dicKey)) { repeatInfoDic.Add(dicKey, new RepeatInfo()); } RepeatInfo info = repeatInfoDic[dicKey]; bool ret = false; if (Input.GetKeyUp(key)) { info.count = info.count == 0 ? 1 : info.count; if (Time.time - info.time <= inteval) { info.count++; } info.time = Time.time; } if (Time.time - info.time > inteval && info.count != 0) { if (info.count == clickCount) { ret = true; } info.count = 0; } return(ret); }
private void CheckStopedRepeat(RepeatInfo rep) { if (rep.hasStop) { removeList.Add(rep); } }
public void RepeatParseFromString(RepeatAmount expAmount, int expCount, string pattern) { var repeat = RepeatInfo.FromString(pattern); Assert.Equal(expAmount, repeat.RepeatAmount); Assert.Equal(expCount, repeat.RepeatCount); }
private static RepeatInfo FindRepeat(byte[] data, int pos, int endLimit) { if (endLimit - pos <= 3) { return(new RepeatInfo { Length = 0 }); } var maxMatch = 0x0FFF; var startPos = pos; var endPos = Math.Min(endLimit, pos + maxMatch); var bestLength = 0; var i = startPos; while (i < endPos && data[pos] == data[i]) { bestLength++; i++; } var result = new RepeatInfo { Length = bestLength >= 3 ? bestLength : 0 }; return(result); }
public new string RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo) { HtmlTextWriter writer = new HtmlTextWriter(new StringWriter()); base.RenderItem(itemType, repeatIndex, repeatInfo, writer); return(writer.InnerWriter.ToString()); }
public void RepeatToStringMatch(RepeatAmount actAmount, int actCount, string pattern) { var repeat = new RepeatInfo { RepeatAmount = actAmount, RepeatCount = actCount }; Assert.Equal(pattern, repeat.ToString()); }
public void DefaultValues() { RepeatInfo ri = new RepeatInfo(); Assert.AreEqual(0, ri.RepeatColumns, "RepeatColumns"); Assert.AreEqual(RepeatDirection.Vertical, ri.RepeatDirection, "RepeatDirection"); Assert.AreEqual(RepeatLayout.Table, ri.RepeatLayout, "RepeatLayout"); Assert.IsFalse(ri.OuterTableImplied, "OuterTableImplied"); }
public void RepeatColumns_Negative() { RepeatInfo ri = new RepeatInfo(); ri.RepeatColumns = -1; Assert.AreEqual(-1, ri.RepeatColumns, "-1"); ri.RepeatColumns = Int32.MinValue; Assert.AreEqual(Int32.MinValue, ri.RepeatColumns, "Int32.MinValue"); }
protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { ListItem listItem = this.Items[repeatIndex]; if (_UnderlyingCheckbox != null) { _UnderlyingCheckbox.InputAttributes["value"] = listItem.Value; } base.RenderItem(itemType, repeatIndex, repeatInfo, writer); }
private void CheckStartTime(RepeatInfo rep) { if (!rep.hasStart) { rep.curTime += Time.deltaTime; if (rep.curTime > rep.startTime) { rep.hasStart = true; rep.curTime = 0f; } } }
string DoTest(int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool ftr, bool hdr, bool sep) { HtmlTextWriter htw = GetWriter(); RepeatInfo ri = new RepeatInfo(); ri.RepeatColumns = cols; ri.RepeatDirection = d; ri.RepeatLayout = l; ri.OuterTableImplied = OuterTableImplied; ri.RenderRepeater(htw, new RepeatInfoUser(ftr, hdr, sep, cnt), new TableStyle(), new DataList()); return(htw.InnerWriter.ToString()); }
private void RenderRepeater_BaseControl(string s, string msg, WebControl wc) { RepeatInfo ri = new RepeatInfo(); ri.RepeatColumns = 3; ri.RepeatDirection = RepeatDirection.Vertical; ri.RepeatLayout = RepeatLayout.Table; HtmlTextWriter writer = GetWriter(); ri.RenderRepeater(writer, new RepeatInfoUser(false, false, false, 1), new TableStyle(), wc); Assert.AreEqual(s, writer.InnerWriter.ToString(), msg); }
private void CheckRepeatTimes(RepeatInfo rep) { if (rep.hasStart && !rep.hasStop) { if (rep.repeatTimes == 0) { if (rep.onStop != null) { rep.onStop(); } rep.hasStop = true; } } }
protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, System.Web.UI.HtmlTextWriter writer) { // extract string fulltext = Items[repeatIndex].Text; var split = fulltext.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); Items[repeatIndex].Text = split[0]; writer.WriteBeginTag("div"); //Add a style writer.Write(" style"); writer.Write(HtmlTextWriter.EqualsDoubleQuoteString); writer.WriteStyleAttribute("float", "left"); writer.Write(HtmlTextWriter.DoubleQuoteChar); //Output the '>' for the 'div' tag writer.Write(HtmlTextWriter.TagRightChar); // renders radio button first line of text base.RenderItem(itemType, repeatIndex, repeatInfo, writer); //Write end tag writer.WriteEndTag("div"); if (split.Length > 1) { string text2 = split[1]; writer.WriteBeginTag("br"); writer.WriteEndTag("br"); //Write begin tag without closing > writer.WriteBeginTag("label"); //Add a style writer.Write(" style"); writer.Write(HtmlTextWriter.EqualsDoubleQuoteString); writer.WriteStyleAttribute("padding-left", "18px"); writer.WriteStyleAttribute("clear", "left"); writer.Write(HtmlTextWriter.DoubleQuoteChar); //Output the '>' for the 'label' tag writer.Write(HtmlTextWriter.TagRightChar); // renders second line of text writer.Write(text2); //Write end tag writer.WriteEndTag("label"); } }
public static string GetStringRepeatMost(List <string> list) { // result集合存放扫描结果 Dictionary <string, RepeatInfo> result = new Dictionary <string, RepeatInfo>(); RepeatInfo RepeatMost = null; // 遍历整型列表集合,查找其中的重复项 foreach (string v in list) { RepeatInfo item; if (result.ContainsKey(v)) { result[v].RepeatNum += 1; item = result[v]; } else { item = new RepeatInfo() { Value = v, RepeatNum = 1 }; result.Add(v, item); } if (RepeatMost == null) { RepeatMost = item; } else { if (RepeatMost.RepeatNum <= item.RepeatNum) { RepeatMost = item; } } } if (RepeatMost != null) { return(RepeatMost.Value); } else { return(null); } }
public void RepeatInfoRenderItem() { StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); CheckBoxList c = new CheckBoxList(); IRepeatInfoUser ri = (IRepeatInfoUser)c; RepeatInfo r = new RepeatInfo(); c.Items.Add("one"); c.Items.Add("two"); ri.RenderItem(ListItemType.Item, 0, r, tw); Assert.AreEqual("<input id=\"0\" type=\"checkbox\" name=\"0\" />" + "<label for=\"0\">one</label>", sw.ToString(), "A1"); }
public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep) { HtmlTextWriter htw = GetWriter (); RepeatInfo ri = new RepeatInfo (); ri.RepeatColumns = cols; ri.RepeatDirection = d; ri.RepeatLayout = l; ri.OuterTableImplied = OuterTableImplied; // get some variation in if we use style or not Style s = new Style (); if (cols != 3) s.CssClass = "mainstyle"; ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ()); return htw.InnerWriter.ToString (); }
private void CheckRepeatInterval(RepeatInfo rep) { if (rep.hasStart && !rep.hasStop) { rep.curTime += Time.deltaTime; if (rep.curTime > rep.timeInterval) { if (rep.onRepeat != null) { rep.onRepeat(); } rep.curTime = 0f; rep.repeatTimes--; } } }
/// <summary> /// 用指定的信息呈现列表中的项 /// </summary> /// <param name="itemType"><see cref="ListItemType"/> 枚举值之一</param> /// <param name="repeatIndex">指定列表控件中项的位置的序号索引。</param> /// <param name="repeatInfo">表示用于呈现列表中的项的信息。</param> /// <param name="writer">表示要在客户端呈现 HTML 内容的输出流。</param> protected virtual void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { ListItem item = this.Items[repeatIndex]; Literal checktext = new Literal(); checktext.Text = item.Selected ? this.CheckedText : this.UnCheckedText; HtmlGenericControl controlToRepeat = new HtmlGenericControl("span"); controlToRepeat.Attributes.Clear(); if (item.Attributes.Count > 0) { foreach (string str in item.Attributes.Keys) { controlToRepeat.Attributes[str] = item.Attributes[str]; } } controlToRepeat.ID = repeatIndex.ToString(NumberFormatInfo.InvariantInfo); controlToRepeat.InnerText = item.Text; if (repeatIndex != 0) { Literal splittext = new Literal(); splittext.Text = this.SplitString; splittext.RenderControl(writer); } switch (this.TextAlign) { default: { checktext.RenderControl(writer); controlToRepeat.RenderControl(writer); } break; case TextAlign.Left: { controlToRepeat.RenderControl(writer); checktext.RenderControl(writer); } break; } }
void IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { writer.WriteBeginTag("input"); writer.WriteAttribute("type", "checkbox"); writer.WriteAttribute("name", UniqueID); writer.WriteAttribute("id", ClientID + "_" + repeatIndex.ToString(NumberFormatInfo.InvariantInfo)); writer.WriteAttribute("value", Items[repeatIndex].Value); System.Web.UI.AttributeCollection attrs = Items[repeatIndex].Attributes; foreach (string key in attrs.Keys) { writer.WriteAttribute(key, attrs[key]); } writer.Write(">"); writer.WriteBeginTag("label"); writer.Write(">"); writer.Write(Items[repeatIndex].Text); writer.WriteEndTag("label"); }
// On recupere le style de this pour l'appliquer au Text protected override void RenderItem ( ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer ) { CheckBox checkBox = new CheckBox(); checkBox.Page = this.Page; // Avec le // radioButton.GroupName = this.UniqueID; mais checkBox ne possede pas cette propriete // c'est le debut de la galere 3 heures de recherche de bug pour finalement ecrire // writer.AddAttribute l'objet a 2 attributs name mais ca marche ! // checkBox.ID = this.ClientID + "_" + repeatIndex.ToString(); string text = string.Format ( "<font color=\"{0}\" style=\"font-family:{1};font-size:{2};font-weight:{3}\">{4}</font>", Colors.ToHtml(this.ForeColor), this.Font.Name, this.Font.Size, this.Font.Bold == true ? "bold" : "normal", this.Items[repeatIndex].Text ); checkBox.Text = text; checkBox.Attributes["value"] = this.Items[repeatIndex].Value; checkBox.Checked = this.Items[repeatIndex].Selected; checkBox.TextAlign = this.TextAlign; checkBox.AutoPostBack = this.AutoPostBack; checkBox.TabIndex = this.TabIndex; checkBox.Enabled = this.Enabled; // modifie le input writer.AddAttribute("name", this.UniqueID + "$" + repeatIndex.ToString()); writer.AddAttribute("value", this.Items[repeatIndex].Value); checkBox.RenderControl(writer); }
protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { if (Items[repeatIndex].Value.Equals("%subheader%")) { writer.Write("<h3 class=\'shipsrvc\'>{0}</h3>", Items[repeatIndex].Text); } else { if (Items[repeatIndex].Value.Equals("%msg%")) { writer.Write("<h4 class=\'shipsrvcmsg\'>{0}</h4>", Items[repeatIndex].Text); } else { base.RenderItem(itemType, repeatIndex, repeatInfo, writer); } } }
public int StartRepeat(float startTime, float timeInterval, int repeatTimes, Action onRepeat, Action onStop) { RepeatInfo repeat = new RepeatInfo() { repeatId = repeatId, startTime = startTime, timeInterval = timeInterval, repeatTimes = repeatTimes, onRepeat = onRepeat, onStop = onStop, curTime = 0, hasStart = false, hasStop = false, }; repeatId++; repeats.Add(repeat); return(repeatId); }
protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { if (RepeatDirection == RepeatDirection.Horizontal) { if (repeatIndex == 0) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } else if (RepeatColumns > 0 && repeatIndex % RepeatColumns == 0) { writer.RenderEndTag(); // close tr writer.RenderBeginTag(HtmlTextWriterTag.Tr); } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Style, "margin-right:20px;"); // fix render for table } writer.AddAttribute(HtmlTextWriterAttribute.Class, RepeatDirection == System.Web.UI.WebControls.RepeatDirection.Horizontal ? "checkbox-inline" : "checkbox"); writer.RenderBeginTag(HtmlTextWriterTag.Div); // required if (IsRequired && EnableClientValidation) { writer.AddAttribute(HtmlTextWriterAttribute.Class, this.ClientID); if (repeatIndex == 0) { writer.AddAttribute("data-rule-require_from_group", string.Format("[{0}, \".{1}\"]", this.MinNumberFieldsRequired, this.ClientID)); } } base.RenderItem(itemType, repeatIndex, repeatInfo, writer); writer.RenderEndTag(); // close div if (RepeatDirection == RepeatDirection.Horizontal) { writer.RenderEndTag(); // close td if (repeatIndex == this.Items.Count - 1) { writer.RenderEndTag(); // close tr } } }
public static string DoTest(int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep) { HtmlTextWriter htw = GetWriter(); RepeatInfo ri = new RepeatInfo(); ri.RepeatColumns = cols; ri.RepeatDirection = d; ri.RepeatLayout = l; ri.OuterTableImplied = OuterTableImplied; // get some variation in if we use style or not Style s = new Style(); if (cols != 3) { s.CssClass = "mainstyle"; } ri.RenderRepeater(htw, new RepeatInfoUser(hdr, ftr, sep, cnt), s, new DataList()); return(htw.InnerWriter.ToString()); }
protected override void Render(HtmlTextWriter writer) { // Create and setup a RepeatInfo class. RepeatInfo repeatInfo = new RepeatInfo(); repeatInfo.RepeatColumns = 0; repeatInfo.RepeatDirection = RepeatDirection.Horizontal; repeatInfo.RepeatLayout = RepeatLayout.Table; // Get a self-referencing IRepeatInfoUser object IRepeatInfoUser repeatInfoUser = (IRepeatInfoUser)this; // Render the items using the above RepeatInfo class. repeatInfoUser.RenderItem(ListItemType.Item, 0, repeatInfo, writer); repeatInfoUser.RenderItem(ListItemType.Item, 1, repeatInfo, writer); repeatInfoUser.RenderItem(ListItemType.Item, 2, repeatInfo, writer); repeatInfoUser.RenderItem(ListItemType.Item, 3, repeatInfo, writer); repeatInfoUser.RenderItem(ListItemType.Item, 4, repeatInfo, writer); repeatInfoUser.RenderItem(ListItemType.Item, 5, repeatInfo, writer); }
public void RepeatInfoRenderItem() { #if NET_4_0 string origHtml = "<input id=\"0\" type=\"checkbox\" name=\"0\" value=\"one\" /><label for=\"0\">one</label>"; #else string origHtml = "<input id=\"0\" type=\"checkbox\" name=\"0\" /><label for=\"0\">one</label>"; #endif StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); CheckBoxList c = new CheckBoxList(); IRepeatInfoUser ri = (IRepeatInfoUser)c; RepeatInfo r = new RepeatInfo(); c.Items.Add("one"); c.Items.Add("two"); ri.RenderItem(ListItemType.Item, 0, r, tw); string html = sw.ToString(); Assert.AreEqual(origHtml, html, "A1"); }
private async Task EditEventInDatabase(IUnitOfWork database, Event editThisEvent, EventVM eventVM) { EventInfo eventInfoEdit = editThisEvent.EventInfo; RepeatInfo repeatInfoEdit = eventInfoEdit.RepeatInfo; editThisEvent.Title = eventVM.Title; eventInfoEdit = Context.Mapper.MapTo <EventInfo, EventInfoVM>(eventVM.EventInfo); if (eventVM.EventInfo.IsRepeated == false) { eventInfoEdit.RepeatInfo = null; editThisEvent.EventInfo = eventInfoEdit; } else { repeatInfoEdit = Context.Mapper.MapTo <RepeatInfo, RepeatInfoVM>(eventVM.EventInfo.RepeatInfo); eventInfoEdit.RepeatInfo = repeatInfoEdit; editThisEvent.EventInfo = eventInfoEdit; } database.Events.Update(editThisEvent); await database.SaveAsync(); }
public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { writer.Write ("({0},{1},{2})", counter++, itemType, repeatIndex); }