Exemplo n.º 1
0
        private void CreateBarriers()
        {
            var left = 10.0;

            for (int i = 0; i < 3; i++)
            {
                var barrier = new CustomShape();
                barrier.shape        = new Rectangle();
                barrier.shape.Width  = 100;
                barrier.shape.Height = 50;
                barrier.Health       = 10;
                barrier.shape.Fill   = new ImageBrush(new BitmapImage(new Uri(barrierPath, UriKind.Relative)));
                barriers.Add(barrier);

                Canvas.SetTop(barrier.shape, canvas.ActualHeight - barrier.shape.Height * 2);
                if (i > 0)
                {
                    left = (barrier.Health * barrier.Health) * (i + i);
                }
                Canvas.SetLeft(barrier.shape, left);
                barrier.PositionX = Canvas.GetLeft(barrier.shape);
                barrier.PositionY = Canvas.GetTop(barrier.shape);
                canvas.Children.Add(barrier.shape);
            }
            barriersArray = barriers.ToArray();
        }
Exemplo n.º 2
0
        public GroupButton(CustomShape shape) : base(shape)
        {
            // add the amount of children this group has to the text.
            textBlock.Text += $" ({((Group)shape).GetChildren().Count})";

            // create 3 columns for this grid make the second one have the same width as the height of the grid
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(marginThickness)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(Height)
            });
            // initialize the text block.
            var arrowText = new TextBlock
            {
                // make the text an arrow.
                Text = ">",
                // assign the text colors.
                Background = new BrushConverter().ConvertFromString("#2ecc71") as SolidColorBrush,
                Foreground = Brushes.Black,
                // assign the alignment.
                HorizontalAlignment = HorizontalAlignment.Stretch,
                TextAlignment       = TextAlignment.Center,
                // set the font size equal to the font size of the text block.
                FontSize = textBlock.FontSize
            };

            arrowText.MouseLeftButtonDown += (a, b) => CommandManager.GetInstance().InvokeCommand(new SwitchGroupCommand(shape as Group));
            // set the text block to the third column
            SetColumn(arrowText, 2);
            // add the text block to the grid.
            Children.Add(arrowText);
        }
Exemplo n.º 3
0
        private void kUp(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Left:
                leftPressed = false;
                break;

            case Key.Right:
                rightPressed = false;
                break;

            case Key.Space:
                CustomShape bullet = new CustomShape();
                bullet.shape = new Rectangle();
                //player.Play();
                bullet.shape.Fill   = new ImageBrush(new BitmapImage(new Uri(bulletPath, UriKind.Relative)));
                bullet.Name         = "Bullet";
                bullet.shape.Width  = 10;
                bullet.shape.Height = 20;
                Canvas.SetTop(bullet.shape, canvas.ActualHeight - ship.shape.ActualHeight);
                Canvas.SetLeft(bullet.shape, Canvas.GetLeft(ship.shape) + (ship.shape.ActualWidth / 2.0));
                shipbullets.Add(bullet);
                bullet.PositionY = Canvas.GetTop(bullet.shape);
                bullet.PositionX = Canvas.GetLeft(bullet.shape);
                canvas.Children.Add(bullet.shape);
                bulletTimer.Start();
                break;
            }
        }
Exemplo n.º 4
0
        public static void practice15()
        {
            MyPaint paint = new MyPaint();

            Triangle t = new Triangle(3, 4, 5);

            paint.DrawShape(t);
            Console.WriteLine();

            Rectangle r = new Rectangle(5, 10);

            paint.DrawShape(r);
            Console.WriteLine();

            CustomShape cs = new CustomShape(5, 10, 2, 2);

            paint.DrawShape(cs);

            // Output
            //Draw Triangle(3,4,5)
            //Draw Triangle(3,4,5)
            //Draw Rectangle(5,10)
            //
            //Draw Triangle(3,4,5)
            //Draw Rectangle(5,10)
            //Draw CustomShape(5,10,2,2)
        }
