コード例 #1
0
        private async Task  LoadDataAsync()
        {
            if (IsBusy)
            {
                return;
            }

            Exception myEx = null;

            IsBusy = true;
            try
            {
                if (_arduinoStationID == null || !_arduinoStationID.HasValue || _arduinoStationID.Value == 0)
                {
                    ArduinoStation = new ArduinoStation()
                    {
                        Id = 0, Description = "arduino 1", Location = "37.973555, 23.680971", WaterStatus = false
                    };
                }
                else
                {
                    var lst = await HttpService.GetArduinoStationList();

                    if (lst != null)
                    {
                        ArduinoStation = lst.FirstOrDefault(x => x.Id == _arduinoStationID.Value);
                        RaiseAllPropertiesChanged();
                    }
                }
            }
            catch (Exception ex)
            {
                myEx = ex;
                //throw;
            }
            finally
            {
                Device.BeginInvokeOnMainThread(() => IsBusy = false);
                IsBusy = false;
            }

            if (myEx != null)
            {
                try
                {
                    var p = new ContentPage();
                    await p.DisplayAlert("Σφάλμα", myEx.Message, "ΟΚ");
                }
                catch (Exception ex)
                {
                    Mvx.Exception(ex.Message);
                }
            }
        }
コード例 #2
0
        public string GetString(string key)
        {
            var translation = _resmgr.GetString(key, _currentLanguage.CultureInfo);

            if (translation == null)
            {
#if DEBUG
                // throw new ArgumentException(
                Mvx.Exception($"Key '{key}' was not found in resources '{_resourceId}' for culture '{_currentLanguage.CultureInfo.Name}'.", "Text");
                translation = key;
#else
                translation = key; // HACK: returns the key, which GETS DISPLAYED TO THE USER
#endif
            }
            return(translation);
        }
コード例 #3
0
        public MvxFrameControl(int templateId, Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            _templateId = templateId;

            if (!(context is IMvxLayoutInflaterHolder))
            {
                throw Mvx.Exception("The owning Context for a MvxFrameControl must implement LayoutInflater");
            }

            _bindingContext = new MvxAndroidBindingContext(context, (IMvxLayoutInflaterHolder)context);
            this.DelayBind(() =>
            {
                if (Content == null && _templateId != 0)
                {
                    Mvx.Trace("DataContext is {0}", DataContext?.ToString() ?? "Null");
                    Content = _bindingContext.BindingInflate(_templateId, this);
                }
            });
        }