public void SwitchTransition()
        {
            var state = !TransitionAssist.GetDisableTransitions(Program.MainWindow);

            TransitionAssist.SetDisableTransitions(Program.MainWindow, state);
            DialogHelper.DisableTransitions = state;
        }
        private Task <TResult> Procedure(Action action)
        {
            var tcs = new TaskCompletionSource <TResult>();

            void OnceHandler(object sender, EventArgs args)
            {
                tcs.TrySetResult(m_Window.GetResult());
                m_Window.Closed -= OnceHandler;
            }

            m_Window.Closed += OnceHandler;
            TransitionAssist.SetDisableTransitions(m_Window as AvaloniaObject, DialogHelper.DisableTransitions);
            action();
            return(tcs.Task);
        }
Example #3
0
 private static void IsActivePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
 {
     ((Underline)dependencyObject).GotoVisualState(!TransitionAssist.GetDisableTransitions(dependencyObject));
 }
        private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            var dialogHost = (DialogHost)dependencyObject;

            if (dialogHost._popupContentControl != null)
            {
                ValidationAssist.SetSuppress(dialogHost._popupContentControl, !dialogHost.IsOpen);
            }
            VisualStateManager.GoToState(dialogHost, dialogHost.SelectState(), !TransitionAssist.GetDisableTransitions(dialogHost));

            if (dialogHost.IsOpen)
            {
                WatchWindowActivation(dialogHost);
                dialogHost._currentSnackbarMessageQueueUnPauseAction = dialogHost.SnackbarMessageQueue?.Pause();
            }
            else
            {
                dialogHost._asyncShowWaitHandle.Set();
                dialogHost._attachedDialogClosingEventHandler = null;
                if (dialogHost._currentSnackbarMessageQueueUnPauseAction != null)
                {
                    dialogHost._currentSnackbarMessageQueueUnPauseAction();
                    dialogHost._currentSnackbarMessageQueueUnPauseAction = null;
                }
                dialogHost._session.IsEnded = true;
                dialogHost._session         = null;
                dialogHost._closeCleanUp();

                // Don't attempt to Invoke if _restoreFocusDialogClose hasn't been assigned yet. Can occur
                // if the MainWindow has started up minimized. Even when Show() has been called, this doesn't
                // seem to have been set.
                dialogHost.Dispatcher.InvokeAsync(() => dialogHost._restoreFocusDialogClose?.Focus(), DispatcherPriority.Input);

                return;
            }

            dialogHost._asyncShowWaitHandle.Reset();
            dialogHost._session = new DialogSession(dialogHost);
            var window = Window.GetWindow(dialogHost);

            dialogHost._restoreFocusDialogClose = window != null?FocusManager.GetFocusedElement(window) : null;

            //multiple ways of calling back that the dialog has opened:
            // * routed event
            // * the attached property (which should be applied to the button which opened the dialog
            // * straight forward dependency property
            // * handler provided to the async show method
            var dialogOpenedEventArgs = new DialogOpenedEventArgs(dialogHost._session, DialogOpenedEvent);

            dialogHost.OnDialogOpened(dialogOpenedEventArgs);
            dialogHost._attachedDialogOpenedEventHandler?.Invoke(dialogHost, dialogOpenedEventArgs);
            dialogHost.DialogOpenedCallback?.Invoke(dialogHost, dialogOpenedEventArgs);
            dialogHost._asyncShowOpenedEventHandler?.Invoke(dialogHost, dialogOpenedEventArgs);

            dialogHost.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                CommandManager.InvalidateRequerySuggested();
                var child = dialogHost.FocusPopup();

                //https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/187
                //totally not happy about this, but on immediate validation we can get some weird looking stuff...give WPF a kick to refresh...
                Task.Delay(300).ContinueWith(t => child.Dispatcher.BeginInvoke(new Action(() => child.InvalidateVisual())));
            }));
        }
