コード例 #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adjust current index of destination list to be same as source list.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void AdjustCurrentIndex(DifferenceList destList, DifferenceList srcList)
 {
     if (srcList.CurrentDifferenceIndex < destList.Count)
     {
         destList.CurrentDifferenceIndex = srcList.CurrentDifferenceIndex;
     }
 }
コード例 #2
0
ファイル: DiffView.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Executes in two distinct scenarios.
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            base.Dispose(disposing);

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_diffViewVc != null)
                {
                    m_diffViewVc.Dispose();
                }
                if (m_contextMenu != null)
                {
                    m_contextMenu.Dispose();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_diffViewVc      = null;
            m_scrBook         = null;
            m_SelectionHelper = null;
            m_contextMenu     = null;
            m_mnuCopy         = null;
            m_mnuPaste        = null;
            m_mnuCut          = null;
            m_Differences     = null;
        }
コード例 #3
0
        public void Should_ReturnCorrectExampleCaseSolution_When_GivenExampleInput()
        {
            var x              = "abcde,fghij,klmno,pqrst,fguij,axcye,wvxyz".Split(',');
            var ids            = x.Select(y => new BoxId(y)).ToList();
            var differenceList = DifferenceList.FromBoxIds(ids);

            Assert.Equal("fgij", differenceList.SmallestId);
        }
コード例 #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Replaces contents of a difference list with saved contents.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void ReplaceListContents(DifferenceList diffList, DifferenceList savedList)
 {
     diffList.Clear();
     foreach (Difference diff in savedList)
     {
         diffList.Add(diff.Clone());
     }
 }
コード例 #5
0
ファイル: DiffFootnoteView.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the DiffFootnoteView class
		/// </summary>
		/// <param name="cache">The FDO cache.</param>
		/// <param name="book">Scripture book to be displayed as the root in this view</param>
		/// <param name="differences">the list of differences</param>
		/// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we
		/// display the current version.</param>
		/// <param name="filterInstance">The filter instance.</param>
		/// ------------------------------------------------------------------------------------
		public DiffFootnoteView(FdoCache cache, IScrBook book, DifferenceList differences,
			bool fRev, int filterInstance) : base(cache)
		{
			m_filterInstance = filterInstance;
			m_scrBook = book;
			m_Differences = differences;
			m_fRev = fRev;
			Editable = false;
		}
コード例 #6
0
ファイル: DiffFootnoteView.cs プロジェクト: sillsdev/WorldPad
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the DiffFootnoteView class
 /// </summary>
 /// <param name="cache">The FDO cache.</param>
 /// <param name="book">Scripture book to be displayed as the root in this view</param>
 /// <param name="differences">the list of differences</param>
 /// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we
 /// display the current version.</param>
 /// <param name="filterInstance">The filter instance.</param>
 /// ------------------------------------------------------------------------------------
 public DiffFootnoteView(FdoCache cache, IScrBook book, DifferenceList differences,
                         bool fRev, int filterInstance) : base(cache)
 {
     m_filterInstance = filterInstance;
     m_scrBook        = book;
     m_Differences    = differences;
     m_fRev           = fRev;
     Editable         = false;
 }
コード例 #7
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Reverses (or "un-does") an action.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public override bool Undo()
 {
     m_redoDifferenceListClone = m_bookMerger.Differences.Clone();
     m_redoReviewListClone     = m_bookMerger.ReviewedDiffs.Clone();
     AdjustCurrentIndex(m_redoDifferenceListClone, m_undoDifferenceListClone);
     UndoRedoAction(m_undoDifferenceListClone, m_undoReviewListClone);
     m_undoDifferenceListClone = null;
     m_undoReviewListClone     = null;
     return(true);
 }
コード例 #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Replaces contents of difference lists in BookMerger with saved contents.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UndoRedoAction(DifferenceList savedDiffList, DifferenceList savedReviewList)
        {
            ReplaceListContents(m_bookMerger.Differences, savedDiffList);
            ReplaceListContents(m_bookMerger.ReviewedDiffs, savedReviewList);

            // move to the difference that was just inserted
            System.Diagnostics.Debug.Assert(
                savedDiffList.CurrentDifferenceIndex < savedDiffList.Count);
            m_bookMerger.Differences.CurrentDifferenceIndex = savedDiffList.CurrentDifferenceIndex;
        }
