Example #1
0
        public virtual bool Setup(
            Point position,
            RotateAngle rotate  = RotateAngle.angle0,
            bool isreflectedbyx = false,
            bool isreflectedbyy = false)
        {
            if (!CheckSetupPossible(position, rotate, isreflectedbyx, isreflectedbyy))
            {
                return(false);
            }

            Position       = position;
            IsReflectedByX = isreflectedbyx;
            IsReflectedByY = isreflectedbyy;
            Rotate         = rotate;


            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    SetShipElement(Map.GetCell(new Point(Position.X + i, Position.Y + j)), this);
                }
            }
            return(true);
        }
        private void Rotate(RotateAngle angle)
        {
            uint uInt;

            uint.TryParse(angleTextBox.Text, out uInt);
            angleTextBox.Text = (ImageUtils.MaxRotationAngle((int)angle + (int)uInt)).ToString();
        }
 public void RotateFlip(bool horizontalFlip, bool verticalFlip, RotateAngle angle)
 {
     this.mBmp          = BitmapHelper.RotateFlip(this.mBmp, horizontalFlip, verticalFlip, angle);
     this.mPointsWidth  = this.mBmp.Width;
     this.mPointsHeight = this.mBmp.Height;
     this.Invalidate();
 }
Example #4
0
 private void btnRotate_Click(object sender, RoutedEventArgs e)
 {
     if (this.pdfDocumentViewer1.IsDocumentLoaded && this.CboRotate.SelectedIndex != -1)
     {
         RotateAngle rotateAngle = (RotateAngle)this.CboRotate.SelectedIndex;
         //Rotate PDF document
         this.pdfDocumentViewer1.Rotate(rotateAngle);
     }
 }
Example #5
0
 public XmlSavingOptions()
 {
     this.mFlipHorizontal = false;
     this.mFlipVertical   = false;
     this.mAngle          = RotateAngle.None;
     this.mInverse        = false;
     this.mAlignRight     = false;
     this.mMirrorEachByte = false;
 }
Example #6
0
 public XmlSavingOptions(bool flipHorizontal, bool flipVertical, RotateAngle angle, bool inverse, bool alignRight, bool mirrorEachByte)
 {
     this.mFlipHorizontal = flipHorizontal;
     this.mFlipVertical   = flipVertical;
     this.mAngle          = angle;
     this.mInverse        = inverse;
     this.mAlignRight     = alignRight;
     this.mMirrorEachByte = mirrorEachByte;
 }
Example #7
0
 public override bool Setup(Point position, RotateAngle rotate = RotateAngle.angle0, bool isreflectedbyx = false, bool isreflectedbyy = false)
 {
     if (base.Setup(position, rotate, isreflectedbyx, isreflectedbyy))
     {
         CheckConnection();
         return(true);
     }
     return(false);
 }
Example #8
0
 /// <summary>
 /// Rotate PDF document
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRotate_Click(object sender, EventArgs e)
 {
     if (this.pdfDocumentViewer1.IsDocumentLoaded)
     {
         if (this.comBoxAngle.SelectedIndex != -1)
         {
             RotateAngle angle = (RotateAngle)this.comBoxAngle.SelectedIndex;
             this.pdfDocumentViewer1.Rotate(angle);
         }
     }
 }
Example #9
0
        private void BtnGoStart_Click(object sender, RoutedEventArgs e)
        {
            //偵測數值有誤
            const double HEIGHT_MAX    = 1100;
            const double HEIGHT_MIN    = 60;
            const double DISTANCE_MAX  = 50;
            double       measureHeight =
                DistanceSensor.Distance;
            double measureLeftDistance =
                Utility.ultraSonicSensor2.GetDistanceInCentimeters;
            double measureRightDistance =
                Utility.ultraSonicSensor2.GetDistanceInCentimeters;

            if (measureHeight > HEIGHT_MAX || measureHeight < HEIGHT_MIN)
            {
                ShowErrorDialog("高度偵測錯誤!!請再試一次");
                return;
            }
            if (measureLeftDistance > DISTANCE_MAX ||
                measureRightDistance > DISTANCE_MAX)
            {
                ShowErrorDialog("距離偵測錯誤!!請面向牆壁後再試一次");
                return;
            }

            //取得角度
            int horizontalRotateAngle =
                (int)RotateAngle.HorizontalRotateAngle(CenterPoint,
                                                       facePoint,
                                                       targetPoint);
            int verticalRotateAngle =
                (int)RotateAngle.VerticalRotateAngle(CenterPoint,
                                                     targetPoint,
                                                     DistanceSensor.Distance / 100);

            //垂直校準
            Utility.verticalMotor.Correction();
            //水平校準
            Utility.horizontalMotor.Correction();
            //垂直轉動
            Utility.verticalMotor.PositiveRotation(verticalRotateAngle);
            //水平轉動
            if (horizontalRotateAngle < 0)
            {
                Utility.horizontalMotor.PositiveRotation(-horizontalRotateAngle);
            }
            else
            {
                Utility.horizontalMotor.ReverseRotation(horizontalRotateAngle);
            }

            ShowSuccessDialog();
        }
