本文整理汇总了C#中IMainWindow.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IMainWindow.Close方法的具体用法?C# IMainWindow.Close怎么用?C# IMainWindow.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMainWindow
的用法示例。
在下文中一共展示了IMainWindow.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// 起動後にモデルの動作を開始します。
/// NOTE: エントリポイント的に動作する
/// </summary>
private void Initialize(IMainWindow mainWindow)
{
string characterName = CommonSettingRecord.Load().CharacterName;
CharacterSetting = CharacterSetting.Load(characterName);
_characterOperator = new HarrietCharacterOperator(
characterName,
mainWindow,
CharacterSetting.CharacterAppearance
);
_scriptingOperator = new ScriptingOperator(
characterName,
mainWindow,
_characterOperator.Character,
CharacterSetting
);
Observable.FromEventPattern<EventArgs>(_scriptingOperator, nameof(_scriptingOperator.Initialized))
.Take(1)
.Subscribe(_ => _timer.Start());
Observable.FromEventPattern<EventArgs>(_scriptingOperator, nameof(_scriptingOperator.Closed))
.Take(1)
.Subscribe(_ => mainWindow.Close());
_scriptingOperator.Start();
//タイマーは初期化スクリプトが読み終わってから稼働開始するのでここでは放置
//_timer.Start();
}
示例2: LoadDataDictionary
/// <summary>
/// Ask the user to select an XML data dictionary and then load this data dictionary into the PTU application.
/// </summary>
/// <param name="mainWindow">Reference to the main application window interface.</param>
public static void LoadDataDictionary(IMainWindow mainWindow)
{
string fullyQualifiedSourceFilename = General.FileDialogOpenFile(Resources.FileDialogOpenTitleDataDictionary,
CommonConstants.ExtensionDataDictionary,
Resources.FileDialogOpenFilterDataDictionary,
DirectoryManager.PathPTUConfigurationFiles);
// Skip, if the user didn't select a data dictionary XML file.
if (fullyQualifiedSourceFilename == string.Empty)
{
return;
}
#region - [Exclude 'PTU Configuration.xml' or '*.PTU Configuration.xml'] -
// if the user has selected either the default configuration file, 'PTU Configuration.xml', or one of the project default configuration files,
// '<project-identifier>.PTU Configuration.xml', terminate the operation.
if (Path.GetFileName(fullyQualifiedSourceFilename).ToLower().Contains(Resources.FilenameDefaultDataDictionary.ToLower()))
{
MessageBox.Show(string.Format(Resources.MBTConfigSelectionInvalid, Resources.FilenameDefaultDataDictionary), Resources.MBCaptionError,
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
#endregion - [Exclude 'PTU Configuration.xml' or '*.PTU Configuration.xml'] -
FileInfo fileInfoSource = new FileInfo(fullyQualifiedSourceFilename);
DataDictionary dataDictionary = new DataDictionary();
try
{
// Load the specified XML configuration file.
FileHandling.LoadDataSet<DataDictionary>(fullyQualifiedSourceFilename, ref dataDictionary);
#region - [Check whether the selected data dictionary is valid for the current project] -
// If the project identifier was passed to the application as a desktop shortcut parameter, ensure that the project identifier associated with
// the selected data dictionary matches this, and if not, terminate the operation.
if (mainWindow.ProjectIdentifierPassedAsParameter.Equals(string.Empty))
{
// Do nothing. It is perfectly acceptable to select the configuration file associated with ANY project if no project identifier was passed to the
// application as the desktop shortcut parameter. Indeed, this is the recommended way of quickly changing between different projects
// for Bombardier field engineers. Simply set up a desktop shortcut that points to the PTU application but do not supply any shortcuts.
;
}
else
{
// The project identifier was passed to the application as a desktop shortcut parameter. Check that the project identifier associated with the
// selected configuration file matches this and, if not, terminate the operation.
if (dataDictionary.FILEINFO[0].PROJECTSTRING != mainWindow.ProjectIdentifierPassedAsParameter)
{
// The data dictionary is not associated with the current project, terminate the operation.
MessageBox.Show(string.Format(Resources.MBTConfigProjectAsParameterMismatch, mainWindow.ProjectIdentifierPassedAsParameter),
Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
#endregion - [Check whether the selected data dictionary is valid for the current project] -
// Update the appropriate default configuration file.\
string fullyQualifiedDestinationFilename;
if (mainWindow.ProjectIdentifierPassedAsParameter.Equals(string.Empty))
{
// Copy to the default configuration file.
fullyQualifiedDestinationFilename = DirectoryManager.PathPTUConfigurationFiles + CommonConstants.BindingFilename +
Resources.FilenameDefaultDataDictionary;
}
else
{
// Copy to the default project configuration file.
fullyQualifiedDestinationFilename = DirectoryManager.PathPTUConfigurationFiles + CommonConstants.BindingFilename +
dataDictionary.FILEINFO[0].PROJECTSTRING + CommonConstants.Period + Resources.FilenameDefaultDataDictionary;
}
FileInfo fileInfoDestination = new FileInfo(fullyQualifiedDestinationFilename);
fileInfoSource.CopyTo(fullyQualifiedDestinationFilename, true);
if (mainWindow != null)
{
mainWindow.SetRestart(true);
mainWindow.Close();
}
}
catch (ArgumentNullException)
{
MessageBox.Show(Resources.MBTConfigurationFileLoadFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}