Ejemplo n.º 1
0
        /// <inheritdoc />
        public void DrawLine(Point point1, Point point2, IPaint paint)
        {
            var dashPattern = new DoubleCollection();

            if (paint.DashPattern != null && paint.DashPattern.Length == 4)
            {
                dashPattern = new DoubleCollection()
                {
                    paint.DashPattern[0],
                    paint.DashPattern[1],
                    paint.DashPattern[2],
                    paint.DashPattern[3],
                };
            }

            Canvas.Children.Add(new Line
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                X1              = point1.X,
                X2              = point2.X,
                Y1              = point1.Y,
                Y2              = point2.Y,
                Fill            = new SolidColorBrush(paint.Fill.ToSystemColor()),
                Stroke          = new SolidColorBrush(paint.Stroke.ToSystemColor()),
                StrokeThickness = paint.StrokeThickness,
                StrokeDashArray = dashPattern,
                Opacity         = paint.Opacity
            });
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var notification = new VideoNotification();

            notification.RegisterNotificationChannel(new MailNotificationChannel());
            notification.RegisterNotificationChannel(new SmsNotificationChannel());
            //notification.Notification();

            //object a = new object();
            //var testIsOperator = new SmsNotificationChannel();
            //if (testIsOperator is INotificationChannel)
            //    Console.WriteLine("object implements INoticationChannel");

            //var castAsObject = (INotificationChannel)testIsOperator;

            ExampleClass conflict = new ExampleClass();
            IPaint       paint    = conflict;
            ISurface     surface  = conflict;

            conflict.Paint();
            paint.Paint();
            surface.Paint();

            Console.WriteLine(conflict.Mystery());
            //conflict.Mystery();

            Console.ReadKey();
        }
Ejemplo n.º 3
0
 public static void DrawCurrenFigure(IPaint screen)
 {
     if (currentFigure != null)
     {
         currentFigure.Draw(screen);
     }
 }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public void DrawEllipse(Point location, float radius, IPaint paint)
        {
            using (var skPaint = new SKPaint
            {
                Color = paint.Fill.ToSkColor(paint.Opacity),
                IsAntialias = paint.IsAntialiased
            })
            {
                Surface.Canvas.DrawCircle(location.X, location.Y, radius, skPaint);
            }

            if (!(paint.StrokeThickness > 0))
            {
                return;
            }

            using (var skPaint = new SKPaint
            {
                Color = paint.Stroke.ToSkColor(paint.Opacity),
                IsAntialias = paint.IsAntialiased,
                StrokeWidth = paint.StrokeThickness,
                IsStroke = true,
            })
            {
                Surface.Canvas.DrawCircle(location.X, location.Y, radius, skPaint);
            }
        }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public void DrawRectangle(Point location, Size size, IPaint paint, float cornerRadius = 0)
        {
            using (var skPaint = new SKPaint
            {
                Color = paint.Fill.ToSkColor(paint.Opacity),
                IsAntialias = paint.IsAntialiased
            })
            {
                Surface.Canvas.DrawRoundRect(location.X, location.Y, size.Width, size.Height,
                                             cornerRadius, cornerRadius, skPaint);
            }

            if (!(paint.StrokeThickness > 0))
            {
                return;
            }

            using (var skPaint = new SKPaint
            {
                Color = paint.Stroke.ToSkColor(paint.Opacity),
                IsAntialias = paint.IsAntialiased,
                StrokeWidth = paint.StrokeThickness,
                IsStroke = true
            })
            {
                Surface.Canvas.DrawRoundRect(location.X, location.Y, size.Width, size.Height,
                                             cornerRadius, cornerRadius, skPaint);
            }
        }
Ejemplo n.º 6
0
        private void NeuerMaler_Click(object sender, RoutedEventArgs e)
        {
            IPaint paint = null;
            IWalk  walk  = null;

            // Momentan noch statische Werte
            // Evtl. die Maleigenschaften, die hier gebraucht werden als Variablen von dieser WindowKlasse setzen
            if (Malarten.SelectedIndex == 0)
            {
                paint = new PaintImage(new Image());
            }
            else if (Malarten.SelectedIndex == 1)
            {
                paint = new PaintSpray(Colors.Black, new Size(2, 2));
            }
            if (BewArten.SelectedIndex == 0)
            {
                walk = new WalkDirectional(7, 3);
            }
            else if (BewArten.SelectedIndex == 1)
            {
                walk = new WalkRectangular(10, 7, 20, 8, 2, DirType.Up);
            }

            Painter newPainter = new Painter(paint, walk);

            newPainter.setStartPos(new Point(0, 0));
            if ((paint != null) && (walk != null))
            {
                DrawingCanvas.AddPainter(newPainter);
            }

            //Maler
        }
