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(); }
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); }
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; } }
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) }
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()); }
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()); } } }
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; }
public void AddToHierarchy(CustomShape shape) { currentGroup.AddChild(shape); shape.SetActive(true); Refresh(); }
public void RemoveFromHierarchy(CustomShape shape) { currentGroup.RemoveChild(shape); shape.SetActive(false); Refresh(); }
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(""); }
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; }
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); } }
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); }
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); }
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); }
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); }
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); }
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)); }
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()); }
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); }
public Form1() { InitializeComponent(); this.EnabledQSFButtons = ~QSFButtons.ChangeTheme; this.customShape1 = new CustomShape(); customShape1.CreateClosedShape(CreateInitialShape(5, 100, 60)); SetTheme(); SetShapes(); this.SelectedControl = this.radRadioCustShape; }
/// <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); }
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(); }
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; }
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); } } }
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(); }
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()); } } }
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 }; }
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()); }
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); }