Ejemplo n.º 1
0
        private void VisualizeOtherAffectedObjects()
        {
            var IncludeOriginatedSubtree = (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
            var IncludeTargetedSubtree   = (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl));
            var OtherAffectedObjects     = this.OwnerManager.OwnerView.GetCurrentManipulableObjects(IncludeOriginatedSubtree, IncludeTargetedSubtree, true)
                                           .Select(obj => obj.Item1).Distinct()              // Notice that duplicates are informed, so they must be excluded
                                           .Except(this.ManipulatedObject.IntoEnumerable()); // Exclude current object to avoid visual interference in resizing

            foreach (var AffectedObject in OtherAffectedObjects)
            {
                var DeltaX      = 0.0;
                var DeltaY      = 0.0;
                var DeltaWidth  = 0.0;
                var DeltaHeight = 0.0;

                // Do not consider other intention, particularly resizing (due to its implicit move)
                if (this.IntendedAction == ESymbolManipulationAction.Move)
                {
                    DeltaX = this.ManipulatingHeadingRectangle.X - this.ManipulatedSymbol.BaseArea.X;
                    DeltaY = this.ManipulatingHeadingRectangle.Y - this.ManipulatedSymbol.BaseArea.Y;
                }

                // Only the manipulated symbol show a change in size
                // (because multi-resize is postponed due to difficulty)
                if (this.ManipulatedSymbol == AffectedObject)
                {
                    DeltaWidth  = this.ManipulatingHeadingRectangle.Width - this.ManipulatedSymbol.BaseArea.Width;
                    DeltaHeight = this.ManipulatingHeadingRectangle.Height - this.ManipulatedSymbol.BaseArea.Height;
                }

                var SelectionZone = (AffectedObject is VisualSymbol && ((VisualSymbol)AffectedObject).IsHidden
                                     ? new Rect(AffectedObject.BaseCenter.X - 4, AffectedObject.BaseCenter.Y - 4,
                                                8, 8)
                                     : new Rect(AffectedObject.BaseLeft + DeltaX,
                                                AffectedObject.BaseTop + DeltaY,
                                                (AffectedObject.BaseWidth + DeltaWidth).EnforceMinimum(4),
                                                (AffectedObject.TotalArea.Height + DeltaHeight).EnforceMinimum(4)));
                var SelectionGeom = (SelectionZone.Width > 8 && SelectionZone.Height > 8
                                     ? new CombinedGeometry(GeometryCombineMode.Exclude,
                                                            new RectangleGeometry(SelectionZone),
                                                            new RectangleGeometry(new Rect(SelectionZone.X + 4, SelectionZone.Y + 4,
                                                                                           (SelectionZone.Width - 8).EnforceMinimum(4),
                                                                                           (SelectionZone.Height - 8).EnforceMinimum(4))))
                                     : (new RectangleGeometry(SelectionZone)) as Geometry);
                var SelectionDrawing = new GeometryDrawing(this.FrmStroke, this.FrmPencil, SelectionGeom);
                var SelectionVisual  = SelectionDrawing.RenderToDrawingVisual();
                SelectionVisual.Opacity = (AffectedObject.IsIn(this.OwnerManager.OwnerView.SelectedObjects)
                                           ? this.FrmOpacity : this.FrmOpacity / 2.0);
                this.Indicators.Add(SelectionVisual);
            }
        }
