public void ToStringTest() { // Arange double[] v = { 5, 4 }; RectangleFigure rectangleFigure = new RectangleFigure(v); string str = "Прямоугольник с площадью " + rectangleFigure.GetArea() + " и периметром " + rectangleFigure.GetPerimeter(); var expected = str; //Act var result = rectangleFigure.ToString(); // Assert Assert.AreEqual(result, expected); }
public void GetPerimeterTest() { // Arange double[] v = { 5, 4 }; RectangleFigure rectangleFigure2 = new RectangleFigure(v); FigureBuilder rectangleBuilder = new RectangleBuilder("RectangleFigure"); Figures rectangleFigure1 = rectangleBuilder.Create(5, 4); double expected = 18; //Act var result = rectangleFigure2.GetPerimeter(); // Assert Assert.AreEqual(result, expected); }
public void Equals1_RectangleFigure_True() { // Arange double[] v = { 3, 6 }; RectangleFigure rectangleFigure2 = new RectangleFigure(v); FigureBuilder rectangleBuilder1 = new RectangleBuilder("RectangleFigure"); Figures rectangleFigure1 = rectangleBuilder1.Create(3, 6); //Act var result = RectangleFigure.Equals1(rectangleFigure1, rectangleFigure2); // Assert Assert.IsTrue(result); }
private void ResetChart() { _drawings = new List <SelectedFigureBase>(); _zoomArea = null; _selectedDrawing = null; _tempDrawing = null; _drawAdditionChartHelper = null; _actions = DrawingActions.Default; _chartHelpers = ChartHelpers.Default; _isZoomed = true; SetForChartMinMaxPoints(0); }
private void ZoomUpChart(int x, int y) { if (_zoomArea == null) { _zoomArea = new RectangleFigure(_d2DRenderTarget); } var isSetted = _zoomArea.SetPosition(new ScreenPoint(x, y)); if (!isSetted) { return; } _chartHelpers = ChartHelpers.Default; _isZoomed = false; }
public void RectangleFigureTest() { // Arange double[] v = { 5, 4 }; // RectangleFigure rectangleFigure = new RectangleFigure(v); FigureBuilder rectangleBuilder = new RectangleBuilder("RectangleFigure"); Figures rectangleFigure1 = rectangleBuilder.Create(5, 4); var expected = Convert.ToString(rectangleFigure1); //Act var result = new RectangleFigure(v); var result1 = Convert.ToString(result); // Assert Assert.AreEqual(expected, result1); // Assert.Fail(); }
//private Workspace _workspace; public DataInitialization(int Width, int Height) { var unityContainerInit = new UnityContainer(); _action = unityContainerInit.Resolve <Actions>(); _selectClass = unityContainerInit.Resolve <Selection>(); _pointSelection = unityContainerInit.Resolve <PointSelection>(); _rectangleSelection = unityContainerInit.Resolve <RectangleSelection>(); _drawClass = unityContainerInit.Resolve <DrawOnCanvas>(new OrderedParametersOverride(new object[] { Width, Height, _action })); _editDate = unityContainerInit.Resolve <EditData>(new OrderedParametersOverride(new object[] { _drawClass, _action })); _rectangl = unityContainerInit.Resolve <RectangleFigure>(); _ellipse = unityContainerInit.Resolve <EllipseFigure>(); _line = unityContainerInit.Resolve <Line>(); _poliLine = unityContainerInit.Resolve <PolylineFigure>(); _polygon = unityContainerInit.Resolve <PolygonFigure>(); _rectangleSelect = unityContainerInit.Resolve <RectangleSelect>(); _listFigures.Add(_rectangl); _listFigures.Add(_ellipse); _listFigures.Add(_line); _listFigures.Add(_poliLine); _listFigures.Add(_polygon); _drawListFigures.Add(_rectangl); _drawListFigures.Add(_ellipse); _drawListFigures.Add(_line); _drawListFigures.Add(_poliLine); _drawListFigures.Add(_polygon); _drawListFigures.Add(_rectangleSelect); _selectionList.Add(_pointSelection); _selectionList.Add(_rectangleSelection); _modesList.Add(unityContainerInit.Resolve <DrawMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass }))); _modesList.Add(unityContainerInit.Resolve <SelectRegionMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass, _editDate, _selectionList }))); _modesList.Add(unityContainerInit.Resolve <SelectPointoMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass, _editDate, _selectionList }))); _workspace = new Workspace(_selectClass, _drawClass, _editDate, _listFigures, _modesList, _drawListFigures); }
public void AppendLine(string line) { const double Eps = 0.00001; if (RecognizeRegex.IsMatch(line)) { var match = RecognizeRegex.Match(line); var x1 = Convert.ToDouble(match.Groups[2].Value); var y1 = Convert.ToDouble(match.Groups[3].Value); var x2 = Convert.ToDouble(match.Groups[4].Value); var y2 = Convert.ToDouble(match.Groups[5].Value); if ((Math.Abs(x1 - x2) > Eps) && (Math.Abs(y1 - y2) > Eps)) { var p1 = new Point { X = x1, Y = y1 }; var p2 = new Point { X = x2, Y = y2 }; this.rectangle = new RectangleFigure(p1, p2); this.name = match.Groups[1].Value; } else { throw new Exception("Точки не задают прямоугольник"); } } else { throw new Exception("Неправильный формат ввода данных"); } }
public void Setup() { rectangleFigure = new RectangleFigure(new Pen(Color.Black, 5)); }
public static void Main(string[] args) { Menu menu = new Menu(); menu.ChooseAction(); int choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: menu.ChooseLab(); int choiceLab = int.Parse(Console.ReadLine()); if (choiceLab == 1) { Console.WriteLine("Enter points:"); Console.Write("LeftTopX: "); double leftTopX = double.Parse(Console.ReadLine()); Console.Write("LeftTopY: "); double leftTopY = double.Parse(Console.ReadLine()); Console.Write("RightDownX: "); double rightDownX = double.Parse(Console.ReadLine()); Console.Write("RightDownY: "); double rightDownY = double.Parse(Console.ReadLine()); // Lab#1Task1 Console.WriteLine("Task 1: "); Rectangle myRectangle1 = new Rectangle(leftTopX, leftTopY, rightDownX, rightDownY); Console.WriteLine(myRectangle1.square()); Console.WriteLine(myRectangle1.perimeter()); // Lab#1Task2 Console.WriteLine("Task 2: "); Rectangle_Auto_Implemented myRectangleAuto1 = new Rectangle_Auto_Implemented(); myRectangleAuto1.leftTopX = leftTopX; myRectangleAuto1.leftTopY = leftTopY; myRectangleAuto1.rightDownX = rightDownX; myRectangleAuto1.rightDownY = rightDownY; Console.WriteLine(myRectangleAuto1.GetPerimeter); Console.WriteLine(myRectangleAuto1.GetSquare); // Lab#1Task3 Console.Write("Enter radius: "); double radius = double.Parse(Console.ReadLine()); Console.WriteLine("Task 3: "); Circle myCircle1 = new Circle(); Console.WriteLine(myCircle1.length(radius)); Console.WriteLine(myCircle1.square(radius)); Console.WriteLine("Task 4: "); // Lab#1Task4 Console.WriteLine(StatRectangle.perimeter(leftTopX, leftTopY, rightDownX, rightDownY)); Console.WriteLine(StatRectangle.square(leftTopX, leftTopY, rightDownX, rightDownY)); Console.WriteLine(StatCircle.length(radius)); Console.WriteLine(StatCircle.square(radius)); // Lab#1Task5 Console.WriteLine("Task 5: "); Console.Write("Num1RealPart: "); double real1 = double.Parse(Console.ReadLine()); Console.Write("Num1ImagPart: "); double imag1 = double.Parse(Console.ReadLine()); Console.Write("Num2RealPart: "); double real2 = double.Parse(Console.ReadLine()); Console.Write("Num2ImagPart: "); double imag2 = double.Parse(Console.ReadLine()); ComplexNumber numfirst = new ComplexNumber(real1, imag1); ComplexNumber numsecond = new ComplexNumber(real2, imag2); Console.WriteLine(numfirst * numsecond); Console.WriteLine(numfirst / numsecond); } if (choiceLab == 2) { Console.WriteLine("Task 1: "); RectangleFigure rect1 = new RectangleFigure(); rect1.Draw(); SquareFigure square1 = new SquareFigure(); square1.Draw(); Console.WriteLine("Task 2: "); Console.WriteLine("Look my code"); RectangleReadOnly rectangleRead1 = new RectangleReadOnly(2, 3); SquareReadOnly squareRead1 = new SquareReadOnly(2, 3); Console.WriteLine("Task 3: "); FigureVirtual figure1 = new FigureVirtual(2, 3); figure1.Draw(); FigureVirtual newfigureone = new RectangleVirtual(2, 3); newfigureone.Draw(); FigureVirtual newfiguresecond = new SquareVirtual(2, 3); newfiguresecond.Draw(); Console.WriteLine("Task 4: "); FigureDraw figuretoDraw1 = new FigureDraw(2, 3); RectangleDraw rectangleDraw1 = new RectangleDraw(2, 3); figuretoDraw1.DrawAll(figuretoDraw1, rectangleDraw1); } if (choiceLab == 3) { // Lab#3Task1 Console.WriteLine("\t Lab 3: "); Console.WriteLine("Task 1: "); List <Person> newList1 = new List <Person>(); CreateDisplayPerson create1 = new CreateDisplayPerson(newList1); create1.CreateSomePerson(); create1.DisplayPerson(); // Lab#3Task2 Console.WriteLine("Task 2: "); AddRangePerson add1 = new AddRangePerson(newList1); add1.AddTwoPerson(); add1.DisplayPhoneNumbers(); // Lab#3Task3 Console.WriteLine("Task 3: "); RandomList randomList1 = new RandomList(); Console.Write("Enter number of Page: "); string numberPage1 = Console.ReadLine(); int number1; bool success1 = Int32.TryParse(numberPage1, out number1); if (success1) { number1 = Int32.Parse(numberPage1); randomList1.DisplayPage(number1); } else { Console.WriteLine("Please enter number as digit"); break; } } break; case 2: Console.WriteLine("\tLab 1: "); // Lab#1Task1 Console.WriteLine("Task 1: "); Rectangle myRectangle = new Rectangle(2, 3, 3, 1); Console.WriteLine(myRectangle.square()); Console.WriteLine(myRectangle.perimeter()); // Lab#1Task2 Console.WriteLine("Task 2: "); Rectangle_Auto_Implemented myRectangleAuto = new Rectangle_Auto_Implemented(); myRectangleAuto.leftTopX = 2; myRectangleAuto.leftTopY = 3; myRectangleAuto.rightDownX = 3; myRectangleAuto.rightDownY = 1; Console.WriteLine(myRectangleAuto.GetPerimeter); Console.WriteLine(myRectangleAuto.GetSquare); // Lab#1Task3 Console.WriteLine("Task 3: "); Circle myCircle = new Circle(); Console.WriteLine(myCircle.length(2)); Console.WriteLine(myCircle.square(3)); // Lab#1Task4 Console.WriteLine("Task 4: "); Console.WriteLine(StatRectangle.perimeter(2, 3, 3, 1)); Console.WriteLine(StatRectangle.square(2, 3, 3, 1)); Console.WriteLine(StatCircle.length(2)); Console.WriteLine(StatCircle.square(3)); // Lab#1Task5 Console.WriteLine("Task 5: "); ComplexNumber num1 = new ComplexNumber(1, 1); ComplexNumber num2 = new ComplexNumber(1, 3); Console.WriteLine(num1 * num2); Console.WriteLine(num1 / num2); Console.WriteLine("\t Lab 2: "); // Lab#2Task1 Console.WriteLine("Task 1: "); RectangleFigure rect = new RectangleFigure(); rect.Draw(); SquareFigure square = new SquareFigure(); square.Draw(); // Lab#2Task2 Console.WriteLine("Task 2: "); Console.WriteLine("Look my code"); RectangleReadOnly rectangleRead = new RectangleReadOnly(2, 3); SquareReadOnly squareRead = new SquareReadOnly(2, 3); // Lab#2Task3 Console.WriteLine("Task 3: "); FigureVirtual figure = new FigureVirtual(2, 3); figure.Draw(); FigureVirtual newfigure1 = new RectangleVirtual(2, 3); newfigure1.Draw(); FigureVirtual newfigure2 = new SquareVirtual(2, 3); newfigure2.Draw(); // Lab#2Task4 Console.WriteLine("Task 4: "); FigureDraw figuretoDraw = new FigureDraw(2, 3); RectangleDraw rectangleDraw = new RectangleDraw(2, 3); figuretoDraw.DrawAll(figuretoDraw, rectangleDraw); // Lab#3Task1 Console.WriteLine("\t Lab 3: "); Console.WriteLine("Task 1: "); List <Person> newList = new List <Person>(); CreateDisplayPerson create = new CreateDisplayPerson(newList); create.CreateSomePerson(); create.DisplayPerson(); // Lab#3Task2 Console.WriteLine("Task 2: "); AddRangePerson add = new AddRangePerson(newList); add.AddTwoPerson(); add.DisplayPhoneNumbers(); // Lab#3Task3 Console.WriteLine("Task 3: "); RandomList randomList = new RandomList(); Console.Write("Enter number of Page: "); string numberPage = Console.ReadLine(); int number; bool success = Int32.TryParse(numberPage, out number); if (success) { number = Int32.Parse(numberPage); randomList.DisplayPage(number); } else { Console.WriteLine("Please enter number as digit"); break; } break; default: Console.WriteLine("Choose 1 or 2 variant"); break; } }
public void SideA(double a) { var rectangle = new RectangleFigure(); }
// Add some rectangles. private void CreateRectangles() { Figure figure = new RectangleFigure { IsFilled = false, WidthX = 1f, WidthY = 0.5f, }; FigureNode figureNode = new FigureNode(figure) { Name = "Rectangle #1", StrokeThickness = 1, StrokeColor = new Vector3F(0.7f, 0.3f, 0.5f), StrokeAlpha = 1, PoseLocal = new Pose(new Vector3F(-2, 1, 0)) }; _scene.Children.Add(figureNode); figure = new RectangleFigure { IsFilled = false, WidthX = 0.5f, WidthY = 0.8f, }; figureNode = new FigureNode(figure) { Name = "Rectangle #2", StrokeThickness = 3, StrokeColor = new Vector3F(0.2f, 0.3f, 0.3f), StrokeAlpha = 0.5f, StrokeDashPattern = new Vector4F(10, 2, 3, 2), DashInWorldSpace = false, PoseLocal = new Pose(new Vector3F(-1, 1, 0)) }; _scene.Children.Add(figureNode); figure = new RectangleFigure { IsFilled = true, WidthX = 0.6f, WidthY = 0.7f, }; figureNode = new FigureNode(figure) { Name = "Rectangle #3", StrokeThickness = 2, StrokeColor = new Vector3F(0.3f, 0, 0.2f), StrokeAlpha = 1, StrokeDashPattern = new Vector4F(10, 2, 3, 2) / 100, DashInWorldSpace = true, FillColor = new Vector3F(0.7f, 0, 0.5f), FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(-0, 1, 0)) }; _scene.Children.Add(figureNode); figure = new RectangleFigure { IsFilled = true, WidthX = 1f, WidthY = 0.2f, }; figureNode = new FigureNode(figure) { Name = "Rectangle #4", StrokeThickness = 2, StrokeColor = new Vector3F(0, 0, 0), StrokeAlpha = 1, StrokeDashPattern = new Vector4F(1, 1, 1, 1) / 100, DashInWorldSpace = true, FillColor = new Vector3F(0.3f, 0.3f, 0.3f), FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(1, 1, 0)) }; _scene.Children.Add(figureNode); figure = new RectangleFigure { IsFilled = true, WidthX = 0.4f, WidthY = 0.5f, }; figureNode = new FigureNode(figure) { Name = "Rectangle #5", StrokeThickness = 2, StrokeColor = new Vector3F(0.3f), StrokeAlpha = 1, FillColor = new Vector3F(0.3f), FillAlpha = 1, PoseLocal = new Pose(new Vector3F(2, 1, 0)) }; _scene.Children.Add(figureNode); }
// Add some transparent figures to test alpha blending. private void CreateAlphaBlendedFigures() { var rectangle = new RectangleFigure { IsFilled = true, WidthX = 0.5f, WidthY = 0.9f, }; var figureNode = new FigureNode(rectangle) { Name = "Rectangle #6", StrokeThickness = 2, StrokeColor = new Vector3F(0.1f, 0.2f, 0.3f), FillColor = new Vector3F(0.1f, 0.2f, 0.3f), StrokeAlpha = 0.5f, FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(-4, 1, -2)) }; _scene.Children.Add(figureNode); figureNode = new FigureNode(rectangle) { Name = "Rectangle #7", StrokeThickness = 2, StrokeColor = new Vector3F(0.1f, 0.2f, 0.3f), FillColor = new Vector3F(0.1f, 0.2f, 0.3f), StrokeAlpha = 0.5f, FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(-4, 1, -1)) }; _scene.Children.Add(figureNode); figureNode = new FigureNode(rectangle) { Name = "Rectangle #8", StrokeThickness = 2, StrokeColor = new Vector3F(0.1f, 0.2f, 0.3f), FillColor = new Vector3F(0.1f, 0.2f, 0.3f), StrokeAlpha = 0.5f, FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(-4, 1, 0)) }; _scene.Children.Add(figureNode); figureNode = new FigureNode(rectangle) { Name = "Rectangle #9", StrokeThickness = 2, StrokeColor = new Vector3F(0.1f, 0.2f, 0.3f), FillColor = new Vector3F(0.1f, 0.2f, 0.3f), StrokeAlpha = 0.5f, FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(-4, 1, 1)) }; _scene.Children.Add(figureNode); figureNode = new FigureNode(rectangle) { Name = "Rectangle #10", StrokeThickness = 2, StrokeColor = new Vector3F(0.1f, 0.2f, 0.3f), FillColor = new Vector3F(0.1f, 0.2f, 0.3f), StrokeAlpha = 0.5f, FillAlpha = 0.5f, PoseLocal = new Pose(new Vector3F(-4, 1, 2)) }; _scene.Children.Add(figureNode); }
private void KeyKeyboardChecker(Keys key) { switch (key) { case Keys.Escape: { _renderForm.Close(); this.Hide(); this.Close(); break; } case Keys.D1: { if (_barType != BarType.Candle) { _barType = BarType.Candle; SetForChartMinMaxPoints(_barRendering.Skip); _barRendering = new BarCandle(_d2DRenderTarget, _barRendering.Bars, _chart, _barRendering.Skip); break; } break; } case Keys.D2: { if (_barType != BarType.OHLC) { _barType = BarType.OHLC; SetForChartMinMaxPoints(_barRendering.Skip); _barRendering = new BarOHLC(_d2DRenderTarget, _barRendering.Bars, _chart, _barRendering.Skip); break; } break; } case Keys.Q: { if (_chartHelpers != ChartHelpers.Net) { _chartHelpers = ChartHelpers.Net; _drawAdditionChartHelper = DrawNet; break; } _drawAdditionChartHelper -= DrawNet; _chartHelpers = ChartHelpers.Default; break; } case Keys.W: { if (_chartHelpers != ChartHelpers.Lines) { _chartHelpers = ChartHelpers.Lines; _drawAdditionChartHelper = DrawLines; break; } _drawAdditionChartHelper -= DrawLines; _chartHelpers = ChartHelpers.Default; break; } case Keys.E: { if (_actions != DrawingActions.LineDrawing) { _actions = DrawingActions.LineDrawing; _tempDrawing = new LineFigure(_d2DRenderTarget); break; } _tempDrawing = null; _actions = DrawingActions.Default; break; } case Keys.R: { if (_actions != DrawingActions.RectangleDrawing) { _tempDrawing = new RectangleFigure(_d2DRenderTarget); _actions = DrawingActions.RectangleDrawing; break; } _tempDrawing = null; _actions = DrawingActions.Default; break; } case Keys.T: { if (_actions != DrawingActions.EllipseDrawing) { _tempDrawing = new EllipseFigure(_d2DRenderTarget); _actions = DrawingActions.EllipseDrawing; break; } _tempDrawing = null; _actions = DrawingActions.Default; break; } case Keys.A: { if (_actions != DrawingActions.StraightLineXDrawing) { _actions = DrawingActions.StraightLineXDrawing; break; } _actions = DrawingActions.Default; break; } case Keys.S: { if (_actions != DrawingActions.StraightLineYDrawing) { _actions = DrawingActions.StraightLineYDrawing; break; } _actions = DrawingActions.Default; break; } case Keys.Z: { if (_chartHelpers != ChartHelpers.Zoom) { _zoomArea = null; _chartHelpers = ChartHelpers.Zoom; break; } _chartHelpers = ChartHelpers.Default; break; } case Keys.Delete: { RemoveFigure(); break; } case Keys.C: { _chart.ChangeColor(); break; } case Keys.Enter: { ResetChart(); break; } } }