Example #1
0
        private void addColor(MakeXML xmlHolder, Ink ink, Shape.ShapeType type)
        {
            Shape[] shapes = new Shape[0];
            switch (type)
            {
            case (Shape.ShapeType.LABELED):
                shapes = xmlHolder.getSketch().Labeled;
                break;

            case (Shape.ShapeType.CLUSTERED):
                shapes = xmlHolder.getSketch().Clustered;
                break;
            }

            foreach (Shape shape in shapes)
            {
                string name = shape.Name;
                Color  c    = getRandomColor();
                foreach (Shape.Arg arg in shape.Args)
                {
                    string guid    = arg.Id;
                    Shape  toColor = (Shape)xmlHolder.getSketch().IdToShape[guid];
                    if (toColor != null)
                    {
                        string guid2 = toColor.Id;

                        if (guidToMStroke.ContainsKey(guid2))
                        {
                            ((Microsoft.Ink.Stroke)guidToMStroke[guid2]).DrawingAttributes.Color = c;
                        }
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Converts the XML format into Ink strokes and creates a mapping between the XML stroke Ids and the
 /// Ink stroke Ids.
 /// </summary>
 public MakeInk(MakeXML xmlHolder, Ink ink, Shape.ShapeType type)
 {
     this.ink         = ink;
     this.idToCStroke = this.getIdToCStroke(xmlHolder.getSketch(), this.ink);
     calculateIdToMStroke();
     this.idToMSubstrokes = new Hashtable();
     addColor(xmlHolder, ink, type);
 }
Example #3
0
    public void Initialise(Shape.ShapeType shapeType, Quaternion rotation, Vector3 position, float radius, float length = 0.0f)
    {
        gameObject.SetActive(true);
        transform.rotation = rotation;
        transform.position = position;

        ShapeDefinition.ShapeEnum = shapeType;
        ShapeDefinition.Radius    = radius;
        ShapeDefinition.Length    = length;
    }
Example #4
0
 private void SwitchShapeType()
 {
     if (shapeType != Shape.ShapeType.Type3)
     {
         shapeType++;
     }
     else
     {
         shapeType = Shape.ShapeType.Type1;
     }
 }
        void circlec(Shape.ShapeType st, int sol, int gol, int bol, int loc1, int loc2)
        {
            Shape newShape = new Shape();

            newShape.Size      = new Size(20, 20);
            newShape.Type      = st;
            newShape.Location  = new Point(loc1, loc2);
            newShape.BackColor = Color.FromArgb(sol, gol, bol);
            newShape.ForeColor = Color.FromArgb(sol, gol, bol);
            newShape.ShapeName = "R: " + sol + "G: " + gol + "B: " + bol;
            this.Controls.Add(newShape);
        }
Example #6
0
        /// <summary>
        /// Creates a new shape and puts it on the grid.
        /// </summary>
        public void CreateNewShape(Shape.ShapeType type)
        {
            // shape size is random therefore doesn't need to be added as a param
            var shape = new Shape(new CellPosition(x: random.Next(0, GridManager.SizeX - 4)), type, colors[random.Next(0, colors.Length)]);

            shapes.Add(shape);
            currentShape = shape;

            // decreate the timer interval by 5% of what it currently is
            Tetris.main.IncreaseShapeUpdate();

            // add 4 to the score since each block is 4 cells
            GameManager.AddScore();
        }
Example #7
0
        void manageShapes(Shape.ShapeType sht)
        {
            Shape newShape = new Shape();

            newShape.Location   = new Point(100, 100);
            newShape.Size       = new Size(50, 50);
            newShape.ForeColor  = colorDialog1.Color;
            newShape.Type       = sht;
            newShape.MouseDown += new MouseEventHandler(_MouseDown);
            newShape.MouseMove += new MouseEventHandler(_MouseMove);
            newShape.MouseUp   += new MouseEventHandler(_MouseUp);
            newShape.BackColor  = Color.Red;
            Cursor.Clip         = new Rectangle(this.Location, this.Size);

            this.Controls.Add(newShape);
        }
Example #8
0
        /// <summary>
        /// Creates and adds new shape based on the specified <paramref name="shapeType"/> to the screen.
        /// </summary>
        /// <param name="shapeType">Type of the shape to create.</param>
        /// <returns>Returns <see cref="ShapeState"/> of the added shape.</returns>
        public ShapeState AddShape(Shape.ShapeType shapeType)
        {
            ShapeState newState = null;

            switch (shapeType)
            {
            case Shape.ShapeType.Polygon:
                newState = new PolygonEditState(new Polygon(), this)
                {
                    Color = ColorSettings.GoodColors[goodColorsIndex]
                };
                State = newState;
                break;

            case Shape.ShapeType.Circle:
                newState = new CircleEditState(new Circle(), this)
                {
                    Color = ColorSettings.GoodColors[goodColorsIndex]
                };
                State = newState;
                break;

            case Shape.ShapeType.Edge:
                newState = new EdgeEditState(new Edge(), this)
                {
                    Color = ColorSettings.GoodColors[goodColorsIndex]
                };
                State = newState;
                break;
            }

            if (newState != null)
            {
                if (++goodColorsIndex >= ColorSettings.GoodColors.Length)
                {
                    goodColorsIndex = 0;
                }
                Shapes.Add(newState);
            }

            return(newState);
        }
 private void cbShape_SelectionChangeCommitted(object sender, EventArgs e)
 {
     //Sự kiện "chọn hình khối"
     if (cbShape.SelectedIndex == 0)
     {
         choosingShape = Shape.ShapeType.CUBE;
     }
     else if (cbShape.SelectedIndex == 1)
     {
         choosingShape = Shape.ShapeType.PYRAMID;
     }
     else if (cbShape.SelectedIndex == 2)
     {
         choosingShape = Shape.ShapeType.PRISMATIC;
     }
     else
     {
         choosingShape = Shape.ShapeType.NONE;
     }
 }
        void shapik(Shape.ShapeType st, Point cur)
        {
            newShape            = new Shape();
            newShape.Size       = new Size(0, 0);
            newShape.ForeColor  = Color.Black;
            newShape.Type       = st;
            newShape.Location   = cur;
            newShape.MouseDown += new MouseEventHandler(_MouseDown);
            newShape.MouseMove += new MouseEventHandler(_MouseMove);
            newShape.MouseUp   += new MouseEventHandler(_MouseUp);
            newShape.BackColor  = Color.Green;
            // shape = newShape;
            this.Controls.Add(newShape);
            // MessageBox.Show("sssssssssssssssssssssssssssss");

            ContextMenu contextMenu = new ContextMenu();

            contextMenu.MenuItems.Add("Pick Back colour", new EventHandler(newShape.BackColourChange));
            contextMenu.MenuItems.Add("Pick Font colour", new EventHandler(newShape.ForeColourChange));
            newShape.ContextMenu = contextMenu;

            newShape.BackColor = Color.Red;
            this.Controls.Add(newShape);
        }
        public void OnBodyAddedCallback(Body body)// IntPtr bodyHandle)
        {
            // Create the game object
            bool       isFinger = false;
            GameObject gameObject;

            Shape.ShapeType type = body.Shape.Type;
            if (type == Shape.ShapeType.Capsule)
            {
                float capsuleRadius        = body.Shape.CapsuleRadius;
                float capsuleSegmentLength = body.Shape.CapsuleSegmentLength;

                gameObject = GameObject.Instantiate(Resources.Load(UnityUtil.ResourcesFolder + UnityUtil.FingerBoneTemplateName) as GameObject) as GameObject;

                // Adjust dimensions
                float capsuleHeight = capsuleRadius * 2f + capsuleSegmentLength;
                float yScale        = capsuleHeight / 2f;
                float zxScale       = capsuleRadius / 0.5f;
                gameObject.transform.localScale = new Vector3(zxScale, yScale, zxScale);
                gameObject.name = UnityUtil.FingerBoneName;

                LeapTransform t = new LeapTransform();
                t = new LeapTransform(Native.AccessPropertyAsTransform(body, Native.Property.BodyTransform, Native.Mode.Get, t.ToNative()));
                gameObject.transform.position = t.Position;
                gameObject.transform.rotation = t.Rotation;

                gameObject.rigidbody.maxAngularVelocity = 100.0f;

                isFinger = true;
                fingerBoneCount++;
            }
            else
            {
                gameObject      = GameObject.Instantiate(Resources.Load(UnityUtil.ResourcesFolder + UnityUtil.HandPalmTemplateName) as GameObject) as GameObject;
                gameObject.name = UnityUtil.HandPalmName;
                LeapTransform t = new LeapTransform();
                t = new LeapTransform(Native.AccessPropertyAsTransform(body, Native.Property.BodyTransform, Native.Mode.Get, t.ToNative()));
                gameObject.transform.position = t.Position;
                gameObject.transform.rotation = t.Rotation;

                gameObject.rigidbody.maxAngularVelocity = 100.0f;

                latestHandPalmAdded = gameObject;
                fingerBoneCount     = 0;
            }

            BodyMapper.Add(gameObject, body);

            GameObject container = isFinger && latestHandPalmAdded != null ? latestHandPalmAdded : GameObject.Find(UnityUtil.DynamicObjectContainerName) as GameObject;

            gameObject.transform.parent = container.transform;

            gameObject.layer = UnityUtil.LayerForHands;

            if (fingerBoneCount % 3 == 0 && fingerBoneCount > 0)
            {
                gameObject.name = UnityUtil.FingerTipBoneName;
                if (fingerBoneCount == 3)
                {
                    gameObject.name = UnityUtil.ThumbTipBoneName;
                }
            }

            if (fingerBoneCount == 15)
            {
                latestHandPalmAdded = null;
                fingerBoneCount     = 0;

                if (UnityUtil.FilterHandCollisionPerColliderExplicitly)
                {
                    DisableHandSelfCollisions(gameObject.transform.parent);
                }
            }
        }