private void LoadingThread()
        {
            ProgressTextBlock.Dispatcher.Invoke(new UpdateUIStateDelegate(UpdateProgressLabel),
                "Loading Config File(config.xml).", ProgressState.LoadingStart);
            Thread.Sleep(1000);

            Config con = Config.LoadConfig(@"config.xml");
            _Config = con;
            if (con.State == ConfigState.NotExisted)
            {
                ProgressTextBlock.Dispatcher.Invoke(new UpdateUIStateDelegate(UpdateProgressLabel),
                    "配置文件(config.xml)不存在。", ProgressState.LoadingStart);
                Thread.Sleep(100);

                ProgressTextBlock.Dispatcher.Invoke(new UpdateUIStateDelegate(UpdateProgressLabel),
                    "创建配置文件(config.xml)。", ProgressState.CreateConfig);
                Thread.Sleep(1000);

                con.Save();
            }

            ProgressTextBlock.Dispatcher.Invoke(new UpdateUIStateDelegate(UpdateProgressLabel),
                "Loading TinyFS.", ProgressState.LoadingTinyFS);
            Thread.Sleep(500);

            ProgressTextBlock.Dispatcher.Invoke(new UpdateUIStateDelegate(UpdateProgressLabel),
                "启动中。", ProgressState.End);
        }
Beispiel #2
0
        public static Config LoadConfig(string strFile)
        {
            Config con = new Config();

            if (!Path.IsPathRooted(strFile))
                strFile = Path.Combine(Directory.GetCurrentDirectory(), strFile);
            con.ConfigFile = strFile;

            if (!File.Exists(strFile))
            {
                con.State = ConfigState.NotExisted;
                return con;
            }

            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(strFile);

                XmlElement xmlEle = xmlDoc.SelectSingleNode("tfs-config/Environment") as XmlElement;
                con.OpenFileDirection = xmlEle.GetAttribute("Direction");

                xmlEle = xmlDoc.SelectSingleNode("tfs-config/OpenList") as XmlElement;
                foreach (XmlNode xmlNode in xmlEle.ChildNodes)
                {
                    XmlElement ele = xmlNode as XmlElement;
                    con.LastOpenedFiles.Add(ele.GetAttribute("Path"));
                }
            }
            catch (System.Exception)
            {
                con.State = ConfigState.FormatError;
            }

            return con;
        }