示例#1
0
        public Form1()
        {
            InitializeComponent();
            admin_EditionMode = MyronWebUAT.admin_editmode_none;
            adminGroupBoxes   = new GroupBox[5] {
                Grp_DataRows, Grp_StdTranslations, Grp_FixedTranslations, Grp_ConditionalTranslations, Grp_Template
            };

            currentDataRow  = null;
            currentTemplate = null;
            dataRowNewPart  = MyronWebUAT.admin_notSelected;

            // Load WebUATController data from Json file. If file doesn't exist it will create a new one from an empty instance.
            controller = WebUATController.LoadWebUATJsonData();
        }
        /// <summary>
        /// Constructor that loads from the JSON files all the data
        /// </summary>
        public static WebUATController LoadWebUATJsonData()
        {
            WebUATController result = null;

            //Check if there's previous WebUATController data saved as json
            if (File.Exists(MyronWebUAT.json_filepath))
            {
                // If so, load the file and return the object
                StreamReader   streamReader = new StreamReader(MyronWebUAT.json_filepath);
                JsonTextReader reader       = new JsonTextReader(streamReader);
                JsonSerializer serializer   = new JsonSerializer();
                result = serializer.Deserialize <WebUATController>(reader);
                reader.Close();
            }
            // If file doesn't exist create a new instance of WebUATController and save it as Json
            else
            {
                result = new WebUATController();
                result.SaveWebUATJsonData();
            }

            return(result);
        }