Пример #1
0
        public void add_model(String source_model_path, String parent_name)
        {
            String folder_name = Path.GetFileName(source_model_path);

            Regex cXX = new Regex("^[c]([0-9]{2}|xx|[0-9]x|x[0-9])$", RegexOptions.IgnoreCase);
            Regex lXX = new Regex("^[l]([0-9]{2}|xx|[0-9]x|x[0-9])$", RegexOptions.IgnoreCase);

            if (cXX.IsMatch(Path.GetFileName(folder_name)))
            {
                logger.log("folder is cXX/lXX match");

                //If source != destination
                if (source_model_path != modelpath)
                {
                    if (Directory.Exists(modelpath + Path.GetFileName(parent_name) + "/c" + this.modelslotstring))
                    {
                        Directory.Delete(modelpath + Path.GetFileName(parent_name) + "/c" + this.modelslotstring, true);
                        logger.log("deleting destination");
                    }

                    Directory.CreateDirectory(modelpath + Path.GetFileName(parent_name) + "/c" + this.modelslotstring);
                    logger.log("creating destination");
                    foreach (String file in Directory.GetFiles(source_model_path))
                    {
                        File.Copy(file, modelpath + Path.GetFileName(parent_name) + "/c" + this.modelslotstring + "/" + Path.GetFileName(file));
                    }
                }
                logger.log("files copied in : " + modelpath + Path.GetFileName(parent_name));
                this.models.Add(Path.GetFileName(parent_name) + "/cXX");
                Library.add_skin_model(this.fullname, this.slot, Path.GetFileName(parent_name) + "/cXX");
                set_model_workspace_status(Path.GetFileName(parent_name), "cXX", "new");
                logger.log("setting to new");
            }
            if (lXX.IsMatch(Path.GetFileName(folder_name)))
            {
                logger.log("folder is cXX/lXX match");
                if (Directory.Exists(modelpath + Path.GetFileName(parent_name) + "/l" + this.modelslotstring))
                {
                    Directory.Delete(modelpath + Path.GetFileName(parent_name) + "/l" + this.modelslotstring, true);
                    logger.log("deleting destination");
                }

                logger.log("creating destination");
                Directory.CreateDirectory(modelpath + Path.GetFileName(parent_name) + "/l" + this.modelslotstring);
                logger.log("files copied in : " + modelpath + Path.GetFileName(parent_name));
                foreach (String file in Directory.GetFiles(source_model_path))
                {
                    File.Copy(file, modelpath + Path.GetFileName(parent_name) + "/l" + this.modelslotstring + "/" + Path.GetFileName(file));
                }
                logger.log("files copied in : " + modelpath + Path.GetFileName(parent_name));
                this.models.Add(Path.GetFileName(parent_name) + "/lXX");
                Library.add_skin_model(this.fullname, this.slot, Path.GetFileName(parent_name) + "/lXX");
                set_model_workspace_status(Path.GetFileName(parent_name), "lXX", "new");
                logger.log("setting to new");
            }
        }