public void TestHSSFShapeCompatibility() { HSSFSimpleShape shape = new HSSFSimpleShape(null, new HSSFClientAnchor()); shape.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); Assert.AreEqual(0x08000040, shape.LineStyleColor); Assert.AreEqual(0x08000009, shape.FillColor); Assert.AreEqual(HSSFShape.LINEWIDTH_DEFAULT, shape.LineWidth); Assert.AreEqual(HSSFShape.LINESTYLE_SOLID, shape.LineStyle); Assert.IsFalse(shape.IsNoFill); AbstractShape sp = AbstractShape.CreateShape(shape, 1); EscherContainerRecord spContainer = sp.SpContainer; EscherOptRecord opt = spContainer.GetChildById(EscherOptRecord.RECORD_ID) as EscherOptRecord; Assert.AreEqual(7, opt.EscherProperties.Count); Assert.AreEqual(true, ((EscherBoolProperty)opt.Lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE)).IsTrue); Assert.AreEqual(0x00000004, ((EscherSimpleProperty)opt.Lookup(EscherProperties.GEOMETRY__SHAPEPATH)).PropertyValue); Assert.AreEqual(0x08000009, ((EscherSimpleProperty)opt.Lookup(EscherProperties.FILL__FILLCOLOR)).PropertyValue); Assert.AreEqual(true, ((EscherBoolProperty)opt.Lookup(EscherProperties.FILL__NOFILLHITTEST)).IsTrue); Assert.AreEqual(0x08000040, ((EscherSimpleProperty)opt.Lookup(EscherProperties.LINESTYLE__COLOR)).PropertyValue); Assert.AreEqual(true, ((EscherBoolProperty)opt.Lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).IsTrue); Assert.AreEqual(true, ((EscherBoolProperty)opt.Lookup(EscherProperties.GROUPSHAPE__PRINT)).IsTrue); }
public void ShapeAct(Keys key, AbstractShape selection) { switch (key) { case Keys.Back: { if (!history.Any()) { return; } Command lastcommand = history.Pop(); lastcommand.undo(); break; } } if (selection != null && commands.ContainsKey(key)) { Command command = commands[key]; Command newcommand = command.clone(); newcommand.execute(selection); history.Push(newcommand); } }
/// <summary> /// Performs saving changes to the currently loaded file for <see cref="Save"/> method. /// </summary> /// <param name="finishedSuccessfully">Indicating whether opening the file /// was successful or not.</param> private void Saving(out bool finishedSuccessfully) { if (this.OpenedFilePath == string.Empty) { this.SavingAs(out finishedSuccessfully); return; } finishedSuccessfully = false; if (!this.OpenedFilePath.EndsWith(".json") && !this.OpenedFilePath.EndsWith(".JSON")) { return; } try { AbstractShape[] buffer = new AbstractShape[this.shapeListBox.Items.Count]; this.shapeListBox.Items.CopyTo(buffer, 0); SerializationManager.Serialization(this.OpenedFilePath, buffer); //this.Serialization(this.OpenedFilePath); finishedSuccessfully = true; } catch (Exception e) { MessageBox.Show(e.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void PentagonDefaultConstructor() { sut = new Pentagon(); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(_defaultSize * 5)); Assert.That(sut.CalculateArea(), Is.EqualTo(GetExpectedAreaForPentagon(_defaultSize))); }
public void SquareDefaultConstructor() { sut = new Square(); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(_defaultSize * 4)); Assert.That(sut.CalculateArea(), Is.EqualTo(Math.Pow(_defaultSize, 2))); }
protected override AbstractShape createShapes(string code) { AbstractShape shape = null; switch (code) { case "Circle": shape = new CCircle(); break; case "Rectangle": shape = new CRectangle(); break; case "Polygon": shape = new CPolygon(); break; case "Star": shape = new CStar(); break; case "Group": shape = new CGroup(); break; } return(shape); }
public FigureParametrs(AbstractShape figure) : this() { Type figureType = figure.GetType(); foreach (PropertyInfo pi in figureType.GetProperties()) { if (pi.Name != "GraphicsPath" && pi.Name != "Pen") { this.AddLabel(pi.Name); this.AddNumericUpDown(pi.Name, (int)pi.GetValue(figure)); } } this.Draw_button.Click += (sender, args) => { foreach (PropertyInfo pi in figureType.GetProperties()) { if (pi.Name != "GraphicsPath" && pi.Name != "Pen") { pi.SetValue(figure, (int)(this.ElementsPanel.Controls[pi.Name + NumericUpDownPostfix] as NumericUpDown).Value); } } this.DialogResult = DialogResult.OK; }; }
private void GetConnectedShapes(Shape vsoShape, Page vsoPage) { Shape vsoOutShape; int outNodes; bool beenChecked = false; try { AbstractShape absShape = new AbstractShape(); absShape.PageName = vsoPage.Name; absShape.Name = vsoShape.Text; absShape.Type = vsoShape.NameU; absShape.UniqueID = vsoShape.ID; // Get an array of all the shapes connected to the shape passed into the argument. var shapeIDArray = vsoShape.ConnectedShapes( VisConnectedShapesFlags.visConnectedShapesOutgoingNodes, ""); if (shapeIDArray.Length > 0) { outNodes = shapeIDArray.Length; for (var node = 0; node < outNodes; node++) { //vsoOutShape = _vsoPage.Shapes.get_ItemFromID((int)shapeIDArray.GetValue(node)); vsoOutShape = vsoPage.Shapes.get_ItemFromID((int)shapeIDArray.GetValue(node)); absShape.ConnectedTo.Add(vsoOutShape.Text); shapes.Add(absShape); // We need to see if the connected shape has shapes connected to it, // so we'll get array of all the shapes connected to it. var outShapeIDArray = vsoOutShape.ConnectedShapes( VisConnectedShapesFlags.visConnectedShapesOutgoingNodes, ""); string value; if (shapeList != null && shapeList.TryGetValue(vsoOutShape.ID, out value)) { beenChecked = true; } ; // The connected shape has shapes attached to it and it hasn't been, // checked yet, so we'll crawl it next. if ((outShapeIDArray.Length > 0) & (!beenChecked && shapeList != null)) { shapeList.Add(vsoOutShape.ID, vsoOutShape.Text); GetConnectedShapes(vsoOutShape, vsoPage); } } } } catch (Exception ex) { //Console.WriteLine(ex.Message); } }
/// <summary> /// 移除指定图形 /// </summary> /// <param name="shape"></param> public void RemoveShape(AbstractShape shape) { if (IsDisposed) { return; } throw new NotImplementedException(); }
/// <summary>Renders a graphical representation of this tree's cells using the specified shape renderer.</summary> /// <param name="index">The tree to render.</param> /// <param name="shape">The shape renderer to paint with.</param> /// <param name="translation">The translation to apply to all draw operation.</param> public static void Draw<T>(this SpatialHashedQuadTree<T> index, AbstractShape shape, TPoint translation) { foreach (var tree in index.GetTreeEnumerable()) { // ReSharper disable RedundantCast Necessary for FarCollections. tree.Item2.Draw(shape, (Vector2) (tree.Item1 + translation)); // ReSharper restore RedundantCast } }
public void TestPerimeter() { foreach (KeyValuePair <string, IShape> shape in shapes) { var ashape = new AbstractShape(shape.Value); Assert.AreEqual(shape.Key + ".Perimeter", ashape.GetShapePerimeter()); } }
public override void execute(AbstractShape sel) { selection = sel; if (selection != null) { selection.Resize(size, g); } }
public void CircleParameterizedConstructor() { var radius = 10; sut = new Circle(radius); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(2 * Math.PI * radius)); Assert.That(sut.CalculateArea(), Is.EqualTo(Math.PI * Math.Pow(radius, 2))); }
public void PentagonParameterizedConstructor() { var len = 10; sut = new Pentagon(len); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(len * 5)); Assert.That(sut.CalculateArea(), Is.EqualTo(GetExpectedAreaForPentagon(len))); }
public override void execute(AbstractShape sel) { selection = sel; if (selection != null) { selection.Move(dx, dy, g); } }
public AbstractShape MouseDown(MouseManager m, PointF pt) { shape = m.HitShape(pt); #if PerfMon System.Diagnostics.Debug.WriteLine($"{StateManager.GetCurrentStateAndAction()} Hit {shape.ToDebugString()}"); #endif return(shape); }
public void SquareParameterizedConstructor() { var len = 10; sut = new Square(len); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(len * 4)); Assert.That(sut.CalculateArea(), Is.EqualTo(Math.Pow(len, 2))); }
public void PentagonCopyConstructor() { var len = 15; var PentagonToCopy = new Pentagon(len); sut = new Pentagon(PentagonToCopy); Assert.That(sut.CalculateArea(), Is.EqualTo(PentagonToCopy.CalculateArea())); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(PentagonToCopy.CalculatePerimeter())); }
public void SquareCopyConstructor() { var len = 15; var squareToCopy = new Square(len); sut = new Square(squareToCopy); Assert.That(sut.CalculateArea(), Is.EqualTo(squareToCopy.CalculateArea())); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(squareToCopy.CalculatePerimeter())); }
public void RectangleParameterizedConstructor() { var width = 10; var height = 20; sut = new Rectangle(width, height); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(2 * width + 2 * height)); Assert.That(sut.CalculateArea(), Is.EqualTo(width * height)); }
public void CircleCopyConstructor() { var radius = 5; var circleToCopy = new Circle(radius); sut = new Circle(circleToCopy); Assert.That(sut.CalculateArea(), Is.EqualTo(circleToCopy.CalculateArea())); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(circleToCopy.CalculatePerimeter())); }
public void RectangleCopyConstructor() { var width = 5; var height = 15; var rectangleToCopy = new Rectangle(width, height); sut = new Rectangle(rectangleToCopy); Assert.That(sut.CalculateArea(), Is.EqualTo(rectangleToCopy.CalculateArea())); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(rectangleToCopy.CalculatePerimeter())); }
public void EllipseCopyConstructor() { var semiMajorAxis = 5; var semiMinorAxis = 15; var EllipseToCopy = new Ellipse(semiMajorAxis, semiMinorAxis); sut = new Ellipse(EllipseToCopy); Assert.That(sut.CalculateArea(), Is.EqualTo(EllipseToCopy.CalculateArea())); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(EllipseToCopy.CalculatePerimeter())); }
public void EllipseParameterizedConstructor() { var semiMajorAxis = 10; var semiMinorAxis = 20; sut = new Ellipse(semiMajorAxis, semiMinorAxis); Assert.That(sut.CalculatePerimeter(), Is.EqualTo(2 * Math.PI * Math.Sqrt( (Math.Pow(semiMajorAxis, 2) + Math.Pow(semiMinorAxis, 2)) / 2))); Assert.That(sut.CalculateArea(), Is.EqualTo(Math.PI * semiMajorAxis * semiMinorAxis)); }
public bool IsBindedShape(AbstractShape shape, bool isPressed, bool isTexting = false) { if (isTexting) { if (shape.TypeString == "Text") { __text = shape as Text; return(true); } } return(false); }
public Gamefield(int fieldX, int fieldY) { th.getAnothershape(); abSh = th.getShape; field = new int[fieldX, fieldY]; // Field(fieldX, fieldY).gamefield; tempfield = new int[fieldX, fieldY]; // Field(fieldX, fieldY).gamefield; SetShape(abSh); height = fieldX; length = fieldY; left = 0; }
private void RectMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (Top != null) { Top.BorderBrush = Brushes.Black; Top.BorderThickness = new Thickness(0.2); } Top = this; Canvas.SetZIndex(this, ++LastZIndex); CaptureMouse(); BorderThickness = new Thickness(2); BorderBrush = Brushes.Red; }
public int[,] command(AbstractShape ab) { int[,] reverse = new int[4, 4]; for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { reverse[x, y] = ab.shape[3 - y, x]; // по часовой // reverse[x, y] = ab.shape[ y, 3-x];//против часовой } } return(reverse); }
public bool IsBindedShape(AbstractShape shape, bool isPressed, bool isTexting = false) { if (isPressed && !isTexting) { switch (shape.TypeString) { case "Rect": case "Line": case "Ellipse": case "Text": return(true); } } return(false); }
public override void execute(AbstractShape sel) { selection = sel; if (selection != null) { backcolor = selection.hBrush.BackgroundColor; //Сохраняем цвет фигуры colorChoose.Color = backcolor; //Вызываем color dialog colorChoose.ShowDialog(); //Задаём кисть с выбранным цветом selection.ColorChange(new HatchBrush(HatchStyle.Cross, Color.PaleVioletRed, colorChoose.Color)); } }
public Circle(AbstractShape.COLOR color) { mColor = color; }
public Square(AbstractShape.COLOR color) { mColor = color; }
public Rectangle(AbstractShape.COLOR color) { mColor = color; }