Example #10
0
 void TurnBlock(int turnCount)
 {
     TargetFromEast  = ValueToRotateAngle(targetPoint[(int)StartPosition.East]);
     TargetFromNorth = ValueToRotateAngle(targetPoint[(int)StartPosition.North]);
     TargetFromWest  = ValueToRotateAngle(targetPoint[(int)StartPosition.West]);
     TargetFromSouth = ValueToRotateAngle(targetPoint[(int)StartPosition.South]);
     for (; turnCount > 0; --turnCount)
     {
         var temp = TargetFromEast;
         TargetFromEast  = TargetFromNorth;
         TargetFromNorth = TargetFromWest;
         TargetFromWest  = TargetFromSouth;
         TargetFromSouth = temp;
     }
 }
Example #11
0
        Vector3 SetDirection(RotateAngle ra)
        {
            Vector3 temp = Vector3.zero;

            switch (ra)
            {
            case RotateAngle.Right:
                temp = new Vector3(1, 0, 0);
                break;

            case RotateAngle.RightDown:
                temp = new Vector3(1, 0, -1);
                break;

            case RotateAngle.Down:
                temp = new Vector3(0, 0, -1);
                break;

            case RotateAngle.LeftDown:
                temp = new Vector3(-1, 0, -1);
                break;

            case RotateAngle.Left:
                temp = new Vector3(-1, 0, 0);
                break;

            case RotateAngle.LeftTop:
                temp = new Vector3(-1, 0, 1);
                break;

            case RotateAngle.Top:
                temp = new Vector3(0, 0, 1);
                break;

            case RotateAngle.RightTop:
                temp = new Vector3(1, 0, 1);
                break;
            }

            return(temp);
        }
