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;
            }
        }
示例#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));
        }
示例#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();
            }
        }
示例#4
0
 public override bool Contains(Shape other)
 {
     return(Shapes.Any(x => x.Contains(other)));
 }
示例#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)));
 }
示例#7
0
 private void UpdateUndoRedo()
 {
     CanUndo = Shapes.Any();
     CanRedo = _undoneShapes.Any();
 }
 private bool CanGetPermiter(object param)
 {
     return(Shapes.Any());
 }
示例#9
0
 bool IResourceProvider.ContainsResource(string resourceName)
 {
     return(Shapes.Any(s => s.Name == resourceName) || Animations.Any(a => a.Name == resourceName));
 }