예제 #1
0
        public bool SaveSettings()
        {
            List <string> configlines = new List <string>();

            configlines.Add("VD2Path|" + VD2Path);
            configlines.Add("TreeIconSize|" + TreeIconSize.ToString());
            bool abort = false;

            try
            {
                File.WriteAllLines("EditorUserSettings.cfg", configlines);
            }
            catch (Exception ex)
            {
                UI.ErrorMessageDialog dialog = new UI.ErrorMessageDialog();
                dialog.ErrorTitleText   = "Can't write config file!";
                dialog.ErrorMessageText = "An exception occurred while attempting to write config to file, this is often because of write protections on the folder you installed this editor to.\r\nProgram Files has elevated priviledges, and requires admin permissions to write there.\r\n\r\nPlease use the exception below to diagnose the problem and try again.\r\n\r\n" + ex.Message + ex.StackTrace + "\r\n\r\n";
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                    dialog.ErrorMessageText += ex.Message + ex.StackTrace + "\r\n\r\n";
                }
                dialog.ShowDialog();
                abort = true;
                //Application.Exit();
            }
            if (abort)
            {
                return(false);
            }
            return(true);
        }
        private void LoadInData(string inPath, VD2FileSource inSource)
        {
            string fullpath = EditorUserSettings.UserSettings.VD2Path + inSource.Path + "Data\\" + inPath;

            if (Directory.Exists(fullpath))
            {
                List <string> datafiles = Directory.EnumerateFiles(fullpath).ToList();
                for (int i = 0; i < datafiles.Count; i++)
                {
                    if (datafiles[i].EndsWith(".xml"))
                    {
                        //string dataname = inSource.ShortName + "\\" + datafiles[i].Substring(fullpath.Length + 1, (datafiles[i].Length - fullpath.Length) - 5);
                        string dataname = inSource.ShortName + ":" + datafiles[i];
                        if (Data.ContainsKey(dataname))
                        {
                            UI.ErrorMessageDialog dialog = new UI.ErrorMessageDialog();
                            dialog.ErrorTitleText    = "Duplicate File Name";
                            dialog.ErrorMessageText  = "The file " + datafiles[i] + "would result in a duplicate key error\r\n";
                            dialog.ErrorMessageText += "The resulting key would be:\r\n" + dataname + "\r\nThe file will be skipped.";
                            dialog.ShowDialog();
                        }
                        else
                        {
                            T currentdata = System.Activator.CreateInstance(typeof(T), datafiles[i], inSource) as T;
                            Data.Add(dataname, currentdata);
                        }
                    }
                }
            }
        }