Beispiel #1
0
        private void UpdateStateConfigs()
        {
            this.Invalidate();
            //update Default State Enum
            //EnumManager.UpdateEnum(EnumName, stateList[0].Name, stateList.Select(x => x.Name).ToArray());
            StateXML = State.DataSerializeState(stateList); //save config

            //new enum technique
            //EnumManager.UpdateEnum(myGUID + "_States", stateList[0].Name, stateList.Select(x => x.Name).ToArray());
            StatesEnum.Clear();
            stateList.ForEach(state => StatesEnum.AddEntry(state.Name));
            //FLogger.Log(LogType.Debug, "update enums state");
        }
Beispiel #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;
            }
        }