コード例 #9
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// <param name="differenceList"></param>
 /// <param name="reviewedList"></param>
 /// <param name="fRevert"><code>true</code> if we are reverting the difference (as
 /// opposed to keeping the current). If <c>true</c> a revert action is being created</param>
 /// ------------------------------------------------------------------------------------
 public UndoDifferenceAction(DifferenceList differenceList, DifferenceList reviewedList,
                             bool fRevert)
 {
     m_differenceList  = differenceList;
     m_reviewedList    = reviewedList;
     m_differenceRef   = m_differenceList.CurrentDifference;
     m_differenceClone = m_differenceList.CurrentDifference.Clone();
     m_index           = m_differenceList.CurrentDifferenceIndex;
     m_fReverted       = fRevert;
 }
コード例 #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Reverses (or "un-does") an action.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override bool Undo()
		{
			m_redoDifferenceListClone = m_bookMerger.Differences.Clone();
			m_redoReviewListClone = m_bookMerger.ReviewedDiffs.Clone();
			AdjustCurrentIndex(m_redoDifferenceListClone, m_undoDifferenceListClone);
			UndoRedoAction(m_undoDifferenceListClone, m_undoReviewListClone);
			m_undoDifferenceListClone = null;
			m_undoReviewListClone = null;
			return true;
		}
コード例 #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="differenceList"></param>
		/// <param name="reviewedList"></param>
		/// <param name="fRevert"><code>true</code> if we are reverting the difference (as
		/// opposed to keeping the current). If <c>true</c> a revert action is being created</param>
		/// ------------------------------------------------------------------------------------
		public UndoDifferenceAction(DifferenceList differenceList, DifferenceList reviewedList,
			bool fRevert)
		{
			m_differenceList = differenceList;
			m_reviewedList = reviewedList;
			m_differenceRef = m_differenceList.CurrentDifference;
			m_differenceClone = m_differenceList.CurrentDifference.Clone();
			m_index = m_differenceList.CurrentDifferenceIndex;
			m_fReverted = fRevert;
		}
コード例 #12
0
ファイル: ResourceTableWriter.cs プロジェクト: fjiang2/sqlcon
        /// <summary>
        /// Compare data table and resouce file, and find differences
        /// </summary>
        /// <param name="format"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public List <ResourceEntry> Differ(ResourceFormat format, DataTable dt, bool trimName, bool trimValue)
        {
            List <ResourceEntry> list = new List <ResourceEntry>();
            int index = 0;

            //load data rows from database
            var rows = dt.ToList(row => new entry
            {
                name  = row.GetField <string>(name_column),
                value = row.GetField <string>(value_column)
            });

            //load data from resx file
            ResourceFileReader reader = new ResourceFileReader
            {
                TrimPropertyName  = trimName,
                TrimPropertyValue = trimValue,
            };
            List <entry> entries = reader.Read(format, path);



            DifferenceList <entry> diff = new DifferenceList <entry>(rows);

            diff.OnItemAdded(x => list.Add(new ResourceEntry
            {
                Action   = DataRowAction.Add,
                Name     = x.name,
                NewValue = x.value,
                Index    = index++
            }));

            diff.OnItemModified((x, y) => list.Add(new ResourceEntry
            {
                Action   = DataRowAction.Change,
                Name     = x.name,
                OldValue = x.value,
                NewValue = y.value,
                Index    = index++
            }));

            diff.OnItemDeleted(x => list.Add(new ResourceEntry
            {
                Action = DataRowAction.Delete,
                Name   = x.name,
                Index  = index++
            }));

            diff.Differ(entries);

            return(list);
        }
コード例 #13
0
ファイル: DiffFootnoteVc.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the DiffFootnoteVc class
        /// </summary>
        /// <param name="differences">List of differences</param>
        /// <param name="fRev"><c>true</c> for revision, <c>false</c> for current version</param>
        /// <param name="cache">The database cache</param>
        /// ------------------------------------------------------------------------------------
        public DiffFootnoteVc(DifferenceList differences, bool fRev, FdoCache cache) :
            base(0, LayoutViewTarget.targetDraft, cache.DefaultVernWs)
        {
            base.Cache       = cache;
            m_Differences    = differences;
            m_fRev           = fRev;
            m_fNeedHighlight = true;             // assume we start needing the highlight

            // Start the view as editable.  Non-editable mode is now handled in the
            // DiffFootnoteView by eating the keyboard input.  This allows movement of the IP
            // inside of a read-only DiffFootnoteView.
            Editable = true;
        }
