示例#1
0
 public MainPage(IDeviceDisplay deviceDisplay)
 {
     this.deviceDisplay = deviceDisplay;
     this.InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     this.Appearing += this.OnAppearing;
 }
示例#2
0
        public static void SetCurrent(IDeviceDisplay?implementation)
        {
            lock (locker)
            {
                if (currentImplementation == implementation)
                {
                    return;
                }

                var newImplementation = implementation ?? new DeviceDisplayImplementation();

                var oldImplementation = currentImplementation;
                currentImplementation = newImplementation;

                if (oldImplementation is not null)
                {
                    oldImplementation.MainDisplayInfoChanged -= OnMainDisplayInfoChanged;

                    var wasAlwaysOn = oldImplementation.KeepScreenOn;
                    if (wasAlwaysOn)
                    {
                        oldImplementation.KeepScreenOn = false;
                        newImplementation.KeepScreenOn = true;
                    }

                    var wasRunning = MainDisplayInfoChangedInternal != null;
                    if (wasRunning)
                    {
                        oldImplementation.StopScreenMetricsListeners();
                        newImplementation.StartScreenMetricsListeners();
                    }
                }

                newImplementation.MainDisplayInfoChanged += OnMainDisplayInfoChanged;

                SetCurrent(newImplementation.GetMainDisplayInfo());
            }
        }
示例#3
0
 static DeviceDisplay()
 {
     currentImplementation = new DeviceDisplayImplementation();
     currentImplementation.MainDisplayInfoChanged += OnMainDisplayInfoChanged;
 }