コード例 #1
0
        public void Rotates()
        {
            ILogger logger  = new NullLogger <object>();
            var     grid    = new Grid(5, 5);
            State?  state   = new State(MoveDirection.East, new Coordinate(1, 3));
            var     command = new RotateCommand(RotateDirection.Left);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.North, state.Value.Direction);
            Assert.AreEqual(1, state.Value.Coordinate.X);
            Assert.AreEqual(3, state.Value.Coordinate.Y);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.West, state.Value.Direction);

            command = new RotateCommand(RotateDirection.Right);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.North, state.Value.Direction);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.East, state.Value.Direction);
            Assert.AreEqual(1, state.Value.Coordinate.X);
            Assert.AreEqual(3, state.Value.Coordinate.Y);
        }
コード例 #2
0
 private void InitCommands()
 {
     OpenCommand              = new OpenCommand(this);
     ApplyCommand             = new ApplyCommand(this);
     FlipCommand              = new FlipCommand(this);
     HistogramEqualizeCommand = new HistogramEqualizeCommand(this);
     HistogramStretchCommand  = new HistogramStretchCommand(this);
     CropCommand              = new CropCommand(this);
     InpaintCommand           = new InpaintCommand(this);
     ResizeCommand            = new ResizeCommand(this);
     RotateCommand            = new RotateCommand(this);
     SaveAsCommand            = new SaveAsCommand(this);
     SaveCommand              = new SaveCommand(this);
     ZoomCommand              = new ZoomCommand(this);
     ResetCommand             = new ResetCommand(this);
     CloseCommand             = new CloseCommand(this);
     SelectToolCommand        = new SelectToolCommand(this);
     UndoCommand              = new UndoCommand(this);
     RedoCommand              = new RedoCommand(this);
     DropboxCommand           = new DropboxCommand(this);
     DownloadCommand          = new DownloadCommand(this);
     UploadCommand            = new UploadCommand(this);
     DCommand       = new DCommand(this);
     ECommand       = new ECommand(this);
     PrewittCommand = new PrewittCommand(this);
 }
コード例 #3
0
ファイル: Explorer.cs プロジェクト: AlbertMin/AlbertCAD
        /// <summary>
        /// 转动指定的图形元素
        /// </summary>
        /// <returns></returns>
        public RotateCommand RotateCommand()
        {
            var c = new RotateCommand();

            DrawingControl.SetCommand(c);
            return(c);
        }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        float z = Input.GetAxisRaw("Vertical");
        float x = Input.GetAxisRaw("Horizontal");

        if (z <= -0.1f || z >= 0.1f)
        {
            //Vector3 current = transform.position;
            //Vector3 destination = new Vector3(current.x, current.y, current.z + z);
            //Vector3 direction = destination - transform.position;
            //transform.Translate(direction.normalized * speed * Time.deltaTime);
            MoveCommand move = new MoveCommand(transform, speed, z);
            move.Execute();
        }

        //if(x >= 0.1f)
        //{
        //    transform.Rotate(new Vector3(0, 1, 0) * r_speed/60f, Space.World);
        //}

        //if (x <= -0.1f)
        //{
        //    transform.Rotate(new Vector3(0, -1, 0) * r_speed/60f, Space.World);
        //}
        if (x <= -0.1f || x >= 0.1f)
        {
            RotateCommand rotate = new RotateCommand(transform, r_speed, x);
            rotate.Execute();
        }
    }
コード例 #5
0
 public GameFieldViewModel()
 {
     RotateClick    = new RotateCommand(this);
     MoveClick      = new ChangePositionCommand(this);
     StartGameClick = new StartGameCommand(this);
     GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <MvvmMessage>(this, HandleMessage);
 }
コード例 #6
0
    /// <summary>
    /// This methods rotates hexagons. Rotate information comes from input manager
    /// </summary>
    /// <param name="clockwise"></param>
    /// <returns></returns>
    public IEnumerator CheckRotate(bool clockwise)
    {
        List <Hexagon> matchList = new List <Hexagon>();
        // temporary group
        CellGroup tempGroup = selectedGroup;
        // Initialize our rotate command
        ICommand rotateCommand;

        for (int i = 0; i < selectedGroup.NeighbourGroup.Length; i++)
        {
            SetState(States.RotatingState);
            // create new rotate command for start rotating
            rotateCommand = new RotateCommand(clockwise);
            rotateCommand.Execute();
            // adding new command to command buffer. It can be used for later events
            CommandManager.Instance.AddCommand(rotateCommand);
            yield return(new WaitForSeconds(HexMetrics.ROTATION_DELAY));

            // calculation for matches
            matchList = CalculateMatches(hexagons);

            if (matchList.Count > 0)
            {
                OnMoveMade?.Invoke();
                SetState(States.ExplosionState);
                StartCoroutine(HandleMatch(matchList));
                break;
            }
        }
        // if everything is compleated we are going to take our next input
        SetState(States.InputState);
    }
コード例 #7
0
    private void CheckCommand(Commands command)
    {
        switch (command)
        {
        case Commands.Place:
            placementCoordinates = testCase.ReturnPlacementCoordinates(PlacementCoordinatesIndex);
            PlaceCommand placeCommand = new PlaceCommand(toyRobot, placementCoordinates);
            commandExucute.ExcutePlace(placeCommand);
            PlacementCoordinatesIndex++;
            break;

        case Commands.Move:
            MoveCommand moveCommand = new MoveCommand(toyRobot);
            commandExucute.ExcuteMovement(moveCommand);
            break;

        case Commands.Left:
        case Commands.Right:
            RotateCommand rotateCommand = new RotateCommand(toyRobot, command);
            commandExucute.ExcuteRotate(rotateCommand);
            break;

        case Commands.Report:
            ReportCommand reportCommand = new ReportCommand(toyRobot);
            commandExucute.ExcuteReport(reportCommand);
            break;
        }
    }
コード例 #8
0
        /// <summary>
        /// Builds the proccessing command to process current captured frame.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ChangeProcessingCommandHandler(object sender, EventArgs e)
        {
            List <ProcessingCommandBase> commands = new List <ProcessingCommandBase>();

            // Invert
            switch (invertComboBox.SelectedIndex)
            {
            case 1:
                commands.Add(new InvertCommand());
                break;

            case 2:
                commands.Add(new ColorBlendCommand(BlendingMode.Difference, Color.FromArgb(255, 0, 0)));
                break;

            case 3:
                commands.Add(new ColorBlendCommand(BlendingMode.Difference, Color.FromArgb(0, 255, 0)));
                break;

            case 4:
                commands.Add(new ColorBlendCommand(BlendingMode.Difference, Color.FromArgb(0, 0, 255)));
                break;
            }

            // Grayscale
            if (grayscaleCheckBox.Checked)
            {
                commands.Add(new ChangePixelFormatToGrayscaleCommand(PixelFormat.Gray8));
            }

            // Rotate
            int rotate;

            if (int.TryParse(rotateComboBox.Text, out rotate))
            {
                if (rotate != 0)
                {
                    RotateCommand rotateCommand = new RotateCommand(rotate);
                    rotateCommand.BorderColorType = BorderColorType.Black;
                    commands.Add(rotateCommand);
                }
            }

            if (commands.Count == 0)
            {
                _processingCommand = null;
            }
            else if (commands.Count == 1)
            {
                _processingCommand = commands[0];
            }
            else
            {
                _processingCommand = new CompositeCommand(commands.ToArray());
            }
        }
