当前位置: 首页>>代码示例>>C#>>正文


C# Photo.AddTag方法代码示例

本文整理汇总了C#中Photo.AddTag方法的典型用法代码示例。如果您正苦于以下问题:C# Photo.AddTag方法的具体用法?C# Photo.AddTag怎么用?C# Photo.AddTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Photo的用法示例。


在下文中一共展示了Photo.AddTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Step

	public override bool Step (out Photo photo, out Pixbuf thumbnail, out int count)
	{
		thumbnail = null;

		if (import_info == null)
			throw new ImportException ("Prepare() was not called");

		if (this.count == import_info.Count)
			throw new ImportException ("Already finished");

		// FIXME Need to get the EXIF info etc.
		ImportInfo info = (ImportInfo)import_info [this.count];
		bool needs_commit = false;
		bool abort = false;
		try {
			string destination = info.OriginalPath;
			if (copy)
				destination = ChooseLocation (info.OriginalPath, directories);
			
			// Don't copy if we are already home
			if (info.OriginalPath == destination) {
				info.DestinationPath = destination;
				photo = store.Create (info.DestinationPath, roll.Id, out thumbnail);
			} else {
				System.IO.File.Copy (info.OriginalPath, destination);
				info.DestinationPath = destination;

				photo = store.Create (info.DestinationPath, info.OriginalPath, roll.Id, out thumbnail);

				try {
					File.SetAttributes (destination, File.GetAttributes (info.DestinationPath) & ~FileAttributes.ReadOnly);
					DateTime create = File.GetCreationTime (info.OriginalPath);
					File.SetCreationTime (info.DestinationPath, create);
					DateTime mod = File.GetLastWriteTime (info.OriginalPath);
					File.SetLastWriteTime (info.DestinationPath, mod);
				} catch (IOException) {
					// we don't want an exception here to be fatal.
				}
			} 

			if (tags != null) {
				foreach (Tag t in tags) {
					photo.AddTag (t);
				}
				needs_commit = true;
			}

			needs_commit |= xmptags.Import (photo, info.DestinationPath, info.OriginalPath);

			if (needs_commit)
				store.Commit(photo);
			
			info.Photo = photo;
		} catch (System.Exception e) {
			System.Console.WriteLine ("Error importing {0}{2}{1}", info.OriginalPath, e.ToString (), Environment.NewLine);
			if (thumbnail != null)
				thumbnail.Dispose ();

			thumbnail = null;
			photo = null;

			HigMessageDialog errordialog = new HigMessageDialog (parent,
									     Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent,
									     Gtk.MessageType.Error,
									     Gtk.ButtonsType.Cancel,
									     Catalog.GetString ("Import error"),
									     String.Format(Catalog.GetString ("Error importing {0}{2}{2}{1}"), info.OriginalPath, e.Message, Environment.NewLine ));
			errordialog.AddButton ("Skip", Gtk.ResponseType.Reject, false);
			ResponseType response = (ResponseType) errordialog.Run ();
			errordialog.Destroy ();
			if (response == ResponseType.Cancel)
				abort = true;
		}

		this.count ++;
		count = this.count;

		return (!abort && count != import_info.Count);
	}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:79,代码来源:FileImportBackend.cs