Ejemplo n.º 2
0
        public override void ApplyFluidTheme(IDataFluidTheme theme)
        {
            if (LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR)
            {
                foreach (var featurePair in Features)
                {
                    var    feature  = featurePair.Key;
                    var    geometry = featurePair.Value.Geometry as PathGeometry;
                    var    poly     = new Geometry.PointString(feature.GeoData);
                    double length   = poly.Length();
                    if (length < 10)
                    {
                        continue;
                    }

                    double velocity  = theme.GetVelocity(feature);
                    double time      = length / velocity;
                    double space     = 1 / theme.GetDensity(feature);
                    int    spotCount = (int)(length / space) + 1;
                    var    color     = theme.GetColor(feature);

                    for (int i = 0; i < spotCount; i++)
                    {
                        var pointAnimation = new PointAnimationUsingPath
                        {
                            PathGeometry   = geometry,
                            Duration       = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))),
                            RepeatBehavior = RepeatBehavior.Forever,
                            BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000))
                        };

                        var colorAnimation = new ColorAnimation(
                            fromValue: color.Item1,
                            toValue: color.Item2,
                            duration: new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))))
                        {
                            RepeatBehavior = RepeatBehavior.Forever,
                            BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000))
                        };

                        double radius      = theme.GetDiameter(feature) / 2;
                        var    fill        = new SolidColorBrush(color.Item1);
                        var    spot        = new EllipseGeometry(new Point(), radius, radius);
                        var    spotDrawing = new GeometryDrawing(fill, null, spot);
                        this.AddOverlayChildren(spotDrawing);
                        spot.BeginAnimation(EllipseGeometry.CenterProperty, pointAnimation);
                        fill.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
                    }
                }
            }
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Geometry iconGeometry    = null;
            Brush    foregroundBrush = App.Current.TryFindResource("IdealForegroundColorBrush") as Brush;

            switch ((PuzzleSolverState)value)
            {
            case PuzzleSolverState.UNSOLVED:
                iconGeometry = Geometry.Parse((new PackIconModern()
                {
                    Kind = PackIconModernKind.Page
                }).Data); break;

            case PuzzleSolverState.INIT_PIECES:
                iconGeometry = Geometry.Parse((new PackIconMaterial()
                {
                    Kind = PackIconMaterialKind.Magnify
                }).Data); break;

            case PuzzleSolverState.COMPARE_EDGES:
                iconGeometry = Geometry.Parse((new PackIconFontAwesome()
                {
                    Kind = PackIconFontAwesomeKind.EqualsSolid
                }).Data); break;

            case PuzzleSolverState.SOLVE_PUZZLE:
                iconGeometry = Geometry.Parse((new PackIconModern()
                {
                    Kind = PackIconModernKind.LayerAdd
                }).Data); break;

            case PuzzleSolverState.SOLVED:
                iconGeometry = Geometry.Parse((new PackIconFontAwesome()
                {
                    Kind = PackIconFontAwesomeKind.CheckSolid
                }).Data); break;

            case PuzzleSolverState.ERROR:
                iconGeometry = Geometry.Parse((new PackIconEntypo()
                {
                    Kind = PackIconEntypoKind.CircleWithCross
                }).Data); break;

            default:
                return(null);
            }

            GeometryDrawing iconGeometryDrawing = new GeometryDrawing(foregroundBrush, new Pen(foregroundBrush, 1), iconGeometry);

            return(iconGeometryDrawing);
        }
Ejemplo n.º 4
0
        public DrawingImage Drawing()
        {
            GeometryDrawing mainDrawing      = new GeometryDrawing();
            GeometryGroup   mainDrawingGroup = new GeometryGroup();

            mainDrawing.Brush = Brushes.Beige;
            mainDrawing.Pen   = new Pen(Brushes.RosyBrown, 3);
            foreach (IShape shape in mainList)
            {
                shape.Draw(mainDrawingGroup);
            }
            mainDrawing.Geometry = mainDrawingGroup;
            return(new DrawingImage(mainDrawing));
        }
Ejemplo n.º 5
0
        void Update(BitmapImage ImageButton)
        {
            FormattedText TextF = new FormattedText(text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Areal"), point, Brushes.Black);

            Geometry TextG = TextF.BuildGeometry(new Point(border.X + (border.Width / 2 - TextF.Width / 2), border.Y + (border.Height / 2 - TextF.Height / 2)));

            GeometryDrawing TextGD = new GeometryDrawing(Brushes.White, new Pen(Brushes.White, 0), TextG);

            button.Children.Clear();
            button.Children.Add(new ImageDrawing(ImageButton, border));
            button.Children.Add(TextGD);
            width  = border.Width;
            height = border.Height;
        }
Ejemplo n.º 6
0
        private static void AddFluid(DrawingMapLayer animationLayer, TongJi.Gis.Display.IDataFluidTheme theme, TongJi.Gis.IFeature f)
        {
            var    poly   = new TongJi.Geometry.Polyline(f.GeoData);
            double length = poly.Length;

            if (length < 10)
            {
                return;
            }

            // 生成PathGeometry
            var          points   = poly.Points.Select(p => new Point(p.x, p.y)).ToList();
            PathGeometry geometry = new PathGeometry();
            PathFigure   figure   = new PathFigure {
                StartPoint = points.First()
            };
            PolyLineSegment segment = new PolyLineSegment(points, true);

            figure.Segments.Add(segment);
            geometry.Figures.Add(figure);

            // 读取参数
            double velocity  = theme.GetVelocity(f);
            double time      = length / velocity;
            double space     = 1 / theme.GetDensity(f);
            int    spotCount = (int)(length / space) + 1;
            var    color     = theme.GetColor(f);

            // 应用动画
            for (int i = 0; i < spotCount; i++)
            {
                PointAnimationUsingPath paup = new PointAnimationUsingPath();
                paup.PathGeometry   = geometry;
                paup.Duration       = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000)));
                paup.RepeatBehavior = RepeatBehavior.Forever;
                paup.BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000));

                ColorAnimation ca = new ColorAnimation(color.Item1, color.Item2, new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))));
                ca.RepeatBehavior = RepeatBehavior.Forever;
                ca.BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000));

                double          radius      = theme.GetDiameter(f) / 2;
                var             fill        = new SolidColorBrush(color.Item1);
                EllipseGeometry spot        = new EllipseGeometry(new Point(), radius, radius);
                GeometryDrawing spotDrawing = new GeometryDrawing(fill, null, spot);
                animationLayer.AddOverlayChildren(spotDrawing);
                spot.BeginAnimation(EllipseGeometry.CenterProperty, paup);
                fill.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
        }
