Exemple #1
0
 private void removeChildren(DesignPatternCL.Models.Shapes.Shape _Container)
 {
     canvas.Children.Remove(_Container.SystemShape);
     if (_Container.GetType() == ShapeFactory.ShapeType.Rectangle)
     {
         foreach (var rect in ((DesignPatternCL.Models.Shapes.Rectangle)_Container).Shapes)
         {
             removeChildren(rect);
         }
     }
 }
Exemple #2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Citation                     = new Citation(ActionFactory.Build(ActionFactory.ActionType.Music));
     Container                    = ShapeFactory.Build(ShapeFactory.ShapeType.Rectangle, ActionFactory.Build(ActionFactory.ActionType.Music), Citation);
     Container.SystemShape        = CreateRectangle(Colors.White, canvas.ActualHeight, canvas.ActualWidth);
     Container.SystemShape.Width  = 3000;
     Container.SystemShape.Height = 2000;
     canvas.Children.Add(Container.SystemShape);
     dict.Add(Container.SystemShape, new Tuple <DesignPatternCL.Models.Shapes.Shape, DesignPatternCL.Models.Shapes.Shape>(null, Container));
     SelectedShape            = Container.SystemShape;
     SelectedShapeSize.Height = SelectedShape.Height;
     SelectedShapeSize.Width  = SelectedShape.Width;
 }
Exemple #3
0
 private DesignPatternCL.Models.Shapes.Shape GetModelFromShape(DesignPatternCL.Models.Shapes.Shape _Container, Shape shape)
 {
     if (shape.GetHashCode() == _Container.SystemShape.GetHashCode())
     {
         return(_Container);
     }
     else if (_Container is DesignPatternCL.Models.Shapes.Rectangle)
     {
         foreach (var s in ((DesignPatternCL.Models.Shapes.Rectangle)_Container).Shapes)
         {
             return(GetModelFromShape(s, shape));
         }
     }
     return(null);
 }
Exemple #4
0
 private void Draw(DesignPatternCL.Models.Shapes.Shape container)
 {
     canvas.Children.Add(container.SystemShape);
     try
     {
         if (container.GetType() == ShapeFactory.ShapeType.Rectangle)
         {
             foreach (var shape in ((DesignPatternCL.Models.Shapes.Rectangle)container).Shapes)
             {
                 Draw(shape);
             }
         }
     }
     catch
     {
     }
 }
Exemple #5
0
        private void AddShapeBtn_Click(object sender, RoutedEventArgs e)
        {
            DesignPatternCL.Models.Shapes.Shape shape = null;
            switch (Shapes[ShapesCombobox.SelectedIndex])
            {
            case ShapeFactory.ShapeType.Rectangle:
                shape             = ShapeFactory.Build(ShapeFactory.ShapeType.Rectangle, Container.Action, Citation);
                shape.SystemShape = CreateRectangle(Color.FromRgb(Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255))));
                break;

            case ShapeFactory.ShapeType.Circle:
                shape             = ShapeFactory.Build(ShapeFactory.ShapeType.Circle, Container.Action, Citation);
                shape.SystemShape = CreateEllipse(Color.FromRgb(Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255))));
                break;

            case ShapeFactory.ShapeType.Square:
                shape             = ShapeFactory.Build(ShapeFactory.ShapeType.Square, Container.Action, Citation);
                shape.SystemShape = CreateSquare(Color.FromRgb(Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255))));
                break;

            default:
                shape             = ShapeFactory.Build(ShapeFactory.ShapeType.Square, Container.Action, Citation);
                shape.SystemShape = CreateSquare(Color.FromRgb(Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255)), Convert.ToByte(rand.Next(255))));
                break;
            }
            var s = dict[SelectedShape];

            if (s != null && s.Item2.GetType() == ShapeFactory.ShapeType.Rectangle)
            {
                ((DesignPatternCL.Models.Shapes.Rectangle)s.Item2).Shapes.Add(shape);
                canvas.Children.Add(shape.SystemShape);
                Details.Text = Container.Details();
                dict.Add(shape.SystemShape, new Tuple <DesignPatternCL.Models.Shapes.Shape, DesignPatternCL.Models.Shapes.Shape>(s.Item2, shape));
            }
            else
            {
                MessageBox.Show($"We can't add shape to {s?.GetType().ToString()}");
            }
        }