/// <summary> /// Initialize new instance of <see cref="ToolEllipseSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolEllipseSelection(IServiceProvider serviceProvider, ILayerContainer layer, IEllipseShape shape, IShapeStyle style) { _serviceProvider = serviceProvider; _layer = layer; _ellipse = shape; _style = style; }
protected internal void InitStyle() { if (StyleFactory.Instance == null || MyControl == null) { return; } string styleName = StyleName(); if (!string.IsNullOrEmpty(styleName)) { IShapeStyle newStyle = StyleFactory.Instance.GetStyle(styleName); if (newStyle != null) { MyControl.Style = newStyle; } } string selectedStyleName = SelectedStyleName(); if (!string.IsNullOrEmpty(selectedStyleName)) { IShapeStyle newSelectedStyle = StyleFactory.Instance.GetStyle(selectedStyleName); if (newSelectedStyle != null) { MyControl.SelectedStyle = newSelectedStyle; } } }
public PointDrawNode(IPointShape point, IShapeStyle pointStyle, double pointSize) { Style = pointStyle; Point = point; PointSize = pointSize; UpdateGeometry(); }
/// <summary> /// Initialize new instance of <see cref="ToolTextSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolTextSelection(IServiceProvider serviceProvider, ILayerContainer layer, ITextShape shape, IShapeStyle style) { _serviceProvider = serviceProvider; _layer = layer; _text = shape; _style = style; }
/// <summary> /// Initialize new instance of <see cref="ToolRectangleSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolRectangleSelection(IServiceProvider serviceProvider, ILayerContainer layer, IRectangleShape shape, IShapeStyle style) { _serviceProvider = serviceProvider; _layer = layer; _rectangle = shape; _style = style; }
/// <summary> /// Initialize new instance of <see cref="ToolImageSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolImageSelection(IServiceProvider serviceProvider, ILayerContainer layer, IImageShape shape, IShapeStyle style) { _serviceProvider = serviceProvider; _layer = layer; _image = shape; _style = style; }
/// <summary> /// Initialize new instance of <see cref="ToolCubicBezierSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolCubicBezierSelection(IServiceProvider serviceProvider, ILayerContainer layer, ICubicBezierShape shape, IShapeStyle style) { _serviceProvider = serviceProvider; _layer = layer; _cubicBezier = shape; _style = style; }
/// <summary> /// Initialize new instance of <see cref="ToolPathSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolPathSelection(ILayerContainer layer, IPathShape shape, IShapeStyle style, IBaseShape point) { _layer = layer; _path = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="ToolArcSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolArcSelection(IServiceProvider serviceProvider, ILayerContainer layer, IArcShape shape, IShapeStyle style) { _serviceProvider = serviceProvider; _layer = layer; _arc = shape; _style = style; }
public RectangleDrawNode(IRectangleShape rectangle, IShapeStyle style) : base() { Style = style; Rectangle = rectangle; Text = rectangle; UpdateGeometry(); }
/// <summary> /// Initialize new instance of <see cref="ToolLineSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolLineSelection(IServiceProvider serviceProvider, ILayerContainer layer, ILineShape shape, IShapeStyle style, IBaseShape point) { _serviceProvider = serviceProvider; _layer = layer; _line = shape; _style = style; _point = point; }
public void Add(IShapeStyle NewStyle) { if (NewStyle == null) { return; } StyleList.Add(NewStyle.Name, NewStyle); }
/// <summary> /// Initialize new instance of <see cref="ToolQuadraticBezierSelection"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolQuadraticBezierSelection(IServiceProvider serviceProvider, ILayerContainer layer, IQuadraticBezierShape shape, IShapeStyle style, IBaseShape point) { _serviceProvider = serviceProvider; _layer = layer; _quadraticBezier = shape; _style = style; _point = point; }
public EllipseDrawNode(IEllipseShape ellipse, IShapeStyle style) : base() { Style = style; Ellipse = ellipse; Text = ellipse; UpdateGeometry(); }
public void AddAlias(string name, string existingStyleName) { IShapeStyle existing = GetStyle(existingStyleName); if (existing != null) { Add(name, existing); } }
public ImageDrawNode(IImageShape image, IShapeStyle style, IImageCache imageCache, ICache <string, IDisposable> bitmapCache) : base() { Style = style; Image = image; Text = image; ImageCache = imageCache; BitmapCache = bitmapCache; UpdateGeometry(); }
internal void GetStylesFromFactory() { Style = StyleFactory.Instance.GetStyle(StyleName); SelectedStyle = StyleFactory.Instance.GetStyle(SelectedStyleName); if (Style == null || SelectedStyle == null) { InitStyleBase(); StyleFactory.Instance.Add(StyleName, Style); StyleFactory.Instance.Add(SelectedStyleName, SelectedStyle); } }
public void Add(string name, IShapeStyle existingStyle) { if (existingStyle == null) { return; } if (string.IsNullOrEmpty(existingStyle.Name)) { existingStyle.Name = name; } StyleList.Add(name, existingStyle); }
/// <param name="shapeType">Typically Layout.StyleName</param> /// <returns>ShapeStyle with the specified name, if it exists, null otherwise. /// </returns> public IShapeStyle GetStyle(string shapeType) { // It's OK when there are no styles, GetStyle will just return null. /*if (!IsInit) * { * Init(); * } */ IShapeStyle result = null; StyleList.TryGetValue(shapeType, out result); return(result); }
/// <summary> /// Clones shape style. /// </summary> /// <param name="shapeStyle">The shape style to clone.</param> /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns> public static IShapeStyle Clone(this IShapeStyle shapeStyle) { return(new ShapeStyle() { Name = shapeStyle.Name, Stroke = shapeStyle.Stroke.Clone(), Fill = shapeStyle.Fill.Clone(), Thickness = shapeStyle.Thickness, LineCap = shapeStyle.LineCap, Dashes = shapeStyle.Dashes, DashOffset = 0.0, LineStyle = shapeStyle.LineStyle.Clone(), TextStyle = shapeStyle.TextStyle.Clone(), StartArrowStyle = shapeStyle.StartArrowStyle.Clone(), EndArrowStyle = shapeStyle.EndArrowStyle.Clone() }); }
public CubicBezierDrawNode(ICubicBezierShape cubicBezier, IShapeStyle style) { Style = style; CubicBezier = cubicBezier; UpdateGeometry(); }
public QuadraticBezierDrawNode(IQuadraticBezierShape quadraticBezier, IShapeStyle style) { Style = style; QuadraticBezier = quadraticBezier; UpdateGeometry(); }
public void Add(IShapeStyle NewStyle) { if (NewStyle == null) return; StyleList.Add(NewStyle.Name, NewStyle); }
/// <summary> /// Initialize new instance of <see cref="ToolPathSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolPathSelection(ILayerContainer layer, IPathShape shape, IShapeStyle style) { _layer = layer; _path = shape; _style = style; }
public PathDrawNode(IPathShape path, IShapeStyle style) { Style = style; Path = path; UpdateGeometry(); }
private void Remove(IShapeStyle style) { if (style == null) { return; } style.PropertyChanged -= ObserveStyle; if (style.Stroke != null) { style.Stroke.PropertyChanged -= ObserveStyle; } if (style.Fill != null) { style.Fill.PropertyChanged -= ObserveStyle; } if (style.LineStyle != null) { style.LineStyle.PropertyChanged -= ObserveStyle; if (style.LineStyle.FixedLength != null) { style.LineStyle.FixedLength.PropertyChanged -= ObserveStyle; } } if (style.StartArrowStyle != null) { style.StartArrowStyle.PropertyChanged -= ObserveStyle; if (style.StartArrowStyle.Stroke != null) { style.StartArrowStyle.Stroke.PropertyChanged -= ObserveStyle; } if (style.StartArrowStyle.Fill != null) { style.StartArrowStyle.Fill.PropertyChanged -= ObserveStyle; } } if (style.EndArrowStyle != null) { style.EndArrowStyle.PropertyChanged -= ObserveStyle; if (style.EndArrowStyle.Stroke != null) { style.EndArrowStyle.Stroke.PropertyChanged -= ObserveStyle; } if (style.EndArrowStyle.Fill != null) { style.EndArrowStyle.Fill.PropertyChanged -= ObserveStyle; } } if (style.TextStyle != null) { style.TextStyle.PropertyChanged -= ObserveStyle; if (style.TextStyle.FontStyle != null) { style.TextStyle.FontStyle.PropertyChanged -= ObserveStyle; } } }
public void BreakPathFigure(IPathFigure pathFigure, IShapeStyle style, bool isStroked, bool isFilled, List <IBaseShape> result) { var factory = _serviceProvider.GetService <IFactory>(); var firstPoint = pathFigure.StartPoint; var lastPoint = pathFigure.StartPoint; foreach (var segment in pathFigure.Segments) { switch (segment) { case ILineSegment lineSegment: { var convertedStyle = style != null ? (IShapeStyle)style?.Copy(null) : factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName); var convertedPathShape = factory.CreateLineShape( lastPoint, lineSegment.Point, convertedStyle, isStroked); lastPoint = lineSegment.Point; result.Add(convertedPathShape); } break; case IQuadraticBezierSegment quadraticBezierSegment: { var convertedStyle = style != null ? (IShapeStyle)style?.Copy(null) : factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName); var convertedPathShape = factory.CreateQuadraticBezierShape( lastPoint, quadraticBezierSegment.Point1, quadraticBezierSegment.Point2, convertedStyle, isStroked, isFilled); lastPoint = quadraticBezierSegment.Point2; result.Add(convertedPathShape); } break; case ICubicBezierSegment cubicBezierSegment: { var convertedStyle = style != null ? (IShapeStyle)style?.Copy(null) : factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName); var convertedPathShape = factory.CreateCubicBezierShape( lastPoint, cubicBezierSegment.Point1, cubicBezierSegment.Point2, cubicBezierSegment.Point3, convertedStyle, isStroked, isFilled); lastPoint = cubicBezierSegment.Point3; result.Add(convertedPathShape); } break; case IArcSegment arcSegment: { var convertedStyle = style != null ? (IShapeStyle)style?.Copy(null) : factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName); var point2 = factory.CreatePointShape(0, 0); // TODO: var point3 = factory.CreatePointShape(0, 0); // TODO: var convertedPathShape = factory.CreateArcShape( lastPoint, point2, point3, arcSegment.Point, convertedStyle, isStroked, isFilled); lastPoint = arcSegment.Point; result.Add(convertedPathShape); } break; } } if (pathFigure.Segments.Length > 0 && pathFigure.IsClosed) { var convertedStyle = style != null ? (IShapeStyle)style?.Copy(null) : factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName); var convertedPathShape = factory.CreateLineShape( lastPoint, firstPoint, convertedStyle, isStroked); result.Add(convertedPathShape); } }
/// <summary> /// Initialize new instance of <see cref="ToolPointSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> public ToolPointSelection(ILayerContainer layer, IPointShape shape, IShapeStyle style) { _layer = layer; _shape = shape; _style = style; }
/// <summary> /// Set shape style. /// </summary> /// <param name="project">The project instance.</param> /// <param name="shape">The shape instance.</param> /// <param name="style">The style instance.</param> public static void ApplyStyle(this IProjectContainer project, IBaseShape shape, IShapeStyle style) { if (shape != null && style != null) { if (shape is IGroupShape group) { var shapes = ProjectContainer.GetAllShapes(group.Shapes); foreach (var child in shapes) { var previous = child.Style; var next = (IShapeStyle)style.Copy(null); project?.History?.Snapshot(previous, next, (p) => child.Style = p); child.Style = next; } } else { var previous = shape.Style; var next = (IShapeStyle)style.Copy(null); project?.History?.Snapshot(previous, next, (p) => shape.Style = p); shape.Style = next; } } }
/// <summary> /// Remove style. /// </summary> /// <param name="project">The project instance.</param> /// <param name="style">The style instance.</param> /// <returns>The owner style library.</returns> public static ILibrary <IShapeStyle> RemoveStyle(this IProjectContainer project, IShapeStyle style) { if (project?.StyleLibraries != null && style != null) { var library = project.StyleLibraries.FirstOrDefault(l => l.Items.Contains(style)); if (library?.Items != null) { var previous = library.Items; var next = library.Items.Remove(style); project?.History?.Snapshot(previous, next, (p) => library.Items = p); library.Items = next; } return(library); } return(null); }
/// <summary> /// Add style. /// </summary> /// <param name="project">The project instance.</param> /// <param name="library">The style library instance.</param> /// <param name="style">The style instance.</param> public static void AddStyle(this IProjectContainer project, ILibrary <IShapeStyle> library, IShapeStyle style) { AddItem(project, library, style); }
public void AddStyle(string name, IShapeStyle existingStyleToAdd) { //existingStyleToAdd.Name = name; Add(name, existingStyleToAdd); }