private static CanvasStrokeStyle CreateStrokeStyle(BaseStyle style) { var ss = new CanvasStrokeStyle(); switch (style.LineCap) { case LineCap.Flat: ss.StartCap = CanvasCapStyle.Flat; ss.EndCap = CanvasCapStyle.Flat; ss.DashCap = CanvasCapStyle.Flat; break; case LineCap.Square: ss.StartCap = CanvasCapStyle.Square; ss.EndCap = CanvasCapStyle.Square; ss.DashCap = CanvasCapStyle.Square; break; case LineCap.Round: ss.StartCap = CanvasCapStyle.Round; ss.EndCap = CanvasCapStyle.Round; ss.DashCap = CanvasCapStyle.Round; break; } if (style.Dashes != null) { ss.CustomDashStyle = style.Dashes.Select(x => (float)x).ToArray(); } ss.DashOffset = (float)style.DashOffset; return(ss); }
protected override void Generate(BaseStyle style) { var flexibleImageStyle = style as FlexibleImageStyle; _borderWidth = flexibleImageStyle.BorderWidth; _borderHeight = flexibleImageStyle.BorderHeight; if (_orientation == CoreUIOrientation.Horizontal) { Height = _borderHeight; GenerateHorizontal(); } else { Height = Width; Width = _borderHeight; GenerateVertical(); } ApplyUV(); Triangles = new List<int>() { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, }; }
private static Pen CreatePen(BaseStyle style, double thickness) { var brush = CreateBrush(style.Stroke); var pen = new Pen(brush, thickness); switch (style.LineCap) { case LineCap.Flat: pen.StartLineCap = PenLineCap.Flat; pen.EndLineCap = PenLineCap.Flat; pen.DashCap = PenLineCap.Flat; break; case LineCap.Square: pen.StartLineCap = PenLineCap.Square; pen.EndLineCap = PenLineCap.Square; pen.DashCap = PenLineCap.Square; break; case LineCap.Round: pen.StartLineCap = PenLineCap.Round; pen.EndLineCap = PenLineCap.Round; pen.DashCap = PenLineCap.Round; break; } pen.DashStyle = new DashStyle( ShapeStyle.ConvertDashesToDoubleArray(style.Dashes), style.DashOffset); pen.DashStyle.Offset = style.DashOffset; pen.Freeze(); return(pen); }
internal void UpdateStyle(BaseStyle activeStyle, StylePropertyType stylePropertyType, object value) { LevelStyle levelStyle = activeStyle as LevelStyle; InlineNoteStyle inlineStyle = activeStyle as InlineNoteStyle; WalkRecursively(__FakeRootNote, delegate(OutlinerNote note, out bool shouldWalkSubnotes, out bool shouldContinue) { shouldContinue = true; shouldWalkSubnotes = true; if (activeStyle.StyleType == StyleType.Inline) { if (!note.HasInlineNote) { return; } TextRange range = new TextRange(note.InlineNoteDocument.ContentStart, note.InlineNoteDocument.ContentEnd); UndoManager.PushUndoAction(new Undo.UndoFlowDocumentFormatting(note, 0, true, false)); LevelStyle.ApplyPropertyToRange(range, stylePropertyType, value); LevelStyle.ApplyPropertyToFlowDocument(note.InlineNoteDocument, stylePropertyType, value); } else // if (activeStyle.StyleType == StyleType.Level) { if (note.Level == levelStyle.Level || levelStyle.Level == -1) { ApplyStylePropertyForAllColumns(stylePropertyType, value, levelStyle, note); } } }); }
public static void TextDecorationConverter(ref BaseStyle style, Declaration declaration) { style.IsLineThrough = false; style.IsOverline = false; style.IsUnderline = false; var flags = declaration.Expression.Terms.Select(flag => flag.Value).ToArray(); if (!flags.Any()) { throw new FormatException("Style 'text-decoration' has incorrect value. [text-decoration: [line-through | overline | underline] | none]"); } if (flags.Contains("none")) { return; } if (flags.Contains("line-through")) { style.IsLineThrough = true; } if (flags.Contains("overline")) { style.IsOverline = true; } if (flags.Contains("underline")) { style.IsUnderline = true; } }
public static void FontWeightConverter(ref BaseStyle style, Declaration declaration) { string flag; try { flag = declaration.Expression.Terms.First().Value; } catch (InvalidOperationException exception) { throw new FormatException("Style 'font-weight' has incorrect value. [font-weight: normal | bold]", exception); } catch (ArgumentNullException exception) { throw new FormatException("Style 'font-weight' has incorrect value. [font-weight: normal | bold]", exception); } catch (NullReferenceException exception) { throw new FormatException("Style 'font-weight' has incorrect value. [font-weight: normal | bold]", exception); } switch (flag) { case "normal": style.IsBold = false; break; case "bold": style.IsBold = true; break; default: throw new FormatException("Style 'font-weight' has incorrect value. [font-weight: normal | bold]"); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { BaseStyle baseStyle = new BaseStyle(); baseStyle.VerticalAlignment = VerticalAlignment.Center; //构建对话框 tbBPM = baseStyle.GetTexeBox(Value); baseStyle.AddTitleAndControl("ValueColon", tbBPM, Orientation.Vertical) .AddDockPanel(out DockPanel dp, GeneralMainViewBusiness.CreateInstance().GetButton("Ok", btnOk_Click), GeneralMainViewBusiness.CreateInstance().GetButton("Cancel", btnCancel_Click)) .CreateDialogNormal(); //DockPanel dp = baseStyle.GetDockPanel(baseStyle.GetButton("Ok", btnOk_Click), baseStyle.GetButton("Cancel", btnCancel_Click)); dp.HorizontalAlignment = HorizontalAlignment.Center; //baseStyle.AddUIElement(dp); //baseStyle.CreateDialogNormal(); spMain.Children.Add(baseStyle); baseStyle.Margin = new Thickness(30); tbBPM.SelectionStart = tbBPM.Text.Length; //tbBPM.Focus(); Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() => tbBPM.Focus())); }
private AM.Pen ToPen(BaseStyle style, Func <double, float> scale) { var lineCap = default(AM.PenLineCap); var dashStyle = default(AM.DashStyle); switch (style.LineCap) { case LineCap.Flat: lineCap = AM.PenLineCap.Flat; break; case LineCap.Square: lineCap = AM.PenLineCap.Square; break; case LineCap.Round: lineCap = AM.PenLineCap.Round; break; } if (style.Dashes != null) { dashStyle = new AM.DashStyle( ShapeStyle.ConvertDashesToDoubleArray(style.Dashes), style.DashOffset); } var pen = new AM.Pen( ToBrush(style.Stroke), scale(style.Thickness / State.ZoomX), dashStyle, lineCap, lineCap, lineCap); return(pen); }
public void AddStyle(BaseStyle style) { var styles = _styles.ToList(); styles.Add(style); _styles = styles.ToArray(); }
private static void SaveStyle(XmlWriter wr, BaseStyle outlinerStyle) { wr.WriteStartElement("Style"); wr.WriteAttributeString("Type", outlinerStyle.StyleType.ToString()); switch (outlinerStyle.StyleType) { case StyleType.Level: wr.WriteAttributeString("Level", ((LevelStyle)outlinerStyle).Level.ToString()); break; case StyleType.WholeDocument: wr.WriteAttributeString("Level", ((LevelStyle)outlinerStyle).Level.ToString()); break; } for (int i = 0; i < outlinerStyle.Properties.Count; i++) { wr.WriteAttributeString( OutlinerStyles.StylePropertyTypesToString[outlinerStyle.Properties[i].PropertyType], outlinerStyle.Properties[i].Value.ToString()); } wr.WriteEndElement(); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="scale"></param> /// <returns></returns> private Pen ToPen(BaseStyle style, Func <double, float> scale) { var pen = new Pen( ToColor(style.Stroke), scale(style.Thickness / _state.Zoom)); switch (style.LineCap) { case Core2D.LineCap.Flat: pen.LineCap = PenLineCap.Butt; break; case Core2D.LineCap.Square: pen.LineCap = PenLineCap.Square; break; case Core2D.LineCap.Round: pen.LineCap = PenLineCap.Round; break; } if (style.Dashes != null) { pen.DashStyle = new DashStyle( (float)style.DashOffset, style.Dashes.Select(x => (float)x).ToArray()); } return(pen); }
protected override void DrawContentEditor() { _size.x = Width; _size.y = Height; Style = EditorGUILayout.ObjectField("Style", Style, typeof(BaseStyle), false) as BaseStyle; _yesPossible = Style != null; }
private SKPaint ToSKPaintPen(BaseStyle style, Func <double, float> scale, double sourceDpi, double targetDpi) { var paint = new SKPaint(); paint.IsAntialias = _isAntialias; paint.IsStroke = true; paint.StrokeWidth = scale(style.Thickness * targetDpi / sourceDpi); paint.Color = ToSKColor(style.Stroke); switch (style.LineCap) { case LineCap.Flat: paint.StrokeCap = SKStrokeCap.Butt; break; case LineCap.Square: paint.StrokeCap = SKStrokeCap.Square; break; case LineCap.Round: paint.StrokeCap = SKStrokeCap.Round; break; } if (style.Dashes != null) { paint.PathEffect = SKPathEffect.CreateDash( BaseStyle.ConvertDashesToFloatArray(style.Dashes), (float)style.DashOffset); } return(paint); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="scale"></param> /// <returns></returns> private Pen ToPen(BaseStyle style, Func <double, float> scale) { var pen = new Pen(ToColor(style.Stroke), (float)(style.Thickness / State.ZoomX)); switch (style.LineCap) { case Core2D.Style.LineCap.Flat: pen.StartCap = System.Drawing.Drawing2D.LineCap.Flat; pen.EndCap = System.Drawing.Drawing2D.LineCap.Flat; pen.DashCap = System.Drawing.Drawing2D.DashCap.Flat; break; case Core2D.Style.LineCap.Square: pen.StartCap = System.Drawing.Drawing2D.LineCap.Square; pen.EndCap = System.Drawing.Drawing2D.LineCap.Square; pen.DashCap = System.Drawing.Drawing2D.DashCap.Flat; break; case Core2D.Style.LineCap.Round: pen.StartCap = System.Drawing.Drawing2D.LineCap.Round; pen.EndCap = System.Drawing.Drawing2D.LineCap.Round; pen.DashCap = System.Drawing.Drawing2D.DashCap.Round; break; } if (style.Dashes != null) { // TODO: Convert to correct dash values. pen.DashPattern = ShapeStyle.ConvertDashesToFloatArray(style.Dashes); } pen.DashOffset = (float)style.DashOffset; return(pen); }
private static XPen ToXPen(BaseStyle style, Func <double, double> scale, double sourceDpi, double targetDpi) { var pen = new XPen(ToXColor(style.Stroke), scale(style.Thickness * targetDpi / sourceDpi)); switch (style.LineCap) { case LineCap.Flat: pen.LineCap = XLineCap.Flat; break; case LineCap.Square: pen.LineCap = XLineCap.Square; break; case LineCap.Round: pen.LineCap = XLineCap.Round; break; } if (style.Dashes != null) { // TODO: Convert to correct dash values. pen.DashPattern = ShapeStyle.ConvertDashesToDoubleArray(style.Dashes); } pen.DashOffset = style.DashOffset; return(pen); }
public void ConvertDashesToFloatArray_Should_Not_Throw() { var dashes = "0 A"; var target = BaseStyle.ConvertDashesToFloatArray(dashes); Assert.Null(target); }
private static TableRow ParseBodyRow( XElement tableBodyRowTag, BaseStyle tbodyStyle, IDictionary <string, BaseStyle> classes) { var attrClass = tableBodyRowTag.Attributes("class").FirstOrDefault(); BaseStyle rowStyle; if (attrClass != null) { var tbodyClasses = GetStylesByClasses(classes, attrClass); rowStyle = StyleFactory.MergeStyles(tbodyStyle, tbodyClasses); } else { rowStyle = tbodyStyle; } var cells = tableBodyRowTag.Elements("td").Select(td => ParseCell(td, rowStyle, classes)); var tableRow = new TableRow { Style = rowStyle, Cells = cells.ToArray() }; return(tableRow); }
private static TableBody ParseTableBody( XElement tableBodyTag, BaseStyle tablestyle, IDictionary <string, BaseStyle> classes) { var attrClass = tableBodyTag.Attributes("class").FirstOrDefault(); BaseStyle tbodyStyle; if (attrClass != null) { var tbodyClasses = GetStylesByClasses(classes, attrClass); tbodyStyle = StyleFactory.MergeStyles(tablestyle, tbodyClasses); } else { tbodyStyle = tablestyle; } var rows = tableBodyTag.Elements("tr").Select(tr => ParseBodyRow(tr, tbodyStyle, classes)); var tbody = new TableBody { Style = tbodyStyle, Rows = rows.ToArray() }; return(tbody); }
private void StrokeRectangle(DxfDocument dxf, Layer layer, BaseStyle style, double x, double y, double width, double height) { DrawLineInternal(dxf, layer, style, true, x, y, x + width, y); DrawLineInternal(dxf, layer, style, true, x + width, y, x + width, y + height); DrawLineInternal(dxf, layer, style, true, x + width, y + height, x, y + height); DrawLineInternal(dxf, layer, style, true, x, y + height, x, y); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="scale"></param> /// <returns></returns> private Pen ToPen(BaseStyle style, Func <double, float> scale) { var lineCap = default(PenLineCap); var dashStyle = default(DashStyle); switch (style.LineCap) { case LineCap.Flat: lineCap = PenLineCap.Flat; break; case LineCap.Square: lineCap = PenLineCap.Square; break; case LineCap.Round: lineCap = PenLineCap.Round; break; } if (style.Dashes != null) { dashStyle = new DashStyle( style.Dashes, style.DashOffset); } var pen = new Pen( ToSolidBrush(style.Stroke), scale(style.Thickness / _state.Zoom), dashStyle, lineCap, lineCap, lineCap); return(pen); }
public virtual void Init(BaseStyle style, Rect rect) { _terxture = style.Texture; _pixelWidth = style.PixelWidth; _position = rect; Generate(style); UpdateMeshInfo(); }
private static void InseretTractorBody(Slide slide) { var frame = new Rect(left: 50, top: 900, width: 350, height: 130); var lineStyle = new LineStyle(Color.Black, thickness: 3); var fillStyle = new BaseStyle(Color.Blue); slide.InsertShape(new Rectangle(frame, lineStyle, fillStyle), 0); }
private static void InsertSun(Slide slide) { var frame = new Rect(left: 900, top: 100, width: 100, height: 100); var lineStyle = new LineStyle(Color.Yellow, thickness: 0); var fillStyle = new BaseStyle(Color.Yellow); slide.InsertShape(new Ellipse(frame, lineStyle, fillStyle), 0); }
private static void InsertField(Slide slide) { var frame = new Rect(left: 0, top: 1000, width: 1000, height: 250); var lineStyle = new LineStyle(Color.Green, thickness: 0); var fillStyle = new BaseStyle(Color.Green); slide.InsertShape(new Rectangle(frame, lineStyle, fillStyle), 0); }
private static void InsertTractorTube(Slide slide) { var lineStyle = new LineStyle(Color.Black, thickness: 3); var fillStyle = new BaseStyle(Color.Black); var frame = new Rect(left: 55, top: 770, width: 20, height: 70); slide.InsertShape(new Rectangle(frame, lineStyle, fillStyle), 0); }
public static void FontFamilyConverter(ref BaseStyle style, Declaration declaration) { var family = declaration.Expression.Terms.First().Value; new Font(family, 10); style.Font = family; }
private static void InsertTractorCabin(Slide slide) { var fillStyle = new BaseStyle(Color.Empty); var lineStyle = new LineStyle(Color.Black, thickness: 6); var frame = new Rect(left: 268.5f, top: 770, width: 130, height: 100); slide.InsertShape(new Rectangle(frame, lineStyle, fillStyle), 0); }
public void ConvertDashesToFloatArray_Should_Return_Dashes_Float_Array() { var dashes = "2 2 0 2 0 2"; var expected = new float[] { 2.0f, 2.0f, 0.0f, 2.0f, 0.0f, 2.0f }; var target = BaseStyle.ConvertDashesToFloatArray(dashes); Assert.Equal(expected, target); }
public void ConvertDashesToDoubleArray_Should_Return_Dashes_Double_Array() { var dashes = "2 2 0 2 0 2"; var expected = new double[] { 2.0, 2.0, 0.0, 2.0, 0.0, 2.0 }; var target = BaseStyle.ConvertDashesToDoubleArray(dashes); Assert.Equal(expected, target); }
public void ConvertFloatArrayToDashes_Should_Return_Dashes_String() { var dashes = new float[] { 2.0f, 2.0f, 0.0f, 2.0f, 0.0f, 2.0f }; var expected = "2 2 0 2 0 2"; var target = BaseStyle.ConvertFloatArrayToDashes(dashes); Assert.Equal(expected, target); }
public CellStyle(BaseStyle cellStyle, string formula, string numberFormat, string title, int colspan, int rowspan) : this() { Style = cellStyle; Formula = formula; NumberFormat = numberFormat; Title = title; Colspan = colspan; Rowspan = rowspan; }
/// <summary> /// Initializes a new instance of the <see cref="ArrowStyle"/> class. /// </summary> /// <param name="source">The source style.</param> public ArrowStyle(BaseStyle source) : this() { Stroke = ArgbColor.Create (source.Stroke.A, source.Stroke.R, source.Stroke.G, source.Stroke.B); Fill = ArgbColor.Create (source.Fill.A, source.Fill.R, source.Fill.G, source.Fill.B); Thickness = source.Thickness; LineCap = source.LineCap; Dashes = source.Dashes != null ? source.Dashes : default(string); DashOffset = source.DashOffset; }
/// <summary> /// Creates a new <see cref="ArrowStyle"/> instance. /// </summary> /// <param name="name">The arrow style name.</param> /// <param name="source">The source style.</param> /// <param name="arrowType">The arrow type.</param> /// <param name="isStroked">The arrow shape stroke flag.</param> /// <param name="isFilled">The arrow shape fill flag.</param> /// <param name="radiusX">The arrow X axis radius.</param> /// <param name="radiusY">The arrow Y axis radius.</param> /// <returns>The new instance of the <see cref="ArrowStyle"/> class.</returns> public static ArrowStyle Create(string name, BaseStyle source, ArrowType arrowType = ArrowType.None, bool isStroked = true, bool isFilled = false, double radiusX = 5.0, double radiusY = 5.0) { return new ArrowStyle(source) { Name = name, ArrowType = arrowType, IsStroked = isStroked, IsFilled = isFilled, RadiusX = radiusX, RadiusY = radiusY }; }