Exemplo n.º 1
0
        public void Delete([NotNull] IShape shape)
        {
            Assert.ArgumentNotNull(shape, nameof(shape));

            Canvas.Children.Remove(shape as FrameworkElement);
            RemoveSelectedItem(shape);

            if (!Shapes.Any())
            {
                Empty.Visibility  = Visibility.Visible;
                Canvas.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 2
0
        public override IntersectionCollection LocalIntersect(Ray localRay)
        {
            if (!Shapes.Any() || !HitsBoundingBox(localRay))
            {
                return(new IntersectionCollection());
            }

            var xs = Shapes
                     .SelectMany(shape => shape.Intersect(localRay).Intersections)
                     .OrderBy(intersection => intersection.T);

            return(new IntersectionCollection(xs));
        }
Exemplo n.º 3
0
        private void SyncBrushesWithShapes()
        {
            if (_context?.Factory == null || Shapes == null)
            {
                return;
            }

            //add any missing brushes
            foreach (var instance in Shapes)
            {
                foreach (var color in instance.GetColorsToCache())
                {
                    if (!_brushResources.ContainsKey(color))
                    {
                        //color missing, add it
                        var solidBrush = new SolidColorBrush(_context, color.ToDirect2dColor());
                        _brushResources.Add(color, solidBrush);
                    }
                }
            }

            var colorsToDelete = new List <Wpf.Color>();

            //delete any brushes not in use anymore
            foreach (var color in _brushResources.Keys)
            {
                bool colorFound = Shapes.Any(instance => instance.GetColorsToCache().Contains(color));
                if (!colorFound)
                {
                    colorsToDelete.Add(color);
                }
            }

            //remove brushes to be deleted
            foreach (var color in colorsToDelete)
            {
                var brush = _brushResources[color];
                _brushResources.Remove(color);
                brush.Dispose();
            }
        }
Exemplo n.º 4
0
 public override bool Contains(Shape other)
 {
     return(Shapes.Any(x => x.Contains(other)));
 }
Exemplo n.º 5
0
 private bool DoesShapesContainInitialNode()
 {
     return(Shapes.Any(shape => shape.Type == EShape.Initial));
 }
 public override bool Contains(IShape shape)
 {
     return(ReferenceEquals(shape, this) || Shapes.Any(s => s.Contains(shape)));
 }
Exemplo n.º 7
0
 private void UpdateUndoRedo()
 {
     CanUndo = Shapes.Any();
     CanRedo = _undoneShapes.Any();
 }
Exemplo n.º 8
0
 private bool CanGetPermiter(object param)
 {
     return(Shapes.Any());
 }
Exemplo n.º 9
0
 bool IResourceProvider.ContainsResource(string resourceName)
 {
     return(Shapes.Any(s => s.Name == resourceName) || Animations.Any(a => a.Name == resourceName));
 }