Ejemplo n.º 1
0
        public MainWindow()
        {
            _mainPage               = new MainPage(this);
            _systemPage             = new SystemPage(this);
            _selfTestPage           = new SelfTestPage(this);
            _factoryResetPage       = new FactoryResetPage(this);
            _findMyGearPage         = new FindMyGearPage(this);
            _touchpadPage           = new TouchpadPage(this);
            _ambientSoundPage       = new AmbientSoundPage(this);
            _equalizerPage          = new EqualizerPage(this);
            _connectionLostPage     = new ConnectionLostPage(this);
            _deviceSelectPage       = new DeviceSelectPage(this);
            _settingPage            = new SettingPage(this);
            _updatePage             = new UpdatePage(this);
            _advancedPage           = new AdvancedPage(this);
            _unsupportedFeaturePage = new UnsupportedFeaturePage(this);

            InitializeComponent();

            SPPMessageHandler.Instance.AnyMessageReceived           += InstanceOnAnyMessageReceived;
            BluetoothService.Instance.MessageReceived               += SPPMessageHandler.Instance.MessageReceiver;
            BluetoothService.Instance.InvalidDataException          += InstanceOnInvalidDataException;
            BluetoothService.Instance.SocketException               += InstanceOnSocketException;
            BluetoothService.Instance.PlatformNotSupportedException += InstanceOnPlatformNotSupportedException;
            BluetoothService.Instance.CreateClient();

            Closing                            += OnClosing;
            OptionsClicked                     += OnOptionsClicked;
            _mainPage.MainMenuClicked          += MainPageOnMainMenuClicked;
            _connectionLostPage.RetryRequested += ConnectionLostPageOnRetryRequested;

            BluetoothAddress savedAddress = GetRegisteredDevice();

            if (savedAddress == null)
            {
                PageControl.TransitionType = PageTransitionType.Fade;
                PageControl.ShowPage(new WelcomePage(this));
            }
            else
            {
                PageControl.TransitionType = PageTransitionType.Fade;
                PageControl.ShowPage(_mainPage);
                _mainPage.SetLoaderVisible(true);
                Task.Delay(100).ContinueWith((_) =>
                {
                    BluetoothService.Instance.Connect(savedAddress);
                    CheckForUpdates(manual: false);
                });
                _address = savedAddress;
            }
        }
        public MainWindow()
        {
            if (Settings.Default.DarkMode2 == DarkMode.Unset)
            {
                Settings.Default.DarkMode2 = (DarkMode)Convert.ToInt32(Settings.Default.DarkMode);
                Settings.Default.Save();
            }

            DarkModeHelper.Update();

            _mainPage               = new MainPage(this);
            _systemPage             = new SystemPage(this);
            _selfTestPage           = new SelfTestPage(this);
            _factoryResetPage       = new FactoryResetPage(this);
            _findMyGearPage         = new FindMyGearPage(this);
            _touchpadPage           = new TouchpadPage(this);
            _customActionPage       = new CustomActionPage(this);
            _ambientSoundPage       = new AmbientSoundPage(this);
            _equalizerPage          = new EqualizerPage(this);
            _connectionLostPage     = new ConnectionLostPage(this);
            _deviceSelectPage       = new DeviceSelectPage(this);
            _settingPage            = new SettingPage(this);
            _updatePage             = new UpdatePage(this);
            _advancedPage           = new AdvancedPage(this);
            _unsupportedFeaturePage = new UnsupportedFeaturePage(this);
            _popupSettingPage       = new PopupSettingPage(this);

            InitializeComponent();

            _tbi = new TaskbarIcon();
            Stream iconStream = Application.GetResourceStream(new Uri("pack://*****:*****@"CRITICAL: Unknown Win32 Bluetooth service error");
                Console.WriteLine(e);
            }
        }