示例#1
0
        public CommandForm(Project project)
        {
            InitializeComponent();

            _project = project;

            destDirBox.Text =
                Utilities.GetRelativePath(
                Path.Combine(
                Path.GetDirectoryName(_project.OriginalFullPath),
                "gen"));

            selectDestDirButton.Click += new EventHandler(selectDestDirButton_Click);
            runButton.Click += new EventHandler(runButton_Click);
            copyCBButton.Click += new EventHandler(copyCBButton_Click);
        }
示例#2
0
        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;
        }
示例#3
0
        public DenshaImage(Project project, string fileName, string thumbName)
        {
            _project = project;
            _id = getUniqId();

            OriginalName = Path.GetFileNameWithoutExtension(fileName);
            ThumbnailName = Path.GetFileNameWithoutExtension(thumbName);
            ExtName = Path.GetExtension(fileName);

            OnPropertyChanged("OriginalName");
            OnPropertyChanged("OriginalPath");
            OnPropertyChanged("OriginalFullPath");
            OnPropertyChanged("ThumbnailName");
            OnPropertyChanged("ThumbnailPath");
            OnPropertyChanged("ThumbnailFullPath");
            OnPropertyChanged("ExtName");
            OnPropertyChanged("FileName");

            ReadExif();

            Recital = "";
            Tags = new List<Tag>();
            IsUsed = true;
        }
示例#4
0
 public DenshaImage(Project project, string fileName)
     : this(project, fileName, "s-" + fileName)
 {
 }
示例#5
0
        public static DenshaImage ReadXml(Project project, XmlNode node)
        {
            if (node.Name != "image") return null;

            string origname = null;
            string thumbname = null;
            string extname = null;
            DateTime time = DateTime.Now;
            bool use = false;
            string recital = "";
            List<Tag> tags = new List<Tag>();

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                    case "origname":
                        origname = child.InnerText.Trim();
                        break;
                    case "thumbname":
                        thumbname = child.InnerText.Trim();
                        break;
                    case "extname":
                        extname = child.InnerText.Trim();
                        break;
                    case "time":
                        DateTime.TryParseExact(child.InnerText.Trim(), SAVETIME_FORMAT, null,
                            System.Globalization.DateTimeStyles.AllowWhiteSpaces, out time);
                        break;
                    case "use":
                        use = child.InnerText.Trim() == "1";
                        break;
                    case "recital":
                        recital = child.InnerText.Trim();
                        break;
                    case "tags":
                        {
                            foreach (XmlNode tagNode in child.ChildNodes)
                            {
                                int tagId = -1;
                                int.TryParse(tagNode.InnerText.Trim(), out tagId);
                                Tag tag = project.Tags.FindById(tagId);
                                if (tag != null) tags.Add(tag);
                            }
                        }
                        break;
                }
            }

            if (String.IsNullOrEmpty(origname) || String.IsNullOrEmpty(thumbname)) return null;

            extname = extname ?? ".jpg";
            DenshaImage img = new DenshaImage(project, origname + extname, thumbname + extname);
            img._isUsed = use;
            img.Recital = recital;
            img.ShootingTime = time;
            foreach (Tag tag in tags)
            {
                img.AddTag(tag);
            }

            return img;
        }
示例#6
0
        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;
        }
示例#7
0
        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;
        }
示例#8
0
 void onProjectLoadComplete(object sender, RunWorkerCompletedEventArgs e)
 {
     // set project
     Project project = e.Result as Project;
     if (project != null)
     {
         Project = project;
     }
     else
     {
         Project = null;
     }
 }