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


C# Note.GetCompleteNoteXml方法代码示例

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


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

示例1: RenameNote

		// TODO: This appears to add <link:internal> around the note title
		//       in the content.
		private void RenameNote (Note note, string newTitle, bool updateReferencingNotes)
		{
			string oldTitle = note.Title;
			// Rename the note (skip for now...never using updateReferencingNotes option)
			//if (updateReferencingNotes) // NOTE: This might never work, or lead to a ton of conflicts
			// note.Title = newTitle;
			//else
			// note.RenameWithoutLinkUpdate (newTitle);
			//string oldContent = note.XmlContent;
			//note.XmlContent = NoteArchiver.Instance.GetRenamedNoteXml (oldContent, oldTitle, newTitle);

			// Preserve note information
			note.Save (); // Write to file
			bool noteOpen = note.IsOpened;
			string newContent = //note.XmlContent;
			        NoteArchiver.Instance.GetRenamedNoteXml (note.XmlContent, oldTitle, newTitle);
			string newCompleteContent = //note.GetCompleteNoteXml ();
			        NoteArchiver.Instance.GetRenamedNoteXml (note.GetCompleteNoteXml (), oldTitle, newTitle);
			//Logger.Debug ("RenameNote: newContent: " + newContent);
			//Logger.Debug ("RenameNote: newCompleteContent: " + newCompleteContent);

			// We delete and recreate the note to simplify content conflict handling
			Tomboy.DefaultNoteManager.Delete (note);

			// Create note with old XmlContent just in case GetCompleteNoteXml failed
			Logger.Debug ("RenameNote: about to create " + newTitle);
			Note renamedNote = Tomboy.DefaultNoteManager.Create (newTitle, newContent);
			if (newCompleteContent != null) {// TODO: Anything to do if it is null?
				try {
					renamedNote.LoadForeignNoteXml (newCompleteContent, ChangeType.OtherDataChanged);
				} catch {} // TODO: Handle exception in case that newCompleteContent is invalid XML
			}
		if (noteOpen)
				renamedNote.Window.Present ();
		}
开发者ID:MichaelAquilina,项目名称:tomboy,代码行数:37,代码来源:SyncDialog.cs

示例2: NoteConflictDetected

		public void NoteConflictDetected (NoteManager manager,
		                             Note localConflictNote,
		                             NoteUpdate remoteNote,
		                             IList<string> noteUpdateTitles)
		{
			SyncTitleConflictResolution savedBehavior = SyncTitleConflictResolution.Cancel;
			object dlgBehaviorPref = Preferences.Get (Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR);
			if (dlgBehaviorPref != null && dlgBehaviorPref is int) // TODO: Check range of this int
				savedBehavior = (SyncTitleConflictResolution)dlgBehaviorPref;

			SyncTitleConflictResolution resolution = SyncTitleConflictResolution.OverwriteExisting;
			// This event handler will be called by the synchronization thread
			// so we have to use the delegate here to manipulate the GUI.
			// To be consistent, any exceptions in the delgate will be caught
			// and then rethrown in the synchronization thread.
			Exception mainThreadException = null;
			Gtk.Application.Invoke (delegate {
				try {
					SyncTitleConflictDialog conflictDlg =
					new SyncTitleConflictDialog (localConflictNote, noteUpdateTitles);
					Gtk.ResponseType reponse = Gtk.ResponseType.Ok;

					bool noteSyncBitsMatch =
					        SyncManager.SynchronizedNoteXmlMatches (localConflictNote.GetCompleteNoteXml (),
					                                                remoteNote.XmlContent);

					// If the synchronized note content is in conflict
					// and there is no saved conflict handling behavior, show the dialog
					if (!noteSyncBitsMatch && savedBehavior == 0)
						reponse = (Gtk.ResponseType) conflictDlg.Run ();


					if (reponse == Gtk.ResponseType.Cancel)
						resolution = SyncTitleConflictResolution.Cancel;
					else {
						if (noteSyncBitsMatch)
							resolution = SyncTitleConflictResolution.OverwriteExisting;
						else if (savedBehavior == 0)
							resolution = conflictDlg.Resolution;
						else
							resolution = savedBehavior;

						switch (resolution) {
						case SyncTitleConflictResolution.OverwriteExisting:
							if (conflictDlg.AlwaysPerformThisAction)
								savedBehavior = resolution;
							// No need to delete if sync will overwrite
							if (localConflictNote.Id != remoteNote.UUID)
								manager.Delete (localConflictNote);
							break;
						case SyncTitleConflictResolution.RenameExistingAndUpdate:
							if (conflictDlg.AlwaysPerformThisAction)
								savedBehavior = resolution;
							RenameNote (localConflictNote, conflictDlg.RenamedTitle, true);
							break;
						case SyncTitleConflictResolution.RenameExistingNoUpdate:
							if (conflictDlg.AlwaysPerformThisAction)
								savedBehavior = resolution;
							RenameNote (localConflictNote, conflictDlg.RenamedTitle, false);
							break;
						}
					}

					Preferences.Set (Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR,
					                 (int) savedBehavior); // TODO: Clean up

					conflictDlg.Hide ();
					conflictDlg.Destroy ();

					// Let the SyncManager continue
					SyncManager.ResolveConflict (/*localConflictNote, */resolution);
				} catch (Exception e) {
					mainThreadException = e;
				}
			});
			if (mainThreadException != null)
				throw mainThreadException;
		}
开发者ID:MichaelAquilina,项目名称:tomboy,代码行数:78,代码来源:SyncDialog.cs


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