コード例 #1
0
ファイル: Main.cs プロジェクト: wirmachenbunt/AutomataUI
        private void InitSettings()
        {
            //load settings
            if (stateList.Count < 2 && StateXML[0].Length > 3 && Initialize)
            {
                try
                {
                    stateList      = State.DataDeserializeState(StateXML[0]);
                    transitionList = Transition.DataDeserializeTransition(TransitionXML[0]);

                    if (RegionXML[0].Length > 3)
                    {
                        regionList = AutomataRegion.DataDeserializeRegion(RegionXML[0]);
                    }
                    EnumManager.UpdateEnum(myGUID + "_Regions", regionList[0].Name, regionList.Select(x => x.Name).ToArray());
                }
                catch { FLogger.Log(LogType.Debug, "Loading XML Graph failed!"); }

                //new enum technique
                EnumManager.UpdateEnum(myGUID + "_States", stateList[0].Name, stateList.Select(x => x.Name).ToArray());
                EnumManager.UpdateEnum(myGUID + "_Transitions", transitionList[0].Name, transitionList.Select(x => x.Name).Distinct().ToArray());
                EnumManager.UpdateEnum(myGUID + "_AllTransitions", transitionList[0].Name, transitionList.Select(x => x.Name).ToArray());

                //repair relation
                foreach (Transition transition in transitionList)
                {
                    transition.startState = stateList.First(x => x.ID.Contains(transition.startState.ID));
                    transition.endState   = stateList.First(x => x.ID.Contains(transition.endState.ID));
                }

                this.Invalidate();
                previousPosition = MousePosition;
                p.StagePos.X     = 0;
                p.StagePos.Y     = 0;

                UpdateOutputs(); //update State and Transition Outputs
                Initialize = false;
            }
        }
コード例 #2
0
        private void InitSettings()
        {
            //load settings
            if (stateList.Count < 2 && StateXML.Length > 3 && Initialize)
            {
                try
                {
                    stateList      = State.DataDeserializeState(StateXML);
                    transitionList = Transition.DataDeserializeTransition(TransitionXML);

                    if (RegionXML.Length > 3)
                    {
                        regionList = AutomataRegion.DataDeserializeRegion(RegionXML);
                    }
                }
                catch { debug = "Loading XML Graph failed!"; }

                //new enum technique
                //EnumManager.UpdateEnum(myGUID + "_States", stateList[0].Name, stateList.Select(x => x.Name).ToArray());
                stateList.ForEach(state => StatesEnum.AddEntry(state.Name));
                //EnumManager.UpdateEnum(myGUID + "_Transitions", transitionList[0].Name, transitionList.Select(x => x.Name).Distinct().ToArray());
                transitionList.ForEach(transition => TransitionsEnum.AddEntry(transition.Name));
                //EnumManager.UpdateEnum(myGUID + "_Regions", regionList[0].Name, regionList.Select(x => x.Name).ToArray());
                regionList.ForEach(region => RegionsEnum.AddEntry(region.Name));
                //EnumManager.UpdateEnum(myGUID + "_AllTransitions", transitionList[0].Name, transitionList.Select(x => x.Name).ToArray());

                //repair relation
                foreach (Transition transition in transitionList)
                {
                    transition.startState = stateList.First(x => x.ID.Contains(transition.startState.ID));
                    transition.endState   = stateList.First(x => x.ID.Contains(transition.endState.ID));
                }

                this.Invalidate();
                previousPosition = MousePosition;
                p.StagePos.X     = 0;
                p.StagePos.Y     = 0;

                Initialize = false;
            }
            else if (stateList.Count < 2 && Initialize)
            {
                //add state to state list

                stateList.Add(new State()
                {
                    ID     = "Init",
                    Name   = "Init",
                    Bounds = new Rectangle(new Point(0, 0), new Size(p.StateSize, p.StateSize))
                });


                UpdateStateConfigs(); // update JSON,Enums and Redraw
                this.Invalidate();
                previousPosition = MousePosition;
                p.StagePos.X     = 0;
                p.StagePos.Y     = 0;

                Initialize = false;
            }
        }