private async Task UpdateSwatchAsync()
        {
            if (Symbol == null)
            {
                _imageView.Image = null;
                return;
            }

#pragma warning disable ESRI1800 // Add ConfigureAwait(false) - This is UI Dependent code and must return to UI Thread
            try
            {
                var scale     = GetScaleFactor();
                var imageData = await Symbol.CreateSwatchAsync(scale * 96);

                var width  = (int)(imageData.Width / scale);
                var height = (int)(imageData.Height / scale);
                _imageView.Image = await imageData.ToImageSourceAsync();

                _intrinsicContentSize = new CGSize(Math.Min(width, MaxSize), Math.Min(height, MaxSize));
                Hidden = false;
                InvalidateIntrinsicContentSize();
                SetNeedsUpdateConstraints();
                UpdateConstraints();
                SourceUpdated?.Invoke(this, EventArgs.Empty);
            }
            catch
            {
                _imageView.Image = null;
            }
#pragma warning restore ESRI1800
        }
Exemple #2
0
 private static IEnumerable <Issue.IssueCompleter> ValidateSource(SourceUpdated arg)
 {
     if (string.IsNullOrWhiteSpace(arg.Source))
     {
         yield return(Issue.New(Issues.EmptySource));
     }
 }
Exemple #3
0
        private async Task UpdateSwatchAsync()
        {
            var img = GetTemplateChild("image") as Image;

            if (img == null)
            {
                return;
            }

            if (Symbol == null)
            {
                img.Source    = null;
                img.MaxWidth  = 0;
                img.MaxHeight = 0;
            }
            else
            {
                try
                {
                    var scale = GetScaleFactor();
#pragma warning disable ESRI1800 // Add ConfigureAwait(false) - This is UI Dependent code and must return to UI Thread
                    var imageData = await Symbol.CreateSwatchAsync(scale * 96);

                    img.MaxWidth  = imageData.Width / scale;
                    img.MaxHeight = imageData.Height / scale;
                    img.Source    = await imageData.ToImageSourceAsync();

                    SourceUpdated?.Invoke(this, EventArgs.Empty);
#pragma warning restore ESRI1800
                }
                catch
                {
                    img.Source    = null;
                    img.MaxWidth  = 0;
                    img.MaxHeight = 0;
                }
            }
        }
Exemple #4
0
        private async Task UpdateSwatchAsync()
        {
            if (Symbol == null)
            {
                SetImageResource(0);
                return;
            }

#pragma warning disable ESRI1800 // Add ConfigureAwait(false) - This is UI Dependent code and must return to UI Thread
            try
            {
                var scale     = GetScaleFactor(Context);
                var imageData = await Symbol.CreateSwatchAsync(scale * 96);

                SetImageBitmap(await imageData.ToImageSourceAsync());
                SourceUpdated?.Invoke(this, System.EventArgs.Empty);
            }
            catch
            {
                SetImageResource(0);
            }
#pragma warning restore ESRI1800
        }