예제 #1
0
        private int mNextPreferedActiveConnectionIndex = 0; // the prefered active connection index according to the brick library

        #endregion Fields

        #region Constructors

        public AddConnectBrick(LayerBrick layer, string partNumber, int wantedConnexion)
        {
            mBrickLayer = layer;
            mBrick = new LayerBrick.Brick(partNumber);
            LayerBrick.Brick selectedBrick = layer.getConnectableBrick();

            if (selectedBrick != null)
            {
                // check if the selected brick has connection point
                if (selectedBrick.HasConnectionPoint && mBrick.HasConnectionPoint)
                {
                    // choose the best active connection point for the brick
                    setBestConnectionPointIndex(selectedBrick, mBrick, wantedConnexion);

                    // after setting the active connection point index from which this brick will be attached,
                    // get the prefered index from the library
                    mNextPreferedActiveConnectionIndex = BrickLibrary.Instance.getConnectionNextPreferedIndex(partNumber, mBrick.ActiveConnectionPointIndex);

                    // then rotate the brick to connect
                    mBrick.Orientation = sGetOrientationOfConnectedBrick(selectedBrick, mBrick);
                    // the place the brick to add at the correct position
                    mBrick.ActiveConnectionPosition = selectedBrick.ActiveConnectionPosition;
                }
                else
                {
                    PointF position = selectedBrick.Position;
                    position.X += selectedBrick.DisplayArea.Width;
                    mBrick.Position = position;
                }

                // set the index of the brick in the list just after the selected brick
                mBrickIndex = layer.BrickList.IndexOf(selectedBrick) + 1;
            }
        }
 public AttachRulerToBrick(LayerRuler.RulerItem rulerItem, LayerBrick.Brick brick)
 {
     // compute the attach offset in local coordinate
     PointF attachOffset = RulerAttachementSet.Anchor.sComputeLocalOffsetFromLayerItem(brick, rulerItem.CurrentControlPoint);
     // create a new Anchor
     mAnchor = new RulerAttachementSet.Anchor(rulerItem, rulerItem.CurrentControlPointIndex, attachOffset);
     mBrick = brick;
 }
예제 #3
0
 public BrickTransform(LayerBrick.Brick brick, PointF position, float orientation)
 {
     mBrick = brick;
     mPosition = position;
     mOrientation = orientation;
 }
예제 #4
0
 /// <summary>
 /// Call this function when you want to detach the current control point.
 /// Be sure to choose the correct current point before calling this function.
 /// <param name="index">useless parameter for a circular ruler</param>
 /// </summary>
 public override void detachControlPoint(int index)
 {
     mAttachedBrick = null;
 }
예제 #5
0
 /// <summary>
 /// Call this function when you want to attach the current control point to the specified brick.
 /// Be sure to choose the correct current point before calling this function
 /// </summary>
 /// <param name="index">useless for circular ruler</param>
 /// <param name="brick">the brick to which the current control point will be attached</param>
 public override void attachControlPointToBrick(int index, LayerBrick.Brick brick)
 {
     // the circular ruler only have one attach
     mAttachedBrick = brick;
 }
 public RulerAttachementSet(LayerBrick.Brick owner)
 {
     mOwnerBrick = owner;
 }
 public RotateBrickOnPivotBrick(LayerBrick layer, List<Layer.LayerItem> bricks, float angle, LayerBrick.Brick pivotBrick)
     : base(layer, bricks, angle)
 {
     mPivotBrick = pivotBrick;
 }