Exemplo n.º 5
0
 public override void RemoveChild(CustomShape shape)
 {
     // remove the given shape.
     base.RemoveChild(shape);
     // remove or update the outline bases on if there are children in the group.
     ToggleOutline(GetChildren().Any());
 }
Exemplo n.º 6
0
        private static void shuffle_z()
        {
            float z_start = 5f;
            float z_end   = 100f;
            float z;

            if (uConsole.GetNumParameters() == 2)
            {
                z_start = uConsole.GetFloat();
                z_end   = uConsole.GetFloat();
            }
            for (var i = 0; i < SandboxSelectionSet.m_Items.Count; i++)
            {
                var         obj       = SandboxSelectionSet.m_Items[i];
                CustomShape component = obj.gameObject.GetComponent <CustomShape>();
                if (component != null)
                {
                    z = UnityEngine.Random.Range(z_start, z_end);
                    string  orig_pos = component.gameObject.transform.position.ToString();
                    Vector3 new_pos  = new Vector3(component.gameObject.transform.position.x, component.gameObject.transform.position.y, z);
                    component.gameObject.transform.position = new_pos;
                    uConsole.Log(orig_pos + " -> " + component.gameObject.transform.position.ToString());
                }
            }
        }
Exemplo n.º 7
0
        private void Initialize()
        {
            this.customShape = new CustomShape();
            this.customShape.CreateClosedShape(CreateInitialShape(5, 100, 60));

            RadListDataItem item = new RadListDataItem("CustomShape");

            item.Value = typeof(CustomShape);
            this.radDropDownListShapes.Items.Add(item);
            item       = new RadListDataItem("RoundRectShape");
            item.Value = typeof(RoundRectShape);
            this.radDropDownListShapes.Items.Add(item);
            item       = new RadListDataItem("EllipseShape");
            item.Value = typeof(EllipseShape);
            this.radDropDownListShapes.Items.Add(item);
            item       = new RadListDataItem("DonutShape");
            item.Value = typeof(DonutShape);
            this.radDropDownListShapes.Items.Add(item);
            this.radDropDownListShapes.SelectedIndex = 0;

            this.radDropDownListShapes.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(radDropDownListShapes_SelectedIndexChanged);
            this.radDropDownListSeries.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(radDropDownListSeries_SelectedIndexChanged);

            for (int i = 0; i < this.radChartView1.Series.Count; i++)
            {
                item       = new RadListDataItem("Series " + (i + 1));
                item.Value = this.radChartView1.Series[i];
                this.radDropDownListSeries.Items.Add(item);
            }

            this.radDropDownListSeries.SelectedIndex = 0;
            this.radDropDownListShapes.SelectedIndex = 2;

            this.radSpinEditorPointRadius.Value = (decimal)this.radChartView1.Series[0].PointSize.Width;
        }
Exemplo n.º 8
0
        public void AddToHierarchy(CustomShape shape)
        {
            currentGroup.AddChild(shape);

            shape.SetActive(true);

            Refresh();
        }
Exemplo n.º 9
0
        public void RemoveFromHierarchy(CustomShape shape)
        {
            currentGroup.RemoveChild(shape);

            shape.SetActive(false);

            Refresh();
        }
Exemplo n.º 10
0
        public string Visit(CustomShape shape)
        {
            // Move the shape based on their origin transform plus an offset.
            shape.Move(offset);
            // update the origin transform
            shape.UpdateOriginTransform();

            return("");
        }
Exemplo n.º 11
0
 private void BoundingBoxColoringHelper(ref CustomShape shape)
 {
     shape.Visible       = false;
     shape.Ambient       = new Color4(1f, 0.0f, 0.0f, 0.5f);
     shape.Diffuse       = new Color4(1f, 0.0f, 0.0f, 0.5f);
     shape.Emission      = new Color4(1f, 0.0f, 0.0f, 0.5f);
     shape.Specular      = new Color4(0.0f, 0.0f, 0.0f, 1f);
     shape.CullBackFaces = false;
 }