コード例 #14
0
ファイル: DiffFootnoteVc.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the DiffFootnoteVc class
		/// </summary>
		/// <param name="differences">List of differences</param>
		/// <param name="fRev"><c>true</c> for revision, <c>false</c> for current version</param>
		/// <param name="cache">The database cache</param>
		/// ------------------------------------------------------------------------------------
		public DiffFootnoteVc(DifferenceList differences, bool fRev, FdoCache cache) :
			base(0, LayoutViewTarget.targetDraft, cache.DefaultVernWs)
		{
			base.Cache = cache;
			m_Differences = differences;
			m_fRev = fRev;
			m_fNeedHighlight = true; // assume we start needing the highlight

			// Start the view as editable.  Non-editable mode is now handled in the
			// DiffFootnoteView by eating the keyboard input.  This allows movement of the IP
			// inside of a read-only DiffFootnoteView.
			Editable = true;
		}
コード例 #15
0
ファイル: DiffView.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the DiffView class
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="book">Scripture book to be displayed as the root in this view</param>
        /// <param name="differences">List of differences</param>
        /// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we
        /// display the current version.</param>
        /// <param name="filterInstance">The filter instance.</param>
        /// ------------------------------------------------------------------------------------
        public DiffView(FdoCache cache, IScrBook book, DifferenceList differences, bool fRev,
                        int filterInstance)
            : base(cache)
        {
            m_filterInstance = filterInstance;
            m_scrBook        = book;
            m_Differences    = differences;
            m_fRev           = fRev;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            BackColor   = SystemColors.Window;
            Editable    = false;
            HorizMargin = 10;
        }
コード例 #16
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Redo cannot currently be done.
 /// </summary>
 /// <param name="fRefreshPending">Ignored</param>
 /// ------------------------------------------------------------------------------------
 public override bool Redo(bool fRefreshPending)
 {
     // If the bookMerger is disposed, it is probably being called outside the Diff dialog,
     // in which case, the difference lists are no longer needed.
     if (m_bookMerger.IsDisposed)
     {
         return(true);
     }
     m_undoDifferenceListClone = m_bookMerger.Differences.Clone();
     m_undoReviewListClone     = m_bookMerger.ReviewedDiffs.Clone();
     AdjustCurrentIndex(m_undoDifferenceListClone, m_redoDifferenceListClone);
     UndoRedoAction(m_redoDifferenceListClone, m_redoReviewListClone);
     m_redoDifferenceListClone = null;
     m_redoReviewListClone     = null;
     return(true);
 }
コード例 #17
0
ファイル: DiffView.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the DiffView class
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="book">Scripture book to be displayed as the root in this view</param>
		/// <param name="differences">List of differences</param>
		/// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we
		/// display the current version.</param>
		/// <param name="filterInstance">The filter instance.</param>
		/// ------------------------------------------------------------------------------------
		public DiffView(FdoCache cache, IScrBook book, DifferenceList differences, bool fRev,
			int filterInstance)
			: base(cache)
		{
			m_filterInstance = filterInstance;
			m_scrBook = book;
			m_Differences = differences;
			m_fRev = fRev;

			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			BackColor = SystemColors.Window;
			Editable = false;
			HorizMargin = 10;
		}
コード例 #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the DiffViewVc class
        /// </summary>
        /// <param name="differences">List of differences</param>
        /// <param name="fRev"><c>true</c> for revision, <c>false</c> for current version</param>
        /// <param name="cache">The database cache</param>
        /// ------------------------------------------------------------------------------------
        public DiffViewVc(DifferenceList differences, bool fRev, FdoCache cache) :
            base(TeStVc.LayoutViewTarget.targetDraft, 0, null, false)
        {
            m_Differences    = differences;
            m_fRev           = fRev;
            m_fNeedHighlight = true;             // assume we start needing the highlight

            // Start the view as editable.  Non-editable mode is now handled in the DiffView by
            // eating the keyboard input.  This allows movement of the IP inside of a read-only
            // DiffView.
            Editable = true;

            Cache = cache;

            // Because this is a diff view, we want to show trailing white space
            m_fShowTailingSpace = true;
        }
コード例 #19
0
ファイル: DiffViewVc.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the DiffViewVc class
		/// </summary>
		/// <param name="differences">List of differences</param>
		/// <param name="fRev"><c>true</c> for revision, <c>false</c> for current version</param>
		/// <param name="cache">The database cache</param>
		/// ------------------------------------------------------------------------------------
		public DiffViewVc(DifferenceList differences, bool fRev, FdoCache cache) :
			base(TeStVc.LayoutViewTarget.targetDraft, 0, null, false)
		{
			m_Differences = differences;
			m_fRev = fRev;
			m_fNeedHighlight = true; // assume we start needing the highlight

			// Start the view as editable.  Non-editable mode is now handled in the DiffView by
			// eating the keyboard input.  This allows movement of the IP inside of a read-only
			// DiffView.
			Editable = true;

			Cache = cache;

			// Because this is a diff view, we want to show trailing white space
			m_fShowTailingSpace = true;
		}
