XCore.XMessageBoxExManager.ReadSettingsFile C# (CSharp) Method

ReadSettingsFile() public method

load with properties stored in the settings file, if that file is found.
public ReadSettingsFile ( ) : void
return void
		public void  ReadSettingsFile ()
		{
			CheckDisposed();

			string path = SettingsPath();

			if(!System.IO.File.Exists(path))
				return;

			System.IO.StreamReader reader =null;
			try
			{
				XmlSerializer szr = new XmlSerializer(typeof(StringPair[]));
				reader = new System.IO.StreamReader(path);

				StringPair[] list = (StringPair[])szr.Deserialize(reader);
				ReadStringPairArrayForDeserializing(list);
			}
			catch(System.IO.FileNotFoundException)
			{
				//don't do anything
			}
			catch(Exception )
			{
				var activeForm = Form.ActiveForm;
				if (activeForm == null)
					MessageBoxUtils.Show(xCoreInterfaces.CannotRestoreSavedResponses);
				else
				{
					// Make sure as far as possible it comes up in front of any active window, including the splash screen.
					activeForm.Invoke((Func<DialogResult>)(() => MessageBoxUtils.Show(activeForm, xCoreInterfaces.CannotRestoreSavedResponses, string.Empty)));
				}
			}
			finally
			{
				if (reader != null)
					reader.Dispose();
			}
		}

Usage Example

Beispiel #1
0
		/// <summary>
		/// Initialize the required inventories.
		/// </summary>
		private void InitializeMessageDialogs()
		{
			WriteSplashScreen(LexTextStrings.ksInitializingMessageDialogs_);
			m_messageBoxExManager = XMessageBoxExManager.CreateXMessageBoxExManager();
			m_messageBoxExManager.DefineMessageBox("TextChartNewFeature",
				LexTextStrings.ksNewFeature,
				LexTextStrings.ksChartTemplateWarning, true, "exclamation");
			m_messageBoxExManager.DefineMessageBox("CategorizedEntry-Intro",
				LexTextStrings.ksInformation,
				LexTextStrings.ksUsedForSemanticBasedEntry, true, "info");
			m_messageBoxExManager.DefineMessageBox("CreateNewFromGrammaticalCategoryCatalog",
				LexTextStrings.ksInformation,
				LexTextStrings.ksCreatingCustomGramCategory, true, "info");
			m_messageBoxExManager.DefineMessageBox("CreateNewLexicalReferenceType",
				LexTextStrings.ksInformation,
				LexTextStrings.ksCreatingCustomLexRefType, true, "info");
			m_messageBoxExManager.DefineMessageBox("ClassifiedDictionary-Intro",
				LexTextStrings.ksInformation,
				LexTextStrings.ksShowingSemanticClassification, true, "info");

			m_messageBoxExManager.ReadSettingsFile();
			WriteSplashScreen("");
		}