public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { int direction = (pointer == Pointer.Type.Future) ? 1 : -1; // WARN: Does not use Calendar return span.Add(direction * amount * RepeaterSecond.SECOND_SECONDS); }
public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { var direction = pointer == Pointer.Type.Future ? 1 : -1; // WARN: Does not use Calendar return(span.Add(direction * amount * SECOND_SECONDS)); }
private static void DumpExpImpl( MidMethodApp app, Span span) { span.Write("{0}(", app.MethodDecl.Name); span.Add(from a in app.Args select a.Dump(), ", "); span.Write(")"); }
public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { int direction = (pointer == Pointer.Type.Future) ? 1 : -1; // WARN: Does not use Calendar return(span.Add(direction * amount * RepeaterSecond.SECOND_SECONDS)); }
/// <summary> /// Create a text with Capital Drop /// </summary> /// <param name="parent">parent container insert into</param> /// <param name="text">text to insert</param> private void AddAsDrop(List <IHTMLItem> parent, SimpleText text) { var span1 = new Span(HTMLElementType.XHTML11); SetClassType(span1, ElementStylesV2.CapitalDrop); int dropEnd = 0; // "pad" the white spaces so drop starts from visible character while (dropEnd < text.Text.Length && UnicodeHelpers.IsSpaceLike(text.Text[dropEnd])) { dropEnd++; } if (dropEnd >= text.Text.Length) // in case the text is too short for drop { parent.Add(new SimpleHTML5Text(HTMLElementType.XHTML11) { Text = text.Text }); return; } // calculate the initial drop part string dropPart = text.Text.Substring(0, dropEnd + 1); // non-drop part starts from the next character int nondropPosition = dropEnd + 1; // If first character is dash/hyphen like we need to add character to // capital drop so it looks better with next character if (UnicodeHelpers.IsNeedToBeJoinInDrop(dropPart[dropEnd])) { // we need to add to capital drop all spaces if any while (nondropPosition < text.Text.Length && UnicodeHelpers.IsSpaceLike(text.Text[nondropPosition])) { nondropPosition++; } // we need to advance to include one following nonspace character , unless // we already at last character of the text if (nondropPosition < text.Text.Length) { nondropPosition++; } // update drop part with the "string" we calculated dropPart += text.Text.Substring(dropEnd + 1, nondropPosition - dropEnd - 1); } span1.Add(new SimpleHTML5Text(HTMLElementType.XHTML11) { Text = dropPart }); parent.Add(span1); string substring = text.Text.Substring(nondropPosition); if (substring.Length > 0) { parent.Add(new SimpleHTML5Text(HTMLElementType.XHTML11) { Text = substring }); } }
/// <summary> /// Processes all the references and removes invalid anchors /// Invalid meaning pointing to non-existing IDs /// only "internal" anchors are removed /// </summary> public void RemoveInvalidAnchors() { var listToRemove = new List <string>(); foreach (var reference in _references) { // If reference does not points on one of valid IDs and it's not external reference if (!IsIdUsed(reference.Key) && !ReferencesUtils.IsExternalLink(reference.Key)) { listToRemove.Add(reference.Key); // remove all references to this ID foreach (var element in _references[reference.Key]) { // The Anchor element can't have empty reference so // we remove it and in case it has some meaningful content // replace with span that is meaningless non-block element // so contained text etc are kept if (element.SubElements().Count != 0) { var spanElement = new Span(element.HTMLStandard); foreach (var subElement in element.SubElements()) { spanElement.Add(subElement); } if (element.Parent != null) { int index = element.Parent.SubElements().IndexOf(element); if (index != -1) { spanElement.Parent = element.Parent; element.Parent.SubElements().Insert(index, spanElement); } } if (!string.IsNullOrEmpty((string)element.GlobalAttributes.ID.Value)) { spanElement.GlobalAttributes.ID.Value = element.GlobalAttributes.ID.Value; // Copy ID anyway - may be someone "jumps" here _ids[(string)element.GlobalAttributes.ID.Value] = spanElement; // and update the "pointer" to element } spanElement.GlobalAttributes.Class.Value = ElementStylesV3.BadExternalLink; } if (element.Parent != null) { element.Parent.Remove(element); } } } } // Remove the unused anchor (and their ID if they have one) // from the lists foreach (var toRemove in listToRemove) { _references.Remove(toRemove); } }
private static void DumpTypeImpl( MidBuiltinType builtin, Span span) { span.Write("{0}", builtin.Name); if (builtin.Args.Length != 0) { span.Write("["); span.Add(from a in builtin.Args select((MidType)a).Dump(), ", "); span.Write("]"); } }
/// <summary> /// Processes all the references and removes invalid anchors /// Invalid meaning pointing to non-existing IDs /// only "internal" anchors are removed /// </summary> private void RemoveInvalidAnchor(KeyValuePair <string, List <Anchor> > link) { // remove all references to this ID foreach (var element in _references[link.Key]) { // The Anchor element can't have empty reference so // we remove it and in case it has some meaningful content // replace with span that is meaningless non-block element // so contained text etc are kept if (element.SubElements().Count != 0) { var spanElement = new Span(element.HTMLStandard); foreach (var subElement in element.SubElements()) { spanElement.Add(subElement); } if (element.Parent != null) { int index = element.Parent.SubElements().IndexOf(element); if (index != -1) { spanElement.Parent = element.Parent; element.Parent.SubElements().Insert(index, spanElement); } } if (!string.IsNullOrEmpty((string)element.GlobalAttributes.ID.Value)) { spanElement.GlobalAttributes.ID.Value = element.GlobalAttributes.ID.Value; // Copy ID anyway - may be someone "jumps" here _ids[(string)element.GlobalAttributes.ID.Value] = spanElement; // and update the "pointer" to element } spanElement.GlobalAttributes.Class.Value = ElementStylesV2.BadExternalLink; } if (element.Parent != null) { element.Parent.Remove(element); } } }
protected override Span NextSpan(Pointer.Type pointer) { var range = GetRange(Value); DateTime rangeStart; if (_currentSpan == null) { var now = Now.Value; var nowSeconds = (long)Math.Truncate(now.TimeOfDay.TotalSeconds); if (nowSeconds < range.StartSecond) { if (pointer == Pointer.Type.Future) { rangeStart = now.Date.AddSeconds(range.StartSecond); } else if (pointer == Pointer.Type.Past) { rangeStart = now.Date.AddDays(-1).AddSeconds(range.StartSecond); } else { throw new ArgumentException("Unable to handle pointer type " + pointer, "pointer"); } } else if (nowSeconds > range.EndSecond) { if (pointer == Pointer.Type.Future) { rangeStart = now.Date.AddDays(1).AddSeconds(range.StartSecond); } else if (pointer == Pointer.Type.Past) { rangeStart = now.Date.AddSeconds(range.StartSecond); } else { throw new ArgumentException("Unable to handle pointer type " + pointer, "pointer"); } } else { if (pointer == Pointer.Type.Future) { rangeStart = now.Date.AddDays(1).AddSeconds(range.StartSecond); } else if (pointer == Pointer.Type.Past) { rangeStart = now.Date.AddSeconds(range.StartSecond); } else { throw new ArgumentException("Unable to handle pointer type " + pointer, "pointer"); } } _currentSpan = new Span(rangeStart, rangeStart.AddSeconds(range.Width)); } else { if (pointer == Pointer.Type.Future) { _currentSpan = _currentSpan.Add(FULL_DAY_SECONDS); } else if (pointer == Pointer.Type.Past) { _currentSpan = _currentSpan.Add(-FULL_DAY_SECONDS); } else { throw new ArgumentException("Unable to handle pointer type " + pointer, "pointer"); } } return(_currentSpan); }
public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { var direction = (pointer == Pointer.Type.Future) ? 1 : -1; return(span.Add(direction * amount * RepeaterWeek.WEEK_SECONDS)); }
public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { var direction = pointer == Pointer.Type.Future ? 1 : -1; return(span.Add(direction * amount * HOUR_SECONDS)); }
public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { int direction = (pointer == Pointer.Type.Future) ? 1 : -1; return(span.Add(direction * amount * RepeaterMinute.MINUTE_SECONDS)); }
private static Style GetStyle(Record data) { var style = new Style(); var path = data["path"]; if (path != null) { style.Add(Common.BorderRadiusValue.Parse(path)); } var layer = data["layer"] ?? data; if (layer != null) { if (layer["Vsbl"] != null && (bool)layer["Vsbl"]) { style.Name = layer["Nm "]; style.Add(Common.BackgroundColorValue.Parse(layer)); int globalAngle = layer["gblA"]; if ((bool)layer["lfxv"]) { var Lefx = layer["Lefx"]; var overlay = Common.Overlay.Parse(Lefx); style.Add(Common.Shadows.Parse(globalAngle, overlay, Lefx)); style.Add(Common.BorderValue.Parse(Lefx)); style.Add(Common.GradientValue.Parse(overlay, Lefx)); } if (style.Contains <Border>() && style.Get <Border>().ToString().Contains("rgba") && (style.Contains <BackgroundImage>() || style.Contains <BackgroundColor>())) { style.Add(new BackgroundClip(BackgroundClip.Value.PaddingBox)); } if (!style.Contains <Width>()) { style.Add(Common.Size.Parse(layer)); } var text = Text.Parse(layer); if (text != null) { var textStyle = Text.Style.GetCommonStyle(text.Blocks.ConvertAll(x => x.Style)); textStyle = textStyle.Normalize(true); style.Add(textStyle.ToArray()); textStyle = textStyle.Normalize(false); for (int i = 0; i < text.Blocks.Length; i++) { var span = new Span(); var from = Math.Min(text.Blocks[i].From, text.Value.Length); var to = Math.Min(text.Blocks[i].To, text.Value.Length); span.Text = text.Value.Substring(from, to - from); span.Add((text.Blocks[i].Style - textStyle).ToArray()); style.Text.Add(span); } var boxShadow = style.Get <BoxShadow>(); if (boxShadow != null) { style.Remove(boxShadow); style.Add(new TextShadow(boxShadow.value.ConvertAll(x => { x.SkipSize = true; return(x); }))); } var width = style.Get <Width>(); if (width != null) { style.Remove(width); } var height = style.Get <Height>(); if (height != null) { style.Remove(height); } } } } return(style.Count > 0 ? style : null); }
public override Span GetOffset(Span span, int amount, Pointer.Type pointer) { var direction = (int)pointer; return(span.Add(direction * amount * DAY_SECONDS)); }
private EmitValHLSL EmitExpImpl(MidMethodApp app, Span span) { // Make sure we've emitted the method. var method = GetMethod(app.MethodDecl); Span builder = new Span(); builder.Write("{0}(", method); var resultType = EmitType(app.MethodDecl.ResultType); var resultVar = resultType.CreateVal( _shared.GenerateName(app.MethodDecl.Name.ToString())); DeclareLocal(resultVar, span); bool first = true; AddArgs( resultVar, ref first, builder); foreach (var a in app.Args) { var argVal = EmitVal(a, span); AddArgs( argVal, ref first, builder); } builder.WriteLine(");"); span.Add(builder); return resultVar; }
private EmitValHLSL EmitExpImpl(MidElementCtorApp val, Span span) { var ctorInfo = GetElementCtor(val.Element); var elemType = EmitType(val.Element); var elemVal = elemType.CreateVal(_shared.GenerateName("e_")); DeclareLocal(elemVal, span); var sb = new Span(); sb.Write("{0}(", ctorInfo.Name); bool first = true; AddArgs(elemVal, ref first, sb); foreach (var param in ctorInfo.InputAttributes) { var arg = (from a in val.Args where a.Attribute == param select a.Val).First(); AddArgs( EmitVal(arg, span), ref first, sb); } sb.WriteLine(");"); span.Add(sb); return elemVal; }
public void AppendComment(Span span) { _span.Add(span.Prefix("// ")); _span.WriteLine(); }