コード例 #1
0
ファイル: Manager.cs プロジェクト: hirekoke/Densha
        public Project CreateProject(string origDirPath, string thumbDirPath)
        {
            Project project = new Project();
            project.OriginalPath = origDirPath;
            project.ThumbnailPath = thumbDirPath;
            project.TagTypes = new TagTypeCollection();
            Tag tag1 = new Tag(TagType.Default, "a", "あaaほあえljうぇlgkjwヶgawefwefw");
            Tag tag2 = new Tag(TagType.Default, "c", "bbb");
            Tag tag3 = new Tag(TagType.Default, "b", "あaaほあえljうぇlgkjwヶgawefwefw");
            project.Tags.Add(tag1);
            project.Tags.Add(tag2);
            project.Tags.Add(tag3);

            DirectoryInfo dOriginalDirInfo = new DirectoryInfo(project.OriginalFullPath);
            DirectoryInfo dThumbnailDirInfo = new DirectoryInfo(project.ThumbnailFullPath);
            if (!dOriginalDirInfo.Exists)
            {

            }
            else
            {
                FileInfo[] fInfos = dOriginalDirInfo.GetFiles("*.jpg");
                for (int i = 0; i < 100; i++)
                {
                    foreach (FileInfo fInfo in fInfos)
                    {
                        DenshaImage img = new DenshaImage(project, fInfo.Name);
                        img.AddTag(tag1);
                        img.AddTag(tag2);
                        img.AddTag(tag3);
                        project.AddImage(img);
                    }
                }
            }

            return project;
        }
コード例 #2
0
ファイル: Project.cs プロジェクト: hirekoke/Densha
        public static Project ReadXml(XmlDocument doc, BackgroundWorker worker)
        {
            if (doc.GetElementsByTagName("project") == null) return null;

            Project project = new Project();

            XmlNode origpathNode = doc.SelectSingleNode("/project/origpath");
            if (origpathNode == null) return null;
            project.OriginalPath = origpathNode.InnerText.Trim();

            XmlNode thumbpathNode = doc.SelectSingleNode("/project/thumbpath");
            if (thumbpathNode == null) return null;
            project.ThumbnailPath = thumbpathNode.InnerText.Trim();

            XmlNode tagtypesNode = doc.SelectSingleNode("/project/tagtypes");
            if (tagtypesNode == null) return null;
            TagTypeCollection ttcol = TagTypeCollection.ReadXml(project, tagtypesNode);
            project.TagTypes = ttcol;

            XmlNode tagNode = doc.SelectSingleNode("/project/tags");
            if (tagNode == null) return null;
            TagCollection tcol = TagCollection.ReadXml(project, tagNode);
            project.Tags = tcol;

            XmlNode imagesNode = doc.SelectSingleNode("/project/images");
            if (imagesNode == null) return null;
            float imgCount = imagesNode.ChildNodes.Count - 1;
            int i = 0;
            foreach (XmlNode imgNode in imagesNode.ChildNodes)
            {
                DenshaImage img = DenshaImage.ReadXml(project, imgNode);
                if (img != null) project.AddImage(img);
                if (worker != null)
                {
                    worker.ReportProgress((int)(i * 100 / imgCount), "loading images");
                    i++;
                }
            }
            return project;
        }
コード例 #3
0
ファイル: Project.cs プロジェクト: hirekoke/Densha
        public static Project CreateProject(string origDirPath, string thumbDirPath, string thumbnailNamePattern, BackgroundWorker worker)
        {
            worker.ReportProgress(0, "creating project");

            Project project = new Project();
            project.OriginalPath = origDirPath;
            project.ThumbnailPath = thumbDirPath;
            project.TagTypes = new TagTypeCollection();

            DirectoryInfo dOriginalDirInfo = new DirectoryInfo(project.OriginalFullPath);
            DirectoryInfo dThumbnailDirInfo = new DirectoryInfo(project.ThumbnailFullPath);
            if (!dOriginalDirInfo.Exists)
            {

            }
            else
            {
                FileInfo[] fInfos = dOriginalDirInfo.GetFiles("*.jpg");
                int i = 0;
                int imgCount = fInfos.Length;

                foreach (FileInfo fInfo in fInfos)
                {
                    string origName = Path.GetFileNameWithoutExtension(fInfo.Name);
                    DenshaImage img = new DenshaImage(project, fInfo.Name,
                        Utilities.ApplyThumbnailNamePattern(fInfo.Name, thumbnailNamePattern));
                    project.AddImage(img);

                    worker.ReportProgress((int)(i * 100 / imgCount), "loading images");
                    i++;
                }
            }
            project.ProjectFilePath = null;

            worker.ReportProgress(100, "creating project");

            project._notifyChange = true;
            return project;
        }