コード例 #1
0
 /// <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;
 }
コード例 #2
0
ファイル: Block.cs プロジェクト: orb1t/StructuredEditor
        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;
                }
            }
        }
コード例 #3
0
ファイル: PointDrawNode.cs プロジェクト: bangush/Core2D
 public PointDrawNode(IPointShape point, IShapeStyle pointStyle, double pointSize)
 {
     Style     = pointStyle;
     Point     = point;
     PointSize = pointSize;
     UpdateGeometry();
 }
コード例 #4
0
ファイル: ToolTextSelection.cs プロジェクト: bangush/Core2D
 /// <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;
 }
コード例 #5
0
 /// <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;
 }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
ファイル: ToolPathSelection.cs プロジェクト: iomeone/Core2D
 /// <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;
 }
コード例 #9
0
ファイル: ToolArcSelection.cs プロジェクト: dagrigorev/Core2D
 /// <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;
 }
コード例 #10
0
ファイル: RectangleDrawNode.cs プロジェクト: bangush/Core2D
 public RectangleDrawNode(IRectangleShape rectangle, IShapeStyle style)
     : base()
 {
     Style     = style;
     Rectangle = rectangle;
     Text      = rectangle;
     UpdateGeometry();
 }
コード例 #11
0
 /// <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;
 }
コード例 #12
0
ファイル: StyleFactory.cs プロジェクト: molihub/LiveGeometry
 public void Add(IShapeStyle NewStyle)
 {
     if (NewStyle == null)
     {
         return;
     }
     StyleList.Add(NewStyle.Name, NewStyle);
 }
コード例 #13
0
 /// <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;
 }
コード例 #14
0
ファイル: EllipseDrawNode.cs プロジェクト: bangush/Core2D
 public EllipseDrawNode(IEllipseShape ellipse, IShapeStyle style)
     : base()
 {
     Style   = style;
     Ellipse = ellipse;
     Text    = ellipse;
     UpdateGeometry();
 }
コード例 #15
0
        public void AddAlias(string name, string existingStyleName)
        {
            IShapeStyle existing = GetStyle(existingStyleName);

            if (existing != null)
            {
                Add(name, existing);
            }
        }
コード例 #16
0
ファイル: ImageDrawNode.cs プロジェクト: bangush/Core2D
 public ImageDrawNode(IImageShape image, IShapeStyle style, IImageCache imageCache, ICache <string, IDisposable> bitmapCache)
     : base()
 {
     Style       = style;
     Image       = image;
     Text        = image;
     ImageCache  = imageCache;
     BitmapCache = bitmapCache;
     UpdateGeometry();
 }
コード例 #17
0
 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);
     }
 }
コード例 #18
0
ファイル: StyleFactory.cs プロジェクト: Ju2ender/csharp-e
 public void Add(string name, IShapeStyle existingStyle)
 {
     if (existingStyle == null)
     {
         return;
     }
     if (string.IsNullOrEmpty(existingStyle.Name))
     {
         existingStyle.Name = name;
     }
     StyleList.Add(name, existingStyle);
 }
コード例 #19
0
 public void Add(string name, IShapeStyle existingStyle)
 {
     if (existingStyle == null)
     {
         return;
     }
     if (string.IsNullOrEmpty(existingStyle.Name))
     {
         existingStyle.Name = name;
     }
     StyleList.Add(name, existingStyle);
 }
コード例 #20
0
        /// <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);
        }
コード例 #21
0
ファイル: ShapeStyleExtensions.cs プロジェクト: masums/Core2D
 /// <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()
     });
 }
コード例 #22
0
ファイル: CubicBezierDrawNode.cs プロジェクト: bangush/Core2D
 public CubicBezierDrawNode(ICubicBezierShape cubicBezier, IShapeStyle style)
 {
     Style       = style;
     CubicBezier = cubicBezier;
     UpdateGeometry();
 }
コード例 #23
0
 public QuadraticBezierDrawNode(IQuadraticBezierShape quadraticBezier, IShapeStyle style)
 {
     Style           = style;
     QuadraticBezier = quadraticBezier;
     UpdateGeometry();
 }
コード例 #24
0
ファイル: StyleFactory.cs プロジェクト: wcatykid/GeoShader
 public void Add(IShapeStyle NewStyle)
 {
     if (NewStyle == null)
         return;
     StyleList.Add(NewStyle.Name, NewStyle);
 }
コード例 #25
0
 /// <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;
 }
コード例 #26
0
 public PathDrawNode(IPathShape path, IShapeStyle style)
 {
     Style = style;
     Path  = path;
     UpdateGeometry();
 }
コード例 #27
0
        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;
                }
            }
        }
コード例 #28
0
ファイル: ShapeEditor.cs プロジェクト: bangush/Core2D
        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);
            }
        }
コード例 #29
0
 /// <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;
 }
コード例 #30
0
 /// <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;
         }
     }
 }
コード例 #31
0
 /// <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);
 }
コード例 #32
0
 /// <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);
 }
コード例 #33
0
ファイル: StyleFactory.cs プロジェクト: Ju2ender/csharp-e
 public void AddStyle(string name, IShapeStyle existingStyleToAdd)
 {
     //existingStyleToAdd.Name = name;
     Add(name, existingStyleToAdd);
 }