コード例 #20
0
ファイル: DiffFootnoteVc.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_DispPropOverrides != null)
                {
                    m_DispPropOverrides.Clear();                     // Should these be disposed, as well?
                }
            }

            m_Differences       = null;
            m_DispPropOverrides = null;

            base.Dispose(disposing);
        }
コード例 #21
0
ファイル: DiffDialog.cs プロジェクト: sillsdev/WorldPad
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing"><c>true</c> to release both managed and unmanaged
		/// resources; <c>false</c> to release only unmanaged resources.
		/// </param>
		/// -----------------------------------------------------------------------------------
		protected override void Dispose( bool disposing )
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (m_messageFilterInstalled)
				{
					Application.RemoveMessageFilter(this);
					m_messageFilterInstalled = false;
				}
				// We don't want to call Controls.Clear() here, because that causes the controls
				// to change size (and fire the events for it...). It causes CreateMenuAndToolbars()
				// to be called, so we end up with two toolbar adapters, but we dispose only one,
				// so eventually it tries to access the already disposed mediator.
				//Controls.Clear();

				// No, since m_bookMerger owns it.
				// if (m_differences != null)
				//	m_differences.Dispose();
				if (m_viewHelper != null)
					m_viewHelper.Dispose();

				if (m_msgMediator != null)
				{
					m_msgMediator.RemoveColleague(this);
					// m_msgMediator gets disposed from calling components.Dispose() below
				}
				if (m_undoTaskHelper != null)
					m_undoTaskHelper.Dispose();

				if(components != null)
				{
					components.Dispose();
				}
			}

			// Deal with unmanaged stuff here.
			m_viewHelper = null;
			m_differences = null; // Just null it, since m_bookMerger owns it and will dispose it.
			m_msgMediator = null;
			m_bookMerger = null; // Client gave it, so it has to dispose it.
			m_cache = null;
			m_scr = null;
			m_stylesheet = null;
			m_undoTaskHelper = null;

			base.Dispose( disposing );
		}
コード例 #22
0
ファイル: DiffDialog.cs プロジェクト: sillsdev/WorldPad
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="DiffDialog"/> class.
		/// </summary>
		/// <param name="bookMerger"></param>
		/// <param name="cache"></param>
		/// <param name="stylesheet"></param>
		/// <param name="zoomFactorDraft">The zoom percentage to be used for the "draft" (i.e.,
		/// main Scripture) view</param>
		/// <param name="zoomFactorFootnote">The zoom percentage to be used for the "footnote"
		/// view</param>
		/// <param name="fDoCollapseUndo">true if we want to collapse to a single Undo item on close.</param>
		/// -----------------------------------------------------------------------------------
		public DiffDialog(BookMerger bookMerger, FdoCache cache, IVwStylesheet stylesheet,
			float zoomFactorDraft, float zoomFactorFootnote,
			bool fDoCollapseUndo)
		{
			Debug.Assert(cache != null);
			m_viewHelper = new ActiveViewHelper(this);
			m_fDoCollapseUndo = fDoCollapseUndo;

			// Required for Windows Form Designer support
			InitializeComponent();

			// just as fallback in case the Designer replaced FwContainer with Container
			// in InitializeComponent()...
			if (!(components is FwContainer))
				components = new FwContainer(components);

			// the last column of the table layout manager in the last row should have the
			// width of the scroll bar
			TableLayoutPanel tablePanel = tableLayoutPanel.GetControlFromPosition(0, 3)
				as TableLayoutPanel;
			tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth -
				SystemInformation.FixedFrameBorderSize.Width;
			tablePanel = tableLayoutPanel.GetControlFromPosition(1, 3)
							as TableLayoutPanel;
			tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth -
				SystemInformation.FixedFrameBorderSize.Width;

			m_msgMediator = new Mediator();
			m_msgMediator.AddColleague(this);
			components.Add(m_msgMediator);

			m_bookMerger = bookMerger;
			m_differences = bookMerger.Differences;
			m_cache = cache;
			m_scr = m_cache.LangProject.TranslatedScriptureOA;
			m_stylesheet = stylesheet;
			m_zoomFactorDraft = zoomFactorDraft;
			m_zoomFactorFootnote = zoomFactorFootnote;

			// Don't start out in edit mode
			m_editMode = false;

			// If the diff is a comparison of the current against a normal saved version, then
			// change the label text.
			ScrDraft draft = new ScrDraft(m_cache, m_bookMerger.BookRev.OwnerHVO);
			if (draft.Type == ScrDraftType.SavedVersion)
			{
				lblSavedVersion.Text = string.Format(TeDiffViewResources.kstidSavedVersion,
					draft.Description);
			}
			else
				lblSavedVersion.Text = string.Format(lblSavedVersion.Text, draft.Description);

			CreateUndoMark();
		}