Ejemplo n.º 7
0
        public void SetWord(StrokeWord word)
        {
            this.word = word;
            group.Children.Clear();
            group.Children.Add(background);
            group.Children.Add(grid);

            character = new GeometryDrawing(Brushes.Gray, null,
                                            new PathGeometry(word.Strokes.Select(x => x.Outline))
            {
                FillRule = FillRule.Nonzero
            });
            group.Children.Add(character);
        }
Ejemplo n.º 8
0
        public Render(EllipseBounce[] ellipse)
        {
            Group = new DrawingGroup();

            foreach (var item in ellipse)
            {
                var eg  = item.Ellipse;
                var col = Brushes.Black;
                col.Freeze();

                var gd = new GeometryDrawing(col, null, eg);
                Group.Children.Add(gd);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Initializes all general pens and brushes.
        /// </summary>
        void InitializeResources()
        {
            textBrush = new SolidColorBrush(Color.FromRgb(120, 120, 120));
            textBrush.Freeze();

            Brush gridLineBrush = new SolidColorBrush(Color.FromRgb(160, 160, 160));

            ;
            gridLineBrush.Freeze();
            gridLinePen = new Pen(gridLineBrush, 1);
            gridLinePen.Freeze();

            Brush gridBoldLineBrush = new SolidColorBrush(Color.FromRgb(20, 20, 20));

            gridBoldLineBrush.Freeze();
            gridBoldLinePen = new Pen(gridBoldLineBrush, 1);
            gridZeroLinePen = new Pen(gridBoldLineBrush, 2);
            gridBoldLinePen.Freeze();
            gridZeroLinePen.Freeze();


            backgroundBrush = new SolidColorBrush(Color.FromArgb(0, 48, 48, 48));
            backgroundBrush.Freeze();

            glyphs                     = new Glyphs();
            glyphs.FontUri             = new Uri(Environment.GetFolderPath(Environment.SpecialFolder.Fonts) + "\\Arial.TTF");
            glyphs.FontRenderingEmSize = 11;
            glyphs.StyleSimulations    = StyleSimulations.None;

            // Seek Needle
            Brush seekNeedleBrush = Brushes.Red;
            var   seekNeedlePen   = new Pen(Brushes.Black, 1);

            seekNeedlePen.Freeze();
            SeekNeedle = new GeometryDrawing();
            var path = new PathGeometry();

            path.Figures.Add(new PathFigure(
                                 new Point(-4, 0), new[] {
                new PolyLineSegment(new[] {
                    new Point(4, 0),
                    new Point(0, -7),
                    new Point(0, -20),
                    new Point(0, -7)
                }, true)
            }, true));
            SeekNeedle.Geometry = path;
            SeekNeedle.Brush    = seekNeedleBrush;
            SeekNeedle.Pen      = seekNeedlePen;
        }
Ejemplo n.º 10
0
        public Image CreateWpfImpage()
        {
            GeometryDrawing aGeometryDrawing = new GeometryDrawing();

            aGeometryDrawing.Geometry = new EllipseGeometry(new Point(50, 50), 50, 50);
            aGeometryDrawing.Pen      = new Pen(Brushes.Red, 10);
            aGeometryDrawing.Brush    = Brushes.Blue;
            DrawingImage geometryImage = new DrawingImage(aGeometryDrawing);

            Image anImage = new Image();

            anImage.Source = geometryImage;
            return(anImage);
        }
Ejemplo n.º 11
0
        private Drawing GetBombs()
        {
            GeometryGroup bombs = new GeometryGroup();
            Drawing       bmbs;

            foreach (var bomb in this.model.Bombs)
            {
                Geometry box = new RectangleGeometry(new Rect(bomb.Location[0], bomb.Location[1], this.model.TileSize, this.model.TileSize));
                bombs.Children.Add(box);
            }

            bmbs = new GeometryDrawing(this.drawExtension.BombBrush, null, bombs);
            return(bmbs);
        }
Ejemplo n.º 12
0
        protected Icon(double size)
        {
            ComponentDrawingGroup = new DrawingGroup();

            GeometryDrawing rect = new GeometryDrawing(
                new SolidColorBrush(Brushes.White.Color),
                new Pen(Brushes.Black, 4),
                new RectangleGeometry(new Rect(new Point(0, 0), new Point(size, size))
                                      ));

            ComponentDrawingGroup.Children.Add(rect);

            Stretch = Stretch.None;
        }
Ejemplo n.º 13
0
        public void DrawingBackgroundBorderBrushNonUniformBorderThicknessIsCheckedRenderPressed()
        {
            BulletChrome c = new BulletChrome();

            c.Background      = new SolidColorBrush(Color.FromArgb(0x11, 0x11, 0x11, 0x11));
            c.BorderBrush     = new SolidColorBrush(Color.FromArgb(0x22, 0x22, 0x22, 0x22));
            c.BorderThickness = new Thickness(1, 2, 3, 4);
            c.IsChecked       = true;
            c.RenderPressed   = true;
            c.Width           = 100;
            c.Height          = 100;
            Window w = new Window();

            w.Content = c;
            w.Show();
            DrawingGroup drawing_group = VisualTreeHelper.GetDrawing(c);

            Assert.AreEqual(drawing_group.Children.Count, 3, "1");

            GeometryDrawing     gd  = (GeometryDrawing)drawing_group.Children [0];
            LinearGradientBrush lgb = (LinearGradientBrush)gd.Brush;

            Assert.AreEqual(lgb.StartPoint, new Point(0, 0), "2");
            Assert.AreEqual(lgb.EndPoint, new Point(1, 1), "2 1");
            Assert.AreEqual(lgb.GradientStops.Count, 2, "2 2");
            Assert.AreEqual(lgb.GradientStops [0].Color, Color.FromArgb(0xFF, 0xB2, 0xB2, 0xA9), "2 3");
            Assert.AreEqual(lgb.GradientStops [0].Offset, 0, "2 4");
            Assert.AreEqual(lgb.GradientStops [1].Color, Color.FromArgb(0xFF, 0xEB, 0xEA, 0xDA), "2 5");
            Assert.AreEqual(lgb.GradientStops [1].Offset, 1, "2 6");
            Assert.IsNull(gd.Pen, "3");
            RectangleGeometry rg = (RectangleGeometry)gd.Geometry;

            Assert.AreEqual(rg.Rect, new Rect(1, 2, 96, 94), "4");
            Assert.AreEqual(rg.RadiusX, 0, "5");
            Assert.AreEqual(rg.RadiusY, 0, "6");

            Assert.AreEqual(((DrawingGroup)drawing_group.Children [1]).Children.Count, 1, "6 1");
            Assert.AreEqual(((TranslateTransform)((DrawingGroup)drawing_group.Children [1]).Transform).Value, new Matrix(1, 0, 0, 1, 0, 1), "6 2");
            gd = (GeometryDrawing)((DrawingGroup)drawing_group.Children [1]).Children [0];
            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, Color.FromArgb(0xFF, 0x1A, 0x7E, 0x18), "7");
            Assert.IsNull(gd.Pen, "8");
            StreamGeometry sg = (StreamGeometry)gd.Geometry;

            Assert.AreEqual(sg.ToString(), "M3;5L3;7,8 5,5;10,4 10,1;5,8 10,1;3 5,5;7,6z", "9");

            gd = (GeometryDrawing)drawing_group.Children [2];
            Assert.IsNull(gd.Pen, "10");
            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, ((SolidColorBrush)c.BorderBrush).Color, "12");
            Assert.AreEqual(gd.Geometry.ToString(), "M0;0L100;0L100;100L0;100z M1;2L97;2L97;96L1;96z", "13");
        }
