Esempio n. 1
0
        /// <summary>
        /// パラメータチェッカー、show命令を実行する時に、呼び出し関数
        /// </summary>
        /// <param name="GraphIns"></param>
        /// <param name="listIndex"></param>
        private void ParameterChecker(object GraphIns, int listIndex)
        {
            //For Command "Show" Route
            //Debug
            LogOutput("\r\n" + "***ParameterChecker Strat!###");
            LogOutput("***object GraphIns is!###  " + GraphIns);
            //Define
            //DV2_Drawing dv2Draw = new DV2_Drawing();
            string[] GraphicInstruction = Regex.Split(Properties.Settings.Default.GraphicInstruction, @"\|", RegexOptions.IgnoreCase);
            var      SpecialInstruction = Properties.Settings.Default.SpecialInstruction;
            string   GraphCmd = GraphIns.ToString();
            string   temp_ObjCom, temp_ObjAna;

            GraphCmd = Regex.Split(GraphCmd, @"\|", RegexOptions.IgnoreCase)[0];

            //Debug GraphCmd
            LogOutput("@ParameterChecker  ># " + GraphCmd + " #<");

            //Save Displayed Object
            //二回挿入防止
            if (DisplayedObjectFinder(ObjName[listIndex].ToString()) == -1)
            {
                ObjDisplayed.Add(ObjName[listIndex]);
            }

            #region GraphicInstruction
            if (GraphicInstruction.Contains(GraphCmd))
            {
                switch (GraphCmd)
                {
                case "Line":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Line -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Line -- " + temp_ObjAna);

                    Draw_LineMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "DashLine":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd DashLine -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd DashLine -- " + temp_ObjAna);

                    Draw_LineMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "ExLine":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd ExLine -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd ExLine -- " + temp_ObjAna);

                    Draw_ExLineMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "Arc":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Arc -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Arc -- " + temp_ObjAna);

                    Draw_CurveMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "Circle":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Circle -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Circle -- " + temp_ObjAna);

                    Draw_CircleMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "Arrow":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Arrow -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Arrow -- " + temp_ObjAna);

                    Draw_ArrowMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "DashArrow":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd DashArrow -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd DashArrow -- " + temp_ObjAna);

                    Draw_ArrowMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "ExArrow":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd ExArrow -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd ExArrow -- " + temp_ObjAna);

                    Draw_ExArrowMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "Triangle":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Triangle -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Triangle -- " + temp_ObjAna);

                    Draw_TriangleMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "Rectangle":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Rectangle -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Rectangle -- " + temp_ObjAna);

                    Draw_QuadrilateralMode(temp_ObjCom, temp_ObjAna);
                    break;

                case "Point":
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    temp_ObjAna = Convert.ToString(ObjAnalysis[listIndex]);
                    //Debug
                    LogOutput("switch GraphCmd Point -- " + temp_ObjCom);
                    LogOutput("switch GraphCmd Point -- " + temp_ObjAna);

                    Draw_PointMode(temp_ObjCom, temp_ObjAna);
                    break;

                default:
                    codeOutput("Error @ParameterChecker @852");
                    break;
                }
            }
            #endregion

            #region SpecialInstruction
            else if (Regex.IsMatch(SpecialInstruction, GraphCmd, RegexOptions.IgnoreCase))
            {
                if (GraphCmd == "Ident")
                {
                    temp_ObjCom = Convert.ToString(ObjCommand[listIndex]);
                    AssignRemover(ref temp_ObjCom);

                    //GraphIns   Ident|Plus|Ident
                    //temp_ObjCom   obj1|+|obj2
                    for (int i = 0; i < Regex.Split(GraphIns.ToString(), @"\|", RegexOptions.IgnoreCase).Length; i++)
                    {
                        if (Regex.Split(GraphIns.ToString(), @"\|", RegexOptions.IgnoreCase)[i] == "Ident")
                        {
                            if (ObjectFinder(Regex.Split(temp_ObjCom, @"\|", RegexOptions.IgnoreCase)[i]) != -1)
                            {
                                ParameterChecker(ObjAnalysis[ObjectFinder(Regex.Split(temp_ObjCom, @"\|", RegexOptions.IgnoreCase)[i])], ObjectFinder(Regex.Split(temp_ObjCom, @"\|", RegexOptions.IgnoreCase)[i]));
                            }

                            else
                            {
                                tobeRead.SpeakAsync("Errorになっております、入力内容を確認してください。詳しい内容はlogに表示します。");
                                LogOutput("Errorになっております、入力内容を確認してください。詳しい内容はlogに表示します。");
                                LogOutput("Error @ParameterChecker -> SpecialInstruction @923");
                            }
                        }
                    }
                }
            }
            #endregion

            else
            {
                codeOutput("Error @ParameterChecker @933");
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
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);
        }