예제 #1
0
        private void ActiveDocument_ActiveSegmentChanged(object sender, EventArgs e)
        {
            PropertiesCollection.Clear();
            var doc      = sender as Document;
            var segment  = doc?.ActiveSegmentPair;
            var contexts = segment?.GetParagraphUnitProperties().Contexts;

            if (contexts?.Contexts?.Count > 0)
            {
                foreach (var context in contexts.Contexts)
                {
                    var color = context.DisplayColor;

                    var sdiModel = new DsiModel
                    {
                        DisplayName = context.DisplayName,
                        Description = context.Description,
                        Code        = context.DisplayCode,
                    };
                    if (color.Name == "0")                     // it doesn't have a color set
                    {
                        sdiModel.RowColor = "White";
                    }
                    else
                    {
                        sdiModel.RowColor = "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
                    }
                    PropertiesCollection.Add(sdiModel);
                }
            }
        }
        private void ActiveDocument_ActiveSegmentChanged(object sender, EventArgs e)
        {
            PropertiesCollection.Clear();
            var doc      = sender as Document;
            var segment  = doc?.ActiveSegmentPair;
            var contexts = segment?.GetParagraphUnitProperties().Contexts;

            if (contexts?.Contexts?.Count > 0)
            {
                foreach (var context in contexts.Contexts)
                {
                    var sdiModel = new SdiModel
                    {
                        DisplayName = context.DisplayName,
                        Description = context.Description,
                        Code        = context.DisplayCode
                    };
                    PropertiesCollection.Add(sdiModel);
                }
            }
        }
예제 #3
0
        async void LoadProperties()
        {
            PropertiesCollection.Clear();
            var items = Repository.GetProperties();

            try
            {
                location = await Geolocation.GetLastKnownLocationAsync();

                if (location == null)
                {
                    location = await Geolocation.GetLocationAsync();
                }

                foreach (Property item in items)
                {
                    PropertyListItem listitem     = new PropertyListItem(item);
                    Location         currLocation = new Location((double)item.Latitude, (double)item.Longitude);
                    listitem.Distance = Xamarin.Essentials.Location.CalculateDistance(currLocation, location, DistanceUnits.Kilometers);
                    PropertiesCollection.Add(listitem);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
        private void LoadProperties()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            PropertiesCollection.Clear();

            try
            {
                var properties = Repository.GetProperties();
                var items      = new List <PropertyListItemViewModel>();

                foreach (var property in properties)
                {
                    var item = new PropertyListItemViewModel(property);
                    if (_currentLocation != null)
                    {
                        item.DistanceInKilometres = _currentLocation.CalculateDistance(property.Latitude, property.Longitude, DistanceUnits.Kilometers);
                    }
                    items.Add(item);
                }

                foreach (var item in items.OrderBy(x => x.DistanceInKilometres))
                {
                    PropertiesCollection.Add(item);
                }
            }
            finally
            {
                IsBusy = false;
            }
        }