Index: Core/Common/src/Core.Common.Gui/DeltaShellGui.cs =================================================================== diff -u -reee6c7815d1e418eac38c1c552fb279c0887ef55 -rffdd49e6f65bada7314bb033383dd56f70048762 --- Core/Common/src/Core.Common.Gui/DeltaShellGui.cs (.../DeltaShellGui.cs) (revision eee6c7815d1e418eac38c1c552fb279c0887ef55) +++ Core/Common/src/Core.Common.Gui/DeltaShellGui.cs (.../DeltaShellGui.cs) (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -676,12 +676,12 @@ private void ShowSplashScreen() { - splashScreen = new SplashScreen(Application) + splashScreen = new SplashScreen() { - LabelVersionVersion = SettingsHelper.ApplicationVersion, - SplashScreenCopyright = Application.Settings["copyright"], - LabelLicense = Application.Settings["license"], - LabelCompany = SettingsHelper.ApplicationCompany + VersionText = SettingsHelper.ApplicationVersion, + CopyrightText = Application.Settings["copyright"], + LicenseText = Application.Settings["license"], + CompanyText = SettingsHelper.ApplicationCompany }; splashScreen.IsVisibleChanged += delegate Index: Core/Common/src/Core.Common.Gui/Forms/SplashScreen/SplashScreen.xaml =================================================================== diff -u -reee6c7815d1e418eac38c1c552fb279c0887ef55 -rffdd49e6f65bada7314bb033383dd56f70048762 --- Core/Common/src/Core.Common.Gui/Forms/SplashScreen/SplashScreen.xaml (.../SplashScreen.xaml) (revision eee6c7815d1e418eac38c1c552fb279c0887ef55) +++ Core/Common/src/Core.Common.Gui/Forms/SplashScreen/SplashScreen.xaml (.../SplashScreen.xaml) (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -1,30 +1,32 @@ - - + - Index: Core/Common/src/Core.Common.Gui/Forms/SplashScreen/SplashScreen.xaml.cs =================================================================== diff -u -ra503a0d26223fe1067cf2de96ad55c01dc3e8e5e -rffdd49e6f65bada7314bb033383dd56f70048762 --- Core/Common/src/Core.Common.Gui/Forms/SplashScreen/SplashScreen.xaml.cs (.../SplashScreen.xaml.cs) (revision a503a0d26223fe1067cf2de96ad55c01dc3e8e5e) +++ Core/Common/src/Core.Common.Gui/Forms/SplashScreen/SplashScreen.xaml.cs (.../SplashScreen.xaml.cs) (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -1,9 +1,4 @@ -using System; -using System.IO; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Threading; +using System.Windows.Media; using Core.Common.Base; using log4net; @@ -15,195 +10,168 @@ public partial class SplashScreen { private static readonly ILog log = LogManager.GetLogger(typeof(DeltaShellApplication)); + private string progressText; + private int progressValuePercent; + private string licenseText; + private string companyText; + private string copyrightText; + private string versionText; - private readonly DispatcherTimer updateTimer; - - private IApplication app; - private string logoImageFilePath; - private volatile ProgressInfo progressInfo; - private bool scheduleUpdate; - - private int progressBarValue; - - private string lastProgressMessage; // sometimes we progress only percentage, in this case we keep the last message here - - private bool refreshing; - - private bool shutdown; - - public SplashScreen() : this(null) {} - - public SplashScreen(IApplication app) + public SplashScreen() { InitializeComponent(); - if (app == null) - { - throw new ArgumentNullException("app"); - } - this.app = app; + progressBar.Maximum = 100; // classic percentage approach, there is no need for the splash screen to be more precise - progressBar.Maximum = 1; - progressBar.Value = 0; - labelProgressBar.Content = "0 %"; - - IsVisibleChanged += SplashScreen_VisibleChanged; - - updateTimer = new DispatcherTimer(DispatcherPriority.Render, Dispatcher); - updateTimer.Tick += OnTimer; - updateTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); - updateTimer.Start(); + ProgressValuePercent = 0; + ProgressText = ""; + CompanyText = ""; + CopyrightText = ""; + LicenseText = ""; + VersionText = ""; } - public string LabelVersionVersion + /// + /// Version to be shown + /// + public string VersionText { get { - return (string) labelVersion.Content; + return versionText; } set { - labelVersion.Content = value; + versionText = value; + InvalidateVisual(); } } - public string SplashScreenCopyright + /// + /// Copyright owner to be shown + /// + public string CopyrightText { get { - return (string) labelCopyright.Content; + return copyrightText; } set { - labelCopyright.Content = value; + copyrightText = value; + InvalidateVisual(); } } - public string LabelCompany + /// + /// Registred company to be shown + /// + public string CompanyText { get { - return (string) labelCompany.Content; + return companyText; } set { - labelCompany.Content = value; + companyText = value; + InvalidateVisual(); } } - public string LabelLicense + /// + /// Type of the license, plain text + /// + public string LicenseText { get { - return (string) labelLicense.Content; + return licenseText; } set { - labelLicense.Content = value; + licenseText = value; + InvalidateVisual(); } } - public int ProgressBarValue + /// + /// Percentage value to be set as progress indication. + /// + public int ProgressValuePercent { get { - return progressBarValue; + return progressValuePercent; } set { - progressBar.Value = value; - progressBarValue = value; + progressValuePercent = value; + InvalidateVisual(); } } - public string ProgressBarText + /// + /// Text, as a current status of the progress + /// + public string ProgressText { get { - return (string) labelProgressBar.Content; + return progressText; } set { - labelProgressBar.Content = value; + progressText = value; + InvalidateVisual(); } } public void Shutdown() { - shutdown = true; - - updateTimer.Stop(); - while (refreshing) - { - Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { })); - } - Focusable = false; - app = null; - log.Info(Properties.Resources.SplashScreen_Shutdown_Hiding_splash_screen____); - Close(); } - private void OnTimer(object state, EventArgs eventArgs) + /// + /// When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing. + /// + /// The drawing instructions for a specific element. This context is provided to the layout system. + protected override void OnRender(DrawingContext drawingContext) { - UpdateProgress(); - } + base.OnRender(drawingContext); - private void UpdateProgress() - { - if (!scheduleUpdate) + if (progressBar.Value != ProgressValuePercent) { - return; + progressBar.Value = ProgressValuePercent; + labelProgressBar.Content = string.Format("{0} %", ProgressValuePercent); } - scheduleUpdate = false; + if (labelProgressMessage.Content.ToString() != ProgressText) + { + labelProgressMessage.Content = ProgressText; + } - ProgressInfo newInfo = progressInfo; + if (labelLicense.Content.ToString() != LicenseText) + { + labelLicense.Content = LicenseText; + } - ProgressBarValue = newInfo.ProgressValue; - ProgressBarText = newInfo.ProgressText; - - labelProgressMessage.Content = newInfo.Message != "" ? newInfo.Message : lastProgressMessage; - } - - private void SplashScreen_VisibleChanged(object sender, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) - { - if (IsVisible) + if (labelCompany.Content.ToString() != CompanyText) { - log.Debug(Properties.Resources.SplashScreen_SplashScreen_VisibleChanged_Showing_splash_screen____); - string splashScreenLogFilePath = - Path.Combine(app.GetUserSettingsDirectoryPath(), "splash-screen-log-history.xml"); + labelCompany.Content = CompanyText; } - else + + if (labelCopyright.Content.ToString() != CopyrightText) { - updateTimer.Stop(); + labelCopyright.Content = CopyrightText; } - } - private void ScheduleUpdate() - { - if (!shutdown) + if (labelVersion.Content.ToString() != VersionText) { - scheduleUpdate = true; - RefreshControls(); + labelVersion.Content = VersionText; } } - - private void RefreshControls() - { - refreshing = true; - progressBar.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => { })); - labelProgressMessage.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => { })); - refreshing = false; - } - - public class ProgressInfo - { - public string Message; - public string ProgressText; - public int ProgressValue; - } } } \ No newline at end of file Index: Core/Common/test/SplashScreenTest/Core.Common.Gui.Tests.csproj =================================================================== diff -u --- Core/Common/test/SplashScreenTest/Core.Common.Gui.Tests.csproj (revision 0) +++ Core/Common/test/SplashScreenTest/Core.Common.Gui.Tests.csproj (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -0,0 +1,89 @@ + + + + Debug + AnyCPU + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8} + Library + Properties + Core.Common.Gui.Tests + Core.Common.Gui.Tests + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + x86 + bin\x86\Debug\ + + + x86 + bin\x86\Release\ + + + + False + ..\..\..\..\lib\nunit.framework.dll + + + + + + + + + + + + + + + + + + + + + + + {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} + Core.Common.Gui + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtils + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file Index: Core/Common/test/SplashScreenTest/Forms/SplashScreenTest.cs =================================================================== diff -u --- Core/Common/test/SplashScreenTest/Forms/SplashScreenTest.cs (revision 0) +++ Core/Common/test/SplashScreenTest/Forms/SplashScreenTest.cs (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -0,0 +1,63 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using NUnit.Framework; + +namespace Core.Common.Gui.Tests.Forms +{ + [TestFixture] + public class SplashScreenTest + { + [Test] + [RequiresSTA] + public void TestFillsLabelsViaProperties() + { + var strCompany = "Cmp1"; + var strCopyright = "Copy1"; + var strLicense = "License1"; + var strVersion = "Version1"; + var strProgressText = "SomeProgress1"; + + var screen = new Gui.Forms.SplashScreen.SplashScreen + { + CompanyText = strCompany, + CopyrightText = strCopyright, + LicenseText = strLicense, + VersionText = strVersion, + ProgressText = strProgressText + }; + + screen.Show(); + + Assert.AreEqual(strVersion, GetLabelText(screen, "labelVersion")); + Assert.AreEqual(strCompany, GetLabelText(screen, "labelCompany")); + Assert.AreEqual(strLicense, GetLabelText(screen, "labelLicense")); + Assert.AreEqual(strCopyright, GetLabelText(screen, "labelCopyright")); + Assert.AreEqual(strProgressText, GetLabelText(screen, "labelProgressMessage")); + } + + private FrameworkElement FindControlRecursively(FrameworkElement parent, string name) + { + var childrenCount = VisualTreeHelper.GetChildrenCount(parent); + FrameworkElement foundChild = null; + for (var childIndex = 0; childIndex < childrenCount; childIndex++) + { + var child = VisualTreeHelper.GetChild(parent, childIndex) as FrameworkElement; + foundChild = child.Name == name ? child : FindControlRecursively(child, name); + + if (foundChild != null) + { + break; + } + } + + return foundChild; + } + + private string GetLabelText(FrameworkElement parent, string labelName) + { + var label = FindControlRecursively(parent, labelName); + return (label as Label).Content.ToString(); + } + } +} \ No newline at end of file Index: Core/Common/test/SplashScreenTest/Properties/AssemblyInfo.cs =================================================================== diff -u --- Core/Common/test/SplashScreenTest/Properties/AssemblyInfo.cs (revision 0) +++ Core/Common/test/SplashScreenTest/Properties/AssemblyInfo.cs (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SplashScreenTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SplashScreenTest")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5fe7ae89-1597-4bd0-a9f7-7efa9c9f3965")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Index: DeltaShell.sln =================================================================== diff -u -r8e258eec8318163d7ce452ffc0db1fab83f511c1 -rffdd49e6f65bada7314bb033383dd56f70048762 --- DeltaShell.sln (.../DeltaShell.sln) (revision 8e258eec8318163d7ce452ffc0db1fab83f511c1) +++ DeltaShell.sln (.../DeltaShell.sln) (revision ffdd49e6f65bada7314bb033383dd56f70048762) @@ -162,6 +162,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.Piping.Integration.Test", "Ringtoets\Piping\test\Ringtoets.Piping.Integration.Test\Ringtoets.Piping.Integration.Test.csproj", "{813FFA92-1F3F-462B-B596-5919334007A9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Common.Gui.Tests", "Core\Common\test\SplashScreenTest\Core.Common.Gui.Tests.csproj", "{D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CreateInstaller|x86 = CreateInstaller|x86 @@ -492,6 +494,11 @@ {813FFA92-1F3F-462B-B596-5919334007A9}.Debug|x86.Build.0 = Debug|x86 {813FFA92-1F3F-462B-B596-5919334007A9}.Release|x86.ActiveCfg = Release|x86 {813FFA92-1F3F-462B-B596-5919334007A9}.Release|x86.Build.0 = Release|x86 + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8}.CreateInstaller|x86.ActiveCfg = Release|x86 + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8}.Debug|x86.ActiveCfg = Debug|x86 + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8}.Debug|x86.Build.0 = Debug|x86 + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8}.Release|x86.ActiveCfg = Release|x86 + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -525,6 +532,7 @@ {E0990383-FB2E-47D1-99CD-9B9FA2929E5B} = {0D9858E1-CF2D-4DE5-AC0E-64401900D531} {A6A434E0-AE5A-4D5B-97D7-532B00FBDFE9} = {0D9858E1-CF2D-4DE5-AC0E-64401900D531} {FAFDB463-9612-41F4-B3DD-FF9C6E7023BA} = {0D9858E1-CF2D-4DE5-AC0E-64401900D531} + {D5EC1DF2-03C9-467B-B6AF-BE5AC83417F8} = {0D9858E1-CF2D-4DE5-AC0E-64401900D531} {EE2D52A2-9D3E-4056-8A21-F1725F67E5CF} = {D89FA693-A8E9-4560-9957-B74B7E9391F0} {DD70F63E-6459-4C49-86EC-4DB87DCE9B01} = {D89FA693-A8E9-4560-9957-B74B7E9391F0} {38C9E9C3-A3A9-49A0-A0DE-A4EDB9885A61} = {D89FA693-A8E9-4560-9957-B74B7E9391F0}