Example #5
0
 private static void DisplayModePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
 {
     ((Clock)dependencyObject).GotoVisualState(!TransitionAssist.GetDisableTransitions(dependencyObject));
 }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void RegisterEditorController(StartupEventArgs args)
        {
            EditorController.Register(xtmfMainWindow, () =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    var swatches = new SwatchesProvider().Swatches;

                    if (EditorController.Runtime.Configuration.PrimaryColour != null)
                    {
                        var swatch = swatches.First(s =>
                                                    s.Name == EditorController.Runtime.Configuration.PrimaryColour);
                        new PaletteHelper().ReplacePrimaryColor(swatch);
                    }
                    else
                    {
                        var swatch = new SwatchesProvider().Swatches.First(s => s.Name.ToLower() == "blue");
                        new PaletteHelper().ReplacePrimaryColor(swatch);
                        EditorController.Runtime.Configuration.PrimaryColour = swatch.Name;
                    }


                    if (EditorController.Runtime.Configuration.AccentColour != null)
                    {
                        var swatch = swatches.First(s => s.Name == EditorController.Runtime.Configuration.AccentColour);
                        new PaletteHelper().ReplaceAccentColor(swatch);
                        EditorController.Runtime.Configuration.AccentColour = swatch.Name;
                    }
                    else
                    {
                        var swatch = swatches.First(s => s.Name.ToLower() == "amber");
                        new PaletteHelper().ReplaceAccentColor(swatch);
                    }

                    if (EditorController.Runtime.Configuration.IsDarkTheme)
                    {
                        new PaletteHelper().SetLightDark(true);
                    }
                    else
                    {
                        new PaletteHelper().SetLightDark(false);
                    }

                    if (EditorController.Runtime.Configuration.IsDisableTransitionAnimations)
                    {
                        TransitionAssist.SetDisableTransitions(Gui.MainWindow.Us, false);
                    }



                    xtmfMainWindow.UpdateRecentProjectsMenu();

                    if (EditorController.Runtime.Configuration.IsDarkTheme)
                    {
                        new PaletteHelper().SetLightDark(true);
                    }
                    xtmfMainWindow.Show();

                    /*if (args.Args.Contains("--remote-host"))
                     * {
                     *  //use remote host even though a debugger may be attached.
                     *  EditorController.Runtime.Configuration.RemoteHost = true;
                     *
                     * } */

                    EditorController.Runtime.Configuration.LoadModules(() =>
                    {
                        xtmfMainWindow.IsEnabled          = true;
                        xtmfMainWindow.StatusDisplay.Text = "Ready";
                    });
                }));
            }, false);
        }
Example #7
0
 private void UpdateVisualStates(bool?useTransitions = null)
 {
     VisualStateManager.GoToState(this,
                                  IsLeftMenuOpen ? TemplateLeftOpenStateName : TemplateLeftClosedStateName,
                                  useTransitions.HasValue ? useTransitions.Value : !TransitionAssist.GetDisableTransitions(this));
 }
        private void UpdateVisualStates(bool?useTransitions = null)
        {
            var anyOpen = IsTopDrawerOpen || IsLeftDrawerOpen || IsBottomDrawerOpen || IsRightDrawerOpen;

            VisualStateManager.GoToState(this,
                                         !anyOpen ? TemplateAllDrawersAllClosedStateName : TemplateAllDrawersAnyOpenStateName, useTransitions.HasValue ? useTransitions.Value : !TransitionAssist.GetDisableTransitions(this));

            VisualStateManager.GoToState(this,
                                         IsLeftDrawerOpen ? TemplateLeftOpenStateName : TemplateLeftClosedStateName, useTransitions.HasValue ? useTransitions.Value : !TransitionAssist.GetDisableTransitions(this));

            VisualStateManager.GoToState(this,
                                         IsTopDrawerOpen ? TemplateTopOpenStateName : TemplateTopClosedStateName, useTransitions.HasValue ? useTransitions.Value : !TransitionAssist.GetDisableTransitions(this));

            VisualStateManager.GoToState(this,
                                         IsRightDrawerOpen ? TemplateRightOpenStateName : TemplateRightClosedStateName, useTransitions.HasValue ? useTransitions.Value : !TransitionAssist.GetDisableTransitions(this));

            VisualStateManager.GoToState(this,
                                         IsBottomDrawerOpen ? TemplateBottomOpenStateName : TemplateBottomClosedStateName, useTransitions.HasValue ? useTransitions.Value : !TransitionAssist.GetDisableTransitions(this));
        }