Exemplo n.º 12
0
 private void radButtonEditShape_Click(object sender, EventArgs e)
 {
     if (this.radDropDownListShapes.SelectedIndex == 0)
     {
         CustomShapeEditorForm editor = new CustomShapeEditorForm();
         this.customShape = editor.EditShape(this.customShape);
         this.ApplyShapeToPoints(this.customShape);
     }
 }
Exemplo n.º 13
0
        public void Circle_Click(object sender, RoutedEventArgs e)
        {
            var ellipse = new CustomShape(ShapeType.Ellipse).Shape;

            ellipse.Uid = Guid.NewGuid().ToString();
            MainWindow.ShapeList.Add(ellipse);

            MainWindow.canvas.Children.Add(ellipse);
        }
Exemplo n.º 14
0
        public void AddRandomCustomShape()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            CustomShape polygon = new CustomShape(new Rectangle(x, y, 100, 200));

            Shapes.Add(polygon);
        }
Exemplo n.º 15
0
        public void Rectangle_Click(object sender, RoutedEventArgs e)
        {
            var rectangle = new CustomShape(ShapeType.Rectangle).Shape;

            rectangle.Uid = Guid.NewGuid().ToString();

            MainWindow.ShapeList.Add(rectangle);

            MainWindow.canvas.Children.Add(rectangle);
        }
Exemplo n.º 16
0
        public void Triangle_Click(object sender, RoutedEventArgs e)
        {
            var polygon = new CustomShape(ShapeType.Polygon).Shape;

            polygon.Uid = Guid.NewGuid().ToString();

            MainWindow.ShapeList.Add(polygon);

            MainWindow.canvas.Children.Add(polygon);
        }
Exemplo n.º 17
0
        internal static CustomShape GetArrow(int angle)
        {
            CustomShape arrow = new CustomShape(Common.GetArrow(20, 20, 1, angle));

            arrow.SetBackground(Common.Neitral);
            arrow.SetMinSize(8, 15);
            arrow.SetMaxSize(8, 15);
            arrow.SetSizePolicy(SizePolicy.Expand, SizePolicy.Expand);
            arrow.SetAlignment(ItemAlignment.VCenter | ItemAlignment.HCenter);
            return(arrow);
        }
Exemplo n.º 18
0
        public void CalculateTotalArea_CustomShapes_ReturnsSumOfAreas()
        {
            var shape1 = new CustomShape(10);
            var shape2 = new CustomShape(20);

            IShape[] shapes = { shape1, shape2 };

            var expectedArea = shape1.CalculateArea() + shape2.CalculateArea();

            Assert.That(shapes.CalculateTotalArea(), Is.EqualTo(expectedArea).Within(0.00000001));
        }
Exemplo n.º 19
0
 public List <Point> Draw(CustomShape shape)
 {
     return(new List <Point>
     {
         new Point(0, 0),
         new Point(1, 0),
         new Point(1, 1),
         new Point(0, 1),
     }
            .Select(i => new Point(i.X * shape.Width - shape.StrokeThickness, i.Y * shape.Height - shape.StrokeThickness)).ToList());
 }
Exemplo n.º 20
0
        private ElementShape GetShape()
        {
            List <PointF> points = new List <PointF>()
            {
                new PointF(0, 30), new PointF(10, 0), new PointF(200, 0), new PointF(200, 30)
            };
            CustomShape shape = new CustomShape();

            shape.CreateClosedShape(points);
            return(shape);
        }
