public SplashWindow() { InitializeComponent(); _titleSplosion = Resources["TitleSplosion"] as Storyboard; _showSubtitle = Resources["ShowSubTitle"] as Storyboard; _showMessage = Resources["ShowLoadingMessage"] as Storyboard; _hideMessage = Resources["HideLoadingMessage"] as Storyboard; txtLoading.Text = ""; _onShowStoryboard = OnShowStoryboard; _onShowText = OnShowText; _onHideText = OnHideText; }
private void ShowText(string text, bool showIt) { if (System.Threading.Thread.CurrentThread != textBox.Dispatcher.Thread) { if (setText == null) { // Tom Xue: Delegates are used to pass methods as arguments to other methods. setText = new ShowTextHandler(ShowText); } object[] myArray = new object[2]; myArray[0] = text; myArray[1] = showIt; textBox.Dispatcher.Invoke(setText, DispatcherPriority.Normal, myArray); } else { if (showIt) { textBox.AppendText(text + " "); // Set some limitation, otherwise the program needs to refresh all the old data (accumulated) and cause performance down //if (textBox.LineCount > 4500) // textBox.Clear(); } } }