public LoadingDecoratorWindowFree(WindowArrangerContainer parentContainer, SplashScreenLock lockMode, bool useFadeEffect, TimeSpan fadeInDuration, TimeSpan fadeOutDuration)
            {
                ParentContainer = parentContainer;
                if (useFadeEffect)
                {
                    AnimationBehavior = new WindowFadeAnimationBehavior()
                    {
                        FadeInDuration = fadeInDuration, FadeOutDuration = fadeOutDuration
                    };
                    Interaction.GetBehaviors(this).Add(AnimationBehavior);
                }
                WindowStartupLocation = WindowStartupLocation.Manual;
                if (!LoadingDecorator.IsLoadedEx)
                {
                    Opacity = 0d;
                    LoadingDecorator.Loaded += OnLoadingDecoratorLoaded;
                    if (AnimationBehavior != null)
                    {
                        AnimationBehavior.ManualFadeIn = true;
                    }
                }
                var startupLocation = parentContainer.GetControlStartupRect(SplashScreenLocation.CenterContainer);

                if (startupLocation.IsEmpty)
                {
                    startupLocation = parentContainer.GetControlStartupRect(SplashScreenLocation.CenterWindow);
                }
                SetWindowStartupPosition(startupLocation);
                CreateLocker(parentContainer, lockMode);
                ClearValue(ShowActivatedProperty);
            }
 public static void Show(Type splashScreenType)
 {
     if (typeof(Window).IsAssignableFrom(splashScreenType) && !typeof(ISplashScreen).IsAssignableFrom(splashScreenType))
     {
         throw new InvalidOperationException(DXSplashScreenExceptions.Exception2);
     }
     if (typeof(Window).IsAssignableFrom(splashScreenType) && typeof(ISplashScreen).IsAssignableFrom(splashScreenType))
     {
         Func <object, Window> windowCreator = (p) => {
             Type   type         = (Type)p;
             Window splashWindow = (Window)Activator.CreateInstance(type);
             splashWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
             return(splashWindow);
         };
         Func <object, object> splashScreenCreator = null;
         object windowCreatorParameter             = splashScreenType;
         object splashScreenCreatorParameter       = null;
         Show(windowCreator, splashScreenCreator, windowCreatorParameter, splashScreenCreatorParameter);
         return;
     }
     if (typeof(FrameworkElement).IsAssignableFrom(splashScreenType))
     {
         Func <object, Window> splashScreenWindowCreator = (p) => {
             Window res = DefaultSplashScreenWindowCreator(null);
             WindowFadeAnimationBehavior.SetEnableAnimation(res, true);
             return(res);
         };
         Show(splashScreenWindowCreator, CreateDefaultSplashScreen,
              new object[] { }, new object[] { splashScreenType });
         return;
     }
     throw new InvalidOperationException(DXSplashScreenExceptions.Exception2);
 }
Example #3
0
        static void OnEnableAnimationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Window                      w   = d as Window;
            BehaviorCollection          col = Interaction.GetBehaviors(w);
            WindowFadeAnimationBehavior b   = (WindowFadeAnimationBehavior)col.FirstOrDefault(x => x is WindowFadeAnimationBehavior);

            col.Remove(b);
            if ((bool)e.NewValue)
            {
                col.Add(new WindowFadeAnimationBehavior());
            }
        }
 public LoadingDecoratorWindow(bool useFadeEffect, SplashScreenOwner parentContainer, SplashScreenLocation childLocation, bool lockParent)
 {
     WindowStyle           = WindowStyle.None;
     AllowsTransparency    = true;
     ShowInTaskbar         = false;
     Background            = new SolidColorBrush(Colors.Transparent);
     SizeToContent         = SizeToContent.WidthAndHeight;
     WindowStartupLocation = WindowStartupLocation.Manual;
     Left             = parentContainer.ControlStartupPosition.Left;
     Top              = parentContainer.ControlStartupPosition.Top;
     Width            = parentContainer.ControlStartupPosition.Width;
     Height           = parentContainer.ControlStartupPosition.Height;
     Topmost          = false;
     ShowActivated    = false;
     IsHitTestVisible = false;
     Focusable        = false;
     CreateArranger(parentContainer, childLocation);
     CreateLocker(parentContainer, lockParent);
     WindowFadeAnimationBehavior.SetEnableAnimation(this, useFadeEffect);
     Loaded += OnWindowLoaded;
 }
Example #5
0
 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 });
     }
 }
        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);
        }