Ejemplo n.º 14
0
        private static ImageSource GetGlyph(Color color)
        {
            var rectangle = new RectangleGeometry(new Rect(0, 0, 24, 24));

            var brush = new SolidColorBrush(color);

            var drawing = new GeometryDrawing
            {
                Geometry = rectangle,
                Brush    = brush
            };

            return(new DrawingImage(drawing));
        }
Ejemplo n.º 15
0
        public static ImageSource GetImageSourceFromAxoColor(AxoColor axoColor, int width, int height)
        {
            var innerRect       = new Rect(0, 0, width, height);
            var geometryDrawing = new GeometryDrawing()
            {
                Geometry = new RectangleGeometry(innerRect)
            };

            geometryDrawing.Brush = new SolidColorBrush(GuiHelper.ToWpf(axoColor));
            var geometryImage = new DrawingImage(geometryDrawing);

            geometryImage.Freeze(); // Freeze the DrawingImage for performance benefits.
            return(geometryImage);
        }
Ejemplo n.º 16
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var symbol = value as IScatterSymbol;

            if (null == symbol)
            {
                return(null);
            }
            GetPathGeometries(symbol, SymbolSize, out var fill, out var frame, out var inset);
            GetBrushes(symbol, PlotColor, fill, frame, inset, out var fillBrush, out var frameBrush, out var insetBrush);

            // draws a transparent outline to fix the borders
            var drawingGroup = new DrawingGroup();

            if (null != fill)
            {
                var geometryDrawing = new GeometryDrawing
                {
                    Geometry = fill,
                    Brush    = fillBrush
                };
                drawingGroup.Children.Add(geometryDrawing);
            }

            if (null != frame)
            {
                var geometryDrawing = new GeometryDrawing
                {
                    Geometry = frame,
                    Brush    = frameBrush
                };
                drawingGroup.Children.Add(geometryDrawing);
            }

            if (null != inset)
            {
                var geometryDrawing = new GeometryDrawing
                {
                    Geometry = inset,
                    Brush    = insetBrush
                };
                drawingGroup.Children.Add(geometryDrawing);
            }

            var geometryImage = new DrawingImage(drawingGroup);

            // Freeze the DrawingImage for performance benefits.
            geometryImage.Freeze();
            return(geometryImage);
        }
