Example #1
0
        public static Preset Load(string Path)
        {
            int    presetID         = int.Parse(Path.Substring(Path.LastIndexOf("\\") + 1));
            string presetName       = string.Empty;
            int    presetTemplateID = 0;
            int    presetTextID     = 0;

            string[] info = File.ReadAllLines(Path + "\\info.txt", Encoding.UTF8);

            for (int j = 0; j < info.Length; j++)
            {
                if (info[j].StartsWith("Name="))
                {
                    presetName = info[j].Substring(5);
                }
                else if (info[j].StartsWith("TemplateID="))
                {
                    presetTemplateID = int.Parse(info[j].Substring(11));
                }
                else if (info[j].StartsWith("TextID="))
                {
                    presetTextID = int.Parse(info[j].Substring(7));
                }
            }

            Preset preset = new Preset(presetID, presetName);

            preset.TemplateID = presetTemplateID;
            preset.TextID     = presetTextID;

            try
            {
                preset.Settings = PresetSettings.Load(Path + "\\settings.txt");
            }
            catch (Exception)
            {
                preset.Settings = new PresetSettings();
            }

            return(preset);
        }
Example #2
0
File: Task.cs Project: michel50/UDS
        public static Task Load(string Path)
        {
            int      id         = int.Parse(Path.Substring(Path.LastIndexOf("\\") + 1));
            string   name       = string.Empty;
            int      presetID   = 0;
            int      templateID = 0;
            int      textID     = 0;
            DateTime startTime  = new DateTime();
            DateTime endTime    = new DateTime();


            string[] info = File.ReadAllLines(Path + "\\info.txt", Encoding.UTF8);

            for (int j = 0; j < info.Length; j++)
            {
                if (info[j].StartsWith("Name="))
                {
                    name = info[j].Substring(5);
                }
                else if (info[j].StartsWith("PresetID="))
                {
                    presetID = int.Parse(info[j].Substring(9));
                }
                else if (info[j].StartsWith("TemplateID="))
                {
                    templateID = int.Parse(info[j].Substring(11));
                }
                else if (info[j].StartsWith("TextID="))
                {
                    textID = int.Parse(info[j].Substring(7));
                }
                else if (info[j].StartsWith("StartTime="))
                {
                    startTime = DateTime.Parse(info[j].Substring(10));
                }
                else if (info[j].StartsWith("EndTime="))
                {
                    try
                    {
                        endTime = DateTime.Parse(info[j].Substring(8));
                    }
                    catch (Exception)
                    {
                        endTime = new DateTime();
                    }
                }
            }

            Task task = new Task(id, name);

            task.PresetID   = presetID;
            task.TemplateID = templateID;
            task.TextID     = textID;

            task.StartTime = startTime;
            task.EndTime   = endTime;

            try
            {
                task.Settings = PresetSettings.Load(Path + "\\settings.txt");
            }
            catch (Exception)
            {
                task.Settings = new PresetSettings();
            }

            return(task);
        }