C# Класс SIL.FieldWorks.Common.Framework.FwApp

Base application for .net FieldWorks apps (i.e., replacement for AfApp)
Наследование: IApp, ISettings, IFWDisposable, IHelpTopicProvider, IMessageFilter, IFeedbackInfoProvider, IProjectSpecificSettingsKeyProvider
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
m_activeMainWindow System.Windows.Forms.Form
m_debugProcs DebugProcs
m_findPattern IVwPattern
m_findReplaceDlg SIL.FieldWorks.FwCoreDlgs.FwFindReplaceDlg
m_fwManager IFieldWorksManager
m_rgMainWindows List

Private Properties

Свойство Тип Описание
Application_EnterThreadModal void
Application_LeaveThreadModal void
BeginUpdate void
CalcTileSizeAndSpacing void
CloseRootBoxes void
CollectMovableFilesFromFolder void
EndUpdate void
ExpandToFullPath void
IApp string
OnWindowClosed void
RestartSpellChecking void
UpdateAppRuntimeCounter void
fwMainWindow_Activated void
fwMainWindow_HandleDestroyed void

Открытые методы

Метод Описание
ActivateWindow ( int iMainWnd ) : void

Activate the given window.

CalcTileSizeAndSpacing ( Screen scrn, int screenDimension, int minWindowDimension, int &desiredWindowDimension, int &windowSpacing ) : void

This method can be used to do the size and spacing calculations when tiling either side-by-side or stacked. It calculates two things: 1) The desired width or height of tiled windows. 2) how many pixels between the left or top edges of tiled windows. If the calculated width or height of a window is less than the allowable minimum, then tiled windows will be overlapped.

CascadeSize ( int screenSize, int minSize ) : int

Calculate a size (width or height) which is 2/3 of the screen area or the minimum allowable size.

CascadeWindows ( Form wndCurr ) : void

Cascade the windows from top left and resize them to fill 2/3 of the screen area (or the minimum allowable size).

CheckDisposed ( ) : void

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.

Dispose ( ) : void

Must not be virtual.

DoApplicationInitialization ( IProgress progressDlg ) : void

Use this for slow operations that should happen during the splash screen instead of during app construction

EnableMainWindows ( bool fEnable ) : void

Enable or disable all top-level windows. This allows nesting. In other words, calling EnableMainWindows(false) twice requires 2 calls to EnableMainWindows(true) before the top level windows are actually enabled. An example of where not allowing nesting was a problem was the Tools/Options dialog, which could open a PossListChooser dialog. Before, when you closed the PossListChooser, you could select the main window.

ExitAppplication ( ) : void

Close all windows (which will shut down the application)

GetAppFeatures ( ) : SIL.FieldWorks.FDO.Feature[]

Returns the features available for the application

GetHelpString ( string stid ) : string

Gets a URL identifying a Help topic.

GetResourceString ( string stid ) : string

Return a string from a resource ID.

HandleIncomingLink ( SIL.FieldWorks.Common.FwUtils.FwLinkArgs link ) : void

Applications should override this method to handle incoming links. This method is called from FieldWorks when a link is requested. It is guaranteed to be on the correct thread (the thread this application is on) so invoking should not be needed. Overridden in FwXApp. See the class comment on FwLinkArgs for details on how all the parts of hyperlinking work.

HandleOutgoingLink ( SIL.FieldWorks.Common.FwUtils.FwAppArgs link ) : void

Handles an outgoing link request from this application.

InitAndShowMainWindow ( Form fwMainWindow, Form wndCopyFrom ) : void

Registers events for the main window and adds the main window to the list of windows. Then shows the window.

InitCacheForApp ( IThreadedProgress progressDlg ) : bool

Provides a hook for initializing the cache in application-specific ways.

LoadSettings ( ) : void

Called just after DoApplicationInitialization(). Allows a separate overide of loading settings. If you override this you probably also want to override SaveSettings.

NewMainAppWnd ( IProgress progressDlg, bool fNewCache, Form wndCopyFrom, bool fOpeningNewProject ) : Form

Creates a new instance of the main window

PreFilterMessage ( Message &m ) : bool

Filters out a message before it is dispatched.

RefreshAllViews ( ) : void

Refreshes all the views in all of the Main Windows of the app.

RemoveFindReplaceDialog ( ) : void

Close and remove the Find/Replace modeless dialog (result of LT-5702)

RemoveWindow ( IFwMainWnd fwMainWindow ) : void