コード例 #9
0
 private void Start()
 {
     _gm = GameManager.Instance;
     if (transform.forward == Vector3.forward)
     {
         _counted = true;
         _gm.Decrease();
     }
     rc = new RotateCommand(transform, Vector3.zero);
 }
コード例 #10
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            // 右へ90°回転させる
            RotateCommand rc = new RotateCommand();

            rc.Angle     = 90 * 100;
            rc.FillColor = new RasterColor(255, 255, 255);
            //rc.Flags = RotateCommandFlags.Bicubic;
            rc.Flags = RotateCommandFlags.Resize;
            rc.Run(leadImg.Image);
        }
コード例 #11
0
        public override void _presenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (pressedMouseLeftButtonDown)
            {
                if (_startPoint != null)
                {
                    Point       cur     = e.GetPosition(_inkCanvas);
                    StylusPoint current = new StylusPoint(cur.X, cur.Y);
                    double      angle1  = MathTool.getInstance().getAngleP2P(_center, _startPoint);
                    double      angle2  = WPFInk.tool.MathTool.getInstance().getAngleP2P(_center, current);
                    double      angle   = angle2 - angle1;
                    if (selectedStrokes.Count > 0)
                    {
                        foreach (MyStroke myStroke in selectedStrokes)
                        {
                            Command rcInk = new RotateCommand(myStroke, angle, _center);
                            rcInk.execute();
                        }
                    }

                    if (selectImages.Count > 0)
                    {
                        int i = 0;
                        foreach (MyImage image in selectImages)
                        {
                            //double angleImage1 = MathTool.getInstance().getAngle(_center, _startPoint);
                            //double angleImage2 = WPFInk.tool.MathTool.getInstance().getAngle(_center, current);
                            //double angleImage = angleImage2 - angleImage1;
                            image.Angle = angle;
                            Command rcImage = new ImageRotateCommand(image, preImageAngleList[i]);
                            rcImage.execute();
                            i++;
                        }
                    }
                    if (selectedButtons.Count > 0)
                    {
                        int i = 0;
                        foreach (MyButton myButton in selectedButtons)
                        {
                            //double angleButton1 = MathTool.getInstance().getAngle(_center, _startPoint);
                            //double angleButton2 = WPFInk.tool.MathTool.getInstance().getAngle(_center, current);
                            //double angleButton = angleButton2 - angleButton1;
                            myButton.Angle = angle;
                            Command brc = new ButtonRotateCommand(myButton, preButtonAngleList[i]);
                            brc.execute();
                            //myButton.updateArrow(_inkCanvas,_inkCollector);
                            i++;
                        }
                    }

                    _prepoint = current;
                }
            }
        }
コード例 #12
0
        private void Rotate(double angle)
        {
            RotateCommand rotate = new RotateCommand(angle);

            foreach (int i in tViewer.SelectedIndices)
            {
                ScannedImages[i]       = rotate.Apply(ScannedImages[i]).Image;
                tViewer.Items[i].Image = rotate.Apply(tViewer.Items[i].Image).Image;
            }

            RefreshView();
        }
コード例 #13
0
        public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (_startPoint != null)
            {
                Point       cur     = e.GetPosition(_inkCanvas);
                StylusPoint current = new StylusPoint(cur.X, cur.Y);
                double      angle1  = MathTool.getInstance().getAngleP2P(_center, _startPoint);
                double      angle2  = MathTool.getInstance().getAngleP2P(_center, current);

                double angle = angle2 - angle1;
                if (selectedStrokes.Count > 0)
                {
                    foreach (MyStroke myStroke in selectedStrokes)
                    {
                        Command rcInk = new RotateCommand(myStroke, angle, _center);
                        _inkCollector.CommandStack.Push(rcInk);
                    }
                }

                if (selectImages.Count > 0)
                {
                    int j = 0;
                    foreach (MyImage image in selectImages)
                    {
                        double  angleImage1 = MathTool.getInstance().getAngleP2P(_center, _startPoint);
                        double  angleImage2 = WPFInk.tool.MathTool.getInstance().getAngleP2P(_center, current);
                        double  angleImage  = angleImage2 - angleImage1;
                        Command rcImage     = new ImageRotateCommand(image, preImageAngleList[j]);
                        _inkCollector.CommandStack.Push(rcImage);
                        j++;
                    }
                }
                if (selectedButtons.Count > 0)
                {
                    int j = 0;
                    foreach (MyButton myButton in selectedButtons)
                    {
                        double angleButton1 = MathTool.getInstance().getAngleP2P(_center, _startPoint);
                        double angleButton2 = WPFInk.tool.MathTool.getInstance().getAngleP2P(_center, current);
                        double angleButton  = angleButton2 - angleButton1;
                        myButton.Angle = angleButton;
                        Command brc = new ButtonRotateCommand(myButton, preButtonAngleList[j]);

                        _inkCollector.CommandStack.Push(brc);
                        j++;
                    }
                }
            }

            _inkCanvas.ReleaseMouseCapture();
            pressedMouseLeftButtonDown = false;
        }
コード例 #14
0
ファイル: ProcessingActions.cs プロジェクト: sakpung/webstudy
        public static void Rotate(RasterImage image, params string[] parameters)
        {
            if (parameters.Length > 0)
            {
                int angle = 0;

                if (int.TryParse(parameters[0], out angle))
                {
                    RotateCommand cmd = new RotateCommand();

                    cmd.Angle = angle * 100;
                    cmd.Run(image);
                }
            }
        }
コード例 #15
0
        private void CleanupImage(RasterImage imageToClean, int startIndex, int count)
        {
            try
            {
                //Deskew
                if (cleanUpOcrEngine != null && cleanUpOcrEngine.IsStarted)
                {
                    using (IOcrDocument document = cleanUpOcrEngine.DocumentManager.CreateDocument())
                    {
                        for (var i = startIndex; i < startIndex + count; i++)
                        {
                            imageToClean.Page = i;
                            document.Pages.AddPage(imageToClean, null);
                            int           angle = -document.Pages[0].GetDeskewAngle();
                            RotateCommand cmd   = new RotateCommand(angle * 10, RotateCommandFlags.Bicubic, RasterColor.FromKnownColor(RasterKnownColor.White));
                            cmd.Run(imageToClean);
                            document.Pages.Clear();
                        }
                    }
                }
                else
                {
                    for (var i = startIndex; i < startIndex + count; i++)
                    {
                        imageToClean.Page = i;

                        var deskewCommand = new DeskewCommand();
                        if (imageToClean.Height > 3500)
                        {
                            deskewCommand.Flags = DeskewCommandFlags.DocumentAndPictures | DeskewCommandFlags.DoNotPerformPreProcessing | DeskewCommandFlags.UseNormalDetection | DeskewCommandFlags.DoNotFillExposedArea;
                        }
                        else
                        {
                            deskewCommand.Flags = DeskewCommandFlags.DeskewImage | DeskewCommandFlags.DoNotFillExposedArea;
                        }

                        deskewCommand.Run(imageToClean);
                    }
                }
            }
            catch (Exception ex)
            {
                //log.Error(ex);
                Console.WriteLine("Not recognized");
            }
        }
コード例 #16
0
        protected override void DoExecute()
        {
            InteractiveObject interactiveObject = Grid.FindInteractiveObject(m_targetSpawnID);

            if (interactiveObject == null)
            {
                throw new InvalidOperationException("Tried to find the position of something that is not an object!");
            }
            Party      party      = LegacyLogic.Instance.WorldManager.Party;
            EDirection edirection = EDirection.COUNT;

            if (party.Position != interactiveObject.Position)
            {
                edirection = EDirectionFunctions.GetDirection(party.Position, interactiveObject.Position);
            }
            else
            {
                GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position);
                foreach (Spawn spawn in slot.SpawnObjects)
                {
                    if (spawn.ID == m_targetSpawnID)
                    {
                        edirection = spawn.Direction;
                        break;
                    }
                }
            }
            Int32 num = party.Direction - edirection;

            if (num == 1 || num == -3)
            {
                RotateCommand p_command = RotateCommand.Left;
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
            }
            if (num == 2 || num == -2)
            {
                RotateCommand p_command = RotateCommand.TurnAround;
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
            }
            if (num == 3 || num == -1)
            {
                RotateCommand p_command = RotateCommand.Right;
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
            }
            FinishExecution();
        }
コード例 #17
0
 public static void Rotate(User user, int degrees = 90)
 {
     try
     {
         WorldEditCommand command = new RotateCommand(user, degrees);
         if (command.Invoke())
         {
             user.Player.MsgLoc($"Rotation in clipboard done.");
         }
     }
     catch (WorldEditCommandException e)
     {
         user.Player.ErrorLocStr(e.Message);
     }
     catch (Exception e)
     {
         Log.WriteError(Localizer.Do($"{e}"));
     }
 }
コード例 #18
0
 private bool CleanupImage(RasterImage imageToClean, int startIndex, int count)
 {
     try
     {
         if (this.IsStartedOcrEngine())
         {
             using (IOcrDocument document = this.TheOcrEngine.DocumentManager.CreateDocument())
             {
                 for (var i = startIndex; i < startIndex + count; i++)
                 {
                     imageToClean.Page = i;
                     document.Pages.AddPage(imageToClean, null);
                     int           angle = -document.Pages[0].GetDeskewAngle();
                     RotateCommand cmd   = new RotateCommand(angle * 10, RotateCommandFlags.Bicubic, RasterColor.FromKnownColor(RasterKnownColor.White));
                     cmd.Run(imageToClean);
                     document.Pages.Clear();
                 }
             }
         }
         else
         {
             for (var i = startIndex; i < startIndex + count; i++)
             {
                 imageToClean.Page = i;
                 var deskewCommand = new DeskewCommand();
                 if (imageToClean.Height > 3500)
                 {
                     deskewCommand.Flags = DeskewCommandFlags.DocumentAndPictures | DeskewCommandFlags.DoNotPerformPreProcessing | DeskewCommandFlags.UseNormalDetection | DeskewCommandFlags.DoNotFillExposedArea;
                 }
                 else
                 {
                     deskewCommand.Flags = DeskewCommandFlags.DeskewImage | DeskewCommandFlags.DoNotFillExposedArea;
                 }
                 deskewCommand.Run(imageToClean);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #19
0
ファイル: RotateAction.cs プロジェクト: blockspacer/MMXLegacy
        public override void DoAction(Command p_command)
        {
            Party.RotationDone.Reset();
            RotateCommand rotateCommand = (RotateCommand)p_command;

            Party.Rotate((Int32)rotateCommand.Rotation, false);
            if (Party.HasSpotSecrets())
            {
                Grid.SpotSecrets(Party.Position, Party.Direction);
            }
            if (Party.HasClairvoyance())
            {
                Grid.SpotTraps(Party.Position, Party.Direction);
            }
            if (!Party.HasAggro())
            {
                CheckChestInFront();
            }
            Party.SelectedInteractiveObject = null;
        }
コード例 #20
0
ファイル: RotateDialog.cs プロジェクト: sakpung/webstudy
        private void RotateDialog_Load(object sender, EventArgs e)
        {
            RotateCommand cmd = new RotateCommand();

            _initialAngle          = cmd.Angle;
            _initialFlags          = cmd.Flags;
            _initialFillColorLevel = 0;

            Angle                  = _initialAngle / 100;
            Flags                  = _initialFlags;
            FillColorLevel         = _initialFillColorLevel;
            _pnlRevColor.BackColor = FillColor = Converters.ToGdiPlusColor(cmd.FillColor);

            _numAngle.Value          = Angle;
            _cbResize.Checked        = (Flags & RotateCommandFlags.Resize) == RotateCommandFlags.Resize;
            _numFillColorLevel.Value = FillColorLevel;

            if ((Flags & RotateCommandFlags.Resample) == RotateCommandFlags.Resample)
            {
                _rbButtonResample.Checked = true;
            }
            else if ((Flags & RotateCommandFlags.Bicubic) == RotateCommandFlags.Bicubic)
            {
                _rbButtonBicubic.Checked = true;
            }
            else
            {
                _rbButtonNormal.Checked = true;
            }

            if (_isGray)
            {
                _pnlLevel.Visible = true;
                _pnlColor.Visible = false;
            }
            else
            {
                _pnlLevel.Visible = false;
                _pnlColor.Visible = true;
            }
        }
コード例 #21
0
        private void DoWork()
        {
            var army = new VehiclesGroup(Id, VehicleIds, VehicleRegistry, CommandManager);

            if (!binded)
            {
                Bind(army);
                return;
            }
            var vehicles      = VehicleRegistry.GetVehiclesByIds(VehicleIds);
            var width         = vehicles.Select(v => v.X).Max() - vehicles.Select(v => v.X).Min();
            var height        = vehicles.Select(v => v.Y).Max() - vehicles.Select(v => v.Y).Min();
            var rotationAngle = width > height
                                ? -45.ToRadians()
                                : 45.ToRadians();

            army
            .Select(Id)
            .RotateBy(rotationAngle);
            command = CommandManager.PeekLastCommand(Id) as RotateCommand;
        }
コード例 #22
0
ファイル: ImageUtils.cs プロジェクト: EbrahimBGA/Glass
        private static void Transform(Transform transformProperties, RasterImage result)
        {
            var cropCommand   = new CropCommand();
            var rotateCommand = new RotateCommand {
                Angle = (int)(transformProperties.Rotation * 100)
            };

            var rectCrop = new LeadRect(
                (int)transformProperties.Bounds.Left,
                (int)transformProperties.Bounds.Top,
                (int)transformProperties.Bounds.Width,
                (int)transformProperties.Bounds.Height);

            cropCommand.Rectangle = rectCrop;

            rotateCommand.Run(result);
            if (!transformProperties.Bounds.IsEmpty)
            {
                cropCommand.Run(result);
            }
        }
コード例 #23
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Wind"))
     {
         if (rc.direction == Vector3.zero)
         {
             // rc = new RotateCommand(transform, other.transform.forward);
             rc.direction = other.transform.forward;
             rc.Execute();
         }
         else if (other.transform.forward == rc.direction)
         {
             if (_swing)
             {
                 _swing = false;
                 rc     = new RotateCommand(transform, other.transform.forward);
                 // rc.direction = other.transform.forward;
                 rc.Execute();
             }
         }
         else
         {
             if (_swing)
             {
                 rc = new RotateCommand(transform, other.transform.forward);
             }
             else
             {
                 // rc.Stop();
                 first  = Quaternion.LookRotation(rc.direction, Vector3.up);
                 second = Quaternion.LookRotation(other.transform.forward, Vector3.up);
                 // rc = new RotateCommand(transform, other.transform.forward);
                 rc.direction = other.transform.forward;
                 // rc.Execute();
                 _swing = true;
             }
         }
         // ci.command.affected.Push(rc);
     }
 }
コード例 #24
0
ファイル: CommandTests.cs プロジェクト: spetten/opendiagram
        public void CommandTestRotate()
        {
            //Set up the model
            Model model = new Model();

            model.SetSize(new SizeF(1000, 1000)); //Set the container size so that the shape can be moved

            //Set up the shape element
            Shape shape = new Shape();

            shape.AllowRotate = true;
            shape.Location    = new PointF(100, 100);
            model.Shapes.Add("Shape1", shape);

            //Set up the controller
            Controller controller = new Controller(model);

            //Set up the action
            shape.ActionElement = controller.CloneElement(shape);

            //Set up the command
            RotateCommand command = controller.CommandFactory.CreateRotateCommand();

            command.Elements = new ElementList(true);
            command.Elements.Add(shape);
            command.Degrees = 90;

            //Translate the action and execute the command
            command.Rotate();
            command.Execute();
            Assert.IsTrue(shape.Rotation == 90, "Rotate command not applied correctly to shape.");

            command.Undo();
            Assert.IsTrue(shape.Rotation == 0, "Rotate command not undone correctly for shape.");

            command.Redo();
            Assert.IsTrue(shape.Rotation == 90, "Rotate command not redone correctly to shape.");
        }
コード例 #25
0
ファイル: frmOCR.cs プロジェクト: ymgw0867/MNBS
        /// <summary>
        /// OCR処理を実施します
        /// </summary>
        /// <param name="InPath">入力パス</param>
        /// <param name="NgPath">NG出力パス</param>
        /// <param name="rePath">OCR変換結果出力パス</param>
        /// <param name="FormatName">書式ファイル名</param>
        /// <param name="fCnt">書式ファイルの件数</param>
        private void ocrMain(string InPath, string NgPath, string rePath, string FormatName, int fCnt)
        {
            IEngine en       = null;            // OCRエンジンのインスタンスを保持
            string  ocr_csv  = string.Empty;    // OCR変換出力CSVファイル
            int     _okCount = 0;               // OCR変換画像枚数
            int     _ngCount = 0;               // フォーマットアンマッチ画像枚数
            string  fnm      = string.Empty;    // ファイル名

            try
            {
                // 指定された出力先フォルダがなければ作成する
                if (System.IO.Directory.Exists(rePath) == false)
                {
                    System.IO.Directory.CreateDirectory(rePath);
                }

                // 指定されたNGの場合の出力先フォルダがなければ作成する
                if (System.IO.Directory.Exists(NgPath) == false)
                {
                    System.IO.Directory.CreateDirectory(NgPath);
                }

                // OCRエンジンのインスタンスの生成・取得
                en = EngineFactory.GetEngine();
                if (en == null)
                {
                    // エンジンが他で取得されている場合は、Release() されるまで取得できない
                    System.Console.WriteLine("SDKは使用中です");
                    return;
                }

                //オーナーフォームを無効にする
                this.Enabled = false;

                //プログレスバーを表示する
                frmPrg frmP = new frmPrg();
                frmP.Owner = this;
                frmP.Show();

                IFormatList FormatList;
                IFormat     Format;
                IField      Field;
                int         nPage;
                int         ocrPage   = 0;
                int         fileCount = 0;

                // フォーマットのロード・設定
                FormatList = en.FormatList;
                FormatList.Add(FormatName);

                // tifファイルの認識
                foreach (string files in System.IO.Directory.GetFiles(InPath, "*.tif"))
                {
                    nPage = 1;
                    while (true)
                    {
                        try
                        {
                            // 対象画像を設定する
                            en.SetBitmap(files, nPage);

                            //プログレスバー表示
                            fileCount++;
                            frmP.Text          = "OCR変換処理実行中 " + fileCount.ToString() + "/" + fCnt.ToString();
                            frmP.progressValue = fileCount * 100 / fCnt;
                            frmP.ProgressStep();
                        }
                        catch (IDRException ex)
                        {
                            // ページ読み込みエラー
                            if (ex.No == ErrorCode.IDR_ERROR_FORM_FILEREAD)
                            {
                                // ページの終了
                                break;
                            }
                            else
                            {
                                // 例外のキャッチ
                                MessageBox.Show("例外が発生しました:Error No ={0:X}", ex.No.ToString());
                            }
                        }

                        //////Console.WriteLine("-----" + strImageFile + "の" + nPage + "ページ-----");
                        // 現在ロードされている画像を自動的に傾き補正する
                        en.AutoSkew();

                        // 傾き角度の取得
                        double angle = en.GetSkewAngle();
                        //////System.Console.WriteLine("時計回りに" + angle + "度傾き補正を行いました");

                        try
                        {
                            // 現在ロードされている画像を自動回転してマッチする番号を取得する
                            Format = en.MatchFormatRotate();
                            int direct = en.GetRotateAngle();

                            //画像ロード
                            RasterCodecs.Startup();
                            RasterCodecs cs = new RasterCodecs();
                            //RasterImage img;

                            // 描画時に使用される速度、品質、およびスタイルを制御します。
                            //RasterPaintProperties prop = new RasterPaintProperties();
                            //prop = RasterPaintProperties.Default;
                            //prop.PaintDisplayMode = RasterPaintDisplayModeFlags.Resample;
                            //leadImg.PaintProperties = prop;

                            RasterImage img = cs.Load(files, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);

                            RotateCommand rc = new RotateCommand();
                            rc.Angle     = (direct) * 90 * 100;
                            rc.FillColor = new RasterColor(255, 255, 255);
                            rc.Flags     = RotateCommandFlags.Resize;
                            rc.Run(img);
                            //rc.Run(leadImg.Image);

                            //cs.Save(leadImg.Image, files, RasterImageFormat.Tif, 0, 1, 1, 1, CodecsSavePageMode.Overwrite);
                            cs.Save(img, files, RasterImageFormat.CcittGroup4, 0, 1, 1, 1, CodecsSavePageMode.Overwrite);

                            // マッチしたフォーマットに登録されているフィールド数を取得
                            int fieldNum = Format.NumOfFields;
                            int matchNum = Format.FormatNo + 1;
                            //////System.Console.WriteLine(matchNum + "番目のフォーマットがマッチ");
                            int i = 1;
                            ocr_csv = string.Empty;

                            // ファイルの先頭フィールドにファイル番号をセットします
                            ocr_csv = System.IO.Path.GetFileNameWithoutExtension(files) + ",";

                            // ファイルに画像ファイル名フィールドを付加します
                            ocr_csv += System.IO.Path.GetFileName(files);

                            // 認識されたフィールドを順次読み出します
                            Field = Format.Begin();
                            while (Field != null)
                            {
                                //カンマ付加
                                if (ocr_csv != string.Empty)
                                {
                                    ocr_csv += ",";
                                }

                                // 指定フィールドを認識し、テキストを取得
                                string strText = Field.ExtractFieldText();
                                ocr_csv += strText;

                                // 次のフィールドの取得
                                Field = Format.Next();
                                i    += 1;
                            }

                            //出力ファイル
                            System.IO.StreamWriter outFile = new System.IO.StreamWriter(InPath + System.IO.Path.GetFileNameWithoutExtension(files) + ".csv", false, System.Text.Encoding.GetEncoding(932));
                            outFile.WriteLine(ocr_csv);
                            outFile.Close();

                            //OCR変換枚数カウント
                            _okCount++;
                        }
                        catch (IDRWarning ex)
                        {
                            // Engine.MatchFormatRotate() で
                            // フォーマットにマッチしなかった場合の処理
                            if (ex.No == ErrorCode.IDR_WARN_FORM_NO_MATCH)
                            {
                                // NGフォルダへ移動する
                                System.IO.File.Move(files, NgPath + "E" + System.IO.Path.GetFileName(files));

                                //NG枚数カウント
                                _ngCount++;
                            }
                        }

                        ocrPage++;
                        nPage += 1;
                    }
                }

                // いったんオーナーをアクティブにする
                this.Activate();

                // 進行状況ダイアログを閉じる
                frmP.Close();

                // オーナーのフォームを有効に戻す
                this.Enabled = true;

                string        finMessage = string.Empty;
                StringBuilder sb         = new StringBuilder();

                // NGメッセージ
                if (_ngCount > 0)
                {
                    MessageBox.Show("OCR認識を正常に行うことが出来なかった画像があります。確認してください。", "確認", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                // 終了メッセージ
                sb.Clear();
                sb.Append("OCR認識処理が終了しました。");
                sb.Append("引き続き修正確認&受け渡しデータ作成を行ってください。");
                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);
                sb.Append("OK件数 : ");
                sb.Append(_okCount.ToString());
                sb.Append(Environment.NewLine);
                sb.Append("NG件数 : ");
                sb.Append(_ngCount.ToString());
                sb.Append(Environment.NewLine);

                MessageBox.Show(sb.ToString(), "処理終了", MessageBoxButtons.OK, MessageBoxIcon.Information);
                // OCR変換画像とCSVデータをOCR結果出力フォルダへ移動する
                foreach (string files in System.IO.Directory.GetFiles(InPath, "*.*"))
                {
                    System.IO.File.Move(files, rePath + System.IO.Path.GetFileName(files));
                }

                FormatList.Delete(0);
            }
            catch (System.Exception ex)
            {
                // 例外のキャッチ
                string errMessage = string.Empty;
                errMessage += "System例外が発生しました:" + Environment.NewLine;
                errMessage += "必要なDLL等が実行モジュールと同ディレクトリに存在するか確認してください。:" + Environment.NewLine;
                errMessage += ex.Message.ToString();
                MessageBox.Show(errMessage, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                en.Release();
            }
        }
コード例 #26
0
	//
	// Commands
	//

	private void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction)
	{
		RotateCommand command = new RotateCommand (parent);
		
		int [] selected_ids = SelectedIds ();
		if (command.Execute (direction, SelectedPhotos (selected_ids)))
#if MONO_1_9_0
			query.MarkChanged (selected_ids, new PhotoChanges () {DataChanged = true});
#else
		{
			PhotoChanges changes = new PhotoChanges ();
			changes.DataChanged = true;
			query.MarkChanged (selected_ids, changes);
		}
#endif
	}
コード例 #27
0
    public override void TurnOnGUI()
    {
        float buttonHeight = 50;
        float buttonWidth = 150;

        Rect buttonRect = new Rect(0, Screen.height - buttonHeight * 7, buttonWidth, buttonHeight);
        ICharacterActionCommand cmd;
        //move button
        if (GUI.Button(buttonRect, "Move"))
        {
            if (!_isMoving)
            {
                GameManager.instance.removeTileHighlights();
                _isMoving = true;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                cmd = new MoveCommand(null, null);
                _cmdManager.CommandStack.Push(cmd);
                ((MoveCommand)cmd).Execute();
                GameManager.instance.highlightTilesAt(gridPosition, Color.blue, movementPerActionPoint, false);
            }
            else
            {
                _isMoving = false;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = false;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //attack/heal button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 6, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Attack"))
        {
            if (!_isAttacking)
            {
                //GameManager.instance.removeTileHighlights();
                _isMoving = false;
                _isAttacking = true;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                cmd = new AttackCommand(null);
                _cmdManager.CommandStack.Push(cmd);
                ((AttackCommand)cmd).Execute();
                //GameManager.instance.highlightTilesAt(gridPosition, Color.red, attackRange);
            }
            else
            {
                _isMoving = true;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //defend button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 5, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Defend"))
        {
            if (!_isDefending)
            {
                //GameManager.instance.removeTileHighlights();
                _isMoving = false;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = true;
                _isRotating = false;
                cmd = new DefendCommand(null);
                _cmdManager.CommandStack.Push(cmd);
                ((DefendCommand)cmd).Execute(this);
                //GameManager.instance.highlightTilesAt(gridPosition, Color.red, attackRange);
            }
            else
            {
                _isMoving = false;
                _isAttacking = false;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //rotate button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 4, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Rotate"))
        {
            if (!_isRotating)
            {
                //GameManager.instance.removeTileHighlights();
                _isMoving = false;
                _isAttacking = true;
                _hasPerformedAtLeastOneMove = false;
                _isDefending = false;
                _isRotating = true;
                cmd = new RotateCommand(null);
                _cmdManager.CommandStack.Push(cmd);
                ((RotateCommand)cmd).Execute();
                //GameManager.instance.highlightTilesAt(gridPosition, Color.red, attackRange);
            }
            else
            {
                _isMoving = true;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //undo button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 3, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Undo"))
        {
            if (_hasPerformedAtLeastOneMove)
            {
                _cmdManager.Undo(this, _cmdManager.LastCharacterAttacked);
                if (_cmdManager.CommandStack.Count == 0)
                    _hasPerformedAtLeastOneMove = false;
            }
        }

        //skip button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 2, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Skip"))
        {
            GameManager.instance.GoToNextCharacter();
        }

        //end turn button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 1, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "End Turn"))
        {
            GameManager.instance.GoToNextCharacter();
        }

        base.TurnOnGUI();
    }
コード例 #28
0
		void HandleRotate270Command (object sender, System.EventArgs args) 
		{
			RotateCommand command = new RotateCommand (this.Window);
			if (command.Execute (RotateDirection.Counterclockwise, new IBrowsableItem [] { image_view.Item.Current })) {
				collection.MarkChanged (image_view.Item.Index);
			}
		}		
コード例 #29
0
	//
	// Commands
	//

	private void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction)
	{
		RotateCommand command = new RotateCommand (parent);
		
		int [] selected_ids = SelectedIds ();
		if (command.Execute (direction, SelectedPhotos (selected_ids))) {
			foreach (int num in selected_ids)
				query.MarkChanged (num);
		}
	}
コード例 #30
0
ファイル: ImageUtils.cs プロジェクト: SuperJMN/Glass
        private static void Transform(Transform transformProperties, RasterImage result)
        {
            var cropCommand = new CropCommand();
            var rotateCommand = new RotateCommand { Angle = (int)(transformProperties.Rotation * 100) };

            var rectCrop = new LeadRect(
                (int)transformProperties.Bounds.Left,
                (int)transformProperties.Bounds.Top,
                (int)transformProperties.Bounds.Width,
                (int)transformProperties.Bounds.Height);

            cropCommand.Rectangle = rectCrop;

            rotateCommand.Run(result);
            if (!transformProperties.Bounds.IsEmpty)
            {
                cropCommand.Run(result);
            }
        }
コード例 #31
0
ファイル: UndoRedo.cs プロジェクト: Alexz18z35z/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="rotate"></param>
 /// <param name="oldRotate"></param>
 /// <param name="element"></param>
 public void InsertInUnDoRedoForRotate(float rotate, float oldRotate, GameObject element)
 {
     ICommand cmd = new RotateCommand(rotate, oldRotate, element);
     _Undocommands.Push(cmd);
     _Redocommands.Clear();
 }
コード例 #32
0
ファイル: SingleView.cs プロジェクト: Yetangitu/f-spot
 void HandleRotate90Command(object sender, System.EventArgs args)
 {
     RotateCommand command = new RotateCommand (this.Window);
     if (command.Execute (RotateDirection.Clockwise, new IPhoto [] { image_view.Item.Current }))
         collection.MarkChanged (image_view.Item.Index, FullInvalidate.Instance);
 }
コード例 #33
0
ファイル: MainForm.cs プロジェクト: sakpung/webstudy
        /// <summary>
        /// Batch 1 Functions
        /// </summary>
        private void DoBatch1()
        {
            // save the current caption
            string tmpCaption = Text;

            // change cursor
            Cursor = Cursors.SizeNS;
            // disable the form
            Enabled = false;
            // Do Color Resolution
            Text = "Optimizing Image To 8 Bits Per Pixel With Burkes Dithering...";
            ColorResolutionCommand colorResCommand = new ColorResolutionCommand();

            colorResCommand.BitsPerPixel    = 8;
            colorResCommand.DitheringMethod = RasterDitheringMethod.Burkes;
            colorResCommand.PaletteFlags    = ColorResolutionCommandPaletteFlags.Optimized;
            colorResCommand.Mode            = ColorResolutionCommandMode.InPlace;
            colorResCommand.Order           = RasterByteOrder.Bgr;
            colorResCommand.SetPalette(null);
            colorResCommand.Run(_viewer.Image);
            Text = "Image Is Optimized";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeWE;
            // Do Flip
            Text = "Flipping Image...";
            FlipCommand flipCommand = new FlipCommand();

            flipCommand.Horizontal = false;
            flipCommand.Run(_viewer.Image);
            Text = "Image Is Flipped";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeNS;
            // Do Lightening
            Text = "Lightening Image...";
            ChangeIntensityCommand changeIntensityCommand = new ChangeIntensityCommand();

            changeIntensityCommand.Brightness = 200;
            changeIntensityCommand.Run(_viewer.Image);
            Text = "Image Is Lightened";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change cursor
            Cursor = Cursors.SizeWE;
            // Do Resize
            Text = "Resizing Image...";
            ResizeCommand resizeCommand = new ResizeCommand();

            resizeCommand.Flags            = RasterSizeFlags.None;
            resizeCommand.DestinationImage = new RasterImage(RasterMemoryFlags.Conventional,
                                                             (_viewer.Image.Width + 1) / 2,
                                                             (_viewer.Image.Height + 1) / 2,
                                                             _viewer.Image.BitsPerPixel,
                                                             _viewer.Image.Order,
                                                             _viewer.Image.ViewPerspective,
                                                             _viewer.Image.GetPalette(),
                                                             IntPtr.Zero,
                                                             0);
            resizeCommand.Run(_viewer.Image);
            _viewer.Image = resizeCommand.DestinationImage;
            Text          = "Image Is Resized";
            _viewer.Refresh();
            Thread.Sleep(2000);

            Cursor = Cursors.SizeNS;
            // Do Rotate
            Text = "Rotating Image...";
            RotateCommand rotateCommand = new RotateCommand();

            rotateCommand.Angle     = -4500;
            rotateCommand.FillColor = new RasterColor(255, 0, 0);
            rotateCommand.Flags     = RotateCommandFlags.None;

            rotateCommand.Run(_viewer.Image);
            Text = "Image Is Rotated, Batch Is Complete";
            _viewer.Refresh();
            Thread.Sleep(2000);

            // change the cursor to arrow
            Cursor = Cursors.Arrow;

            // return the old caption
            Text = tmpCaption;

            // enable the form
            Enabled = true;
        }
コード例 #34
0
 /// <summary>
 /// 一个转动的命令
 /// </summary>
 /// <param name="c"></param>
 private void SetAction(RotateCommand c)
 {
     tip = new SubRotateCommandTip(DrawingControl, textTip);
     tip.Attention(c);
 }
コード例 #35
0
ファイル: MainWindow.cs プロジェクト: mono/f-spot
		//
		// Commands
		//

		void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction)
		{
			RotateCommand command = new RotateCommand (parent);

			int[] selected_ids = SelectedIds ();
			if (command.Execute (direction, SelectedPhotos (selected_ids)))
				query.MarkChanged (selected_ids, InvalidateData.Instance);
		}
コード例 #36
0
        /// <summary>
        /// OCR処理を実施します
        /// </summary>
        /// <param name="InPath">入力パス</param>
        /// <param name="NgPath">NG出力パス</param>
        /// <param name="rePath">OCR変換結果出力パス</param>
        /// <param name="FormatName">書式ファイル名</param>
        /// <param name="fCnt">書式ファイルの件数</param>
        private void ocrMain(string InPath, string NgPath, string rePath, string FormatName, int fCnt)
        {
            IEngine en        = null;                                                // OCRエンジンのインスタンスを保持
            string  ocr_csv   = string.Empty;                                        // OCR変換出力CSVファイル
            int     _ngCount  = 0;                                                   // フォーマットアンマッチ画像枚数
            string  fnm       = string.Empty;                                        // ファイル名
            string  path2Fdir = Properties.Settings.Default.instDir + global.DIR_2F; // 2F伝票フォルダ

            try
            {
                // 指定された出力先フォルダがなければ作成する
                if (System.IO.Directory.Exists(rePath) == false)
                {
                    System.IO.Directory.CreateDirectory(rePath);
                }

                // 指定されたNGの場合の出力先フォルダがなければ作成する
                if (System.IO.Directory.Exists(NgPath) == false)
                {
                    System.IO.Directory.CreateDirectory(NgPath);
                }

                // 2F伝票フォルダがなければ作成する
                if (System.IO.Directory.Exists(path2Fdir) == false)
                {
                    System.IO.Directory.CreateDirectory(path2Fdir);
                }

                // OCRエンジンのインスタンスの生成・取得
                en = EngineFactory.GetEngine();
                if (en == null)
                {
                    // エンジンが他で取得されている場合は、Release() されるまで取得できない
                    System.Console.WriteLine("SDKは使用中です");
                    return;
                }

                //オーナーフォームを無効にする
                this.Enabled = false;

                //プログレスバーを表示する
                frmPrg frmP = new frmPrg();
                frmP.Owner = this;
                frmP.Show();

                IFormatList FormatList;
                IFormat     Format;
                IField      Field;
                int         nPage;
                int         ocrPage   = 0;
                int         fileCount = 0;

                // フォーマットのロード・設定
                FormatList = en.FormatList;
                FormatList.Add(FormatName);

                // tifファイルの認識
                foreach (string files in System.IO.Directory.GetFiles(InPath, "*.tif"))
                {
                    nPage = 1;
                    while (true)
                    {
                        try
                        {
                            // 対象画像を設定する
                            en.SetBitmap(files, nPage);

                            //プログレスバー表示
                            fileCount++;
                            frmP.Text          = "OCR変換処理実行中 " + fileCount.ToString() + "/" + fCnt.ToString();
                            frmP.progressValue = fileCount * 100 / fCnt;
                            frmP.ProgressStep();
                        }
                        catch (IDRException ex)
                        {
                            // ページ読み込みエラー
                            if (ex.No == ErrorCode.IDR_ERROR_FORM_FILEREAD)
                            {
                                // ページの終了
                                break;
                            }
                            else
                            {
                                // 例外のキャッチ
                                MessageBox.Show("例外が発生しました:Error No ={0:X}", ex.No.ToString());
                            }
                        }

                        //////Console.WriteLine("-----" + strImageFile + "の" + nPage + "ページ-----");
                        // 現在ロードされている画像を自動的に傾き補正する
                        en.AutoSkew();

                        // 傾き角度の取得
                        double angle = en.GetSkewAngle();
                        //////System.Console.WriteLine("時計回りに" + angle + "度傾き補正を行いました");

                        try
                        {
                            // 現在ロードされている画像を自動回転してマッチする番号を取得する
                            Format = en.MatchFormatRotate();
                            int direct = en.GetRotateAngle();

                            //画像ロード
                            RasterCodecs.Startup();
                            RasterCodecs cs = new RasterCodecs();
                            //RasterImage img;

                            // 描画時に使用される速度、品質、およびスタイルを制御します。
                            //RasterPaintProperties prop = new RasterPaintProperties();
                            //prop = RasterPaintProperties.Default;
                            //prop.PaintDisplayMode = RasterPaintDisplayModeFlags.Resample;
                            //leadImg.PaintProperties = prop;

                            RasterImage img = cs.Load(files, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);

                            RotateCommand rc = new RotateCommand();
                            rc.Angle     = (direct) * 90 * 100;
                            rc.FillColor = new RasterColor(255, 255, 255);
                            rc.Flags     = RotateCommandFlags.Resize;
                            rc.Run(img);
                            //rc.Run(leadImg.Image);

                            //cs.Save(leadImg.Image, files, RasterImageFormat.Tif, 0, 1, 1, 1, CodecsSavePageMode.Overwrite);
                            cs.Save(img, files, RasterImageFormat.CcittGroup4, 0, 1, 1, 1, CodecsSavePageMode.Overwrite);

                            // マッチしたフォーマットに登録されているフィールド数を取得
                            int fieldNum = Format.NumOfFields;
                            int matchNum = Format.FormatNo + 1;
                            //////System.Console.WriteLine(matchNum + "番目のフォーマットがマッチ");
                            int i      = 1;
                            int fIndex = 0;
                            ocr_csv = "*,";

                            // ファイルに画像ファイル名フィールドを付加します
                            ocr_csv += System.IO.Path.GetFileName(files);

                            // 認識されたフィールドを順次読み出します
                            Field = Format.Begin();

                            // 3F伝票処理時に2F伝票を判定する 2013/07/01
                            if (FormatName == Properties.Settings.Default.instDir + Properties.Settings.Default.fmtHPath)
                            {
                                string fldText = string.Empty;
                                while (Field != null)
                                {
                                    // 指定フィールドを認識し、テキストを取得(対象は最終フィールド)
                                    fldText = Field.ExtractFieldText();

                                    // 次のフィールドの取得
                                    Field = Format.Next();
                                }

                                // 再度認識されたフィールドを順次読み出します 2013/07/01
                                Field = Format.Begin();

                                // 2F書式伝票のとき(指定フィールドが空白である)
                                if (fldText.Trim().Length == 0)
                                {
                                    // 2F伝票フォルダへ移動する
                                    System.IO.File.Move(files, path2Fdir + System.IO.Path.GetFileName(files));

                                    // ページをカウントして次の画像のOCR処理へ
                                    ocrPage++;
                                    nPage += 1;
                                    continue;
                                }
                            }

                            // 伝票フィールド編集
                            while (Field != null)
                            {
                                //カンマ付加
                                if (ocr_csv != string.Empty)
                                {
                                    ocr_csv += ",";
                                }

                                // 指定フィールドを認識し、テキストを取得
                                string strText = Field.ExtractFieldText();

                                // 年月日のとき各々独立フィールドに分解します
                                if (fIndex == 1)
                                {
                                    string strYYMMDD = strText.PadRight(6, '0');
                                    string ymd       = strYYMMDD.Substring(0, 2) + "," + strYYMMDD.Substring(2, 2) + "," + strYYMMDD.Substring(4, 2);
                                    ocr_csv += ymd;
                                }
                                else if (fIndex != 165)
                                {
                                    ocr_csv += strText;    // 他のフィールドで最終フィールド以外(2013/07/01)
                                }

                                // 摘要複写欄
                                if (fIndex == 10 || fIndex == 19 || fIndex == 28 || fIndex == 37 ||
                                    fIndex == 46 || fIndex == 55 || fIndex == 64 || fIndex == 73 || fIndex == 82 ||
                                    fIndex == 91 || fIndex == 100 || fIndex == 109 || fIndex == 118 || fIndex == 127 ||
                                    fIndex == 136 || fIndex == 145 || fIndex == 154 || fIndex == 163)
                                {
                                    ocr_csv += ",0";
                                }

                                // 改行
                                if (fIndex == 2 || fIndex == 11 || fIndex == 20 || fIndex == 29 || fIndex == 38 ||
                                    fIndex == 47 || fIndex == 56 || fIndex == 65 || fIndex == 74 || fIndex == 83 ||
                                    fIndex == 92 || fIndex == 101 || fIndex == 110 || fIndex == 119 || fIndex == 128 ||
                                    fIndex == 137 || fIndex == 146 || fIndex == 155)
                                {
                                    // ヘッダ業改行のとき明細行数を付加
                                    if (fIndex == 2)
                                    {
                                        ocr_csv += ",";
                                        ocr_csv += global.MAXGYOU_PRN.ToString();
                                    }

                                    ocr_csv += Environment.NewLine;

                                    // 取消欄
                                    ocr_csv += "0";
                                }

                                // 次のフィールドの取得
                                Field = Format.Next();
                                i    += 1;

                                // フィールドインデックスインクリメント
                                fIndex++;
                            }

                            //出力ファイル
                            System.IO.StreamWriter outFile = new System.IO.StreamWriter(InPath + System.IO.Path.GetFileNameWithoutExtension(files) + ".csv", false, System.Text.Encoding.GetEncoding(932));
                            outFile.WriteLine(ocr_csv);
                            outFile.Close();

                            //OCR変換枚数カウント
                            _okCount++;
                        }
                        catch (IDRWarning ex)
                        {
                            // Engine.MatchFormatRotate() で
                            // フォーマットにマッチしなかった場合、空ファイルを出力します
                            if (ex.No == ErrorCode.IDR_WARN_FORM_NO_MATCH)
                            {
                                //////// アンマッチフォルダへ移動する
                                //////System.IO.File.Move(files, NgPath + System.IO.Path.GetFileName(files));

                                // 区切り文字
                                ocr_csv = "*,";

                                // ファイルに画像ファイル名フィールドを付加します
                                ocr_csv += System.IO.Path.GetFileName(files);

                                // ヘッダ部 (決算仕訳区分、年、月、日、伝票№(NG))
                                ocr_csv += ",0,,,,NG," + global.MAXGYOU_PRN.ToString() + Environment.NewLine;

                                //// 明細部
                                string meisai = "0,,,,,,,,,0," + Environment.NewLine;
                                for (int i = 0; i < 18; i++)
                                {
                                    ocr_csv += meisai;
                                }

                                //出力ファイル
                                System.IO.StreamWriter outFile = new System.IO.StreamWriter(InPath + System.IO.Path.GetFileNameWithoutExtension(files) + ".csv", false, System.Text.Encoding.GetEncoding(932));
                                outFile.WriteLine(ocr_csv);
                                outFile.Close();

                                _ngCount++;  //NG枚数カウント
                            }
                        }

                        ocrPage++;
                        nPage += 1;
                    }
                }

                // いったんオーナーをアクティブにする
                this.Activate();

                // 進行状況ダイアログを閉じる
                frmP.Close();

                // オーナーのフォームを有効に戻す
                this.Enabled = true;

                // OCR変換画像とCSVデータをOCR結果出力フォルダへ移動する
                foreach (string files in System.IO.Directory.GetFiles(InPath, "*.*"))
                {
                    System.IO.File.Move(files, rePath + System.IO.Path.GetFileName(files));
                }

                // 終了メッセージ (2F伝票画像がなければ処理終了とみなす)
                var f2Tif = System.IO.Directory.GetFileSystemEntries(Properties.Settings.Default.instDir + global.DIR_2F, "*.tif");

                if (f2Tif.Length == 0)
                {
                    string        finMessage = string.Empty;
                    StringBuilder sb         = new StringBuilder();
                    sb.Append("OCR認識処理が終了しました。");
                    sb.Append("引き続き修正確認&受け渡しデータ作成を行ってください。");
                    sb.Append(Environment.NewLine);
                    sb.Append(Environment.NewLine);
                    sb.Append("OK件数 : ");
                    sb.Append(_okCount.ToString());
                    sb.Append(Environment.NewLine);
                    sb.Append("NG件数 : ");
                    sb.Append(_ngCount.ToString());
                    sb.Append(Environment.NewLine);

                    MessageBox.Show(sb.ToString(), "処理終了", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                FormatList.Delete(0);
            }
            catch (System.Exception ex)
            {
                // 例外のキャッチ
                string errMessage = string.Empty;
                errMessage += "System例外が発生しました:" + Environment.NewLine;
                errMessage += "必要なDLL等が実行モジュールと同ディレクトリに存在するか確認してください。:" + Environment.NewLine;
                errMessage += ex.Message.ToString();
                MessageBox.Show(errMessage, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                en.Release();
            }
        }
コード例 #37
0
ファイル: MainWindow.cs プロジェクト: iainlane/f-spot
        //
        // Commands
        //
        private void RotateSelectedPictures(Gtk.Window parent, RotateDirection direction)
        {
            RotateCommand command = new RotateCommand (parent);

            int [] selected_ids = SelectedIds ();
            if (command.Execute (direction, SelectedPhotos (selected_ids)))
                query.MarkChanged (selected_ids, new PhotoChanges () {DataChanged = true});
        }
コード例 #38
0
        /// <summary>
        /// This method checks if the command line has a valid insert command at the valid position.
        /// </summary>
        /// <param name="commandLine">The command line the user has written.</param>
        /// <exception cref="ArgumentNullException">
        /// If the commandLine is null.
        /// </exception>
        /// <returns>An instanced insert command if the command is valid or null if the command is not valid.</returns>
        public static IEditorCommand Parse(string commandLine)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException();
            }

            string[] possibleCommands = commandLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (possibleCommands.Length < 3)
            {
                return(null);
            }

            string value = possibleCommands[1];
            int    editorValue;

            try
            {
                editorValue = int.Parse(value);
            }
            catch
            {
                return(null);
            }

            string[] newpossibleCommands = new string[possibleCommands.Length - 1];
            newpossibleCommands[0] = possibleCommands[0];

            if (newpossibleCommands.Length == 2)
            {
                newpossibleCommands[1] = possibleCommands[2];
            }
            else if (newpossibleCommands.Length == 3)
            {
                newpossibleCommands[1] = possibleCommands[2];
                newpossibleCommands[2] = possibleCommands[3];
            }

            commandLine = string.Join(" ", newpossibleCommands);
            string         command       = newpossibleCommands[1].ToLower();
            ITurtleCommand turtleCommand = null;

            switch (command)
            {
            case "move":
                turtleCommand = MoveCommand.Parse(commandLine);
                break;

            case "rotate":
                turtleCommand = RotateCommand.Parse(commandLine);
                break;

            case "sleep":
                turtleCommand = SleepCommand.Parse(commandLine);
                break;

            case "penup":
                turtleCommand = PenUpCommand.Parse(commandLine);
                break;

            case "pendown":
                turtleCommand = PenDownCommand.Parse(commandLine);
                break;

            case "changecolor":
                turtleCommand = ChangeColorCommand.Parse(commandLine);
                break;

            case "changetracksymbol":
                turtleCommand = ChangeTrackSymbolCommand.Parse(commandLine);
                break;

            case "changeturtlesymbol":
                turtleCommand = ChangeTurtleSymbolCommand.Parse(commandLine);
                break;
            }

            if (turtleCommand != null && editorValue > 0)
            {
                turtleValue = turtleCommand.GetValue();
                return(new InsertCommand(editorValue, turtleCommand));
            }
            else
            {
                return(null);
            }
        }
コード例 #39
0
ファイル: Player.cs プロジェクト: M-634/Practice_CSharp
        // Update is called once per frame
        void Update()
        {
            if (CommandManager.Instance.m_isLocked)
            {
                return;
            }

            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            var move = new MoveCommand(this.transform, v, h, m_speed);

            //move.Execute();

            //(回転と移動)の同時押し
            if (Input.GetKeyDown(KeyCode.Z) && h == 1 || Input.GetKeyDown(KeyCode.Z) && v == 1)
            {
                Debug.Log("同時におした");
                var rotate = new RotateCommand(this.transform, m_rotate_Z);
                rotate.Execute();
                move.Execute();
                commands[0] = rotate;
                commands[1] = move;
                CommandManager.Instance.AddCommand(true, commands);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.X) && h == 1 || Input.GetKeyDown(KeyCode.X) && v == 1)
            {
                Debug.Log("同時におした");
                var rotate = new RotateCommand(this.transform, m_rotate_Z * -1);
                rotate.Execute();
                move.Execute();
                commands[0] = rotate;
                commands[1] = move;
                CommandManager.Instance.AddCommand(true, commands);
                return;
            }

            //通常

            if (Input.GetKeyDown(KeyCode.Z))
            {
                //左回転
                //transform.Rotate(new Vector3(0, 0, m_rotate_Z));
                var rotate = new RotateCommand(this.transform, m_rotate_Z);
                rotate.Execute();
                commands[0] = rotate;
                CommandManager.Instance.AddCommand(false, commands);
                return;
                //CommandManager.Instance.AddCommand(rotate);
            }
            else if (Input.GetKeyDown(KeyCode.X))
            {
                //右回転
                //transform.Rotate(new Vector3(0, 0, m_rotate_Z * -1));
                var rotate = new RotateCommand(this.transform, m_rotate_Z * -1);
                rotate.Execute();
                commands[0] = rotate;
                CommandManager.Instance.AddCommand(false, commands);
                return;
                // CommandManager.Instance.AddCommand(rotate);
            }

            commands[0] = move;
            CommandManager.Instance.AddCommand(false, commands);
        }