コード例 #23
0
ファイル: DiffFootnoteVc.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_DispPropOverrides != null)
					m_DispPropOverrides.Clear(); // Should these be disposed, as well?
			}

			m_Differences = null;
			m_DispPropOverrides = null;

			base.Dispose(disposing);
		}
コード例 #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Redo cannot currently be done.
		/// </summary>
		/// <param name="fRefreshPending">Ignored</param>
		/// ------------------------------------------------------------------------------------
		public override bool Redo(bool fRefreshPending)
		{
			// If the bookMerger is disposed, it is probably being called outside the Diff dialog,
			// in which case, the difference lists are no longer needed.
			if (m_bookMerger.IsDisposed)
				return true;
			m_undoDifferenceListClone = m_bookMerger.Differences.Clone();
			m_undoReviewListClone = m_bookMerger.ReviewedDiffs.Clone();
			AdjustCurrentIndex(m_undoDifferenceListClone, m_redoDifferenceListClone);
			UndoRedoAction(m_redoDifferenceListClone, m_redoReviewListClone);
			m_redoDifferenceListClone = null;
			m_redoReviewListClone = null;
			return true;
		}
コード例 #25
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Replaces contents of difference lists in BookMerger with saved contents.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void UndoRedoAction(DifferenceList savedDiffList, DifferenceList savedReviewList)
		{
			ReplaceListContents(m_bookMerger.Differences, savedDiffList);
			ReplaceListContents(m_bookMerger.ReviewedDiffs, savedReviewList);

			// move to the difference that was just inserted
			System.Diagnostics.Debug.Assert(
				savedDiffList.CurrentDifferenceIndex < savedDiffList.Count);
			m_bookMerger.Differences.CurrentDifferenceIndex = savedDiffList.CurrentDifferenceIndex;
		}
コード例 #26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adjust current index of destination list to be same as source list.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void AdjustCurrentIndex(DifferenceList destList, DifferenceList srcList)
		{
			if (srcList.CurrentDifferenceIndex < destList.Count)
				destList.CurrentDifferenceIndex = srcList.CurrentDifferenceIndex;
		}
コード例 #27
0
ファイル: DiffDialogTests.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the DummyDiffView class
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="book">Scripture book to be displayed as the root in this view</param>
		/// <param name="differences">List of differences</param>
		/// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we
		/// display the current version.</param>
		/// ------------------------------------------------------------------------------------
		public DummyDiffView(FdoCache cache, IScrBook book, DifferenceList differences, bool fRev)
			: base(cache, book, differences, fRev, 0)
		{
		}
コード例 #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="merger"></param>
		/// ------------------------------------------------------------------------------------
		public UndoMajorDifferenceAction(BookMerger merger)
		{
			m_bookMerger = merger;
			m_undoDifferenceListClone = m_bookMerger.Differences.Clone();
			m_undoReviewListClone = m_bookMerger.ReviewedDiffs.Clone();
		}
コード例 #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Replaces contents of a difference list with saved contents.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void ReplaceListContents(DifferenceList diffList, DifferenceList savedList)
		{
			diffList.Clear();
			foreach (Difference diff in savedList)
				diffList.Add(diff.Clone());
		}
コード例 #30
0
ファイル: DiffView.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			base.Dispose(disposing);

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_diffViewVc != null)
					m_diffViewVc.Dispose();
				if (m_contextMenu != null)
					m_contextMenu.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_diffViewVc = null;
			m_scrBook = null;
			m_SelectionHelper = null;
			m_contextMenu = null;
			m_mnuCopy = null;
			m_mnuPaste = null;
			m_mnuCut = null;
			m_Differences = null;
		}
コード例 #31
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// <param name="merger"></param>
 /// ------------------------------------------------------------------------------------
 public UndoMajorDifferenceAction(BookMerger merger)
 {
     m_bookMerger = merger;
     m_undoDifferenceListClone = m_bookMerger.Differences.Clone();
     m_undoReviewListClone     = m_bookMerger.ReviewedDiffs.Clone();
 }