Removes the specified IFwMainWnd from the list of windows. If it is ok to close down the application and the count of main windows is zero, then this method will also shut down the application.

RestartSpellChecking ( ) : void

Restart the spell-checking process (e.g. when dictionary changed)

ResumePaint ( ) : void

Resumes painting in every view and every main window.

ResumeSynchronize ( ) : void

Resume execution of synchronize messages. If there are any messages in the queue execute them now.

SaveSettings ( ) : void

Triggered by shutting down the app, this is a possible override point for saving any settings to be loaded by LoadSettings. This is the real place to save settings, as opposed to SaveSettingsNow, which is a dummy implementation required because (for the sake of the SettingsKey method) we implement ISettings.

SaveSettingsNow ( ) : void

For now, app has no settings to save. This method is required as part of ISettings implementation. Note that the SaveSettings() method is the appropriate one to modify or override if you really want to save settings. This one is NEVER called!

ShowFindReplaceDialog ( bool fReplace, SIL.FieldWorks.Common.RootSites.RootSite rootsite ) : bool

Display the Find/Replace modeless dialog

ShowFirstTimeMessageDlg ( string suggestedProject ) : string

Displays a message box asking the user whether or not he wants to open a sample DB.

SuppressPaint ( ) : void

Suppresses painting in every view and every main window.

SuppressSynchronize ( ) : void

Suppress execution of all synchronize messages and store them in a queue instead.

Synchronize ( SyncMsg sync ) : bool

Cycle through the applications main windows and synchronize them with database changes.

TileWindows ( Form wndCurr, List windowsToTile, WindowTiling orientation ) : void

Arrange the windows top to bottom or left to right.

TileWindows ( Form wndCurr, WindowTiling orientation ) : void

Arrange the windows top to bottom or left to right.

UpdateExternalLinks ( string sOldLinkedFilesRootDir ) : bool

Handle changes to the LinkedFiles root directory for a language project.

This may not be the best place for this method, but I'm not sure there is a "best place".

Защищенные методы

Метод Описание
AdjustNewWindowPosition ( Form wndNew, Form wndCopyFrom ) : void

Adjust the new window position - offset right and down from the original. Also copy the window size, state, and set the StartPosition mode to manual.

ConfigureFindReplacedialog ( ) : void

This provides a hook for any kind of app that wants to configure the dialog in some special way. TE wants to disable regular expressions for replace.

Dispose ( bool disposing ) : void

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.

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.

FwApp ( IFieldWorksManager fwManager, IHelpTopicProvider helpTopicProvider ) : System

Constructor for FwApp

OnClosingWindow ( object sender, CancelEventArgs e ) : void

The active main window is closing, so try to find some other main window that can "own" the find/replace dialog, so it can stay alive. If we can't find one, then all main windows are going away and we're going to have to close, too.

Приватные методы

Метод Описание
Application_EnterThreadModal ( object sender, EventArgs e ) : void

Handles the EnterThreadModal event of the Application control.

Application_LeaveThreadModal ( object sender, EventArgs e ) : void

Handles the LeaveThreadModal event of the Application control.

BeginUpdate ( ) : void

Suppress all calls to T:RefreshAllViews() until T:EndUpdate is called.

Used by T:ResumeSynchronize to do only one refresh of the view.

CalcTileSizeAndSpacing ( Screen scrn, List windowsToTile, int screenDimension, int minWindowDimension, int &desiredWindowDimension, int &windowSpacing ) : void

This method can be used to do the size and spacing calculations when tiling either side-by-side or stacked. It calculates two things: 1) The desired width or height of tiled windows. 2) how many pixels between the left or top edges of tiled windows. If the calculated width or height of a window is less than the allowable minimum, then tiled windows will be overlapped.

CloseRootBoxes ( Control ctrl ) : void

Recursively look at all the controls belonging to the specified control and save the settings for each root box for controls of type ISettings. Then close the root box for controls of type IRootSite. Ideally IRootSite controls should close their root boxes in the OnHandleDestroyed event, but since sometimes IRootSite controls are created but never shown (which means their handle is never created), we have to close the rootboxes here instead.

CollectMovableFilesFromFolder ( ICmFolder folder, List rgFilesToMove, string sOldRootDir, string sNewRootDir ) : void

Build a list of files that can be moved (or copied) to the new LinkedFiles root directory.

EndUpdate ( ) : void

Do a T:RefreshAllViews() if it was called at least once after T:BeginUpdate