Ejemplo n.º 17
0
        private Drawing GetEnemies()
        {
            GeometryGroup enemies = new GeometryGroup();

            for (int i = 0; i < this.model.Enemies.Count(); i++)
            {
                Geometry box = new RectangleGeometry(new Rect(this.model.Enemies[i].Location[0], this.model.Enemies[i].Location[1], this.model.TileSize, this.model.TileSize));
                enemies.Children.Add(box);
            }

            Drawing enems = new GeometryDrawing(this.drawExtension.EnemyBrush, null, enemies);

            return(enems);
        }
Ejemplo n.º 18
0
        //==========================================================================
        public virtual Drawing GetBaseDrawing()
        {
            Geometry geometry = GetGeometry();

            if (geometry == null)
            {
                return(null);
            }

            if (geometry.IsEmpty())
            {
                return(null);
            }
            if (geometry.Bounds.Width <= 0.0)
            {
                return(null);
            }
            if (geometry.Bounds.Height <= 0.0)
            {
                return(null);
            }

            Brush brush = GetBrush();
            Pen   pen   = GetPen();

            if ((brush == null) && (pen == null))
            {
                return(null);
            }


            // Apply fill-rule...

            if (geometry.GetArea() > 0.0)
            {
                PathGeometry path_geometry = Geometry.Combine(geometry, Geometry.Empty, GeometryCombineMode.Exclude, null);
                if (FillRule == SvgFillRule.Evenodd)
                {
                    path_geometry.FillRule = System.Windows.Media.FillRule.EvenOdd;
                }
                else if (FillRule == SvgFillRule.Nonzero)
                {
                    path_geometry.FillRule = System.Windows.Media.FillRule.Nonzero;
                }
                geometry = path_geometry;
            }
            GeometryDrawing geometry_drawing = new GeometryDrawing(brush, pen, geometry);

            return(geometry_drawing);
        }
Ejemplo n.º 19
0
        private void BackgroundFun()
        {
            GeometryDrawing geometryDrawing = new GeometryDrawing();

            RectangleGeometry rectangleGeometry = new RectangleGeometry();

            rectangleGeometry.Rect   = new Rect(0, 0, 1, 1);
            geometryDrawing.Geometry = rectangleGeometry;

            geometryDrawing.Pen   = new Pen(Brushes.Gray, 0.005);
            geometryDrawing.Brush = Brushes.LightGray;

            drawingGroup.Children.Add(geometryDrawing);
        }