Exemplo n.º 21
0
        public Form1()
        {
            InitializeComponent();

            this.EnabledQSFButtons = ~QSFButtons.ChangeTheme;
            this.customShape1      = new CustomShape();
            customShape1.CreateClosedShape(CreateInitialShape(5, 100, 60));
            SetTheme();
            SetShapes();
            this.SelectedControl = this.radRadioCustShape;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a shape relative to actual points.
        /// </summary>
        /// <returns>New Shape.</returns>
        virtual protected IShape CreateDrawingShape(PointF point)
        {
            if (_points.Count == 0)
            {
                //Ellipse el = new Ellipse();
                //el.Center = point;
                //el.Dimension = new SizeF(2, 2);
                ////el.Dimension.Width = 2;
                ////el.Dimension.Height = 2;
                //_shape = new Sbn.AdvancedControls.Imaging.SbnPaint.Ellipse(el);

                // return null;
                _points.Add(point);
                _points.Add(new PointF(point.X + 1, point.Y + 1));
            }

            _shape = new CustomShape();  //added by rm


            Pen pen = new Pen(this.Color, this.WidthPen);

            pen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
            pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            _shape.Appearance.ActivePen = pen;

            if (_points.Count == 2)
            {
                _shape.Geometric.AddLines(ToPointF(_points));

                //                Line ln = new Line(_points[0], _points[1]);
                //                ln.Appearance.ActivePen = pen;

                //                _shape = new Sbn.AdvancedControls.Imaging.SbnPaint.Line(ln); cmd by ghmhm
            }
            else
            if (_points.Count != 0)
            {
                _shape.Geometric.AddLines(ToPointF(_points));
            }
            else
            {
                return(null);
            }

            IShape shape = _shape.Clone() as IShape;

            pen.Dispose();

            // shape.Selected = true;  //Commented by rm
            shape.Selected = false;   //added by rm
            // shape.Locked = true;      //added by rm

            return(shape);
        }
Exemplo n.º 23
0
        private void radButtonCreate_Click(object sender, EventArgs e)
        {
            CustomShapeEditorForm shapeEditor = new CustomShapeEditorForm();
            CustomShape           s           = shapeEditor.CreateShape();

            if (s != null)
            {
                this.shapedForm.Controls.Clear();
                this.shapedForm.Shape = s;
            }

            this.shapedForm.Invalidate();
        }
Exemplo n.º 24
0
        public StopDrawCommand()
        {
            // assign the shape of this command with the drawn shape.
            shape = m.shapeDrawn;
            // remove the drawn_shape from the canvas.
            //m.drawCanvas.Children.Remove(shape);
            shape.SetActive(false);
            // if any dimension is lower than the min size the it to the min size.
            shape.Width  = shape.Width < MinSize ? MinSize : shape.Width;
            shape.Height = shape.Height < MinSize ? MinSize : shape.Height;

            m.shapeDrawn = null;
        }
Exemplo n.º 25
0
        private void enemyAttack(object sender, EventArgs e)
        {
            double             canvaswidth      = Math.Round(canvas.ActualWidth);
            List <CustomShape> AvailableEnemies = new List <CustomShape>();

            var enemyCount = enemies.Count;

            if (enemyCount > 0)
            {
                var LastEnemy = enemies[enemyCount - 1];
                for (int i = enemyCount - 1; i >= 0; i--)
                {
                    if (enemies[i].PositionY >= LastEnemy.PositionY)
                    {
                        var CurrentEnemy = enemies[i];
                        if (CurrentEnemy.shape.ActualHeight >= LastEnemy.shape.ActualHeight)
                        {
                            AvailableEnemies.Add(CurrentEnemy);
                        }
                    }
                }
                if (AvailableEnemies.Count != 0)
                {
                    var         ChosenEnemyToFire = AvailableEnemies[randomNumber.Next(0, AvailableEnemies.Count - 1)];
                    CustomShape enemybullet       = new CustomShape();
                    enemybullet.shape        = new Rectangle();
                    enemybullet.shape.Fill   = new ImageBrush(new BitmapImage(new Uri(bulletPath, UriKind.Relative)));
                    enemybullet.Name         = "EnemyBullet";
                    enemybullet.shape.Width  = 5;
                    enemybullet.shape.Height = 10;
                    Canvas.SetTop(enemybullet.shape, ChosenEnemyToFire.PositionY);
                    Canvas.SetLeft(enemybullet.shape, Canvas.GetLeft(ChosenEnemyToFire.shape) + (ChosenEnemyToFire.shape.ActualWidth / 2.0));
                    enemybullets.Add(enemybullet);
                    enemybullet.PositionY = Canvas.GetTop(enemybullet.shape);
                    enemybullet.PositionX = Canvas.GetLeft(enemybullet.shape);
                    canvas.Children.Add(enemybullet.shape);
                    enemyBulletTimer.Start();
                    if (delay > 500)
                    {
                        delay -= 50;
                    }
                    else
                    {
                        delay = 500;
                    }
                    enemyAttackTimer.Interval = TimeSpan.FromMilliseconds(delay);
                }
            }
        }
Exemplo n.º 26
0
        public sealed override void Initialize()
        {
            Handler     = GameObject.GetComponent <GUIHandler>(GameObjectComponentSearchMode.ParentalHierarchy);
            RenderLayer = -1;

            this.interactionGraphics = new GUIInteractionColors();

            this.shape = new CustomShape(Render);

            InteractionState = GUIComponentInteractionState.None;

            Width  = 1;
            Height = 1;

            AdditionalInitialize();
        }
Exemplo n.º 27
0
        private static void set_z()
        {
            float z = uConsole.GetFloat();

            for (var i = 0; i < SandboxSelectionSet.m_Items.Count; i++)
            {
                var         obj       = SandboxSelectionSet.m_Items[i];
                CustomShape component = obj.gameObject.GetComponent <CustomShape>();
                if (component != null)
                {
                    string  orig_pos = component.gameObject.transform.position.ToString();
                    Vector3 new_pos  = new Vector3(component.gameObject.transform.position.x, component.gameObject.transform.position.y, z);
                    component.gameObject.transform.position = new_pos;
                    uConsole.Log(orig_pos + " -> " + component.gameObject.transform.position.ToString());
                }
            }
        }
Exemplo n.º 28
0
        public OrnamentDecorator(CustomShape shape, string left, string right, string top, string bottom) : base(shape)
        {
            ornaments = new TextBox[4];

            ornaments[0] = new TextBox {
                Foreground = Brushes.Black, FontSize = 20, BorderThickness = new Thickness(0), Background = Brushes.LightGray, Text = left
            };
            ornaments[1] = new TextBox {
                Foreground = Brushes.Black, FontSize = 20, BorderThickness = new Thickness(0), Background = Brushes.LightGray, Text = right
            };
            ornaments[2] = new TextBox {
                Foreground = Brushes.Black, FontSize = 20, BorderThickness = new Thickness(0), Background = Brushes.LightGray, Text = top
            };
            ornaments[3] = new TextBox {
                Foreground = Brushes.Black, FontSize = 20, BorderThickness = new Thickness(0), Background = Brushes.LightGray, Text = bottom
            };
        }
Exemplo n.º 29
0
 public List <Point> Draw(CustomShape shape)
 {
     return(new List <Point>
     {
         new Point(.5f, 0),
         new Point(.625f, .4f),
         new Point(1, .4f),
         new Point(.69f, .625f),
         new Point(.8f, 1),
         new Point(.5f, .775f),
         new Point(.2f, 1),
         new Point(.31f, .625f),
         new Point(0, .4f),
         new Point(.375f, .4f),
     }
            .Select(i => new Point(i.X * shape.Width - shape.StrokeThickness, i.Y * shape.Height - shape.StrokeThickness)).ToList());
 }
Exemplo n.º 30
0
        public List <Point> Draw(CustomShape shape)
        {
            // initialize the coordinates.
            var coords = new List <Point>();
            // calculate the radius.
            var xRadius = (shape.Width * .5);
            var yRadius = (shape.Height * .5);

            for (var i = 0; i < 65; i++)
            {
                // calculate the next coordinate.
                var x = xRadius + -Math.Cos(i * .1) * xRadius - shape.StrokeThickness;
                var y = yRadius + Math.Sin(i * .1) * yRadius - shape.StrokeThickness;
                // add it to the coordinates list.
                coords.Add(new Point(x, y));
            }

            return(coords);
        }