Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions Src/Common/Controls/XMLViews/XmlBrowseViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using System.Diagnostics;
using SIL.FieldWorks.Common.Framework;
using SIL.FieldWorks.Common.FwUtils;
using static SIL.FieldWorks.Common.FwUtils.FwUtils;
using SIL.FieldWorks.Common.RootSites;
using SIL.LCModel.Application;
using SIL.FieldWorks.Common.ViewsInterfaces;
using SIL.LCModel;
using XCore;
using SIL.FieldWorks.Common.FwUtils;
using static SIL.FieldWorks.Common.FwUtils.FwUtils;
using SIL.LCModel.Application;
using SIL.LCModel.Core.KernelInterfaces;
using SIL.Utils;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using XCore;

namespace SIL.FieldWorks.Common.Controls
{
Expand Down Expand Up @@ -1140,6 +1140,7 @@ protected override void Dispose( bool disposing )
{
Subscriber.Unsubscribe(EventConstants.SaveScrollPosition, SaveScrollPosition);
Subscriber.Unsubscribe(EventConstants.RestoreScrollPosition, RestoreScrollPosition);
Subscriber.Unsubscribe(EventConstants.PrepareToRefresh, PrepareToRefresh);

if (m_bv != null && !m_bv.IsDisposed && m_bv.SpecialCache != null)
m_bv.SpecialCache.RemoveNotification(this);
Expand Down Expand Up @@ -1398,19 +1399,11 @@ internal ISilDataAccessManaged SpecialCache
get { return m_sda; }
}

/// ------------------------------------------------------------------------------------
/// <summary>
/// Called when [prepare to refresh].
/// </summary>
/// <param name="args">The args.</param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public bool OnPrepareToRefresh(object args)
private void PrepareToRefresh(object args)
{
CheckDisposed();

SaveScrollPosition(args);
return false; // other things may wish to prepare too.
}

/// ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2109,6 +2102,7 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod

Subscriber.Subscribe(EventConstants.SaveScrollPosition, SaveScrollPosition);
Subscriber.Subscribe(EventConstants.RestoreScrollPosition, RestoreScrollPosition);
Subscriber.Subscribe(EventConstants.PrepareToRefresh, PrepareToRefresh);
}

#endregion XCore Colleague overrides
Expand Down
2 changes: 2 additions & 0 deletions Src/LexText/Interlinear/InterlinMaster.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Src/LexText/Interlinear/InterlinMaster.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2015 SIL International
// Copyright (c) 2015-2026 SIL International
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

using System;
using System.Collections.Generic;
using System.Drawing;
Expand Down Expand Up @@ -744,6 +745,7 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod
m_fullyInitialized = true;
RefreshPaneBar();

Subscriber.Subscribe(EventConstants.PrepareToRefresh, PrepareToRefresh);
Subscriber.Subscribe(EventConstants.RefreshInterlin, RefreshInterlin);
}

Expand Down Expand Up @@ -783,14 +785,13 @@ private bool SaveWorkInProgress()
return true;
}

public bool OnPrepareToRefresh(object args)
private void PrepareToRefresh(object _)
{
CheckDisposed();

// flag that a refresh was triggered (unless we don't have a current record..see var comment).
// flag that a refresh was triggered (unless we don't have a current record. See comment on m_fRefreshOccurred).
if (RootStTextHvo != 0)
m_fRefreshOccurred = true;
return false; // other things may wish to prepare too.
}

protected override void SetupDataContext()
Expand Down
16 changes: 6 additions & 10 deletions Src/XCore/xWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ private void BootstrapPart1()
m_mediator.SpecificToOneMainWindow = true;

InitializeComponent();

Subscriber.Subscribe(EventConstants.PrepareToRefresh, PrepareToRefresh);
}

/// <summary>
Expand Down Expand Up @@ -1317,6 +1319,7 @@ protected override void Dispose(bool disposing)
/// </summary>
private void ShutDownPart1()
{
Subscriber.Unsubscribe(EventConstants.PrepareToRefresh, PrepareToRefresh);

if (m_mediator != null)
{
Expand Down Expand Up @@ -1937,21 +1940,14 @@ public bool OnCloseWindow(object sender)
/// gives the window a chance to save anything in progress before the Refresh
/// updates the cache.
///
/// Possibly this should be allowed to fail and abort the Refresh, if PrepareToGoAway fails?
/// ENHANCE (2012 or earlier) Possibly this should be allowed to fail and abort the Refresh, if PrepareToGoAway fails?
/// </summary>
/// <param name="sender"></param>
/// <returns></returns>
public bool OnPrepareToRefresh(object sender)
private void PrepareToRefresh(object _)
{
CheckDisposed();

// This can be null when the MasterRefresh is being processed.
if (MainContentControlAsIxCoreContentControl == null)
return false;

MainContentControlAsIxCoreContentControl.PrepareToGoAway();

return false; // others may want to check also.
MainContentControlAsIxCoreContentControl?.PrepareToGoAway();
}

#endregion XCORE Message Handlers
Expand Down
6 changes: 4 additions & 2 deletions Src/xWorks/FwXWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1684,14 +1684,16 @@ protected bool OnRedo(object args)
/// <summary>
/// Called in FwXApp.OnMasterRefresh BEFORE clearing the cache, typically to
/// save any work in progress.
/// REVIEW (Hasso) 2023.07: 2/3 production callers call this in a foreach loop in OnMasterRefresh. There has to be a more efficient way.
/// </summary>
public void PrepareToRefresh()
{
CheckDisposed();

// Use SendMessageToAllNow as this needs to go to everyone right now. This
// REVIEW (Hasso) 2023.07: we had used MediatorSendMessageToAllNow as this needs to go to everyone right now. This
// method on the mediator will not stop when the message is handled, nor is it deferred.
m_mediator.SendMessageToAllNow("PrepareToRefresh", null);
// REVIEW: do we need to replicate this urgency in PubSub?
Publisher.Publish(new PublisherParameterObject(EventConstants.PrepareToRefresh));
}

/// <summary>
Expand Down
Loading