ExpandToFullPath ( ICmFolder folder, string sOldRootDir, string sNewRootDir ) : void

Expand the internal paths from relative to absolute as needed, since the user doesn't want to move (or copy) them.

IApp ( string stid ) : string

Return a string from a resource ID. This should normally not be called directly. Use FwApp.GetResourceString() instead.

OnWindowClosed ( object sender, EventArgs e ) : void

When a window is closed, we need to make sure we close any root boxes that may be on the window.

RestartSpellChecking ( Control root ) : void
UpdateAppRuntimeCounter ( ) : void
fwMainWindow_Activated ( object sender, EventArgs e ) : void

Note the most recent of our main windows to become active.

fwMainWindow_HandleDestroyed ( object sender, EventArgs e ) : void

Make sure a window that's no longer valid isn't considered active.

Описание методов

ActivateWindow() публичный Метод

Activate the given window.
public ActivateWindow ( int iMainWnd ) : void
iMainWnd int Index (in the internal list of main windows) of the window to /// activate
Результат void

AdjustNewWindowPosition() защищенный Метод

Adjust the new window position - offset right and down from the original. Also copy the window size, state, and set the StartPosition mode to manual.
protected AdjustNewWindowPosition ( Form wndNew, Form wndCopyFrom ) : void
wndNew System.Windows.Forms.Form
wndCopyFrom System.Windows.Forms.Form
Результат void

CalcTileSizeAndSpacing() публичный Метод