Ejemplo n.º 20
0
        private void LoadLayerGroup(DrawingGroup group)
        {
            DrawingCollection drawings = group.Children;

            DrawingGroup    drawGroup    = null;
            GeometryDrawing drawGeometry = null;

            for (int i = 0; i < drawings.Count; i++)
            {
                Drawing drawing = drawings[i];
                if (TryCast(drawing, out drawGroup))
                {
                    string groupName = SvgLink.GetKey(drawGroup);
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        groupName = SvgObject.GetId(drawGroup);
                    }
                    //string groupName = SvgObject.GetName(childGroup);
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        LoadLayerGroup(drawGroup);
                    }
                    else
                    {
                        SvgObjectType elementType = SvgObject.GetType(drawGroup);

                        if (elementType == SvgObjectType.Text)
                        {
                            this.AddTextDrawing(drawGroup, groupName);
                        }
                        else
                        {
                            if (drawGroup.Children != null && drawGroup.Children.Count == 1)
                            {
                                this.AddDrawing(drawGroup, groupName);
                            }
                            else
                            {
                                //throw new InvalidOperationException(
                                //    String.Format("Error: The link group is in error - {0}", groupName));
                            }
                        }
                    }
                }
                else if (TryCast(drawing, out drawGeometry))
                {
                    this.AddGeometryDrawing(drawGeometry);
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoomVisual"/> class.
        /// </summary>
        /// <param name="zoneVisual">The zone visual.</param>
        public RoomVisual([NotNull] ZoneVisual zoneVisual)
        {
            _zoneVisual = zoneVisual;
            Assert.ArgumentNotNull(zoneVisual, "zoneVisual");

            _rootDrawing = new DrawingVisual();
            _childVisuals.Add(_rootDrawing);

            var dc = _rootDrawing.RenderOpen();

            _roomDrawing = new GeometryDrawing(zoneVisual.RenderConstants.GetRoomColorBrush(RoomColor.Default), _zoneVisual.RenderConstants.DefaultRoomPen, _zoneVisual.RenderConstants.RoomGeometry);
            dc.DrawDrawing(_roomDrawing);

            _northExitDrawing = new GeometryDrawing(_zoneVisual.RenderConstants.DefaultExitBrush, null, _zoneVisual.RenderConstants.NorthExitGeometry.Clone())
            {
                Geometry = { Transform = new ScaleTransform(1, 1, 1, 5) }
            };
            dc.DrawDrawing(_northExitDrawing);

            _southExitDrawing = new GeometryDrawing(_zoneVisual.RenderConstants.DefaultExitBrush, null, _zoneVisual.RenderConstants.SouthExitGeometry.Clone())
            {
                Geometry = { Transform = new ScaleTransform(1, 1, 1, 25) }
            };
            dc.DrawDrawing(_southExitDrawing);

            _westExitDrawing = new GeometryDrawing(_zoneVisual.RenderConstants.DefaultExitBrush, null, _zoneVisual.RenderConstants.WestExitGeometry.Clone())
            {
                Geometry = { Transform = new ScaleTransform(1, 1, 5, 1) }
            };
            dc.DrawDrawing(_westExitDrawing);

            _eastExitDrawing = new GeometryDrawing(_zoneVisual.RenderConstants.DefaultExitBrush, null, _zoneVisual.RenderConstants.EastExitGeometry.Clone())
            {
                Geometry = { Transform = new ScaleTransform(1, 1, 25, 1) }
            };
            dc.DrawDrawing(_eastExitDrawing);

            _upExitDrawing = new GeometryDrawing(_zoneVisual.RenderConstants.DefaultExitBrush, null, _zoneVisual.RenderConstants.UpExitGeometry);
            dc.DrawDrawing(_upExitDrawing);

            _downExitDrawing = new GeometryDrawing(_zoneVisual.RenderConstants.DefaultExitBrush, null, _zoneVisual.RenderConstants.DownExitGeometry);
            dc.DrawDrawing(_downExitDrawing);

            _iconDrawing = new GeometryDrawing(zoneVisual.RenderConstants.GetRoomIconBrush(RoomIcon.None), new Pen(Brushes.Transparent, 0), new RectangleGeometry(new Rect(5, 5, 20, 20)));
            dc.DrawDrawing(_iconDrawing);
            dc.Close();
            _transform             = new TranslateTransform(-10000, -10000);
            _rootDrawing.Transform = _transform;
        }
Ejemplo n.º 22
0
        public void DrawShaddow(Point innerPoint, Size innerSize)
        {
            var drawingGroup = new DrawingGroup();

            // Create a DrawingBrush.
            DrawingBrush myDrawingBrush = new DrawingBrush();

            // Create a drawing.
            GeometryDrawing myBlackDrawing = new GeometryDrawing();

            // myGeometryDrawing.Brush
            myBlackDrawing.Brush = Brushes.Black;
            myBlackDrawing.Pen   = new Pen(Brushes.Black, 1);
            GeometryGroup rectangle = new GeometryGroup();

            rectangle.FillRule = FillRule.EvenOdd;
            rectangle.Children.Add(new RectangleGeometry(new Rect {
                Height = _canvas.Height, Width = _canvas.Width
            }));

            GeometryGroup rectangle11 = new GeometryGroup();

            rectangle11.FillRule = FillRule.Nonzero;

            rectangle11.Children.Add(
                new RectangleGeometry(new Rect(new System.Windows.Point(innerPoint.X, innerPoint.Y),
                                               new System.Windows.Size(innerSize.Width * 20, innerSize.Height * 20))));

            rectangle.Children.Add(rectangle11);
            var combined = new CombinedGeometry(GeometryCombineMode.Exclude, rectangle, rectangle11);

            myBlackDrawing.Geometry = combined;

            drawingGroup.Children.Add(myBlackDrawing);
            myDrawingBrush.Drawing = drawingGroup;
            Rectangle rec = new Rectangle
            {
                Fill      = myDrawingBrush,
                Stroke    = Brushes.Black,
                Height    = _canvas.Height,
                Width     = _canvas.Width,
                Opacity   = 0.5,
                IsEnabled = false
            };

            _canvas.Children.Add(rec);
            Canvas.SetLeft(rec, 0);
            Canvas.SetTop(rec, 0);
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string iconDataStr     = null;
            Brush  foregroundBrush = App.Current.TryFindResource("IdealForegroundColorBrush") as Brush;

            switch ((PuzzleSavingStates)value)
            {
            case PuzzleSavingStates.PUZZLE_NULL: return(null);

            case PuzzleSavingStates.NEW_UNSAVED:
                iconDataStr = (new PackIconModern()
                {
                    Kind = PackIconModernKind.Page
                }).Data; break;

            case PuzzleSavingStates.SAVED:
                iconDataStr = (new PackIconModern()
                {
                    Kind = PackIconModernKind.Save
                }).Data; break;

            case PuzzleSavingStates.LOADED:
                iconDataStr = (new PackIconModern()
                {
                    Kind = PackIconModernKind.FolderOpen
                }).Data; break;

            case PuzzleSavingStates.SAVING:
            case PuzzleSavingStates.LOADING:
                iconDataStr = (new PackIconModern()
                {
                    Kind = PackIconModernKind.Hourglass
                }).Data; break;

            case PuzzleSavingStates.ERROR:
                iconDataStr = (new PackIconEntypo()
                {
                    Kind = PackIconEntypoKind.CircleWithCross
                }).Data; break;

            default:
                return(null);
            }

            Geometry        iconGeometry        = Geometry.Parse(iconDataStr);
            GeometryDrawing iconGeometryDrawing = new GeometryDrawing(foregroundBrush, new Pen(foregroundBrush, 1), iconGeometry);

            return(iconGeometryDrawing);
        }
Ejemplo n.º 24
0
        public Drawing Teken_jezelf()
        {
            var lijnen = new GeometryGroup();

            lijnen.Children.Add(Tekening);

            var drawing = new GeometryDrawing
            {
                Geometry = lijnen,
                Pen      = new Pen(_brush, 1),
                Brush    = _brush
            };

            return(drawing);
        }
Ejemplo n.º 25
0
        private void HeadPictureBackground()
        {
            DrawingBrush    myDrawingBrush    = new DrawingBrush();
            GeometryDrawing myGeometryDrawing = new GeometryDrawing();

            myGeometryDrawing.Pen = new Pen(Brushes.DarkGray, 1);
            GeometryGroup rectangle = new GeometryGroup();

            rectangle.Children.Add(new RectangleGeometry(new Rect(new Point(0, 0), new Point(100, 100))));

            myGeometryDrawing.Geometry = rectangle;
            myDrawingBrush.Drawing     = myGeometryDrawing;

            HeadPicture.Background = myDrawingBrush;
        }
Ejemplo n.º 26
0
        void UpdateGrid()
        {
            DrawingBrush db = new DrawingBrush();

            db.TileMode      = TileMode.Tile;
            db.Viewbox       = new Rect(XShift, YShift, GridSnap * Scale, GridSnap * Scale);
            db.Viewport      = new Rect(XShift, YShift, GridSnap * Scale, GridSnap * Scale);
            db.ViewportUnits = BrushMappingMode.Absolute;
            db.ViewboxUnits  = BrushMappingMode.Absolute;

            GeometryDrawing geom = new GeometryDrawing(null, new Pen(new SolidColorBrush(Color.FromRgb(22, 22, 22)), 0.5), new RectangleGeometry(new Rect(XShift, YShift, GridSnap * Scale, GridSnap * Scale)));

            db.Drawing          = geom;
            ViewPort.Background = db;
        }
Ejemplo n.º 27
0
        public YOIcon(double size) : base(size)
        {
            Stitch = new YOStitch();
            var drawingPosition = size / 2;
            var drawingSize     = size * .1;

            GeometryDrawing yo = new GeometryDrawing(
                new SolidColorBrush(Brushes.White.Color),
                new Pen(Brushes.Black, 4),
                new EllipseGeometry(new Point(drawingPosition, drawingPosition), drawingSize, drawingSize)
                );

            ComponentDrawingGroup.Children.Add(yo);
            SetSource();
        }
Ejemplo n.º 28
0
        private Brush GetClipTolerance(Geometry clip)
        {
            clip = EnsureClosedGeometry(clip);

            // Since we want this pen to always be the same width (RootTwo) in Device Dependent Units,
            //  we convert this value to Device Independent Units before creating the Pen.
            double thickness = MathEx.ConvertToDeviceIndependentPixels(Const.RootTwo);

            GeometryDrawing drawing = new GeometryDrawing(null, new Pen(Brushes.Black, thickness), clip);
            DrawingBrush    brush   = new DrawingBrush(drawing);

            brush.Viewbox      = new Rect(0, 0, width, height);
            brush.ViewboxUnits = BrushMappingMode.Absolute;
            return(brush);
        }
        /// <summary>
        /// This method creates the visual for a code block background and moves it to the correct position.
        /// </summary>
        /// <param name="adornmentBounds">The bounds of the rectangular adornment.</param>
        /// <param name="codeBlockOccurence">The occurence of the code block for which the visual will be created.</param>
        /// <returns>Returns the image that is the visual adornment (code block background).</returns>
        private Image CreateAndPositionCodeBlockBackgroundVisual(Rect adornmentBounds, CodeBlockOccurrence codeBlockOccurence)
        {
            if (adornmentBounds == null)
            {
                throw new ArgumentNullException(nameof(adornmentBounds));
            }

            if (codeBlockOccurence == null)
            {
                throw new ArgumentNullException(nameof(codeBlockOccurence));
            }

            var backgroundGeometry = new RectangleGeometry(adornmentBounds);
            var feedback           = codeBlockOccurence.Feedbacks.Where(f => f is DrawColoredBackgroundFeedback).FirstOrDefault() as DrawColoredBackgroundFeedback;
            var backgroundColor    = Color.FromArgb(feedback.BackgroundColor.A, feedback.BackgroundColor.R, feedback.BackgroundColor.G, feedback.BackgroundColor.B);

            var backgroundBrush = new SolidColorBrush(backgroundColor);

            backgroundBrush.Freeze();

            var outlineColor = Color.FromArgb(feedback.OutlineColor.A, feedback.OutlineColor.R, feedback.OutlineColor.G, feedback.OutlineColor.B);

            var outlinePenBrush = new SolidColorBrush(outlineColor);

            outlinePenBrush.Freeze();

            var outlinePen = new Pen(outlinePenBrush, 0.5);

            outlinePen.Freeze();

            var drawing = new GeometryDrawing(backgroundBrush, outlinePen, backgroundGeometry);

            drawing.Freeze();

            var drawingImage = new DrawingImage(drawing);

            drawingImage.Freeze();

            var image = new Image
            {
                Source = drawingImage
            };

            Canvas.SetLeft(image, adornmentBounds.Left);
            Canvas.SetTop(image, adornmentBounds.Top);

            return(image);
        }
        private void DrawSingleSyncPoint(Tracking track)
        {
            bool         isSelection = false;
            SnapshotSpan span;

            if (track.IsSelection)
            {
                isSelection = true;
                span        = track.Span.GetSpan(textView.TextSnapshot);
            }
            else
            {
                if (track.Start.GetPosition(textView.TextSnapshot) >= textView.TextSnapshot.Length)
                {
                    return;
                }
                span = new SnapshotSpan(track.Start.GetPoint(textView.TextSnapshot), 1);
            }


            Brush brush = Brushes.LightBlue.Clone();

            brush.Opacity = 0.3;
            var             geom    = textView.TextViewLines.GetLineMarkerGeometry(span);
            GeometryDrawing drawing = new GeometryDrawing(brush, null, geom);

            if (drawing.Bounds.IsEmpty)
            {
                return;
            }

            Rectangle rect = new Rectangle()
            {
                Fill = brush,
                //Width = drawing.Bounds.Width / 6,
                Width  = isSelection ? geom.Bounds.Width : drawing.Bounds.Width / 6,
                Height = drawing.Bounds.Height - 4,
                Margin = new System.Windows.Thickness(0, 2, 0, 0),
            };

            var clip = geom.Clone();

            clip.Transform = new TranslateTransform(-geom.Bounds.Left, -geom.Bounds.Top);
            rect.Clip      = clip;
            Canvas.SetLeft(rect, geom.Bounds.Left);
            Canvas.SetTop(rect, geom.Bounds.Top);
            adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, "MultiEditLayer", rect, null);
        }