Ejemplo n.º 7
0
 public GameLauncher(IMenu menuItm, IPaint ui, PhysicsEngine PhysicsEng)
 {
     menu = menuItm;
     UI = ui;
     ui.AddDrawableItem(menu);
     Physics = PhysicsEng;
     Initialise();
 }
Ejemplo n.º 8
0
 public void Do(params object[] args)
 {
     Entity          = args[0] as IPaint;
     Source          = (Point)args[1];
     Dest            = (Point)args[2];
     Entity.Location = Entity.Location.Add(Dest.Minus(Source));
     Connector.CanvasFlush();
 }
Ejemplo n.º 9
0
 public void Draw(IPaint paint, Point point, decimal scale)
 {
     point = point.Minus(paint.Location).Divide(scale);
     if (paint.Tag != null)
     {
         Program.Controller.Do("eraser", paint.Tag, point, Program.Drawer.Color, Radius);
     }
 }
Ejemplo n.º 10
0
        public void Draw(IPaint paint, Point point, decimal scale)
        {
            point = point.Minus(paint.Location).Divide(scale);
            var image = paint.Image;

            if (paint.Tag != null)
            {
                Program.Connector.Do("pencil", paint.Tag, point, Program.Drawer.Color);
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapShapeContext{TDrawingContext}"/> class.
 /// </summary>
 /// <param name="chart">The chart.</param>
 /// <param name="heatPaint">The heat paint.</param>
 /// <param name="heatStops">The heat stops.</param>
 /// <param name="boundsDictionary">The bounds.</param>
 public MapShapeContext(
     IGeoMapView <TDrawingContext> chart,
     IPaint <TDrawingContext> heatPaint,
     List <Tuple <double, LvcColor> > heatStops,
     Dictionary <int, Bounds> boundsDictionary)
 {
     Chart            = chart;
     HeatPaint        = heatPaint;
     HeatStops        = heatStops;
     BoundsDictionary = boundsDictionary;
 }
Ejemplo n.º 12
0
        public void Highlight(IPaint screen)
        {
            NormPoint a = new NormPoint();
            NormPoint b = new NormPoint();

            a.UpdateCoord(EndCoord.X, BeginCoord.Y);
            b.UpdateCoord(BeginCoord.X, EndCoord.Y);
            screen.drawhighlight(new List <NormPoint> {
                BeginCoord, a, BeginCoord, b, b, EndCoord, EndCoord, a
            });
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapShapeContext{TDrawingContext}"/> class.
 /// </summary>
 /// <param name="chart">The chart.</param>
 /// <param name="heatPaint">The heat paint.</param>
 /// <param name="heatStops">The heat stops.</param>
 /// <param name="bounds">The bounds.</param>
 public MapShapeContext(
     IGeoMapView <TDrawingContext> chart,
     IPaint <TDrawingContext> heatPaint,
     List <Tuple <double, LvcColor> > heatStops,
     Bounds bounds)
 {
     Chart     = chart;
     HeatPaint = heatPaint;
     HeatStops = heatStops;
     Bounds    = bounds;
 }
Ejemplo n.º 14
0
 public static void DrawAll(IPaint screen) //Отрисовка всех фигур из списка screen - класс полотна на котором рисуем
 {
     for (int i = 0; i < ListOfFigures.Count(); i++)
     {
         ListOfFigures[i].Draw(screen);
     }
     if (SelectedItem != -1)
     {
         ListOfFigures[SelectedItem].Highlight(screen);
     }
     screen._flush();
 }
Ejemplo n.º 15
0
        public void Draw(IPaint layer, Point point, decimal scale)
        {
            var image = layer.Image;

            if (image != null && layer.Contains(point))
            {
                //得到鼠标相对图片的坐标
                var p     = point.Minus(layer.Location).Divide(scale);
                var color = image.GetPixel(p.X, p.Y);
                Drawer.Color = color;
            }
        }
Ejemplo n.º 16
0
 public Menu(IPaint ui)
 {
     var position = 0;
     painter = ui;
     Position = new Coordinates();
     MenuButtons = new List<Button>();
     MenuButtons.Add(new StartButton(MenuButtons) {Position = new Coordinates(10, position += 3)});
     MenuButtons.Add(new ScoreButton(MenuButtons) {Position = new Coordinates(10, position += 3)});
     MenuButtons.Add(new ExitButton(MenuButtons) {Position = new Coordinates(10, position += 3)});
     MenuButtons[SelectedButton].IsSelected = true;
     painter.RequireScreenUpdate();
 }
Ejemplo n.º 17
0
 public SkiaPaint(IPaint paint)
 {
     // TODO
     nativePaint             = new SKPaint(); // new SKPaint(((SkiaPaint)paint).NativePaint);
     nativePaint.IsAntialias = ((SkiaPaint)paint).NativePaint.IsAntialias;
     nativePaint.IsStroke    = ((SkiaPaint)paint).NativePaint.IsStroke;
     nativePaint.StrokeWidth = ((SkiaPaint)paint).NativePaint.StrokeWidth;
     nativePaint.StrokeCap   = ((SkiaPaint)paint).NativePaint.StrokeCap;
     nativePaint.StrokeJoin  = ((SkiaPaint)paint).NativePaint.StrokeJoin;
     nativePaint.StrokeWidth = ((SkiaPaint)paint).NativePaint.StrokeWidth;
     nativePaint.StrokeMiter = ((SkiaPaint)paint).NativePaint.StrokeMiter;
     nativePaint.Color       = ((SkiaPaint)paint).NativePaint.Color;
 }
Ejemplo n.º 18
0
        public WayTextContainer(Point point, Point end, Display display, int priority, string text, IPaint paintFront, IPaint paintBack, double textHeight) : base(point, display, priority)
        {
            this.text       = text;
            this.paintFront = paintFront;
            this.paintBack  = paintBack;
            this.end        = end;

            this.boundary = null;
            // a way text container should always run left to right, but I leave this in because it might matter
            // if we support right-to-left text.
            // we also need to make the container larger by textHeight as otherwise the end points do
            // not correctly reflect the size of the text on screen
            this.boundaryAbsolute = (new Rectangle(Math.Min(point.X, end.X), Math.Min(point.Y, end.Y), Math.Max(point.X, end.X), Math.Max(point.Y, end.Y))).Envelope(textHeight / 2d);
        }
Ejemplo n.º 19
0
        public Painter(IPaint paint, IWalk walk)
        {
            InitializeComponent();
            this.Height = size.Height;
            this.Width = size.Width;

            WalkType = walk;
            PaintType = paint;
            VisualBrush WalkBrush = new VisualBrush(WalkType.GetFace(size));
            VisualBrush DrawBrush = new VisualBrush(PaintType.GetFace(size));

            walker.Fill = WalkBrush;
            drawer.Fill = DrawBrush;           
        }
Ejemplo n.º 20
0
        public Painter(IPaint paint, IWalk walk)
        {
            InitializeComponent();
            this.Height = size.Height;
            this.Width  = size.Width;

            WalkType  = walk;
            PaintType = paint;
            VisualBrush WalkBrush = new VisualBrush(WalkType.GetFace(size));
            VisualBrush DrawBrush = new VisualBrush(PaintType.GetFace(size));

            walker.Fill = WalkBrush;
            drawer.Fill = DrawBrush;
        }
Ejemplo n.º 21
0
        private void GetSKPaintFill(IPaint fillPaint, IPaintEffects effects, double scale, out SKPaint brush)
        {
            if (fillPaint.IsTreeDirty() || !_paintCache.TryGetValue(fillPaint, out var brushCached))
            {
                fillPaint.Invalidate();
                brushCached            = SkiaUtil.ToSKPaint(fillPaint, effects, scale, _disposable.Disposables);
                _paintCache[fillPaint] = brushCached;
            }
            else
            {
                SkiaUtil.ToSKPaintUpdate(brushCached, fillPaint, effects, scale, _disposable.Disposables);
            }

            brush = brushCached;
        }
Ejemplo n.º 22
0
 public void Do(params object[] args)
 {
     Entity = args[0] as IPaint;
     Source = (Point)args[1];
     Dest   = (Point)args[2];
     if (Entity is Canvas canvas)
     {
         canvas.RealLocation = canvas.RealLocation.Add(Dest.Minus(Source));
     }
     else
     {
         Entity.Location = Entity.Location.Add(Dest.Minus(Source));
     }
     Connector.CanvasFlush();
 }
Ejemplo n.º 23
0
        public void Highlight(IPaint screen)
        {
            NormPoint a = new NormPoint();
            NormPoint b = new NormPoint();
            NormPoint c = new NormPoint();
            NormPoint d = new NormPoint();

            a.UpdateCoord(BeginCoord.X + 0.001, BeginCoord.Y + 0.01 + LineThick / 200);
            b.UpdateCoord(EndCoord.X + 0.001, EndCoord.Y + 0.01 + LineThick / 200);
            c.UpdateCoord(BeginCoord.X - 0.01, BeginCoord.Y - 0.001 + LineThick / 200);
            d.UpdateCoord(EndCoord.X - 0.01, EndCoord.Y - 0.001 + LineThick / 200);
            screen.drawhighlight(new List <NormPoint> {
                a, b, c, d
            });
        }
Ejemplo n.º 24
0
        public void Highlight(IPaint screen)
        {
            NormPoint a = new NormPoint();
            NormPoint b = new NormPoint();
            NormPoint c = new NormPoint();
            NormPoint d = new NormPoint();

            a.UpdateCoord(BeginCoord.X, BeginCoord.Y);
            b.UpdateCoord(Node3.X, Node3.Y);
            c.UpdateCoord(EndCoord.X, EndCoord.Y);
            d.UpdateCoord(Node4.X, Node4.Y);
            screen.drawhighlight(new List <NormPoint> {
                a, b, b, c, c, d, d, a
            });
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Adds a layer to the map from a stream reader.
        /// </summary>
        /// <param name="streamReader">The path to the stream reader.</param>
        /// <param name="layerName">The layer name.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="fill">The fill.</param>
        /// <returns>The added layer.</returns>
        public MapLayer <TDrawingContext> AddLayerFromStreamReader(
            StreamReader streamReader, IPaint <TDrawingContext> stroke, IPaint <TDrawingContext> fill, string layerName = "default")
        {
            if (!Layers.TryGetValue(layerName, out var layer))
            {
                layer = new MapLayer <TDrawingContext>(layerName, stroke, fill);
                Layers.Add(layerName, layer);
            }

            var geoJson = JsonConvert.DeserializeObject <GeoJsonFile>(streamReader.ReadToEnd()) ?? throw new Exception("Map not found");

            layer.AddFile(geoJson);

            return(layer);
        }
Ejemplo n.º 26
0
        public void Draw(IPaint layer, Point point, decimal scale)
        {
            var image = layer.Image;

            if (image != null && layer.Contains(point))
            {
                if (layer is Canvas canvas && canvas.RealPosition && canvas.Tag is Sprite sprite)
                {
                    point = point.Minus(sprite.Location);
                }
                //得到鼠标相对图片的坐标
                var p     = point.Minus(layer.Location).Divide(scale);
                var color = image.GetPixel(p.X, p.Y);
                Drawer.Color = color;
            }
        }
Ejemplo n.º 27
0
 public void Draw(IPaint paint, Point point, decimal scale)
 {
     point = point.Minus(paint.Location);
     if (paint is Canvas canvas && canvas.RealPosition)
     {
         if (canvas.Tag is Sprite sprite)
         {
             point = point.Minus(sprite.Location);
         }
     }
     point = point.Divide(scale);
     if (paint.Tag != null)
     {
         Program.Connector.Do("eraser", paint.Tag, point, Program.Drawer.Color, Radius);
     }
 }
Ejemplo n.º 28
0
        /// <inheritdoc />
        public void DrawEllipse(Point location, float radius, IPaint paint)
        {
            var x = location.X - radius;
            var y = location.Y - radius;

            Canvas.Children.Add(new Ellipse
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin          = new Thickness(x, y, 0, 0),
                Width           = radius * 2,
                Height          = radius * 2,
                Fill            = new SolidColorBrush(paint.Fill.ToSystemColor()),
                Stroke          = new SolidColorBrush(paint.Stroke.ToSystemColor()),
                StrokeThickness = paint.StrokeThickness,
                Opacity         = paint.Opacity
            });
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StrokeAndFillDrawable{TDrawingContext}"/> class.
        /// </summary>
        /// <param name="stroke">The stroke.</param>
        /// <param name="fill">The fill.</param>
        /// <param name="isHoverState">is hover state?.</param>
        public StrokeAndFillDrawable(IPaint <TDrawingContext>?stroke, IPaint <TDrawingContext>?fill, bool isHoverState = false)
        {
            Stroke = stroke;
            if (stroke is not null)
            {
                stroke.IsStroke = true;
                stroke.IsFill   = false;
            }

            Fill = fill;
            if (fill is not null)
            {
                fill.IsStroke        = false;
                fill.IsFill          = true;
                fill.StrokeThickness = 0;
            }
            IsHoverState = isHoverState;
        }
Ejemplo n.º 30
0
        public void Highlight(IPaint screen)
        {
            NormPoint a = new NormPoint();
            NormPoint b = new NormPoint();
            NormPoint c = new NormPoint();
            NormPoint d = new NormPoint();

            double CX = (BeginCoord.X + EndCoord.X) / 2;
            double CY = (BeginCoord.Y + EndCoord.Y) / 2;

            a.UpdateCoord(CX + (BeginCoord.X - CX) * 1.1, CY + (BeginCoord.Y - CY) * 1.1);
            d.UpdateCoord(CX + (Node4.X - CX) * 1.1, CY + (Node4.Y - CY) * 1.1);
            c.UpdateCoord(CX + (EndCoord.X - CX) * 1.1, CY + (EndCoord.Y - CY) * 1.1);
            b.UpdateCoord(CX + (Node3.X - CX) * 1.1, CY + (Node3.Y - CY) * 1.1);
            screen.drawhighlight(new List <NormPoint> {
                a, b, b, c, c, d, d, a
            });
        }
        public DatabaseTestBase()
        {
            _connection = new SqliteConnection("Filename=:memory:");
            _connection.Open();

            _db = new HobbyListDbContext(
                new DbContextOptionsBuilder <HobbyListDbContext>()
                .UseSqlite(_connection)
                .Options);

            _db.Database.EnsureCreated();

            _paint = new PaintService(_db);

            _supply = new SupplyService(_db);

            _miniModel = new MiniModelService(_db, _paint, _supply);
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Create a new point container, that holds the x-y coordinates of a point, a text variable, two paint objects, and
 /// a reference on a symbolContainer, if the text is connected with a POI.
 /// </summary>
 protected internal PointTextContainer(Point point, Display display, int priority, string text, IPaint paintFront, IPaint paintBack, SymbolContainer symbolContainer, Position position, int maxTextWidth) : base(point, display, priority)
 {
     this.maxTextWidth    = maxTextWidth;
     this.text            = text;
     this.symbolContainer = symbolContainer;
     this.paintFront      = paintFront;
     this.paintBack       = paintBack;
     this.position        = position;
     if (paintBack != null)
     {
         this.textWidth  = paintBack.GetTextWidth(text);
         this.textHeight = paintBack.GetTextHeight(text);
     }
     else
     {
         this.textWidth  = paintFront.GetTextWidth(text);
         this.textHeight = paintFront.GetTextHeight(text);
     }
     this.isVisible = !this.paintFront.Transparent || (this.paintBack != null && !this.paintBack.Transparent);
 }
Ejemplo n.º 33
0
        /// <inheritdoc />
        public void DrawLine(Point point1, Point point2, IPaint paint)
        {
            using var skPaint = new SKPaint
                  {
                      Color       = paint.Fill.ToSkColor(paint.Opacity),
                      StrokeWidth = paint.StrokeThickness,
                      IsAntialias = paint.IsAntialiased,
                      IsStroke    = Math.Abs(paint.StrokeThickness) > float.Epsilon
                  };

            if (paint.DashPattern != null)
            {
                var dashEffect = SKPathEffect.CreateDash(paint.DashPattern, 0);
                skPaint.PathEffect = skPaint.PathEffect != null
                    ? SKPathEffect.CreateCompose(dashEffect, skPaint.PathEffect)
                    : dashEffect;
            }

            Surface.Canvas.DrawLine(point1.ToSkPoint(), point2.ToSkPoint(), skPaint);
        }
Ejemplo n.º 34
0
		protected Paintable(IPaint fill, Stroke stroke)
		{
			this.Fill = fill;
			this.Stroke = stroke;
		}
Ejemplo n.º 35
0
		public Text(IPaint fill, Stroke stroke, Draw.Text text, Geometry2D.Single.Point position) :
			base(fill, stroke)
		{
			this.Data = text;
			this.Position = position;
		}
Ejemplo n.º 36
0
		public Path(IPaint fill, Stroke stroke, Draw.Path path) :
			base(fill, stroke)
		{
			this.Data = path;
		}
Ejemplo n.º 37
0
		public Stroke(IPaint paint, float width) :
			this()
		{
			this.Paint = paint;
			this.Width = width;
		}
Ejemplo n.º 38
0
		public Stroke(IPaint paint, float width, LineCap lineCap, LineJoin lineJoin) :
			this(paint, width)
		{
			this.LineCap = lineCap;
			this.LineJoin = lineJoin;
		}