Exemple #1
0
        public FactoryResetPage()
        {
            AvaloniaXamlLoader.Load(this);

            _pageHeader  = this.FindControl <PageHeader>("PageHeader");
            _resetButton = this.FindControl <IconListItem>("FactoryReset");

            SPPMessageHandler.Instance.ResetResponse += InstanceOnResetResponse;
        }
Exemple #2
0
        private ListResult <IconListItem> GetIcon(int siteId)
        {
            ListResult <IconListItem> data = null;

            if (base.IsUseCache)
            {
                data = MemoryCacher.GetValue("SITE-ICON") as ListResult <IconListItem>;

                if (data != null)
                {
                    return(data);
                }
            }

            IList <IconInfo> list = VShopHelper.GetAllIcon(ClientType.App);

            List <IconListItem> items = new List <IconListItem>();

            if (list != null)
            {
                IconListItem item = null;

                foreach (var current in list)
                {
                    item                 = new IconListItem();
                    item.Title           = current.ShortDesc;
                    item.ImageUrl        = Util.AppendImageHost(current.ImageUrl);
                    item.DisplaySequence = current.DisplaySequence;

                    items.Add(item);
                }
            }

            data = new ListResult <IconListItem>();
            data.TotalNumOfRecords = items.Count;;
            data.Results           = items;

            if (base.IsUseCache)
            {
                MemoryCacher.Add("SITE-ICON", data, DateTimeOffset.UtcNow.AddMinutes(SITE_CACHE_KEEP_TIME));
            }

            return(data);
        }
Exemple #3
0
        public SelfTestPage()
        {
            AvaloniaXamlLoader.Load(this);

            _pageHeader = this.FindControl <PageHeader>("PageHeader");
            _hwVer      = this.FindControl <DetailListItem>("HwVer");
            _swVer      = this.FindControl <DetailListItem>("SwVer");
            _touchFwVer = this.FindControl <DetailListItem>("TouchFwVer");
            _btAddr     = this.FindControl <DetailListItem>("BtAddr");
            _proximity  = this.FindControl <DetailListItem>("Proximity");
            _thermo     = this.FindControl <DetailListItem>("Thermo");
            _adcSoc     = this.FindControl <DetailListItem>("AdcSoc");
            _adcVoltage = this.FindControl <DetailListItem>("AdcVoltage");
            _adcCurrent = this.FindControl <DetailListItem>("AdcCurrent");
            _hall       = this.FindControl <DetailListItem>("Hall");
            _accel      = this.FindControl <DetailListItem>("Accelerator");

            _result = this.FindControl <IconListItem>("SelfTestResult");

            SPPMessageHandler.Instance.SelfTestResponse += InstanceOnSelfTestResponse;
        }
Exemple #4
0
        public HomePage()
        {
            AvaloniaXamlLoader.Load(this);
            _ancSwitch      = this.FindControl <ToggleSwitch>("AncToggle");
            _loadingSpinner = this.FindControl <LoadingSpinner>("LoadingSpinner");

            _caseLabel               = this.FindControl <Label>("CaseLabel");
            _batteryCase             = this.FindControl <Label>("BatteryCase");
            _batteryVoltLeft         = this.FindControl <Label>("BatteryVoltLeft");
            _batteryVoltRight        = this.FindControl <Label>("BatteryVoltRight");
            _batteryPercentageLeft   = this.FindControl <Label>("BatteryPercentageLeft");
            _batteryPercentageRight  = this.FindControl <Label>("BatteryPercentageRight");
            _batteryCurrentLeft      = this.FindControl <Label>("BatteryCurrentLeft");
            _batteryCurrentRight     = this.FindControl <Label>("BatteryCurrentRight");
            _batteryTemperatureLeft  = this.FindControl <Label>("BatteryTemperatureLeft");
            _batteryTemperatureRight = this.FindControl <Label>("BatteryTemperatureRight");

            _batteryIconLeft  = this.FindControl <Image>("BatteryIconLeft");
            _batteryIconRight = this.FindControl <Image>("BatteryIconRight");
            _iconLeft         = this.FindControl <Image>("LeftIcon");
            _iconRight        = this.FindControl <Image>("RightIcon");

            _warningText      = this.FindControl <Label>("WarningText");
            _warningContainer = this.FindControl <Grid>("WarningContainer");

            _ancBorder     = this.FindControl <Border>("AncBorder");
            _ambientBorder = this.FindControl <Border>("AmbientBorder");
            _noiseBorder   = this.FindControl <Border>("NoiseBorder");

            _findMyGear = this.FindControl <IconListItem>("FindMyGear");
            _touch      = this.FindControl <IconListItem>("Touch");

            Loc.LanguageUpdated += OnLanguageUpdated;

            _refreshTimer.Interval = new TimeSpan(0, 0, 7);
            _refreshTimer.Tick    += async(sender, args) =>
                                     await BluetoothImpl.Instance.SendRequestAsync(SPPMessage.MessageIds.DEBUG_GET_ALL_DATA);

            SPPMessageHandler.Instance.BaseUpdate               += (sender, update) => ProcessBasicUpdate(update);
            SPPMessageHandler.Instance.GetAllDataResponse       += (sender, parser) => UpdateDetails(parser);
            SPPMessageHandler.Instance.AncEnabledUpdateResponse += (sender, b) => _ancSwitch.IsChecked = b;
            SPPMessageHandler.Instance.AnyMessageReceived       += (sender, parser) =>
            {
                SetWarning(false);
                _loadingSpinner.IsVisible = false;
            };
            BluetoothImpl.Instance.BluetoothError += (sender, exception) =>
            {
                _lastLeftOnline       = false;
                _lastRightOnline      = false;
                _lastGetAllDataParser = null;
            };
            BluetoothImpl.Instance.Disconnected += (sender, reason) =>
            {
                _lastLeftOnline       = false;
                _lastRightOnline      = false;
                _lastGetAllDataParser = null;
            };
            BluetoothImpl.Instance.Connected += (sender, args) =>
            {
                Dispatcher.UIThread.Post((() => _loadingSpinner.IsVisible = false), DispatcherPriority.Render);
            };
            BluetoothImpl.Instance.Connecting += (sender, args) =>
            {
                Dispatcher.UIThread.Post((() => _loadingSpinner.IsVisible = true), DispatcherPriority.Render);
            };
            BluetoothImpl.Instance.InvalidDataReceived += InstanceOnInvalidDataReceived;

            EventDispatcher.Instance.EventReceived += OnEventReceived;

            /* Restore data if restarted */
            var cache = DeviceMessageCache.Instance.BasicStatusUpdate;

            if (cache != null)
            {
                ProcessBasicUpdate(cache);
            }
        }