internal void InitializeOwner(object parameter) { RelationInfo = SplashScreenHelper.FindParameter <WindowContainer>(parameter, null).Return(x => x.CreateOwnerContainer(), null) ?? SplashScreenHelper.FindParameter <WindowRelationInfo>(parameter, null); Owner = RelationInfo.With(x => x.Parent); RelationInfo.Do(x => x.AttachChild(SplashScreen, false)); }
static Window CreateSplashScreenWindow(object parameter) { object[] parameters = (object[])parameter; bool useFadeEffect = (bool)parameters[0]; WindowArrangerContainer owner = (WindowArrangerContainer)parameters[1]; SplashScreenLock lockMode = (SplashScreenLock)parameters[2]; IList <TimeSpan> durations = SplashScreenHelper.FindParameters <TimeSpan>(parameter); FlowDirection flowDirection = SplashScreenHelper.FindParameter <FlowDirection>(parameter); Style windowStyle = SplashScreenHelper.FindParameter <Style>(parameter); var window = new LoadingDecoratorWindowFree(owner, lockMode); if (windowStyle != null) { window.Style = windowStyle; } else { window.ApplyDefaultSettings(); } window.SetCurrentValue(FlowDirectionProperty, flowDirection); if (useFadeEffect && durations.Any(x => x.TotalMilliseconds > 0)) { Interaction.GetBehaviors(window).Add(new WindowFadeAnimationBehavior() { FadeInDuration = durations[0], FadeOutDuration = durations[1] }); } return(window); }
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 SubscribeParentEvents(object parameter) { SplashScreenClosingMode closingMode = SplashScreenHelper.FindParameter <SplashScreenClosingMode>(parameter, SplashScreenClosingMode.OnParentClosed); if (closingMode == SplashScreenClosingMode.Default || closingMode == SplashScreenClosingMode.OnParentClosed) { ActiveInfo.RelationInfo.Do(x => x.ParentClosed += OnSplashScreenOwnerClosed); } }
static object CreateSplashScreen(object parameter) { object[] parameters = (object[])parameter; string documentType = parameters[0] as string; IViewLocator viewLocator = parameters[1] as IViewLocator; DataTemplate viewTemplate = parameters[2] as DataTemplate; var model = SplashScreenHelper.FindParameter <SplashScreenViewModel>(parameter); model = model == null ? new SplashScreenViewModel() : model.Clone(); return(ViewHelper.CreateAndInitializeView(viewLocator, documentType, model, null, null, viewTemplate, null)); }
static object CreateDefaultSplashScreen(object parameter) { var splashScreenType = SplashScreenHelper.FindParameter <Type>(parameter); var splashScreenViewModel = new SplashScreenViewModel(); object view = null; if (splashScreenType != null) { view = Activator.CreateInstance(splashScreenType); view.With(x => x as FrameworkElement).Do(x => x.DataContext = splashScreenViewModel); } return(view); }
void InternalThreadEntryPoint(object parameter) { Func <object, Window> windowCreator = ((object[])parameter)[0] as Func <object, Window>; Func <object, object> splashScreenCreator = ((object[])parameter)[1] as Func <object, object>; object windowCreatorParameter = ((object[])parameter)[2]; object splashScreenCreatorParameter = ((object[])parameter)[3]; object syncRoot = ((ICollection)(new Style()).Resources).SyncRoot; var info = SplashScreenHelper.FindParameter <SplashScreenInfo>(parameter) ?? ActiveInfo; #if DEBUGTEST || DEBUG if (info.WaitEvent != null) { info.WaitEvent.WaitOne(2000); } #endif info.SplashScreen = windowCreator(windowCreatorParameter); info.Dispatcher = info.SplashScreen.Dispatcher; info.Callbacks.Initialize(); bool isResourcesLocked = Monitor.TryEnter(syncRoot); if (!isResourcesLocked) { SyncEvent.Set(); } else { Monitor.Exit(syncRoot); } splashScreenCreator.Do(x => info.SplashScreen.Content = x(splashScreenCreatorParameter)); SetProgressStateCore(info, true); info.InitializeOwner(parameter); SubscribeParentEvents(windowCreatorParameter); if (isResourcesLocked) { SyncEvent.Set(); } info.Callbacks.ExecuteExceptClose(); bool skipOpen = info.CloseWithParent && info.RelationInfo.Return(x => x.ActualIsParentClosed, () => false); #if DEBUGTEST || DEBUG Test_SkipWindowOpen = skipOpen; #endif if (!skipOpen) { PatchSplashScreenWindowStyle(info.SplashScreen, info.Owner != null); info.Callbacks.ExecuteClose(); info.SplashScreen.ShowDialog(); info.ActivateOwner(); } ReleaseResources(info); }
object GetOwnerContainer(object parameter) { object result = SplashScreenHelper.FindParameter <WindowContainer>(parameter, null).Return(x => x.CreateOwnerContainer(), null) ?? SplashScreenHelper.FindParameter <WindowRelationInfo>(parameter, null); if (result != null) { return(result); } WindowStartupLocation startupLocation = SplashScreenHelper.FindParameter(parameter, WindowStartupLocation.CenterScreen); return(SplashScreenHelper.FindParameter <SplashScreenOwner>(parameter, null).With(x => x.CreateOwnerContainer(startupLocation))); }
static Window CreateDefaultSplashScreenWindow(object parameter) { return(new SplashScreenWindow() { WindowStyle = WindowStyle.None, ResizeMode = ResizeMode.NoResize, AllowsTransparency = true, Background = new SolidColorBrush(Colors.Transparent), ShowInTaskbar = false, Topmost = true, SizeToContent = SizeToContent.WidthAndHeight, WindowStartupLocation = SplashScreenHelper.FindParameter(parameter, WindowStartupLocation.CenterScreen) }); }
public static void Show(Type splashScreenType, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen, SplashScreenOwner owner = null, SplashScreenClosingMode closingMode = SplashScreenClosingMode.Default) { CheckSplashScreenType(splashScreenType); if (typeof(Window).IsAssignableFrom(splashScreenType)) { Func <object, Window> windowCreator = (p) => { Window splashWindow = (Window)Activator.CreateInstance(SplashScreenHelper.FindParameter <Type>(p)); splashWindow.WindowStartupLocation = SplashScreenHelper.FindParameter(p, WindowStartupLocation.CenterScreen); return(splashWindow); }; Show(windowCreator, null, new object[] { splashScreenType, startupLocation, owner, closingMode }, null); } else if (typeof(FrameworkElement).IsAssignableFrom(splashScreenType)) { Func <object, Window> windowCreator = (p) => { Window res = DefaultSplashScreenWindowCreator(p); WindowFadeAnimationBehavior.SetEnableAnimation(res, true); return(res); }; Show(windowCreator, CreateDefaultSplashScreen, new object[] { startupLocation, owner, closingMode }, new object[] { splashScreenType }); } }
void InternalThreadEntryPoint(object parameter) { Func <object, Window> windowCreator = ((object[])parameter)[0] as Func <object, Window>; Func <object, object> splashScreenCreator = ((object[])parameter)[1] as Func <object, object>; object windowCreatorParameter = ((object[])parameter)[2]; object splashScreenCreatorParameter = ((object[])parameter)[3]; var lockMode = (UIThreadReleaseMode?)SplashScreenHelper.FindParameter(parameter, UIThreadReleaseMode); var info = SplashScreenHelper.FindParameter <SplashScreenInfo>(parameter) ?? ActiveInfo; #if DEBUGTEST || DEBUG if (info.WaitEvent != null) { info.WaitEvent.WaitOne(2000); } #endif info.SplashScreen = windowCreator(windowCreatorParameter); info.Dispatcher = info.SplashScreen.Dispatcher; info.Callbacks.Initialize(); if (SplashScreenHelper.IsResourcesLocked()) { lockMode = null; SyncEvent.Set(); } splashScreenCreator.Do(x => info.SplashScreen.Content = x(splashScreenCreatorParameter)); SetProgressStateCore(info, true); info.InitializeOwner(parameter); SubscribeParentEvents(windowCreatorParameter); if (lockMode.HasValue && lockMode.Value == UIThreadReleaseMode.WaitForSplashScreenInitialized) { SyncEvent.Set(); } info.Callbacks.ExecuteExceptClose(); bool skipOpen = info.CloseWithParent && info.RelationInfo.Return(x => x.ActualIsParentClosed, () => false); #if DEBUGTEST || DEBUG Test_SkipWindowOpen = skipOpen; #endif bool unlockRequired = lockMode.HasValue && lockMode.Value == UIThreadReleaseMode.WaitForSplashScreenLoaded; if (!skipOpen) { if (unlockRequired) { info.SplashScreen.Loaded += OnSplashScreenLoaded; } PatchSplashScreenWindowStyle(info.SplashScreen, info.Owner != null); info.Callbacks.ExecuteClose(); info.SplashScreen.ShowDialog(); if (unlockRequired) { info.SplashScreen.Loaded -= OnSplashScreenLoaded; } info.ActivateOwner(); } else if (unlockRequired) { SyncEvent.Set(); } ReleaseResources(info); }