This method can be used to do the size and spacing calculations when tiling either side-by-side or stacked. It calculates two things: 1) The desired width or height of tiled windows. 2) how many pixels between the left or top edges of tiled windows. If the calculated width or height of a window is less than the allowable minimum, then tiled windows will be overlapped.
public CalcTileSizeAndSpacing ( Screen scrn, int screenDimension, int minWindowDimension, int &desiredWindowDimension, int &windowSpacing ) : void
scrn System.Windows.Forms.Screen The screen where the tiling will take place (only windows on this /// screen will actually get tiled).
screenDimension int The width or height, in pixels, of the display on /// which tiling will be performed.
minWindowDimension int The minimum allowable width or height, in pixels, /// of tiled windows.
desiredWindowDimension int The desired width or height, in pixels, of /// tiled windows.
windowSpacing int The distance, in pixels, between the left or top edge /// of each tiled window. If there is only one window, this is undefined.
Результат void

CascadeSize() публичный Метод

Calculate a size (width or height) which is 2/3 of the screen area or the minimum allowable size.
public CascadeSize ( int screenSize, int minSize ) : int
screenSize int Total available width or height (for the screen)
minSize int Minimum width or height for the window
Результат int

CascadeWindows() публичный Метод

Cascade the windows from top left and resize them to fill 2/3 of the screen area (or the minimum allowable size).
public CascadeWindows ( Form wndCurr ) : void
wndCurr System.Windows.Forms.Form Current Window (i.e. window whose menu was used to issue the /// Cascaede command.
Результат void

CheckDisposed() публичный Метод

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.
public CheckDisposed ( ) : void
Результат void

ConfigureFindReplacedialog() защищенный Метод

This provides a hook for any kind of app that wants to configure the dialog in some special way. TE wants to disable regular expressions for replace.
protected ConfigureFindReplacedialog ( ) : void
Результат void

Dispose() публичный Метод

Must not be virtual.
public Dispose ( ) : void
Результат void

Dispose() защищенный Метод

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.
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.
protected Dispose ( bool disposing ) : void
disposing bool
Результат void

DoApplicationInitialization() публичный Метод

Use this for slow operations that should happen during the splash screen instead of during app construction
public DoApplicationInitialization ( IProgress progressDlg ) : void
progressDlg IProgress The progress dialog to use.
Результат void

EnableMainWindows() публичный Метод

Enable or disable all top-level windows. This allows nesting. In other words, calling EnableMainWindows(false) twice requires 2 calls to EnableMainWindows(true) before the top level windows are actually enabled. An example of where not allowing nesting was a problem was the Tools/Options dialog, which could open a PossListChooser dialog. Before, when you closed the PossListChooser, you could select the main window.
public EnableMainWindows ( bool fEnable ) : void
fEnable bool Enable (true) or disable (false).
Результат void

ExitAppplication() публичный Метод

Close all windows (which will shut down the application)
public ExitAppplication ( ) : void
Результат void

FwApp() защищенный Метод

Constructor for FwApp
protected FwApp ( IFieldWorksManager fwManager, IHelpTopicProvider helpTopicProvider ) : System
fwManager IFieldWorksManager The FieldWorks manager for dealing with FieldWorks-level /// stuff.
helpTopicProvider IHelpTopicProvider An application-specific help topic provider.
Результат System

GetAppFeatures() публичный Метод

Returns the features available for the application
public GetAppFeatures ( ) : SIL.FieldWorks.FDO.Feature[]
Результат SIL.FieldWorks.FDO.Feature[]

GetHelpString() публичный Метод

Gets a URL identifying a Help topic.
public GetHelpString ( string stid ) : string
stid string An identifier for the desired Help topic
Результат string

GetResourceString() публичный Метод

Return a string from a resource ID.
public GetResourceString ( string stid ) : string
stid string String resource id
Результат string

HandleIncomingLink() публичный Метод

Applications should override this method to handle incoming links. This method is called from FieldWorks when a link is requested. It is guaranteed to be on the correct thread (the thread this application is on) so invoking should not be needed. Overridden in FwXApp. See the class comment on FwLinkArgs for details on how all the parts of hyperlinking work.
public HandleIncomingLink ( SIL.FieldWorks.Common.FwUtils.FwLinkArgs link ) : void
link SIL.FieldWorks.Common.FwUtils.FwLinkArgs The link to handle.
Результат void

HandleOutgoingLink() публичный Метод

Handles an outgoing link request from this application.
public HandleOutgoingLink ( SIL.FieldWorks.Common.FwUtils.FwAppArgs link ) : void
link SIL.FieldWorks.Common.FwUtils.FwAppArgs The link.
Результат void

InitAndShowMainWindow() публичный Метод

Registers events for the main window and adds the main window to the list of windows. Then shows the window.
public InitAndShowMainWindow ( Form fwMainWindow, Form wndCopyFrom ) : void
fwMainWindow System.Windows.Forms.Form The new main window.
wndCopyFrom System.Windows.Forms.Form Form to copy from, or null
Результат void

InitCacheForApp() публичный абстрактный Метод

Provides a hook for initializing the cache in application-specific ways.
public abstract InitCacheForApp ( IThreadedProgress progressDlg ) : bool
progressDlg IThreadedProgress The progress dialog.
Результат bool

LoadSettings() публичный Метод

Called just after DoApplicationInitialization(). Allows a separate overide of loading settings. If you override this you probably also want to override SaveSettings.
public LoadSettings ( ) : void
Результат void

NewMainAppWnd() публичный абстрактный Метод

Creates a new instance of the main window
public abstract NewMainAppWnd ( IProgress progressDlg, bool fNewCache, Form wndCopyFrom, bool fOpeningNewProject ) : Form
progressDlg IProgress The progress dialog to use, if needed (can be null).
fNewCache bool Flag indicating whether one-time, application-specific /// initialization should be done for this cache.
wndCopyFrom System.Windows.Forms.Form Must be null for creating the original app window. /// Otherwise, a reference to the main window whose settings we are copying.
fOpeningNewProject bool true if opening a brand spankin' new /// project
Результат System.Windows.Forms.Form

OnClosingWindow() защищенный Метод

The active main window is closing, so try to find some other main window that can "own" the find/replace dialog, so it can stay alive. If we can't find one, then all main windows are going away and we're going to have to close, too.
protected OnClosingWindow ( object sender, CancelEventArgs e ) : void
sender object
e CancelEventArgs
Результат void

PreFilterMessage() публичный Метод

Filters out a message before it is dispatched.
public PreFilterMessage ( Message &m ) : bool
m System.Windows.Forms.Message The message to be dispatched. You cannot modify this message.
Результат bool

RefreshAllViews() публичный Метод

Refreshes all the views in all of the Main Windows of the app.
public RefreshAllViews ( ) : void
Результат void

RemoveFindReplaceDialog() публичный Метод

Close and remove the Find/Replace modeless dialog (result of LT-5702)
public RemoveFindReplaceDialog ( ) : void
Результат void

RemoveWindow() публичный Метод

Removes the specified IFwMainWnd from the list of windows. If it is ok to close down the application and the count of main windows is zero, then this method will also shut down the application.
public RemoveWindow ( IFwMainWnd fwMainWindow ) : void
fwMainWindow IFwMainWnd The IFwMainWnd to remove
Результат void

RestartSpellChecking() публичный Метод

Restart the spell-checking process (e.g. when dictionary changed)
public RestartSpellChecking ( ) : void
Результат void

ResumePaint() публичный Метод

Resumes painting in every view and every main window.
public ResumePaint ( ) : void
Результат void

ResumeSynchronize() публичный Метод

Resume execution of synchronize messages. If there are any messages in the queue execute them now.
public ResumeSynchronize ( ) : void
Результат void

SaveSettings() публичный Метод

Triggered by shutting down the app, this is a possible override point for saving any settings to be loaded by LoadSettings. This is the real place to save settings, as opposed to SaveSettingsNow, which is a dummy implementation required because (for the sake of the SettingsKey method) we implement ISettings.
public SaveSettings ( ) : void
Результат void

SaveSettingsNow() публичный Метод

For now, app has no settings to save. This method is required as part of ISettings implementation. Note that the SaveSettings() method is the appropriate one to modify or override if you really want to save settings. This one is NEVER called!
public SaveSettingsNow ( ) : void
Результат void

ShowFindReplaceDialog() публичный Метод

Display the Find/Replace modeless dialog
public ShowFindReplaceDialog ( bool fReplace, SIL.FieldWorks.Common.RootSites.RootSite rootsite ) : bool
fReplace bool true to make the replace tab active
rootsite SIL.FieldWorks.Common.RootSites.RootSite The view where the find will be conducted
Результат bool

ShowFirstTimeMessageDlg() публичный Метод

Displays a message box asking the user whether or not he wants to open a sample DB.
public ShowFirstTimeMessageDlg ( string suggestedProject ) : string
suggestedProject string
Результат string

SuppressPaint() публичный Метод

Suppresses painting in every view and every main window.
public SuppressPaint ( ) : void
Результат void

SuppressSynchronize() публичный Метод

Suppress execution of all synchronize messages and store them in a queue instead.
public SuppressSynchronize ( ) : void
Результат void

Synchronize() публичный Метод

Cycle through the applications main windows and synchronize them with database changes.
public Synchronize ( SyncMsg sync ) : bool
sync SyncMsg synchronization information record
Результат bool

TileWindows() публичный Метод

Arrange the windows top to bottom or left to right.
public TileWindows ( Form wndCurr, List windowsToTile, WindowTiling orientation ) : void
wndCurr System.Windows.Forms.Form Current Window (i.e. window whose menu was used to issue a /// tile vertical or horizontal command.
windowsToTile List A list of all the windows to tile (including the /// current window)
orientation WindowTiling The value indicating whether to tile side by side or /// stacked.
Результат void

TileWindows() публичный Метод

Arrange the windows top to bottom or left to right.
public TileWindows ( Form wndCurr, WindowTiling orientation ) : void
wndCurr System.Windows.Forms.Form Current Window (i.e. window whose menu was used to issue a /// tile vertical or horizontal command.
orientation WindowTiling The value indicating whether to tile side by side or /// stacked.
Результат void

UpdateExternalLinks() публичный Метод

Handle changes to the LinkedFiles root directory for a language project.
This may not be the best place for this method, but I'm not sure there is a "best place".
public UpdateExternalLinks ( string sOldLinkedFilesRootDir ) : bool
sOldLinkedFilesRootDir string The old LinkedFiles root directory.
Результат bool

Описание свойств

m_activeMainWindow защищенное свойство

One of m_rgMainWindows, the one most recently activated.
protected Form,System.Windows.Forms m_activeMainWindow
Результат System.Windows.Forms.Form

m_debugProcs защищенное свойство

protected DebugProcs m_debugProcs
Результат DebugProcs

m_findPattern защищенное свойство

The find patterns for the find/replace dialog, one for each database.
We need one pattern per database (cache). Otherwise it'll crash when we try to load the previous search term because the new database has different writing system hvos (TE-5598).
protected IVwPattern m_findPattern
Результат IVwPattern

m_findReplaceDlg защищенное свойство

protected FwFindReplaceDlg,SIL.FieldWorks.FwCoreDlgs m_findReplaceDlg
Результат SIL.FieldWorks.FwCoreDlgs.FwFindReplaceDlg

m_fwManager защищенное свойство

The FieldWorks manager for dealing with FieldWorks-level stuff.
protected IFieldWorksManager m_fwManager
Результат IFieldWorksManager

m_rgMainWindows защищенное свойство

protected List m_rgMainWindows
Результат List