Пример #1
0
        public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;
            _throttleHelper.ThrottledEvent += ThrottleHelperOnThrottledEvent;

            // process start
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                Element.Visibility = Visibility.Visible;
            }
            else
            {
                // handle click
                Element.Click += new Common.WeakReference <NavButtonBehavior, object, RoutedEventArgs>(this)
                {
                    EventAction  = (i, s, e) => i.Element_Click(s, e),
                    DetachAction = (i, w) => Element.Click -= w.Handler,
                }.Handler;
                CalculateThrottled();


                // TODO: critical!
                // if (Locator.BootStrapper.Instance != null) Locator.BootStrapper.Instance.ShellBackButtonUpdated += Current_ShellBackButtonUpdated;


                _deviceUtils = DeviceUtils.Current(WindowEx.Current());
                if (_deviceUtils != null)
                {
                    _deviceUtils.Changed += DispositionChanged;
                }
            }
        }
Пример #2
0
 public void Attach(DependencyObject associatedObject)
 {
     AssociatedObject = associatedObject;
     _dispatcher      = WindowEx.Current().Dispatcher;
     Central.Messenger.Subscribe <Messages.BackRequestedMessage>(this, e =>
     {
         Interaction.ExecuteActions(AssociatedObject, Actions, null);
     });
 }
Пример #3
0
 public NavButtonBehavior()
 {
     if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         _dispatcher     = WindowEx.Current().Dispatcher;
         _throttleHelper = new EventThrottleHelper {
             Throttle = 1000
         };
     }
 }
Пример #4
0
 public void Attach(DependencyObject associatedObject)
 {
     AssociatedObject = associatedObject;
     _deviceUtils     = DeviceUtils.Current(WindowEx.Current());
     if (_deviceUtils != null)
     {
         _deviceUtils.Changed += DeviceDispositionBehavior_Changed;
     }
     Update();
     _ready = true;
 }
Пример #5
0
 public static void HideBusy()
 {
     WindowEx.Current().Dispatcher.Dispatch(() =>
     {
         var modal = Window.Current.Content as ModalDialog;
         var view  = modal.ModalContent as Busy;
         if (view != null)
         {
             modal.IsModal = view.IsBusy = false;
         }
     });
 }
Пример #6
0
        private static async Task <T> ShowAsync <T>(Func <Task <T> > show, IDispatcherEx dispatcher)
        {
            await _showAsyncSemaphoreSlim.WaitAsync();

            try
            {
                dispatcher = dispatcher ?? WindowEx.Current().Dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
                return(await dispatcher.DispatchAsync(async() => await show()));
            }
            finally
            {
                _showAsyncSemaphoreSlim.Release();
            }
        }
Пример #7
0
 // hide and show busy dialog
 public static void ShowBusyFor(string text = null, int milliseconds = int.MaxValue)
 {
     WindowEx.Current().Dispatcher.Dispatch(() =>
     {
         var modal = Window.Current.Content as ModalDialog;
         var view  = modal.ModalContent as Busy;
         if (view == null)
         {
             modal.ModalContent = view = new Busy();
         }
         modal.IsModal = view.IsBusy = true;
         view.BusyText = text;
     });
     WindowEx.Current().Dispatcher.Dispatch(() =>
     {
         HideBusy();
     }, milliseconds);
 }
Пример #8
0
 internal NavigationService()
 {
     Window = WindowEx.Current();
 }
 public void Attach(DependencyObject associatedObject)
 {
     AssociatedObject = associatedObject;
     _dispatcher      = WindowEx.Current().Dispatcher;
     _BackButtonService.BackRequested += BackButtonService_NavigateBack;
 }
Пример #10
0
        private void Update()
        {
            var w = WindowEx.Current();
            var d = DeviceUtils.Current(w);

            switch (d.DeviceDisposition())
            {
            case DeviceUtils.DeviceDispositions.IoT: if (IoT)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Xbox: if (Xbox)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Team: if (Team)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.HoloLens: if (HoloLens)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Desktop: if (Desktop)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Mobile: if (Mobile)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Phone: if (Phone)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Continuum: if (Continuum)
                {
                    Run();
                }
                break;

            case DeviceUtils.DeviceDispositions.Virtual: if (Virtual)
                {
                    Run();
                }
                break;
            }
        }