• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Shape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Shape的典型用法代码示例。如果您正苦于以下问题:C# Shape类的具体用法?C# Shape怎么用?C# Shape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Shape类属于命名空间,在下文中一共展示了Shape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CopyFrom

		/// <override></override>
		public override void CopyFrom(Shape source)
		{
			base.CopyFrom(source);
			// Copy size if the source is a DiameterShape
			if (source is DiameterShapeBase)
				internalDiameter = ((DiameterShapeBase) source).DiameterInternal;
			else {
				// If not, try to calculate the size a good as possible
				Rectangle srcBounds = Geometry.InvalidRectangle;
				if (source is PathBasedPlanarShape) {
					PathBasedPlanarShape src = (PathBasedPlanarShape) source;
					// Calculate the bounds of the (unrotated) resize handles because with 
					// GetBoundingRectangle(), we receive the bounds including the children's bounds
					List<Point> pointBuffer = new List<Point>();
					int centerX = src.X;
					int centerY = src.Y;
					float angleDeg = Geometry.TenthsOfDegreeToDegrees(-src.Angle);
					foreach (ControlPointId id in source.GetControlPointIds(ControlPointCapabilities.Resize))
						pointBuffer.Add(Geometry.RotatePoint(centerX, centerY, angleDeg, source.GetControlPointPosition(id)));
					Geometry.CalcBoundingRectangle(pointBuffer, out srcBounds);
				}
				else {
					// Generic approach: try to fit into the bounding rectangle
					srcBounds = source.GetBoundingRectangle(true);
				}
				//
				// Calculate new size
				if (Geometry.IsValid(srcBounds)) {
					float scale = Geometry.CalcScaleFactor(DiameterInternal, DiameterInternal, srcBounds.Width, srcBounds.Height);
					DiameterInternal = (int) Math.Round(DiameterInternal*scale);
				}
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:34,代码来源:DiameterShape.cs


示例2: DropConnection

 public static Shape DropConnection(
     Shape source,
     Shape target,
     string masterNameU)
 {
     return DropConnection(source, target, masterNameU, ClassConnections.Right, ClassConnections.Top);
 }
开发者ID:Obles,项目名称:vwdaddin,代码行数:7,代码来源:VisioMaster.cs


示例3: CreateIndexableFields

 //---------------------------------
 // Indexing
 //---------------------------------
 public override Field[] CreateIndexableFields(Shape shape)
 {
     var rect = shape as Rectangle;
     if (rect != null)
         return CreateIndexableFields(rect);
     throw new InvalidOperationException("Can only index Rectangle, not " + shape);
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:10,代码来源:BBoxStrategy.cs


示例4: CreateIndexableFields

		public override AbstractField[] CreateIndexableFields(Shape shape)
		{
			var point = shape as Point;
			if (point != null)
			{
				var f = new AbstractField[2];

				var f0 = new NumericField(fieldNameX, precisionStep, Field.Store.NO, true)
				         	{OmitNorms = true, OmitTermFreqAndPositions = true};
				f0.SetDoubleValue(point.GetX());
				f[0] = f0;

				var f1 = new NumericField(fieldNameY, precisionStep, Field.Store.NO, true)
				         	{OmitNorms = true, OmitTermFreqAndPositions = true};
				f1.SetDoubleValue(point.GetY());
				f[1] = f1;

				return f;
			}
			if (!ignoreIncompatibleGeometry)
			{
				throw new ArgumentException("TwoDoublesStrategy can not index: " + shape);
			}
			return new AbstractField[0]; // nothing (solr does not support null) 
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:25,代码来源:TwoDoublesStrategy.cs


示例5: CollisionMovingRight

        public bool CollisionMovingRight(Shape fallingShape, Dictionary<int, Tile> fallenTiles)
        {
            if (HitRightSideOfGrid(fallingShape) || HitFallenShapesMovingRight(fallingShape, fallenTiles))
                return true;

            return false;
        }
开发者ID:johnhillhouse,项目名称:FallingBricks2,代码行数:7,代码来源:CollisionDetector.cs


示例6: RenderShapeToStream

        public static void RenderShapeToStream(string dataDir, Shape shape)
        {
            //ExStart
            //ExFor:ShapeRenderer
            //ExFor:ShapeRenderer.#ctor(ShapeBase)
            //ExFor:ImageSaveOptions.ImageColorMode
            //ExFor:ImageSaveOptions.ImageBrightness
            //ExFor:ShapeRenderer.Save(Stream, ImageSaveOptions)
            //ExId:RenderShapeToStream
            //ExSummary:Shows how to render a shape independent of the document to a JPEG image and save it to a stream.
            // We can also retrieve the renderer for a shape by using the ShapeRenderer constructor.
            ShapeRenderer r = new ShapeRenderer(shape);

            // Define custom options which control how the image is rendered. Render the shape to the vector format EMF.
            ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg)
            {
                // Output the image in gray scale
                ImageColorMode = ImageColorMode.Grayscale,

                // Reduce the brightness a bit (default is 0.5f).
                ImageBrightness = 0.45f
            };

            FileStream stream = new FileStream(dataDir + "TestFile.RenderToStream Out.jpg", FileMode.CreateNew);

            // Save the rendered image to the stream using different options.
            r.Save(stream, imageOptions);
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:29,代码来源:Program.cs


示例7: FixConnectorTextControl

 public static void FixConnectorTextControl(Shape shape)
 {
     if (Common.GetShapeType(shape) == ShapeTypes.Connector) {
         string pinX = Common.GetCellFormula(shape, "TxtPinX");
         // if the current TxtPinX already is updating another cell via setatref, we don't need to
         // do anything
         if (!pinX.Contains("SETATREF")) {
             shape.AddNamedRow((short)VisSectionIndices.visSectionControls, "TextPosition", 0);
             // get old values and reuse them if we already have text
             string pinY = Common.GetCellFormula(shape, "TxtPinY");
             if (shape.Text.Length > 0) {
                 shape.get_CellsU("Controls.TextPosition.X").Formula = pinX;
                 shape.get_CellsU("Controls.TextPosition.Y").Formula = pinY;
             }
             else {
                 shape.get_CellsU("Controls.TextPosition.Y").FormulaU = "Height*0.5";
                 shape.get_CellsU("Controls.TextPosition.X").FormulaU = "Width*0.5";
             }
             shape.get_CellsU("Controls.TextPosition.XDyn").FormulaU = "Controls.TextPosition.X";
             shape.get_CellsU("Controls.TextPosition.YDyn").FormulaU = "Controls.TextPosition.Y";
             shape.get_CellsU("Controls.TextPosition.XCon").FormulaU = "IF(OR(STRSAME(SHAPETEXT(TheText),\"\"),HideText),5,0)";
             shape.get_CellsU("Controls.TextPosition.CanGlue").FormulaU = "FALSE";
             shape.get_CellsU("Controls.TextPosition.Prompt").FormulaU = "\"Reposition Text\"";
             shape.get_CellsU("TxtPinX").FormulaU = "SETATREF(Controls.TextPosition)";
             shape.get_CellsU("TxtPinY").FormulaU = "SETATREF(Controls.TextPosition.Y)";
         }
     }
 }
开发者ID:pathmakertool,项目名称:pathmaker_os_files,代码行数:28,代码来源:Common.cs


示例8: DistanceGrid

        public DistanceGrid(Shape shape, Scalar spacing)
        {
            if (shape == null) { throw new ArgumentNullException("shape"); }
            if (spacing <= 0) { throw new ArgumentOutOfRangeException("spacing"); }
            //prepare the shape.
            Matrix2D old = shape.Matrix;
            Matrix2D ident = Matrix2D.Identity;
            shape.ApplyMatrix(ref ident);
            shape.CalcBoundingBox2D();

            this.box = shape.BoundingBox2D; 
            this.gridSpacing = spacing;
            this.gridSpacingInv = 1 / spacing;
            int xSize = (int)Math.Ceiling((box.Upper.X - box.Lower.X) * gridSpacingInv) + 2;
            int ySize = (int)Math.Ceiling((box.Upper.Y - box.Lower.Y) * gridSpacingInv) + 2;

            this.nodes = new Scalar[xSize, ySize];
            Vector2D vector;
            vector.X = box.Lower.X;
            for (int x = 0; x < xSize; ++x, vector.X += spacing)
            {
                vector.Y = box.Lower.Y;
                for (int y = 0; y < ySize; ++y, vector.Y += spacing)
                {
                    nodes[x, y] = shape.GetDistance(vector);
                }
            }
            //restore the shape
            shape.ApplyMatrix(ref old);
            shape.CalcBoundingBox2D();
        }
开发者ID:bsvercl,项目名称:physics2d,代码行数:31,代码来源:DistanceGrid.cs


示例9: IsSameType

    /// <summary>
    /// Checks if the current shape is of the same type as the parameter
    /// </summary>
    /// <param name="otherShape"></param>
    /// <returns></returns>
    public bool IsSameType(Shape otherShape)
    {
        if (otherShape == null || !(otherShape is Shape))
            throw new ArgumentException("otherShape");

        return string.Compare(this.Type, (otherShape as Shape).Type) == 0;
    }
开发者ID:LelandLL,项目名称:Breaker,代码行数:12,代码来源:Shape.cs


示例10: CopyFrom

		/// <override></override>
		public override void CopyFrom(Shape source) {
			base.CopyFrom(source);
			if (source is CircularArcBase) {
				// Vertices and CapStyles will be copied by the base class
				// so there's nothing left to do here...
			}
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:8,代码来源:CircularArcBase.cs


示例11: CreatePrimitive

	/**
	 *	\brief If passed a valid ProBuilder::Shape, create it!  Non-valid shape is Shape.Custom.
	 *	\code{.cs}
	 *	// Example usage:
	 *	pb_Object myNewPrism = ProBuilder.CreatePrimitive(ProBuilder.Shape.Prism);
	 *	\endcode
	 *	@param shape The primitive type to create.  Always creates the shape with default parameters (if applicable).
	 *	\returns The new pb_Object.
	 */
	public static pb_Object CreatePrimitive(Shape shape)
	{
		pb_Object pb;
		switch(shape)
		{
			case Shape.Cube:
				pb = pb_Shape_Generator.CubeGenerator(Vector3.one);
				break;

			case Shape.Prism:
				pb = pb_Shape_Generator.PrismGenerator(Vector3.one);
				break;

			case Shape.Stair:
				// steps, width, height, depth, extend sides to floor, generate back, platforms only
				pb = pb_Shape_Generator.StairGenerator(5, 2f, 5f, 7f, true, true, false);
				break;

			case Shape.Cylinder:
				pb = pb_Shape_Generator.CylinderGenerator(6, 1.5f, 4f, 2);
				break;

			case Shape.Plane:
				pb = pb_Shape_Generator.PlaneGenerator(2f, 2f, 3, 3, Axis.Up, false);
				break;

			default:
				return null;
		}

		// pb.Refresh();

		return pb;
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:43,代码来源:ProBuilder.cs


示例12: cardToString

    public static string cardToString(int val, Shape shape)
    {
        string str = System.String.Empty;

        if (val <= 0 || val >= 14)
            return str;

        str = val.ToString();
        switch (shape)
        {
            case Shape.Club:
                str += "c";
                break;
            case Shape.Diamond:
                str += "d";
                break;
            case Shape.Heart:
                str += "h";
                break;
            case Shape.Spade:
                str += "s";
                break;
        }
        return str;
    }
开发者ID:alanbondarun,项目名称:cs492-week2,代码行数:25,代码来源:Card.cs


示例13: Main

    static void Main()
    {
        var shapes = new Shape[numberOfShapes];

        for (int i = 0; i < shapes.Length; i++)
        {
            switch (vladoRandoma.Next() % 3)
            {
                case 0:
                    shapes[i] = new Triangle(widths[vladoRandoma.Next(0, widths.Length)],
                                                 heights[vladoRandoma.Next(0, heights.Length)]);
                    break;
                case 1: shapes[i] = new Rectangle(widths[vladoRandoma.Next(0, widths.Length)],
                                                 heights[vladoRandoma.Next(0, heights.Length)]);
                    break;
                case 2: shapes[i] = new Circle(heights[vladoRandoma.Next(0, heights.Length)]);
                    break;

                default:
                    break;
            }
        }

        foreach (var item in shapes)
        {
            Console.WriteLine(item.ToString().Replace(',', '.'));
        }
    }
开发者ID:tddold,项目名称:Telerik-Academy-Homework-Solutions,代码行数:28,代码来源:Test.cs


示例14: RenderShapeToGraphics

        public static void RenderShapeToGraphics(string dataDir, Shape shape)
        {
            ShapeRenderer r = shape.GetShapeRenderer();

            // Find the size that the shape will be rendered to at the specified scale and resolution.
            Size shapeSizeInPixels = r.GetSizeInPixels(1.0f, 96.0f);

            // Rotating the shape may result in clipping as the image canvas is too small. Find the longest side
            // and make sure that the graphics canvas is large enough to compensate for this.
            int maxSide = Math.Max(shapeSizeInPixels.Width, shapeSizeInPixels.Height);

            using (Bitmap image = new Bitmap((int)(maxSide * 1.25), (int)(maxSide * 1.25)))
            {
                // Rendering to a graphics object means we can specify settings and transformations to be applied to 
                // the shape that is rendered. In our case we will rotate the rendered shape.
                using (Graphics gr = Graphics.FromImage(image))
                {
                    // Clear the shape with the background color of the document.
                    gr.Clear(shape.Document.PageColor);
                    // Center the rotation using translation method below
                    gr.TranslateTransform((float)image.Width / 8, (float)image.Height / 2);
                    // Rotate the image by 45 degrees.
                    gr.RotateTransform(45);
                    // Undo the translation.
                    gr.TranslateTransform(-(float)image.Width / 8, -(float)image.Height / 2);

                    // Render the shape onto the graphics object.
                    r.RenderToSize(gr, 0, 0, shapeSizeInPixels.Width, shapeSizeInPixels.Height);
                }
                dataDir = dataDir + "TestFile.RenderToGraphics_out_.png";
                image.Save(dataDir, ImageFormat.Png);

                Console.WriteLine("\nShape rendered to graphics successfully.\nFile saved at " + dataDir);
            }
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:35,代码来源:RenderShape.cs


示例15: Execute

        public IList<Shape> Execute(StyleOption option, EffectsDesigner designer, ImageItem source,
            Shape imageShape)
        {
            designer.ApplyPseudoTextWhenNoTextShapes();

            if ((option.IsUseBannerStyle 
                || option.IsUseFrostedGlassBannerStyle)
                    && (option.GetTextBoxPosition() == Position.Left
                        || option.GetTextBoxPosition() == Position.Centre
                        || option.GetTextBoxPosition() == Position.Right))
            {
                designer.ApplyTextWrapping();
            }
            else if (option.IsUseCircleStyle
                     || option.IsUseOutlineStyle)
            {
                designer.ApplyTextWrapping();
            }
            else
            {
                designer.RecoverTextWrapping();
            }

            ApplyTextEffect(option, designer);
            designer.ApplyTextGlowEffect(option.IsUseTextGlow, option.TextGlowColor);

            return new List<Shape>();
        }
开发者ID:digawp,项目名称:PowerPointLabs,代码行数:28,代码来源:TextStyleWorker.cs


示例16: CollisionMovingDown

        public bool CollisionMovingDown(Shape fallingShape, Dictionary<int, Tile> fallenTiles)
        {
            if (HitBottomOfGrid(fallingShape) || HitFallenShapesMovingDownwards(fallingShape, fallenTiles))
                return true;

            return false;
        }
开发者ID:johnhillhouse,项目名称:FallingBricks2,代码行数:7,代码来源:CollisionDetector.cs


示例17: TableCell

    /**
     * Create a new TableCell. This constructor is used when a new shape is Created.
     *
     * @param parent    the parent of this Shape. For example, if this text box is a cell
     * in a table then the parent is Table.
     */
    public TableCell(Shape parent){
        base(parent);

        SetShapeType(ShapeTypes.Rectangle);
        //_txtRun.SetRunType(TextHeaderAtom.HALF_BODY_TYPE);
        //_txtRun.GetRichTextRuns()[0].SetFlag(false, 0, false);
    }
开发者ID:hanwangkun,项目名称:npoi,代码行数:13,代码来源:TableCell.cs


示例18: ShapeInfoDialog

        /// <summary>
        /// Displays a dialog showing various information on the given shape:
        /// Template, shape type, shape library and the shape's control points including their capabilities and connected shapes.
        /// </summary>
        public ShapeInfoDialog(Project project, Shape shape)
        {
            if (project == null) throw new ArgumentNullException("project");
            if (shape == null) throw new ArgumentNullException("shape");
            InitializeComponent();

            this.project = project;

            Rectangle shapeBounds = shape.GetBoundingRectangle(false);
            this.shape = shape;
            this.shapeClone = shape.Clone();
            this.shapeClone.Fit(0, 0, shapeBounds.Width, shapeBounds.Height);

            this.diagram.Size = shapeBounds.Size;
            this.diagram.Shapes.Add(shapeClone);

            diagramSetController.Project = project;
            display.DrawDiagramSheet = false;
            display.Diagram = diagram;
            display.ShowGrid = false;
            display.GripSize = 5;
            display.HighQualityRendering = true;
            display.RenderingQualityHighQuality = RenderingQuality.MaximumQuality;
            display.CurrentTool = tool;

            UpdateShapeInfo();
        }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:31,代码来源:ShapeInfoDialog.cs


示例19: PhysxTriangleMesh

        public PhysxTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, IModelo model,Microsoft.Xna.Framework.Matrix localTransformation, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, MaterialDescription MaterialDescription)
        {
            Microsoft.Xna.Framework.Vector3[] vertices = null;
            int[] indices = null;
            ExtractData(ref vertices, ref indices, model);                                    

            
            TriangleMeshDesc meshDesc = new TriangleMeshDesc();            
            Vector3[] points = new Vector3[vertices.Count()];
            for (int i = 0; i < vertices.Count(); i++)
			{
			    points[i] = vertices[i].AsPhysX();
			}            
            meshDesc.Points = points;            
            meshDesc.SetTriangles<int>(indices);
            //meshDesc.Triangles = indices;
            
            MemoryStream ms = new MemoryStream();
            if(PhysxPhysicWorld.Cooking.CookTriangleMesh(meshDesc,ms)==false)
            {
                PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model",Engine.Logger.LogLevel.FatalError);
            }
            
            ms.Position = 0;
            TriangleMesh triangleMesh = PhysxPhysicWorld.Physix.CreateTriangleMesh(ms);
            
            staticActor = PhysxPhysicWorld.Physix.CreateRigidStatic(worldTransformation.AsPhysX());
            TriangleMeshGeometry TriangleMeshGeometry = new TriangleMeshGeometry(triangleMesh,new MeshScale(scale.AsPhysX(),Quaternion.Identity));

            material = PhysxPhysicWorld.Physix.CreateMaterial(MaterialDescription.StaticFriction, MaterialDescription.DynamicFriction, MaterialDescription.Bounciness);
            aTriMeshShape = staticActor.CreateShape(TriangleMeshGeometry, material, localTransformation.AsPhysX());

            this.Scale = scale;
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:34,代码来源:PhysxTriangleMesh.cs


示例20: Run

        public static void Run()
        {
            // ExStart:ConnectVisioSubShapes
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Set sub shape ids
            long shapeFromId = 2;
            long shapeToId = 4;

            // Load diagram
            Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
            // Access a particular page
            Page page = diagram.Pages.GetPage("Page-3");
           
            // Initialize connector shape
            Shape shape = new Shape();
            shape.Line.EndArrow.Value = 4;
            shape.Line.LineWeight.Value = 0.01388;

            // Add shape
            long connecter1Id = diagram.AddShape(shape, "Dynamic connector", page.ID);
            // Connect sub-shapes
            page.ConnectShapesViaConnector(shapeFromId, ConnectionPointPlace.Right, shapeToId, ConnectionPointPlace.Left, connecter1Id);
            // Save Visio drawing
            diagram.Save(dataDir + "ConnectVisioSubShapes_out.vsdx", SaveFileFormat.VSDX);
            // ExEnd:ConnectVisioSubShapes
        }
开发者ID:aspose-diagram,项目名称:Aspose.Diagram-for-.NET,代码行数:28,代码来源:ConnectVisioSubShapes.cs



注:本文中的Shape类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Shape3D类代码示例发布时间:2022-05-24
下一篇:
C# ShadingState类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap