Пример #1
0
        /// <summary>
        /// ペンタブレット移動動作イベント関数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabletMouseMove(object sender, MouseEventArgs e)
        {
            int mouseX, mouseY;

            //for Debug
            //LogOutput("Mouse Position is  ---> " + Cursor.Position.X.ToString() + "," + Cursor.Position.Y.ToString() + " <---");
            mouseX = Cursor.Position.X;
            mouseY = Cursor.Position.Y;

            mouseX = (mouseX - 73) / 5;
            mouseY = (mouseY - 180) / 4;

            if (mouseX < 0)
            {
                mouseX = 0;
            }

            if (mouseY < 0)
            {
                mouseY = 0;
            }

            if (mouseX + 0 >= picBox.Width)
            {
                mouseX = picBox.Width - 0;
            }

            if (mouseY + 0 >= picBox.Height)
            {
                mouseY = picBox.Height - 0;
            }


            //for Debug
            //codeOutput("Mouse Position is  ---> " + Cursor.Position.X.ToString() + "," + Cursor.Position.Y.ToString() + " <---" + "The Fixed Mouse Position is  ---> " + mouseX + "," + mouseY + " <---");

            movement.X = mouseX;
            movement.Y = mouseY;
            DotDataInitialization(ref forDisDots);

            for (int width = 0; width < 48; width++)
            {
                for (int height = 0; height < 32; height++)
                {
                    forDisDots[width, height] = allDotData[movement.X + width, movement.Y + height];
                }
            }
            Dv2Instance.SetDots(forDisDots, BlinkInterval);
            label_posX.Text = movement.X.ToString();
            label_posY.Text = movement.Y.ToString();
        }
Пример #2
0
        /// <summary>
        /// DV-2と接続する時に利用する
        /// </summary>
        /// <param name="fm"></param>
        public void Dv2ConnectFunction(MainForm fm)
        {
            //ConsoleKeyInfo cki;
            // MyDotView インスタンスを取得する
            Dv2Instance = MyDotView.getInstance(fm);

            DotDataInitialization(ref forDisDots);
            DotDataInitialization(ref allDotData);
            //外枠の点滅データ,一回のみ初期化
            DotDataInitialization(ref arroundDotData, true);

            #region Useless

            /*
             * for (int i = 24; i < 48; i++)
             * {
             *  // 1行目の点を表示
             *  forDisDots[i, 20] = 1;
             *  // 2行目の点を点滅
             *  forDisDots[i, 10] = 2;
             *  // 3行目の点を表示
             *  forDisDots[i, 2] = 1;
             * }
             */
            #endregion

            // DotViewにデータを送信する
            Dv2Instance.SetDots(forDisDots, BlinkInterval);

            #region Useless
            // アプリケーション終了時には切断処理を呼ぶ

            /*
             * Console.WriteLine("Press the Escape (Esc) key to quit: \n");
             * try
             * {
             *  cki = Console.ReadKey();
             *  if (cki.Key == ConsoleKey.Escape)
             *  {
             *      Dv2Instance.Disconnect();
             *  }
             * }
             * catch(Exception ex)
             * {
             *  Dv2Instance.Disconnect();
             *  codeOutput(ex.Message);
             * }
             */
            #endregion
        }
Пример #3
0
        /// <summary>
        /// ビットマップ画像からDV-2表示用の点図に変換する関数
        /// </summary>
        private void MakeObjectBraille()
        {
            //この関数はDV2出力データを準備する
            //picBox.Size.Height   400
            //picBox.Size.Width    600
            //allDotData   全てのDotデータを保存する場所
            //focusDotData   拡大縮小用Dotデータを保存する場所
            //forDisDots   DV2 Displayを転送するデータ

            //allDotData = new int[picBox.Width, picBox.Height];
            //int[,] focusDotData = new int[48, 32];
            //左上の原点に戻る
            //movement = new Point(0, 0);
            Color pixel;

            //データ初期化
            DotDataInitialization(ref allDotData);
            DotDataInitialization(ref forDisDots);
            //DotDataInitialization (ref focusDotData);

            LogOutput("MakeObjectBraille Start!");

            for (int width = 0; width < picBox.Size.Width; width++)
            {
                for (int height = 0; height < picBox.Size.Height; height++)
                {
                    //ピクセルデータを0と1に変化する
                    pixel = debug_Image.GetPixel(width, height);

                    if (pixel.Name != "0")
                    {
                        allDotData[width, height] = 1;
                    }
                }
            }

            for (int width = 0; width < 48; width++)
            {
                for (int height = 0; height < 32; height++)
                {
                    forDisDots[width, height] = allDotData[width + movement.X, height + movement.Y];
                }
            }

            Dv2Instance.SetDots(forDisDots, BlinkInterval);
            //tabControl_code.Enabled = false;
            tabControl_code.SelectTab(0);
            tabControl_Graphics.Enabled = false;
        }
Пример #4
0
        /// <summary>
        /// 入力した内容を解析するアルゴリズム
        /// </summary>
        public void FormulaAnalysis()
        {
            //Define Parameters
            ToKen   token;
            TknKind bef_tok_kind = TknKind.None;

            loopInfo = 0;
            //DV2_Drawing dv2d_FA = new DV2_Drawing();
            string objName         = "";
            string objAnalysisData = "";
            string objCommandData  = "";

            string[] storageData;
            int      dataGridView_index = 0;
            int      objFinder_index    = 0;

            System.DateTime currentTime = new System.DateTime();
            currentTime = System.DateTime.Now;
            #region Boolean Flags
            bool pointDef_flg = false;
            bool pointGet_flg = false;
            bool pointSol_flg = false;
            bool objPlus_flg  = false;
            bool rotation_flg = false;
            bool setPoint_flg = false;
            bool clear_flg    = false;
            bool cleartar_flg = false;
            #endregion

            //Debug
            //LogOutput("Resources.Graph_line  :> " + Properties.Resources.Graph_line);
            LogOutput("Formula Analysis Strat at ->   *******  " + currentTime + "  *******");
            //LogOutput("Settings.GraphicInstruction  :> " + DV2.Net_Graphics_Application.Properties.Settings.Default.GraphicInstruction);
            //LogOutput(dataStorage.Text.Length);

            if (dataStorage.Text.Length != 0)
            {
                LogOutput(String.Format("{0, -15}", "Text") + String.Format("{0, -15}", "Kind") + String.Format("{0, -15}", "numVal"));
                LogOutput("---------------------------------------------");

                #region コマンド内容はチャ-の単位として循環処理
                for (char txtChar = ' '; loopInfo < dataStorage.Text.Length;)
                {
                    txtChar = dataStorage.Text[loopInfo];
                    token   = nextTkn(txtChar);
                    LogOutput(">>>token.kind iS -> " + String.Format("{0, -15}", token.kind));
                    //LogOutput(">>bef_tok_kind iS -> " + String.Format("{0, -15}", bef_tok_kind));

                    #region コマンド終わり判断
                    if (token.kind == TknKind.END_line)
                    {
                        break;
                    }
                    #endregion

                    #region Command "Assign" Route
                    if (token.kind == TknKind.Assign)
                    {
                        //例:対象を定義する obj1 = line(0,0,20,10)
                        if (bef_tok_kind == TknKind.Ident)
                        {
                            //dataStorage
                            storageData = Regex.Split(dataStorage.Text, "=", RegexOptions.IgnoreCase);
                            //LogOutput("TknKind.Ident+TknKind.Assign Length ->" + storageData.Length);
                            //入力した命令を保存する
                            if (storageData.Length == 2)
                            {
                                if (ObjectFinder(storageData[0].Replace(" ", "")) == -1)
                                {
                                    ObjName.Add(storageData[0].Replace(" ", ""));
                                    ObjCommand.Add(storageData[1].Replace(" ", ""));
                                }
                                else
                                {
                                    objName = storageData[0].Replace(" ", "");
                                    ObjCommand[ObjectFinder(storageData[0].Replace(" ", ""))] = storageData[1].Replace(" ", "");
                                }
                                //データ監視器--データ導入
                                dataGridView_index = this.dataGridView_monitor.Rows.Add();
                                this.dataGridView_monitor.Rows[dataGridView_index].Cells[0].Value = storageData[0].Replace(" ", "");
                                this.dataGridView_monitor.Rows[dataGridView_index].Cells[1].Value = storageData[1].Replace(" ", "");
                            }
                            else
                            {
                                codeOutput("Error @FormulaAnalysis @341");
                                break;
                            }
                        }
                    }
                    #endregion

                    #region Command "Show" Route
                    if (token.kind == TknKind.Ident)
                    {
                        //表示命令を判別する
                        if (bef_tok_kind == TknKind.Show)
                        {
                            //tabControl_Graphics.SelectTab(1);
                            //表示したい対象名が存在するかどうかを判断する
                            if (ObjectFinder(token.text) != -1)
                            {
                                objFinder_index = ObjectFinder(token.text);
                            }
                            else
                            {
                                tobeRead.SpeakAsync("表示される " + token.text + " 対象は不存在,もう一度確認してください。");
                                codeOutput("表示される " + token.text + " 対象は不存在,もう一度確認してください。");
                                return;
                            }

                            //表示したい対象名が存在する場合は,その同じ順番配列データの有効性を判断する
                            if (ObjName[objFinder_index] != null && ObjAnalysis[objFinder_index] != null)
                            {
                                //LogOutput(ObjCommand[objFinder_index]);
                                //LogOutput(ObjAnalysis[objFinder_index]);
                                //分析結果を転送する
                                ParameterChecker(ObjAnalysis[objFinder_index], objFinder_index);
                                picBox.Refresh();
                            }

                            else
                            {
                                tobeRead.SpeakAsync("表示される " + token.text + " 対象は不存在,もう一度確認してください。");
                                codeOutput("表示される " + token.text + " 対象は不存在,もう一度確認してください。");
                            }

                            if (!ROTATIONFLAG)
                            {
                                LogOutput("ROTATIONFLAG is " + ROTATIONFLAG);
                                debug_Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                                picBox.Refresh();
                                ROTATIONFLAG = true;
                            }
                            MakeObjectBraille();
                        }
                    }
                    #endregion

                    #region Command "Point Define" Route
                    if (token.kind == TknKind.Point)
                    {
                        //変数pをPoint型として宣言
                        if (bef_tok_kind == TknKind.Colon)
                        {
                            //Ex:"var p : Point" -> "p = Point(0,0)"  -- このコマンドは点pを原点に初期値(0,0)に設定する
                            storageData = Regex.Split(dataStorage.Text, ":", RegexOptions.IgnoreCase);
                            if (ObjectFinder(storageData[0].Replace(" ", "")) == -1)
                            {
                                ObjName.Add(storageData[0].Replace(" ", ""));
                                ObjCommand.Add(storageData[1].Replace(" ", ""));
                            }
                            else
                            {
                                objName = storageData[0].Replace(" ", "");
                                ObjCommand[ObjectFinder(storageData[0].Replace(" ", ""))] = storageData[1].Replace(" ", "");
                            }

                            //データ監視器--データ導入
                            dataGridView_index = this.dataGridView_monitor.Rows.Add();
                            this.dataGridView_monitor.Rows[dataGridView_index].Cells[0].Value = storageData[0];
                            this.dataGridView_monitor.Rows[dataGridView_index].Cells[1].Value = storageData[1].Replace(" ", "");
                            //pointDef_flgフラグをtrueに設定する
                            pointDef_flg = true;
                        }
                    }
                    #endregion

                    #region Command "Get P" Route
                    if (token.kind == TknKind.Ident)
                    {
                        //To get the finger point on the object
                        //Ex:get p on obj1
                        if (bef_tok_kind == TknKind.Get)
                        {
                            //pointGet_flgフラグをtrueに設定する
                            pointGet_flg = true;
                        }
                    }
                    #endregion

                    #region Command "Slove" Route
                    if (token.kind == TknKind.Ident)
                    {
                        //Slove the math program
                        //Ex:solve c by contact(obj1,obj2,p)
                        if (bef_tok_kind == TknKind.Solve)
                        {
                            //pointSol_flgフラグをtrueに設定する
                            pointSol_flg = true;
                        }
                    }
                    #endregion

                    #region Command "Object Plus" Route
                    if (token.kind == TknKind.Ident)
                    {
                        //Ex:obj3=obj1+obj2
                        if (bef_tok_kind == TknKind.Plus)
                        {
                            //objPlus_flgフラグをtrueに設定する
                            objPlus_flg = true;
                        }
                    }
                    #endregion

                    #region Command "Clear Object" Route
                    if (token.kind == TknKind.Ident)
                    {
                        //Ex:clear obj
                        if (bef_tok_kind == TknKind.Clear)
                        {
                            LogOutput("Clear The graphObj");
                            //cleartar_flgフラグをtrueに設定する
                            cleartar_flg = true;
                        }
                    }
                    #endregion

                    #region Command "Clear ALL" Route
                    if (token.kind == TknKind.Clear)
                    {
                        //Ex:clear
                        if (dataStorage.Text.Length != 0 && dataStorage.Text.ToLower() == "clear")
                        {
                            LogOutput("Clear ALL The graphObj");
                            //clear_flgフラグをtrueに設定する
                            clear_flg = true;
                        }
                    }
                    #endregion

                    #region Command "Set" Route
                    if (token.kind == TknKind.Set)
                    {
                        //Setting the parameters
                    }
                    #endregion

                    #region Command "Rotate" Route
                    if (token.kind == TknKind.Lparen)
                    {
                        if (bef_tok_kind == TknKind.Rotation)
                        {
                            //画像を回転する
                            rotation_flg = true;
                        }
                    }
                    #endregion

                    #region Command "SetPoint" Route
                    if (token.kind == TknKind.SetPoint)
                    {
                        //相対位置処理入口
                        setPoint_flg = true;
                    }
                    #endregion

                    bef_tok_kind     = token.kind;
                    objAnalysisData += token.kind + "|";
                    objCommandData  += token.text + "|";
                    //LogOutput(String.Format("{0, -15}", token.text) + String.Format("{0, -15}", token.kind) + String.Format("{0, -15}", token.dblVal));
                }
                #endregion

                #region  書き処理
                //Modify old data
                if (ObjAnalysis.Count == ObjName.Count && objName != "" && ObjectFinder(objName) != -1)
                {
                    bool assignFlag = false;
                    int  loop_i;

                    //分析結果を保存する
                    //正規表現関数
                    for (loop_i = 0; loop_i < Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase).Length; loop_i++)
                    {
                        if (Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase)[loop_i] == "Assign")
                        {
                            assignFlag = true;
                            break;
                        }
                    }

                    if (assignFlag)
                    {
                        objAnalysisData = string.Join("|", Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase).Skip(loop_i + 1).ToArray());
                        ObjAnalysis[ObjectFinder(objName)] = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                        this.dataGridView_monitor.Rows[dataGridView_index].Cells[2].Value = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                    }
                    else
                    {
                        ObjAnalysis[ObjectFinder(objName)] = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                        this.dataGridView_monitor.Rows[dataGridView_index].Cells[2].Value = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                    }

                    //Ex:"obj1|=|line|(|1|,|2|,|20.0|,|25.5|)|" -> "obj1|=|line|(|1|,|2|,|20.0|,|25.5|)"
                    ObjCommand[ObjectFinder(objName)] = objCommandData.Substring(0, objCommandData.Length - 1);
                    LogOutput("Modify Debug Point");
                }
                #endregion

                #region 解析結果
                //New data appended!
                if (ObjAnalysis.Count < ObjName.Count)
                {
                    bool assignFlag = false;
                    int  loop_i;

                    //分析結果を保存する
                    //正規表現関数
                    for (loop_i = 0; loop_i < Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase).Length; loop_i++)
                    {
                        if (Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase)[loop_i] == "Assign")
                        {
                            assignFlag = true;
                            break;
                        }
                    }

                    if (assignFlag)
                    {
                        objAnalysisData = String.Join("|", Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase).Skip(loop_i + 1).ToArray());
                        ObjAnalysis.Add(objAnalysisData.Substring(0, objAnalysisData.Length - 1));
                        this.dataGridView_monitor.Rows[dataGridView_index].Cells[2].Value = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                    }
                    else
                    {
                        ObjAnalysis.Add(objAnalysisData.Substring(0, objAnalysisData.Length - 1));
                        this.dataGridView_monitor.Rows[dataGridView_index].Cells[2].Value = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                    }

                    if (ObjCommand.Count == ObjName.Count)
                    {
                        //Ex:"obj1|=|line|(|1|,|2|,|20.0|,|25.5|)|" -> "obj1|=|line|(|1|,|2|,|20.0|,|25.5|)"
                        ObjCommand.RemoveAt(ObjCommand.Count - 1);
                        ObjCommand.Add(objCommandData.Substring(0, objCommandData.Length - 1));
                    }
                }
                #endregion
            }

            else
            {
                codeOutput("Error @FormulaAnalysis MSG: Please Input Data!");
            }

            //此処から処理するのデータは自動保存されていない。
            if (dataStorage.Text.Length != 0 && ObjName.Count != 0)
            {
                //未完成
                //予定機能は対象名の重複データをチェックする
                //DuplicateChecking();
            }

            #region PointDefine Route
            if (pointDef_flg)
            {
                if (Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase)[0].ToLower() == "var")
                {
                    string[] temp = Regex.Split(ObjCommand[ObjCommand.Count - 1].ToString(), @"\|", RegexOptions.IgnoreCase);
                    //Data Remove
                    ObjName.RemoveAt(ObjName.Count - 1);
                    ObjCommand.RemoveAt(ObjCommand.Count - 1);
                    ObjAnalysis.RemoveAt(ObjAnalysis.Count - 1);

                    //New Data Append
                    ObjName.Add(temp[1]);
                    ObjCommand.Add("Point|(|0|,|0|)");
                    ObjAnalysis.Add("Point|Lparen|IntNum|Comma|IntNum|Rparen");
                    //データ監視器 Rewirte
                    this.dataGridView_monitor.Rows[dataGridView_index].Cells[0].Value = temp[1];
                    this.dataGridView_monitor.Rows[dataGridView_index].Cells[1].Value = "point(0,0)";
                    this.dataGridView_monitor.Rows[dataGridView_index].Cells[2].Value = "Point|Lparen|IntNum|Comma|IntNum|Rparen";
                }
            }
            #endregion

            #region PointGet Route
            if (pointGet_flg)
            {
                //get P on obj1
                //objCommandData	"get|p|on|obj1|"
                //objAnalysisData	"Get|Ident|On|Ident|"
                objCommandData  = objCommandData.Substring(0, objCommandData.Length - 1);
                objAnalysisData = objAnalysisData.Substring(0, objAnalysisData.Length - 1);

                if (Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase).Count() == 4)
                {
                    GetPointOnObject(objCommandData, objAnalysisData);
                }
                else
                {
                    //Error
                    LogOutput("Error @FormulaAnalysis PointGet Route");
                    tobeRead.SpeakAsync("入力ミスが発生していた。");
                }
            }
            #endregion

            #region The Solve Route
            if (pointSol_flg)
            {
                //solve c by contact(obj1,ojb2,p)
                //objCommandData	"solve|c|by|contact|(|obj1|,|ojb2|,|p|)|"
                //objAnalysisData	"Solve|Ident|Ident|Contact|Lparen|Ident|Comma|Ident|Comma|Ident|Rparen|"
                objCommandData  = objCommandData.Substring(0, objCommandData.Length - 1);
                objAnalysisData = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                string[] tmpCommData  = Regex.Split(objCommandData, @"\|", RegexOptions.IgnoreCase);
                string[] tmpAnaData   = Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase);
                int      identCounter = 0;
                bool     contact_flag = false;

                foreach (var temp in tmpAnaData)
                {
                    if (temp == "Ident")
                    {
                        identCounter++;
                    }
                    if (temp == "Contact")
                    {
                        contact_flag = true;
                    }
                }
                if (contact_flag == true && identCounter == 5)
                {
                    TheSolveMode(objCommandData, tmpCommData, objAnalysisData, tmpAnaData);
                }
            }
            #endregion

            #region objPlus Route
            if (objPlus_flg)
            {
                //obj3=obj1+obj2
                //objCommandData	"obj3|=|obj1|+|obj2|"
                //objAnalysisData	"Ident|Plus|Ident|"
                objCommandData  = objCommandData.Substring(0, objCommandData.Length - 1);
                objAnalysisData = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                AssignRemover(ref objCommandData);
                string[] tmpCommData = Regex.Split(objCommandData, @"\|", RegexOptions.IgnoreCase);
                string[] tmpAnaData  = Regex.Split(objAnalysisData, @"\|", RegexOptions.IgnoreCase);

                if (objAnalysisData != "Ident|Plus|Ident")
                {
                    //Error Route
                    return;
                }

                for (int i = 0; i < tmpAnaData.Length; i++)
                {
                    if (tmpAnaData[i] == "Ident")
                    {
                        if (ObjectFinder(tmpCommData[i]) == -1)
                        {
                            tobeRead.SpeakAsync(ObjectFinder(tmpCommData[i]) + "対象は定義されていません!");
                            codeOutput(ObjectFinder(tmpCommData[i]) + "対象は定義されていません!");
                        }
                    }
                }
            }
            #endregion

            #region Rotation Route
            if (rotation_flg)
            {
                //rotation -30
                //objCommandData	"rotation|(|obj1|,|30|)|"
                //objAnalysisData	"Rotation|Lparen|Ident|Comma|IntNum|Rparen|"
                objCommandData  = objCommandData.Substring(0, objCommandData.Length - 1);
                objAnalysisData = objAnalysisData.Substring(0, objAnalysisData.Length - 1);

                Rotation(objCommandData, objAnalysisData);
            }
            #endregion

            #region setPoint Route
            if (setPoint_flg)
            {
                //obj1:setpoint(LEFT,obj2,Right,10,0)
                //objCommandData	"obj1|:|setpoint|(|LEFT|,|obj2|,|Right|,|10|,|0|)|"
                //objAnalysisData	"Ident|Colon|SetPoint|Lparen|Left|Comma|Ident|Comma|Right|Comma|IntNum|Comma|IntNum|Rparen|"
                objCommandData  = objCommandData.Substring(0, objCommandData.Length - 1);
                objAnalysisData = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                LogOutput("objCommandData     " + objCommandData);
                LogOutput("objAnalysisData    " + objAnalysisData);

                TheSetPointMode(objCommandData, objAnalysisData);
            }
            #endregion

            #region Clear Route
            if (clear_flg)
            {
                LogOutput("clear_flg" + clear_flg);
                graphObj.Dispose();
                debug_Image.Dispose();
                graphObj     = PreparePaper();
                picBox.Image = (Image)debug_Image;
                picBox.Refresh();

                ObjDisplayed.Clear();
                DotDataInitialization(ref forDisDots);
                DotDataInitialization(ref allDotData);
                Dv2Instance.SetDots(forDisDots, BlinkInterval);

                if (!ROTATIONFLAG)
                {
                    LogOutput("ROTATIONFLAG is " + ROTATIONFLAG);
                    debug_Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    picBox.Refresh();
                    ROTATIONFLAG = true;
                }
            }

            if (cleartar_flg)
            {
                //clear objA
                //objCommandData   clear|objA
                //objAnalysisData  Clear|Ident
                objCommandData  = objCommandData.Substring(0, objCommandData.Length - 1);
                objAnalysisData = objAnalysisData.Substring(0, objAnalysisData.Length - 1);
                LogOutput("objCommandData     " + objCommandData);
                LogOutput("objAnalysisData    " + objAnalysisData);

                if (ObjDisplayed.Count == 1 || ObjDisplayed.Count == 0)
                {
                    graphObj.Dispose();
                    debug_Image.Dispose();
                    graphObj     = PreparePaper();
                    picBox.Image = (Image)debug_Image;
                    picBox.Refresh();

                    ObjDisplayed.Clear();
                    DotDataInitialization(ref forDisDots);
                    DotDataInitialization(ref allDotData);
                    Dv2Instance.SetDots(forDisDots, BlinkInterval);
                }

                else
                {
                    //Processing
                    if (!ClearTargetAndCheck(objCommandData, objAnalysisData))
                    {
                        //処理失敗の流れ
                    }
                }
            }
            #endregion

            LogOutput("---------------------------------------------");
            LogOutput("Formula Analysis End at ->   *******  " + System.DateTime.Now + "  *******");
            if (ROTATIONFLAG)
            {
                LogOutput("ROTATIONFLAG is " + ROTATIONFLAG);
                debug_Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                ROTATIONFLAG = false;
            }
        }
Пример #5
0
        /// <summary>
        /// キーボード動作イベント関数,このイベントを宣言すると,キーボードのキーが押された時に,処理できる
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void KeyMovement(object sender, KeyEventArgs e)
        {
            bool moved_flg = false;

            #region Movement
            if (e.KeyCode == Keys.Up)
            {
                //codeOutput("Up Pressed!");
                movement.Y -= 1;
                moved_flg   = true;

                if (movement.Y < 0)
                {
                    movement.Y = 0;
                    moved_flg  = false;
                }
            }

            if (e.KeyCode == Keys.Down)
            {
                //codeOutput("Down Pressed!");
                movement.Y += 1;
                moved_flg   = true;

                if (movement.Y + 32 > picBox.Height)
                {
                    movement.Y = picBox.Height - 32;
                    moved_flg  = false;
                }
            }

            if (e.KeyCode == Keys.Left)
            {
                //codeOutput("Left Pressed!");
                movement.X -= 1;
                moved_flg   = true;

                if (movement.X < 0)
                {
                    movement.X = 0;
                    moved_flg  = false;
                }
            }

            if (e.KeyCode == Keys.Right)
            {
                //codeOutput("Right Pressed!");
                movement.X += 1;
                moved_flg   = true;

                if (movement.X + 48 > picBox.Width)
                {
                    movement.X = picBox.Width - 48;
                    moved_flg  = false;
                }
            }

            if (e.KeyCode == Keys.End)
            {
                //codeOutput("End Pressed!");
                tobeRead.SpeakAsync("触るモード終了.");
                tabControl_code.SelectTab(0);
                tabControl_code.Enabled     = true;
                tabControl_Graphics.Enabled = true;
            }
            #endregion

            if (moved_flg)
            {
                DotDataInitialization(ref forDisDots);

                for (int width = 0; width < 48; width++)
                {
                    for (int height = 0; height < 32; height++)
                    {
                        forDisDots[width, height] = allDotData[movement.X + width, movement.Y + height];
                    }
                }
                Dv2Instance.SetDots(forDisDots, BlinkInterval);
                label_posX.Text = movement.X.ToString();
                label_posY.Text = movement.Y.ToString();
            }
        }
