public void TestSettingFillColor() { Shape shape = new MyShape(); shape.FillColor = Color.AliceBlue; Assert.AreEqual(Color.AliceBlue, shape.FillColor); }
public void ChangeShapeMethod(MyShape shape) { int index = MyCanvas.Children.IndexOf(shape.Shape); MyCanvas.Children.RemoveAt(index); MyCanvas.Children.Insert(index, shape.Shape); }
public void TestSettingFillColor() { Shape shape = new MyShape(); shape.FillColor = new SolidColorBrush(Colors.AliceBlue); Assert.AreEqual(Colors.AliceBlue, shape.FillColor.Color); }
private static ulong UpdateVoxelShape(MySyncVoxel sync, PaintType type, MyShape Shape, byte Material) { var voxel = sync.Entity as MyVoxelBase; ulong changedVoxelAmount = 0; if (voxel != null) { switch (type) { case PaintType.Paint: MyVoxelGenerator.PaintInShape(voxel, Shape, Material); break; case PaintType.Fill: changedVoxelAmount = MyVoxelGenerator.FillInShape(voxel, Shape, Material); break; case PaintType.Cut: changedVoxelAmount = MyVoxelGenerator.CutOutShape(voxel, Shape); break; } } return(changedVoxelAmount); }
public override void AddShapes() { //必须重新设置元件大小 size.X = 60; size.Y = 20; //定义外部接口的位置 RelativeInterface.Add(new IntPoint(0, 10)); //左端口 RelativeInterface.Add(new IntPoint(100, 10)); //右端口 //左边的导线 MyShape line1 = new MyShape(MyShape.Shape_Line); line1.GetLine().Stroke = System.Windows.Media.Brushes.Red; line1.GetLine().X1 = 0; line1.GetLine().Y1 = 10; line1.GetLine().X2 = 30; line1.GetLine().Y2 = 10; line1.GetLine().StrokeThickness = 5; shapeSet.AddShape(line1); //中间的长方形 MyShape rectangle = new MyShape(MyShape.Shape_Rectangle); rectangle.GetRectangle().Fill = System.Windows.Media.Brushes.Black; rectangle.GetRectangle().Width = 40; rectangle.GetRectangle().Height = 20; Canvas.SetLeft(rectangle.GetRectangle(), 30); Canvas.SetTop(rectangle.GetRectangle(), 0); shapeSet.AddShape(rectangle); //右边的导线 MyShape line2 = new MyShape(MyShape.Shape_Line); line2.GetLine().Stroke = System.Windows.Media.Brushes.Red; line2.GetLine().X1 = 70; line2.GetLine().Y1 = 10; line2.GetLine().X2 = 100; line2.GetLine().Y2 = 10; line2.GetLine().StrokeThickness = 5; shapeSet.AddShape(line2); //左边的定位圆圈 MyShape circle1 = new MyShape(MyShape.Shape_Ellipse); circle1.GetEllipse().Fill = System.Windows.Media.Brushes.Red; circle1.GetEllipse().StrokeThickness = 3; circle1.GetEllipse().Stroke = System.Windows.Media.Brushes.Yellow; circle1.GetEllipse().Width = 10; circle1.GetEllipse().Height = 10; Canvas.SetLeft(circle1.GetEllipse(), -5); Canvas.SetTop(circle1.GetEllipse(), 5); shapeSet.AddShape(circle1); //右边的定位圆圈 MyShape circle2 = new MyShape(MyShape.Shape_Ellipse); circle2.GetEllipse().Fill = System.Windows.Media.Brushes.Red; circle2.GetEllipse().StrokeThickness = 3; circle2.GetEllipse().Stroke = System.Windows.Media.Brushes.Yellow; circle2.GetEllipse().Width = 10; circle2.GetEllipse().Height = 10; Canvas.SetLeft(circle2.GetEllipse(), 95); Canvas.SetTop(circle2.GetEllipse(), 5); shapeSet.AddShape(circle2); }
public Node(Graph graph, int width, int height, MyShape shape, MyPoint position) { this.Graph = graph; this.Width = width; this.Height = height; this.Shape = shape; this.Position = position; UIBorder = new Border { Width = Width + 2, Height = Height + 2 }; UICanvas = new Canvas(); Grid UIGrid = new Grid(); UIGrid.Children.Add(UICanvas); UIBorder.Child = UIGrid; LabelTextBlock = new TextBlock { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, TextAlignment = TextAlignment.Center, IsHitTestVisible = false }; UIGrid.Children.Add(LabelTextBlock); this.Label = "Label"; this.FontSize = 16; this.ForeGroundColor = Colors.Black; this.IsFontBold = false; this.IsFontItalic = false; this.FontDecoration = FontDecoration.None; edges = new List <Edge>(); NodeConnections = new List <NodeConnection>(); foreach (MyPoint p in shape.ConnectionPoints) { new NodeConnection(p, this); } BackgroundColor = Color.FromArgb(255, 31, 73, 125); BackgroundColorStyle = BackgroundColorStyle.Radial; Position.Changed += onPositionChanged; Properties = new List <string>(); this.ZIndex = 0; initialDraw(); ResizeConnector = new ResizeConnector(this); updateResizeConnector(); }
public override object Clone() { MyShape myShape = new MyShape(); myShape.Size = Size; Shape shape = (Shape)(Content as Grid).Children[0]; // string typeName = shape.GetType().UnderlyingSystemType.Name; string typeName = shape.GetType().Name; if (typeName.Equals("Rectangle")) { Rectangle rectangleClone = new Rectangle() { Stroke = shape.Stroke, StrokeThickness = shape.StrokeThickness, Fill = shape.Fill }; (myShape.Content as Grid).Children.Add(rectangleClone); return(myShape); } else { Ellipse ellipseClone = new Ellipse() { Stroke = shape.Stroke, StrokeThickness = shape.StrokeThickness, Fill = shape.Fill }; (myShape.Content as Grid).Children.Add(ellipseClone); return(myShape); } }
public void changeScore(int delta, MyShape shape) { if (shape is RedCircle) { ++redCircles; txtRedCircles.Text = redCircles.ToString(); } else if (shape is RedSquare) { ++redSquares; txtRedSquares.Text = redSquares.ToString(); } else if (shape is GreenCircle) { ++greenCircles; txtGreenCircles.Text = greenCircles.ToString(); } else { ++greenSquares; txtGreenSquares.Text = greenSquares.ToString(); } score += delta; txtScore.Text = score.ToString(); }
public StyleButton(MainWindow owner, Color backgroundColor, BackgroundColorStyle backgroundStyle, Color foregroundColor) { this.backgroundColor = backgroundColor; this.backgroundStyle = backgroundStyle; this.foregroundColor = foregroundColor; this.owner = owner; this.Background = Brushes.White; this.Width = 40; this.Height = 40; this.Margin = new System.Windows.Thickness(2); this.Focusable = false; Canvas canvas = new Canvas(); this.Content = canvas; this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; this.VerticalContentAlignment = System.Windows.VerticalAlignment.Top; MyShape shape = ShapeFactory.CreateFlowchartSymbol9(); shape.Draw(28, 28, new MyPoint(0, 0), Statics.CreateBackgroundBrush(backgroundColor, backgroundStyle), OnMouseDown, canvas); TextBlock textBlock = new TextBlock(); textBlock.Foreground = new SolidColorBrush(foregroundColor); textBlock.Text = "A"; textBlock.IsHitTestVisible = false; textBlock.Margin = new System.Windows.Thickness(10, 5, 0, 0); canvas.Children.Add(textBlock); this.Click += OnClick; }
public void TestSettingBorderColor() { Shape shape = new MyShape(); shape.BorderColor = Colors.AliceBlue; Assert.AreEqual(Colors.AliceBlue, shape.BorderColor); }
public override void AddShapes() { Comp = Comp_Probe; //(已废弃)size.X = 40; //size.Y = 30; RelativeInterface.Add(new IntPoint(-1024, -1024)); //Ground RelativeInterface.Add(new IntPoint(20, 0)); //右端口 //@d 探针的形状,到本函数结束可重写 //直线 MyShape line0 = new MyShape(MyShape.Shape_Line); line0.GetLine().Stroke = System.Windows.Media.Brushes.Black; line0.GetLine().X1 = 20; line0.GetLine().Y1 = 5; line0.GetLine().X2 = 20; line0.GetLine().Y2 = 15; line0.GetLine().StrokeThickness = 5; shapeSet.AddShape(line0); //定位圆圈 MyShape circle1 = new MyShape(MyShape.Shape_Ellipse); circle1.GetEllipse().Fill = System.Windows.Media.Brushes.Red; circle1.GetEllipse().StrokeThickness = 3; circle1.GetEllipse().Stroke = System.Windows.Media.Brushes.Yellow; circle1.GetEllipse().Width = 10; circle1.GetEllipse().Height = 10; Canvas.SetLeft(circle1.GetEllipse(), 15); Canvas.SetTop(circle1.GetEllipse(), -5); shapeSet.AddShape(circle1); //直线 MyShape line1 = new MyShape(MyShape.Shape_Line); line1.GetLine().Stroke = probeColor; line1.GetLine().X1 = 0; line1.GetLine().Y1 = 15; line1.GetLine().X2 = 40; line1.GetLine().Y2 = 15; line1.GetLine().StrokeThickness = 3; shapeSet.AddShape(line1); //直线 MyShape line2 = new MyShape(MyShape.Shape_Line); line2.GetLine().Stroke = probeColor; line2.GetLine().X1 = 7; line2.GetLine().Y1 = 21; line2.GetLine().X2 = 33; line2.GetLine().Y2 = 21; line2.GetLine().StrokeThickness = 3; shapeSet.AddShape(line2); //直线 MyShape line3 = new MyShape(MyShape.Shape_Line); line3.GetLine().Stroke = probeColor; line3.GetLine().X1 = 14; line3.GetLine().Y1 = 27; line3.GetLine().X2 = 26; line3.GetLine().Y2 = 27; line3.GetLine().StrokeThickness = 3; shapeSet.AddShape(line3); }
/* * Purpose: This function handle the actions that occur when the user releases the mouse button. * It removes the last temporary shape drawn from Canvas_MouseDown, and adds the final shape. * * Precondition: The mouse button has been released. * * Postcondition: The shape is drawn and added to the canvas. */ private void Canvas_MouseUp(object sender, MouseButtonEventArgs e) { if (e.ButtonState == MouseButtonState.Released) { m_shape.m_secondPoint = e.GetPosition(myCanvas); if (m_shape.m_instrument != MyShape.DrawingInstrument.PENC) { if (myCanvas.Children.Count != 0) { myCanvas.Children.RemoveAt(myCanvas.Children.Count - 1); } drawShape(m_shape); shapes.Add(m_shape); m_shape = new MyShape(m_shape.m_instrument, m_shape.m_borderColor, m_shape.m_fillColor, m_shape.m_fillSelected, m_shape.m_firstPoint, m_shape.m_secondPoint, m_shape.m_thickness); } else { if (myCanvas.Children.Count != 0) { myCanvas.Children.RemoveAt(myCanvas.Children.Count - 1); } drawShape(m_shape); m_shape.m_pc.Add(e.GetPosition(myCanvas)); shapes.Add(m_shape); m_shape = new MyShape(m_shape.m_instrument, m_shape.m_borderColor, m_shape.m_fillColor, m_shape.m_fillSelected, m_shape.m_firstPoint, m_shape.m_secondPoint, m_shape.m_thickness); } } }
private void PolylineButton_Click(object sender, RoutedEventArgs e) { selectedShape = MyShape.Polyline; selectedDrawMode = DrawMode.Shapes; ClearSelectedTools(); ClearSelectedShapes(((MenuItem)sender).Name); }
void UndoClearAction() { while (TransferClass.ClearShape.Count != 0) { MyShape temp = TransferClass.ClearShape.Pop(); MyCanvas.Children.Add(temp.Draw()); TransferClass.ActiveShape.Push(temp); } }
public IEnumerable <MyEnvironmentSector> GetSectorsInRange(MyShape shape) { var bb = shape.GetWorldBoundaries(); var hierarchyComp = Container.Get <MyHierarchyComponentBase>() as MyHierarchyComponent <MyEntity>; var entities = new List <MyEntity>(); hierarchyComp.QueryAABB(ref bb, entities); return(entities.Cast <MyEnvironmentSector>()); }
private void btnRedo_Click(object sender, RoutedEventArgs e) { if (TransferClass.Undo.Count == 0) { return; } MyShape shape = TransferClass.Undo.Pop(); MyCanvas.Children.Add(shape.Draw()); TransferClass.ActiveShape.Push(shape); }
void AddShapeOnCanvas() { MyShape shape = TransferClass.NewShape; if (shape == null) { return; } TransferClass.ActiveShape.Push(shape); MyCanvas.Children.Add(shape.Draw()); }
void lineButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { Worksheet sheet = _excel.ActiveSheet; if (sheet.Selections.Count == 0) { return; } CellRange cr = sheet.Selections[0]; double X = 0d, Y = 0d; double width = 0d; double height = 0d; for (int i = 0; i < cr.Row; i++) { Y += sheet.GetRowHeight(i); } for (int i = 0; i < cr.Column; i++) { X += sheet.GetColumnWidth(i); } for (int i = 0; i < cr.RowCount; i++) { height += sheet.GetRowHeight(cr.Row + i); } for (int i = 0; i < cr.ColumnCount; i++) { width += sheet.GetColumnWidth(cr.Column + i); } if (myRectangle != null) { sheet.FloatingObjects.Remove(myRectangle); myRectangle = null; } myRectangle = new MyShape("selRec", X, 0, 3, 500); Rectangle rectangle = new Rectangle() { Fill = new SolidColorBrush(Colors.Transparent), StrokeThickness = 1, Stroke = new SolidColorBrush(Colors.Black), }; (myRectangle.Content as Grid).Children.Add(rectangle); sheet.FloatingObjects.Add(myRectangle); myRectangle.CanPrint = false; myRectangle.DynamicMove = false; myRectangle.DynamicSize = false; }
void AddEllipse(Point point, Color fillColor) { MyShape myShape = new MyShape("Ellipse" + ellipseCount, point.X, point.Y, 200, 200); Ellipse ellipse = new Ellipse() { Fill = new SolidColorBrush(fillColor), StrokeThickness = 4, Stroke = new SolidColorBrush(Colors.Black), }; (myShape.Content as Grid).Children.Add(ellipse); _excel.ActiveSheet.FloatingObjects.Add(myShape); ellipseCount++; }
void AddRectangle(Point point, Color fillColor) { MyShape myShape = new MyShape("Rectuangle" + rectangleCount, point.X, point.Y, 200, 200); Rectangle rectangle = new Rectangle() { Fill = new SolidColorBrush(fillColor), StrokeThickness = 4, Stroke = new SolidColorBrush(Colors.Black), }; (myShape.Content as Grid).Children.Add(rectangle); _excel.ActiveSheet.FloatingObjects.Add(myShape); rectangleCount++; }
public ChangePropertiesWindow(MyShape shape, MyShapeEnum myShapeEnum) { imgPath = ""; InitializeComponent(); cbBorder.ItemsSource = typeof(Colors).GetProperties(); cbFill.ItemsSource = typeof(Colors).GetProperties(); AllButons = new List <Button>() { btnCancel, btnDraw, btnFindImage }; this.myShapeEnum = myShapeEnum; ShapeToChange = shape; ChooseTitle(); ChoseWindowsElelment(); }
private void btnUndo_Click(object sender, RoutedEventArgs e) { if (TransferClass.ClearShape.Count != 0) { UndoClearAction(); return; } if (TransferClass.ActiveShape.Count == 0) { return; } MyShape shape = TransferClass.ActiveShape.Pop(); MyCanvas.Children.RemoveAt(MyCanvas.Children.Count - 1); TransferClass.Undo.Push(shape); }
protected void InitiateWireBetween(IntPoint A, IntPoint B) { //左边的导线 MyShape line1 = new MyShape(MyShape.Shape_Line); line1.GetLine().Stroke = System.Windows.Media.Brushes.Blue; line1.GetLine().X1 = A.X; line1.GetLine().Y1 = A.Y; line1.GetLine().X2 = 0; line1.GetLine().Y2 = 0; line1.GetLine().StrokeThickness = 5; shapeSet.AddShape(line1); //右边的导线 MyShape line2 = new MyShape(MyShape.Shape_Line); line2.GetLine().Stroke = System.Windows.Media.Brushes.Blue; line2.GetLine().X1 = 0; line2.GetLine().Y1 = 0; line2.GetLine().X2 = B.X; line2.GetLine().Y2 = B.Y; line2.GetLine().StrokeThickness = 5; shapeSet.AddShape(line2); //左边的定位圆圈 MyShape circle1 = new MyShape(MyShape.Shape_Ellipse); circle1.GetEllipse().Fill = System.Windows.Media.Brushes.Red; circle1.GetEllipse().StrokeThickness = 3; circle1.GetEllipse().Stroke = System.Windows.Media.Brushes.Yellow; circle1.GetEllipse().Width = 10; circle1.GetEllipse().Height = 10; Canvas.SetLeft(circle1.GetEllipse(), A.X - 5); Canvas.SetTop(circle1.GetEllipse(), A.Y - 5); shapeSet.AddShape(circle1); //右边的定位圆圈 MyShape circle2 = new MyShape(MyShape.Shape_Ellipse); circle2.GetEllipse().Fill = System.Windows.Media.Brushes.Red; circle2.GetEllipse().StrokeThickness = 3; circle2.GetEllipse().Stroke = System.Windows.Media.Brushes.Yellow; circle2.GetEllipse().Width = 10; circle2.GetEllipse().Height = 10; Canvas.SetLeft(circle2.GetEllipse(), B.X - 5); Canvas.SetTop(circle2.GetEllipse(), B.Y - 5); shapeSet.AddShape(circle2); //按照折线标准绘图 DrawBetween(A, B); }
private void btnDraw_Click(object sender, RoutedEventArgs e) { MyShape RetVal = null; switch (ShapeToDraw) { case MyShapeEnum.Elipse: if (!(ValidateTexBox(tbxWidth) && ValidateTexBox(tboxHeight) && ValidateTexBox(tbBorderTh) && ValidateColor(cbBorder) && ValidateColor(cbFill))) { return; } RetVal = CreateEllipse(); break; case MyShapeEnum.Rectangle: if (!(ValidateTexBox(tbxWidth) && ValidateTexBox(tboxHeight) && ValidateTexBox(tbBorderTh) && ValidateColor(cbBorder) && ValidateColor(cbFill))) { return; } RetVal = CreateRectangle(); break; case MyShapeEnum.Image: if (!(ValidateTexBox(tbxWidth) && ValidateTexBox(tboxHeight) && ValidateImagePath(imgPath))) { return; } RetVal = CreateImage(); break; case MyShapeEnum.Polygon: if (!(ValidateColor(cbBorder) && ValidateColor(cbFill) && ValidateTexBox(tbBorderTh))) { return; } RetVal = Createpolygon(); break; } TransferClass.NewShape = RetVal; Close(); }
static void Main(string[] args) { Shape MyShape; try { Factory factory = new Factory(); Console.Write("请选择(输入对应字母):A.三角形,B.矩形,C.正方形,D.圆形\t"); char choice = (char)Console.Read(); switch (choice) { case 'A': MyShape = factory.CreateShape('A'); MyShape.GetTheShape(); break; case 'B': MyShape = factory.CreateShape('B'); MyShape.GetTheShape(); break; case 'C': MyShape = factory.CreateShape('C'); MyShape.GetTheShape(); break; case 'D': MyShape = factory.CreateShape('D'); MyShape.GetTheShape(); break; default: Console.WriteLine("输入有误"); break; } Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void _mapEntitiesHub_OnAreaReceived(AreaDto areaDto) { MyShape myShape = new() { Id = areaDto.Id, Name = areaDto.Name, IsClosed = areaDto.IsClosed }; MyShape firstShape = MyShapes.FirstOrDefault(s => s.Id == myShape.Id); if (firstShape is null) { MyShapes.Add(myShape); } else { firstShape.IsClosed = myShape.IsClosed; } }
static bool CanPlaceInArea(OperationType type, MyShape Shape) { if (type == OperationType.Fill) { m_foundElements.Clear(); BoundingBoxD box = Shape.GetWorldBoundaries(); MyEntities.GetElementsInBox(ref box, m_foundElements); foreach (var entity in m_foundElements) { if (IsForbiddenEntity(entity)) { if (entity.PositionComp.WorldAABB.Intersects(box)) { return(false); } } } } return(true); }
public Shape GetContour() { BitmapData data = im.LockBits(new Rectangle(0, 0, im.Width, im.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Shape shape = null; unsafe { MyImage img = new MyImage((uint *)data.Scan0.ToPointer(), im.Width, im.Height); MyImage img2; clone_image_N(img, &img2); binarize2(img2, true); closing(img2); MyShapeListElement *shapeList = null; real_contour_N(img2, &shapeList); if ((shapeList != null) && (shapeList->next != null)) { normalize_shape(&(shapeList->shape)); MyShape current = shapeList->shape; shape = new Shape(new Point(current.pos.X, current.pos.Y), current.scale, current.rot, current.index); MyContourPoint *curp = current.contour; while (curp->next != null) { shape.contour.Add(new Point(curp->pos.X, curp->pos.Y)); curp = curp->next; } } delete_shape_list_D(shapeList); delete_image_D(img2); } im.UnlockBits(data); if (shape != null) { return(shape); } else { return(null); } }
private ulong UpdateVoxelShape(OperationType type, MyShape shape, byte Material) { ulong changedVoxelAmount = 0; switch (type) { case OperationType.Paint: MyVoxelGenerator.PaintInShape(this, shape, Material); break; case OperationType.Fill: changedVoxelAmount = MyVoxelGenerator.FillInShape(this, shape, Material); break; case OperationType.Cut: changedVoxelAmount = MyVoxelGenerator.CutOutShape(this, shape); break; } return(changedVoxelAmount); }
static bool CanPlaceInArea(OperationType type, MyShape Shape) { if (type == OperationType.Fill) { m_foundElements.Clear(); BoundingBoxD box = Shape.GetWorldBoundaries(); MyEntities.GetElementsInBox(ref box, m_foundElements); foreach (var entity in m_foundElements) { if (IsForbiddenEntity(entity)) { if (entity.PositionComp.WorldAABB.Intersects(box)) { MyHud.Notifications.Add(MyNotificationSingletons.CopyPasteAsteoridObstructed); return(false); } } } } return(true); }
public static void Main() { Shape[] s = new Shape[3]; MyShape s2 = new MyShape(3); int r, l, b; Console.WriteLine("Enter the radius for circle : "); r=int.Parse(Console.ReadLine()); s[0] = new Circle(r); Console.WriteLine("Enter the length & breadth for rectangle :"); l=int.Parse(Console.ReadLine()); b = int.Parse(Console.ReadLine()); s[1] = new Rectangle(l,b); Console.WriteLine("Enter the height & width for triangle"); l = int.Parse(Console.ReadLine()); b = int.Parse(Console.ReadLine()); s[2] = new Triangle(l,b); s2[0] = s[0]; s2[1] = s[1]; s2[2] = s[2]; Console.WriteLine("\n----Circle----"); Console.WriteLine(s2[0]); Console.WriteLine("\n----Rectangle----"); Console.WriteLine(s2[1]); Console.WriteLine("\n----Triangle----"); Console.WriteLine(s2[2]); Console.ReadLine(); }
public void TestDefaultBorderColor() { Shape shape = new MyShape(); Assert.AreEqual(Colors.Tomato, shape.BorderColor); }
public void TestSettingFillColor() { Shape shape = new MyShape(); shape.FillColor = Colors.AliceBlue; Assert.AreEqual(Colors.AliceBlue, shape.FillColor); }
private static extern unsafe void normalize_shape(MyShape* shape);
public void TestDefaultFillColor() { Shape shape = new MyShape(); Assert.AreEqual(Colors.Bisque, shape.FillColor); }