示例2: Execute

        public bool Execute(PhotoStore store, Photo [] photos, Photo new_parent, Gtk.Window parent_window)
        {
            string ok_caption = Catalog.GetString ("Re_parent");
            string msg = String.Format (Catalog.GetPluralString ("Really reparent \"{0}\" as version of \"{1}\"?",
                                                                 "Really reparent {2} photos as versions of \"{1}\"?", photos.Length),
                                        new_parent.Name.Replace ("_", "__"), photos[0].Name.Replace ("_", "__"), photos.Length);
            string desc = Catalog.GetString ("This makes the photos appear as a single one in the library. The versions can be detached using the Photo menu.");

            try {
                if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(parent_window, DialogFlags.DestroyWithParent,
                                       MessageType.Warning, msg, desc, ok_caption)) {
                    uint highest_rating = new_parent.Rating;
                    string new_description = new_parent.Description;
                    foreach (Photo photo in photos) {
                        highest_rating = Math.Max(photo.Rating, highest_rating);
                        if (string.IsNullOrEmpty(new_description))
                            new_description = photo.Description;
                        new_parent.AddTag (photo.Tags);

                        foreach (uint version_id in photo.VersionIds) {
                            new_parent.DefaultVersionId = new_parent.CreateReparentedVersion (photo.GetVersion (version_id) as PhotoVersion);
                            store.Commit (new_parent);
                        }
                        uint [] version_ids = photo.VersionIds;
                        Array.Reverse (version_ids);
                        foreach (uint version_id in version_ids) {
                            photo.DeleteVersion (version_id, true, true);
                        }
                        store.Remove (photo);
                    }
                    new_parent.Rating = highest_rating;
                    new_parent.Description = new_description;
                    store.Commit (new_parent);
                    return true;
                }
            }
            catch (Exception e) {
                HandleException ("Could not reparent photos", e, parent_window);
            }
            return false;
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:41,代码来源:PhotoVersionCommands.cs

示例3: AddTagToPhoto

        private void AddTagToPhoto(Photo photo, string new_tag_name, TagInfo sub_tag)
        {
            if (new_tag_name == null)
                return;

            Tag parent = EnsureTag (li_root_tag, tag_store.RootCategory);

            // If we should have a sub root make sure it exists
            if (sub_tag != null)
                parent = EnsureTag (sub_tag, parent as Category);

            Tag tag = EnsureTag (new TagInfo (new_tag_name), parent as Category);

            // Now we have the tag for this place, add the photo to it
            photo.AddTag (tag);
        }
开发者ID:iainlane,项目名称:f-spot,代码行数:16,代码来源:XmpTagsImporter.cs

示例4: Execute

 public bool Execute(PhotoStore store, Photo [] photos, Photo new_parent, Gtk.Window parent_window)
 {
     foreach (Photo photo in photos) {
         new_parent.AddTag (photo.Tags);
         foreach (uint version_id in photo.VersionIds) {
             try {
                 new_parent.DefaultVersionId = new_parent.CreateReparentedVersion (photo.GetVersion (version_id) as PhotoVersion);
                 store.Commit (new_parent);
             } catch (Exception e) {
                 Log.DebugException (e);
             }
         }
         uint [] version_ids = photo.VersionIds;
         Array.Reverse (version_ids);
         foreach (uint version_id in version_ids) {
             try {
                 photo.DeleteVersion (version_id, true, true);
             } catch (Exception e) {
                 Log.DebugException (e);
             }
         }
         MainWindow.Toplevel.Database.Photos.Remove (photo);
     }
     return true;
 }
开发者ID:iainlane,项目名称:f-spot,代码行数:25,代码来源:PhotoVersionCommands.cs

示例5: AddTagToPhoto

		void AddTagToPhoto (Photo photo, string newTagName)
		{
			if (string.IsNullOrEmpty(newTagName))
				return;

			Tag parent = EnsureTag (li_root_tag, tag_store.RootCategory);
			Tag tag = EnsureTag (new TagInfo (newTagName), parent as Category);

			// Now we have the tag for this place, add the photo to it
			photo.AddTag (tag);
		}
开发者ID:cizma,项目名称:f-spot,代码行数:11,代码来源:MetadataImporter.cs

示例6: AddTagToPhoto

        private void AddTagToPhoto(Photo photo, string new_tag_name)
        {
            if (new_tag_name == null || new_tag_name.Length == 0)
                return;

            Tag parent = EnsureTag (li_root_tag, tag_store.RootCategory);
            Tag tag = EnsureTag (new TagInfo (new_tag_name), parent as Category);

            // Now we have the tag for this place, add the photo to it
            photo.AddTag (tag);
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:11,代码来源:MetadataImporter.cs


注:本文中的Photo.AddTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。