Пример #6
0
        /// <summary>
        /// DV-2のボタンを動作イベント関数
        /// このイベントを宣言すると,DV-2のボタンが押された時に,処理できる
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dv2KeyEventHandle(object sender, DV.KeyEventArgs e)
        {
            bool moved_flg = false;
            //for the test
            int objFinder_index = 0;

            tobeRead.SpeakAsyncCancelAll();
            #region Debug
            if (false)
            {
                codeOutput("************************************************");
                codeOutput("Shift -+-> " + e.Shift);
                codeOutput("Kind -+-> " + e.Kind);
                codeOutput("Value -+-> " + e.Value);
            }
            #endregion

            //DotViewの何かのキーが押された時の処理
            #region フロントキー処理
            // ***************フロントキー処理***************
            if (e.Shift == 128 && e.Kind == 0 && e.Value == 0)
            {
                //親指キー
                tobeRead.SpeakAsync("親指キー");
                int cir_x = 24 + movement.X;
                int cir_y = 16 + movement.Y;

                ObjName.Add("obj11");
                ObjCommand.Add("obj11|=|circle|(|" + cir_x + "|,|" + cir_y + "|,|15|)");
                ObjAnalysis.Add("Circle|Lparen|IntNum|Comma|IntNum|Comma|IntNum|Rparen");

                objFinder_index = ObjectFinder("obj11");
                ParameterChecker(ObjAnalysis[objFinder_index], objFinder_index);
                MakeObjectBraille();
            }

            if (e.Shift == 64 && e.Kind == 0 && e.Value == 0)
            {
                //ステータスキー
                tobeRead.SpeakAsync("ステータスキー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 16)
            {
                //拡大キー
                tobeRead.SpeakAsync("拡大キー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 128)
            {
                //縮小キー
                tobeRead.SpeakAsync("縮小キー");
            }

            if (e.Shift == 0 && e.Kind == 5 && e.Value == 8)
            {
                //方向レバー 上
                //tobeRead.SpeakAsync("方向レバー 上");
                movement.Y -= 1;
                moved_flg   = true;

                if (movement.Y < 0)
                {
                    movement.Y = 0;
                    moved_flg  = false;
                }
            }

            if (e.Shift == 0 && e.Kind == 5 && e.Value == 4)
            {
                //方向レバー 下
                //tobeRead.SpeakAsync("方向レバー 下");
                movement.Y += 1;
                moved_flg   = true;

                if (movement.Y + 0 > picBox.Height)
                {
                    movement.Y = picBox.Height - 0;
                    moved_flg  = false;
                }
            }

            if (e.Shift == 0 && e.Kind == 5 && e.Value == 16)
            {
                //方向レバー 左
                //tobeRead.SpeakAsync("方向レバー 左");
                movement.X -= 1;
                moved_flg   = true;

                if (movement.X < 0)
                {
                    movement.X = 0;
                    moved_flg  = false;
                }
            }

            if (e.Shift == 0 && e.Kind == 5 && e.Value == 2)
            {
                //方向レバー 右
                //tobeRead.SpeakAsync("方向レバー 右");
                movement.X += 1;
                moved_flg   = true;

                if (movement.X + 0 > picBox.Width)
                {
                    movement.X = picBox.Width - 0;
                    moved_flg  = false;
                }
            }

            if (e.Shift == 16 && e.Kind == 0 && e.Value == 0)
            {
                //方向レバー 中心
                tobeRead.SpeakAsync("方向レバー 中心");
            }
            #endregion

            #region サイドキー処理
            // ***************サイドキー処理***************
            if (e.Shift == 0 && e.Kind == 4 && e.Value == 1)
            {
                //上矢印キー
                tobeRead.SpeakAsync("上矢印キー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 2)
            {
                //下矢印キー
                tobeRead.SpeakAsync("下矢印キー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 8)
            {
                //左矢印キー
                tobeRead.SpeakAsync("左矢印キー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 4)
            {
                //右矢印キー
                tobeRead.SpeakAsync("右矢印キー");
            }

            if (e.Shift == 32 && e.Kind == 0 && e.Value == 0)
            {
                //センターキー
                tobeRead.SpeakAsync("センターキー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 64)
            {
                //エンドキー
                tobeRead.SpeakAsync("エンドキー");
            }

            if (e.Shift == 0 && e.Kind == 4 && e.Value == 32)
            {
                //ホームキー
                tobeRead.SpeakAsync("ホームキー");
            }
            #endregion

            // *************** 移動処理 ***************
            if (moved_flg)
            {
                DotDataInitialization(ref forDisDots);

                for (int width = 0; width < 48; width++)
                {
                    for (int height = 0; height < 32; height++)
                    {
                        #region for Test

                        /*
                         * if (movement.X + width >= picBox.Width)
                         * {
                         *  movement.X = picBox.Width - width;
                         * }
                         *
                         * if (movement.Y + height >= picBox.Height)
                         * {
                         *  movement.Y = picBox.Height - height;
                         * }
                         */
                        #endregion
                        forDisDots[width, height] = allDotData[movement.X + width, movement.Y + height];
                    }
                }
                Dv2Instance.SetDots(forDisDots, BlinkInterval);
                label_posX.Text = movement.X.ToString();
                label_posY.Text = movement.Y.ToString();
            }
        }
Пример #7
0
        /// <summary>
        /// 指定された対象を図面に削除する関数
        /// </summary>
        /// <param name="targetData">入力データ「空白抜き」</param>
        /// <param name="targetAna">入力データの解析結果</param>
        /// <returns>処理結果を返し、成功や失敗</returns>
        private bool ClearTargetAndCheck(string targetData, string targetAna)
        {
            //Define
            int    tobeDisplay = 0;
            bool   return_flg  = false;
            string CleTarget;

            string[] listTarData    = Regex.Split(targetData, @"\|", RegexOptions.IgnoreCase);
            string[] listTarAnaData = Regex.Split(targetAna, @"\|", RegexOptions.IgnoreCase);

            //削除コマンドの違法性を確認する
            if (listTarData.Length == 2 && listTarAnaData.Length == 2 && listTarAnaData[listTarAnaData.Length - 1] == "Ident")
            {
                CleTarget = listTarData[listTarData.Length - 1];
            }

            else
            {
                //Error Route & Jump Back
                codeOutput("");
                tobeRead.SpeakAsync("");
                LogOutput("");
                return(false);
            }

            if (ObjectFinder(CleTarget) == -1)
            {
                codeOutput(CleTarget + "対象名不存在");
                tobeRead.SpeakAsync("削除する対象名" + CleTarget + "が不存在");
                LogOutput(CleTarget + "対象名不存在");
                return(false);
            }

            //ObjDisplayed  表示された対象名のリスト
            if (ObjDisplayed.Count != 0)
            {
                for (int i = 0; i < ObjDisplayed.Count; i++)
                {
                    if (ObjDisplayed[i].ToString() == CleTarget)
                    {
                        ObjDisplayed.RemoveAt(i);
                        LogOutput("**********************" + "対象" + CleTarget + "を削除完了!" + "**********************");
                    }
                }
            }

            graphObj.Dispose();
            debug_Image.Dispose();
            graphObj     = PreparePaper();
            picBox.Image = debug_Image;
            picBox.Refresh();
            DotDataInitialization(ref forDisDots);
            Dv2Instance.SetDots(forDisDots, BlinkInterval);
            tobeDisplay = ObjDisplayed.Count;

            for (int i = 0; i < tobeDisplay; i++)
            {
                int loop = ObjectFinder(ObjDisplayed[i].ToString());

                if (loop != -1)
                {
                    ParameterChecker(ObjAnalysis[loop], loop);
                }
            }

            picBox.Refresh();
            MakeObjectBraille();

            if (!ROTATIONFLAG)
            {
                LogOutput("ROTATIONFLAG is " + ROTATIONFLAG);
                debug_Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                picBox.Refresh();
                ROTATIONFLAG = true;
            }
            return_flg = true;

            return(return_flg);
        }