Task ISplashScreenService.ShowSplashScreen(string documentType) { if (SplashScreenType != null) { if (!string.IsNullOrEmpty(documentType) || ViewTemplate != null || ViewLocator != null) { throw new InvalidOperationException(DXSplashScreenExceptions.ServiceException1); } if (typeof(ISplashScreen).IsAssignableFrom(SplashScreenType)) { return(DXSplashScreen.Show(SplashScreenType, UseFadeEffect)); } if (typeof(UIElement).IsAssignableFrom(SplashScreenType)) { SplashScreenViewModel = new SplashScreenViewModel(); SplashScreen = (UIElement)Activator.CreateInstance(SplashScreenType); SplashScreen.With(x => x as FrameworkElement).Do(x => x.DataContext = SplashScreenViewModel); return(DXSplashScreen.Show(SplashScreen, UseFadeEffect)); } return(null); } SplashScreenViewModel = new SplashScreenViewModel(); SplashScreen = (UIElement)CreateAndInitializeView(documentType, SplashScreenViewModel, null, null); return(DXSplashScreen.Show(SplashScreen, UseFadeEffect)); }
static Window CreateSplashScreenWindow(object parameter) { Type windowType = SplashScreenHelper.FindParameter <Type>(parameter); Style windowStyle = SplashScreenHelper.FindParameter <Style>(parameter); IList <TimeSpan> fadeDurations = SplashScreenHelper.FindParameters <TimeSpan>(parameter); Window res; if (windowType != null) { res = (Window)Activator.CreateInstance(windowType); } else if (windowStyle != null) { res = new DXSplashScreen.SplashScreenWindow(); } else { res = DXSplashScreen.DefaultSplashScreenWindowCreator(parameter); } res.WindowStartupLocation = SplashScreenHelper.FindParameter <WindowStartupLocation>(parameter, WindowStartupLocation.CenterScreen); if (windowStyle != null) { res.Style = windowStyle; } if (fadeDurations.Any(x => x.TotalMilliseconds > 0) && !Interaction.GetBehaviors(res).Any(x => x is WindowFadeAnimationBehavior)) { Interaction.GetBehaviors(res).Add(new WindowFadeAnimationBehavior() { FadeInDuration = fadeDurations[0], FadeOutDuration = fadeDurations[1] }); } return(res); }
void ISplashScreenService.ShowSplashScreen(string documentType) { if (SplashScreenType != null && (!string.IsNullOrEmpty(documentType) || ViewTemplate != null || ViewLocator != null)) { throw new InvalidOperationException(DXSplashScreenExceptions.ServiceException1); } if (DXSplashScreen.IsActive) { return; } if (SplashScreenType != null) { DXSplashScreen.Show(SplashScreenType); } else { DXSplashScreen.Show(CreateSplashScreenWindow, CreateSplashScreen, new object[] { SplashScreenWindowStyle, SplashScreenStartupLocation }, new object[] { documentType, ViewLocator, ViewTemplate }); } isSplashScreenShown = DXSplashScreen.IsActive; if (Math.Abs(Progress - SplashScreenViewModel.ProgressDefaultValue) > 0.0001) { OnProgressChanged(); } if (Math.Abs(MaxProgress - SplashScreenViewModel.MaxProgressDefaultValue) > 0.0001) { OnMaxProgressChanged(); } if (!object.Equals(State, SplashScreenViewModel.StateDefaultValue)) { OnStateChanged(); } }
void ISplashScreenService.HideSplashScreen() { if (!IsSplashScreenActive) { isSplashScreenShown = false; return; } if (UseIndependentWindow && splashContainer.IsActive) { var container = GetSplashContainer(true); container.Closed -= OnSplashScreenClosed; if (container.IsActive) { container.Close(); } isSplashScreenShown = false; IsSplashScreenActive = false; } else { if (DXSplashScreen.IsActive) { DXSplashScreen.Close(); } isSplashScreenShown = false; } }
void ISplashScreenService.ShowSplashScreen(string documentType) { if (SplashScreenType != null && (!string.IsNullOrEmpty(documentType) || ViewTemplate != null || ViewLocator != null)) { throw new InvalidOperationException(DXSplashScreenExceptions.ServiceException1); } if (IsSplashScreenActive) { return; } Func <object, object> contentCreator = null; object contentCreatorParams = null; IList <object> windowCreatorParams = new List <object>() { SplashScreenWindowStyle, SplashScreenStartupLocation, Owner.With(x => new SplashScreenOwner(x)), SplashScreenClosingMode, FadeInDuration, FadeOutDuration }; if (SplashScreenType == null) { contentCreator = CreateSplashScreen; contentCreatorParams = new object[] { documentType, ViewLocator, ViewTemplate }; } else { DXSplashScreen.CheckSplashScreenType(SplashScreenType); if (typeof(Window).IsAssignableFrom(SplashScreenType)) { windowCreatorParams.Add(SplashScreenType); } else if (typeof(FrameworkElement).IsAssignableFrom(SplashScreenType)) { contentCreator = DXSplashScreen.DefaultSplashScreenContentCreator; contentCreatorParams = SplashScreenType; } } if (UseIndependentWindow) { GetSplashContainer(true).Show(CreateSplashScreenWindow, contentCreator, windowCreatorParams.ToArray(), contentCreatorParams); } else { DXSplashScreen.Show(CreateSplashScreenWindow, contentCreator, windowCreatorParams.ToArray(), contentCreatorParams); } isSplashScreenShown = UseIndependentWindow || DXSplashScreen.IsActive; if (Math.Abs(Progress - SplashScreenViewModel.ProgressDefaultValue) > 0.0001) { OnProgressChanged(); } if (Math.Abs(MaxProgress - SplashScreenViewModel.MaxProgressDefaultValue) > 0.0001) { OnMaxProgressChanged(); } if (!object.Equals(State, SplashScreenViewModel.StateDefaultValue)) { OnStateChanged(); } }
void ISplashScreenService.SetSplashScreenState(object state) { if (!DXSplashScreen.IsActive) { return; } DXSplashScreen.SetState(state); }
void ISplashScreenService.SetSplashScreenProgress(double progress, double maxProgress) { if (!DXSplashScreen.IsActive) { return; } DXSplashScreen.Progress(progress, maxProgress); }
void ISplashScreenService.HideSplashScreen() { if (!DXSplashScreen.IsActive) { return; } DXSplashScreen.Close(); SplashScreenViewModel = null; SplashScreen = null; }
void ISplashScreenService.ShowSplashScreen(string documentType) { if (SplashScreenType != null && (!string.IsNullOrEmpty(documentType) || ViewTemplate != null || ViewLocator != null)) { throw new InvalidOperationException(DXSplashScreenExceptions.ServiceException1); } if (IsSplashScreenActive) { return; } Func <object, object> contentCreator = null; object contentCreatorParams = null; var ssModel = CreateSplashScreenViewModel(); IList <object> windowCreatorParams = new List <object>() { SplashScreenWindowStyle, SplashScreenStartupLocation, Owner.With(x => new SplashScreenOwner(x)), SplashScreenClosingMode, FadeInDuration, FadeOutDuration }; if (SplashScreenType == null) { contentCreator = CreateSplashScreen; contentCreatorParams = new object[] { documentType, ViewLocator, ViewTemplate, ssModel }; } else { DXSplashScreen.CheckSplashScreenType(SplashScreenType); if (typeof(Window).IsAssignableFrom(SplashScreenType)) { windowCreatorParams.Add(SplashScreenType); } else if (typeof(FrameworkElement).IsAssignableFrom(SplashScreenType)) { contentCreator = DXSplashScreen.DefaultSplashScreenContentCreator; contentCreatorParams = new object[] { SplashScreenType, ssModel }; } } isSplashScreenShown = true; if (UseIndependentWindow) { var container = GetSplashContainer(true); container.Closed += OnSplashScreenClosed; container.Show(CreateSplashScreenWindow, contentCreator, windowCreatorParams.ToArray(), contentCreatorParams, null); IsSplashScreenActive = true; } else { DXSplashScreen.Show(CreateSplashScreenWindow, contentCreator, windowCreatorParams.ToArray(), contentCreatorParams); isSplashScreenShown = DXSplashScreen.IsActive; } }
void ISplashScreenService.SetSplashScreenState(object state) { if (!IsSplashScreenActive) { return; } if (UseIndependentWindow) { GetSplashContainer(false).SetState(state); } else { DXSplashScreen.SetState(state); } }
void ISplashScreenService.SetSplashScreenProgress(double progress, double maxProgress) { if (!IsSplashScreenActive) { return; } if (UseIndependentWindow) { GetSplashContainer(false).Progress(progress, maxProgress); } else { DXSplashScreen.Progress(progress, maxProgress); } }
void ISplashScreenService.HideSplashScreen() { if (!DXSplashScreen.IsActive) { return; } DXSplashScreen.Close(); if (AssociatedObject != null) { Window ownerWindow = Window.GetWindow(AssociatedObject); if (ownerWindow != null && !ownerWindow.IsActive) { ownerWindow.Activate(); } } isSplashScreenShown = DXSplashScreen.IsActive; }
void ISplashScreenService.SetSplashScreenProgress(double progress, double maxProgress) { Dispatcher.BeginInvoke(() => { if (SplashScreenType != null && typeof(ISplashScreen).IsAssignableFrom(SplashScreenType)) { DXSplashScreen.Progress(progress); return; } var splashScreenViewModel = SplashScreenViewModel; if (splashScreenViewModel == null) { return; } splashScreenViewModel.IsIndeterminate = false; splashScreenViewModel.MaxProgress = maxProgress; splashScreenViewModel.Progress = progress; }); }
void ISplashScreenService.HideSplashScreen() { if (!IsSplashScreenActive) { isSplashScreenShown = false; return; } if (UseIndependentWindow && splashContainer.IsActive) { GetSplashContainer(true).Close(); isSplashScreenShown = false; } else { DXSplashScreen.Close(); isSplashScreenShown = DXSplashScreen.IsActive; } }
static Window CreateSplashScreenWindow(object parameter) { object[] parameters = (object[])parameter; Style windowStyle = (Style)parameters[0]; WindowStartupLocation startupLocation = (WindowStartupLocation)parameters[1]; Window res; if (windowStyle != null) { res = new Window() { Style = windowStyle, WindowStartupLocation = startupLocation }; } else { res = DXSplashScreen.DefaultSplashScreenWindowCreator(null); res.WindowStartupLocation = startupLocation; WindowFadeAnimationBehavior.SetEnableAnimation(res, true); } return(res); }