Example #12
0
        public virtual bool CheckSetupPossible(
            Point position,
            RotateAngle rotate  = RotateAngle.angle0,
            bool isreflectedbyx = false,
            bool isreflectedbyy = false)
        {
            if (position.X < 0 || position.Y < 0 || Map.Width <= position.X + Width || Map.Heigth <= position.Y + Height)
            {
                return(false);
            }

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    if (GetShipElement(Map.GetCell(new Point(position.X + i, position.Y + j))) != null)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        public static Bitmap RotateFlip(Bitmap bmp, bool horizontalFlip, bool verticalFlip, RotateAngle angle)
        {
            Bitmap result = (Bitmap)bmp.Clone();

            // flip
            if (horizontalFlip || verticalFlip)
            {
                result = bmp.Clone(Rectangle.FromLTRB(0, 0, bmp.Width, bmp.Height), PixelFormat.Format1bppIndexed);
                unsafe
                {
                    BitmapData bmdSrc = bmp.LockBits(Rectangle.FromLTRB(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
                    BitmapData bmdDst = result.LockBits(Rectangle.FromLTRB(0, 0, result.Width, result.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);

                    for (int x = 0; x < bmp.Width; x++)
                    {
                        for (int y = 0; y < bmp.Height; y++)
                        {
                            bool bit = GetPixel(bmdSrc, x, y);
                            //only vertical
                            if (!horizontalFlip && verticalFlip)
                            {
                                SetPixel(bmdDst, x, bmp.Height - y - 1, bit);
                            }
                            //only horizontal
                            if (horizontalFlip && !verticalFlip)
                            {
                                SetPixel(bmdDst, bmp.Width - x - 1, y, bit);
                            }
                            //vertical & horizontal
                            if (horizontalFlip && verticalFlip)
                            {
                                SetPixel(bmdDst, bmp.Width - x - 1, bmp.Height - y - 1, bit);
                            }
                        }
                    }
                    bmp.UnlockBits(bmdSrc);
                    result.UnlockBits(bmdDst);
                }
            }
            if (angle == RotateAngle.Angle180)
            {
                Bitmap result2 = result.Clone(Rectangle.FromLTRB(0, 0, result.Width, result.Height), PixelFormat.Format1bppIndexed);
                unsafe
                {
                    BitmapData bmdSrc = result.LockBits(Rectangle.FromLTRB(0, 0, result.Width, result.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
                    BitmapData bmdDst = result2.LockBits(Rectangle.FromLTRB(0, 0, result2.Width, result2.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);

                    for (int x = 0; x < result.Width; x++)
                    {
                        for (int y = 0; y < result.Height; y++)
                        {
                            bool bit = GetPixel(bmdSrc, x, y);
                            SetPixel(bmdDst, result.Width - x - 1, result.Height - y - 1, bit);
                        }
                    }
                    result.UnlockBits(bmdSrc);
                    result2.UnlockBits(bmdDst);
                    result = result2;
                }
            }
            if (angle == RotateAngle.Angle90 || angle == RotateAngle.Angle270)
            {
                //Bitmap result2 = result.Clone(Rectangle.FromLTRB(0, 0, result.Height, result.Width), PixelFormat.Format1bppIndexed);
                Bitmap result2 = new Bitmap(result.Height, result.Width, PixelFormat.Format1bppIndexed);
                unsafe
                {
                    BitmapData bmdSrc = result.LockBits(Rectangle.FromLTRB(0, 0, result.Width, result.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
                    BitmapData bmdDst = result2.LockBits(Rectangle.FromLTRB(0, 0, result2.Width, result2.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);

                    for (int x = 0; x < result.Width; x++)
                    {
                        for (int y = 0; y < result.Height; y++)
                        {
                            bool bit = GetPixel(bmdSrc, x, y);
                            if (angle == RotateAngle.Angle90)
                            {
                                SetPixel(bmdDst, result2.Width - y - 1, x, bit);
                            }
                            if (angle == RotateAngle.Angle270)
                            {
                                SetPixel(bmdDst, y, result2.Height - x - 1, bit);
                            }
                        }
                    }
                    result.UnlockBits(bmdSrc);
                    result2.UnlockBits(bmdDst);
                    result = result2;
                }
            }

            return(result);
        }
Example #14
0
        void LaserProjection()
        {
            direction = initDirection.position - transform.position;

            Ray ray = new Ray();

            ray.origin    = this.transform.position;
            ray.direction = direction;

            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, 150, layermask))
            {
                ObjectInfo hitInfo = hit.transform.gameObject.GetComponentInParent <ObjectInfo>();

                if (hitInfo != null)
                {
                    ObjectType hitType = hitInfo.objectType;
                    lineRenderer.SetPosition(0, this.transform.position);
                    lineRenderer.SetPosition(1, hit.point);


                    if (hitType == ObjectType.Reflector)
                    {
                        if (!recreate)
                        {
                            RotateAngle angle    = hitInfo.rotateAngle;
                            GameObject  newLight = Instantiate(transform.parent.gameObject, hit.point, Quaternion.identity);
                            newLight.transform.parent = this.transform;
                            LaserSource.laserList.Add(newLight);
                            Laser newLaser = newLight.gameObject.GetComponentInChildren <Laser>();
                            newLaser.initDirection.localPosition = SetDirection(angle);
                            this.recreate = true;
                        }
                    }

                    if (hitType == ObjectType.Dispersant)
                    {
                        if (!recreate)
                        {
                            int          hitKey   = hit.transform.gameObject.GetComponent <ObjectPart>().key;
                            GameObject[] newLight = new GameObject[4];
                            for (int i = 0; i < 4; i++)
                            {
                                if (i == hitKey)
                                {
                                    continue;
                                }
                                ObjectPart  hitPart = hitInfo.objectParts[i];
                                RotateAngle angle   = hitPart.rotateAngle;
                                Vector3     newPos  = hitPart.Position;
                                newLight[i] = Instantiate(transform.parent.gameObject, newPos, Quaternion.identity);
                                Laser newLaser = newLight[i].gameObject.GetComponentInChildren <Laser>();
                                newLaser.initDirection.localPosition = SetDirection(angle);
                            }

                            for (int i = 0; i < 4; i++)
                            {
                                if (newLight[i] == null)
                                {
                                    continue;
                                }
                                newLight[i].transform.parent = this.transform;
                                LaserSource.laserList.Add(newLight[i]);
                            }

                            this.recreate = true;
                        }
                    }

                    if (hitType == ObjectType.Transmission)
                    {
                        if (!recreate)
                        {
                            int        hitKey = hit.transform.gameObject.GetComponent <ObjectPart>().key;
                            GameObject newLight;
                            if (hitKey == 0)
                            {
                                ObjectPart  hitPart = hitInfo.objectParts[1];
                                RotateAngle angle   = hitPart.rotateAngle;
                                Vector3     newPos  = hitPart.Position;
                                newLight = Instantiate(transform.parent.gameObject, newPos, Quaternion.identity);
                                newLight.transform.parent = this.transform;
                                Laser newLaser = newLight.gameObject.GetComponentInChildren <Laser>();
                                newLaser.initDirection.localPosition = SetDirection(angle);
                            }
                            else if (hitKey == 1)
                            {
                                ObjectPart hitPart = hitInfo.objectParts[0];
                                Debug.Log(hitPart.transform.parent.name);
                                RotateAngle angle  = hitPart.rotateAngle;
                                Vector3     newPos = hitPart.Position;
                                newLight = Instantiate(transform.parent.gameObject, newPos, Quaternion.identity);
                                newLight.transform.parent = this.transform;
                                Laser newLaser = newLight.gameObject.GetComponentInChildren <Laser>();
                                newLaser.initDirection.localPosition = SetDirection(angle);
                            }
                        }

                        this.recreate = true;
                    }

                    if (hitType == ObjectType.Absorber)
                    {
                        hitInfo.doors.SetTrigger("Openning");
                    }

                    if (hitType == ObjectType.Wall)
                    {
                        laserSource.isUpdate = true;
                        this.recreate        = true;
                    }
                }
            }

            projection = false;
        }
 public override void RotateFlip(bool horizontalFlip, bool verticalFlip, RotateAngle angle)
 {
     this.mEditor.BmpEditor.RotateFlip(horizontalFlip, verticalFlip, angle);
 }
Example #16
0
 // Use this for initialization
 void Start()
 {
     rotateangle = scanner.GetComponent <RotateAngle>();
 }
Example #17
0
 public virtual void RotateFlip(bool horizontalFlip, bool verticalFlip, RotateAngle angle)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 private void Rotate(RotateAngle angle)
 {
     uint uInt;
     uint.TryParse(angleTextBox.Text, out uInt);
     angleTextBox.Text = (ImageUtils.MaxRotationAngle((int)angle + (int)uInt)).ToString();
 }
        public static Bitmap RotateFlip2(Bitmap bmp, bool horizontalFlip, bool verticalFlip, RotateAngle angle)
        {
            int index = 0;

            if (horizontalFlip)
            {
                index |= 1;
            }
            if (verticalFlip)
            {
                index |= 2;
            }
            if (angle == RotateAngle.Angle90)
            {
                index |= (1 << 2);
            }
            else if (angle == RotateAngle.Angle180)
            {
                index |= (2 << 2);
            }
            else if (angle == RotateAngle.Angle270)
            {
                index |= (3 << 2);
            }
            RotateFlipType[] variants = new RotateFlipType[] {
                RotateFlipType.RotateNoneFlipNone,  //0
                RotateFlipType.RotateNoneFlipX,     //1
                RotateFlipType.RotateNoneFlipY,     //2
                RotateFlipType.RotateNoneFlipXY,    //3
                RotateFlipType.Rotate90FlipNone,    //4
                RotateFlipType.Rotate90FlipX,       //5
                RotateFlipType.Rotate90FlipY,       //6
                RotateFlipType.Rotate90FlipXY,      //7
                RotateFlipType.Rotate180FlipNone,   //8
                RotateFlipType.Rotate180FlipX,
                RotateFlipType.Rotate180FlipY,
                RotateFlipType.Rotate180FlipXY,
                RotateFlipType.Rotate270FlipNone,
                RotateFlipType.Rotate270FlipX,
                RotateFlipType.Rotate270FlipY,
                RotateFlipType.Rotate270FlipXY
            };
            Bitmap result = (Bitmap)bmp.Clone();

            bmp.Save("1.bmp");
            result.RotateFlip(variants[index]);
            result.Save("2.bmp");
            return(result);
        }