Example #1
0
        private void StartupAfterGettingResources(object sender, StartupEventArgs e)
        {
            string   baseUrl  = getBaseUri(e);
            MainPage mainPage = null;

            ViewerApplicationControl viewerControl = new ViewerApplicationControl()
            {
                BaseUri = new Uri(baseUrl, UriKind.Absolute)
            };

            this.RootVisual = mainPage = new MainPage()
            {
                Content = viewerControl
            };
            viewerControl.ViewInitialized += (o, args) =>
            { viewerControl.View.ApplicationColorSet.SyncDesignHostBrushes = true; };

            RTLHelper helper = Application.Current.Resources["RTLHelper"] as RTLHelper;

            Debug.Assert(helper != null);
            if (helper != null)
            {
                mainPage.FlowDirection = helper.FlowDirection;
            }

            WebClientFactory.Initialize();
            ImageUrlResolver.RegisterImageUrlResolver(new UrlResolver(baseUrl));
        }
        private void loadUI()
        {
            MapApplication.SetApplication(BuilderApplication.Instance);
            AppCoreHelper.SetService(new ApplicationServices());

            this.RootVisual = mainPage = new MainPage()
            {
                DataContext = BuilderApplication.Instance,
            };
            ESRI.ArcGIS.Mapping.Core.Utility.SetRTL(mainPage);
            ImageUrlResolver.RegisterImageUrlResolver(new BuilderImageUrlResolver());
            WebClientFactory.Initialize();

            NotificationPanel.Instance.Initialize();

            if (!NotificationPanel.Instance.OptedOutOfNotification)
            {
                EventHandler handler = null;
                handler = (o, e) =>
                {
                    if (NotificationPanel.Instance.OptedOutOfNotification)
                    {
                        NotificationPanel.Instance.NotificationsUpdated -= handler;
                        return;
                    }

                    showExtensionLoadFailedMessageOnStartup();
                };
                NotificationPanel.Instance.NotificationsUpdated += handler;
                if (hasStartupExtensionLoadFailedEvent)
                {
                    showExtensionLoadFailedMessageOnStartup();
                }
            }
        }
Example #3
0
        private void UpdateSymbolProperties()
        {
            BitmapImage bmi = ImageUrlResolver.ResolveUrlForImage(Source);

            if (Source != null)
            {
                var uriKey = ImageUrlResolver.ResolveUrl(Source);
                contentType = GetContentType(System.IO.Path.GetExtension(Source).TrimStart(new char[] { '.' }));
                var key = Source.Contains(IMAGELOCATION) ? Source.Replace(IMAGELOCATION, string.Empty).Replace("/", "\\") : uriKey.OriginalString;
                var imageSymbolEntry = SymbolConfigProvider.ImageSymbolLookup.FirstOrDefault(i => string.Equals(i.Source, key, StringComparison.OrdinalIgnoreCase));
                if (imageSymbolEntry != null)
                {
                    _data = imageSymbolEntry.ImageData;
                }
                else if (uriKey.IsAbsoluteUri)
                {
                    bmi.ImageOpened += (s, e) =>
                    {
                        var uriSource = (s as BitmapImage).UriSource;
                        var webClient = new WebClient();
                        webClient.OpenReadCompleted += (a, b) =>
                        {
                            var symbolKey      = b.UserState as Uri;
                            var length         = (int)b.Result.Length;
                            var contentInBytes = new byte[length];
                            b.Result.Read(contentInBytes, 0, length);
                            _data = System.Convert.ToBase64String(contentInBytes);
                            SymbolConfigProvider.ImageSymbolLookup.Add(new ImageSymbolEntry(symbolKey.OriginalString, _data));
                        };
                        webClient.OpenReadAsync(uriSource, uriSource);
                    };
                }
                else
                {
                    Uri contentUri = new Uri(uriKey.OriginalString.TrimStart(new char[] { '/' }), UriKind.Relative);
                    System.Windows.Resources.StreamResourceInfo sri = Application.GetResourceStream(contentUri);
                    if (sri != null && sri.Stream != null)
                    {
                        int    length         = (int)sri.Stream.Length;
                        byte[] contentInBytes = new byte[length];
                        sri.Stream.Read(contentInBytes, 0, length);
                        _data = System.Convert.ToBase64String(contentInBytes);
                    }
                }
            }
            ImageBrush brush = new ImageBrush()
            {
                ImageSource = bmi
            };

            Fill = brush;
        }
Example #4
0
        protected override void OnAttached()
        {
            base.OnAttached();

            if (this.AssociatedObject != null)
            {
                this.AssociatedObject.MouseRightButtonUp -= AssociatedObject_MouseRightButtonUp;
                this.AssociatedObject.MouseRightButtonUp += AssociatedObject_MouseRightButtonUp;
            }

            if (_urlResolver == null)
            {
                _urlResolver = new ImageUrlResolver();
            }
        }
Example #5
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string urlToBeResolved = value as string;

            if (!string.IsNullOrWhiteSpace(urlToBeResolved))
            {
                return(ImageUrlResolver.ResolveUrlForImage(urlToBeResolved));
            }
            else
            {
                urlToBeResolved = parameter as string;
                if (!string.IsNullOrWhiteSpace(urlToBeResolved))
                {
                    return(ImageUrlResolver.ResolveUrlForImage(urlToBeResolved));
                }
            }
            return(value);
        }
Example #6
0
        /// <summary>
        /// Serializes the ImageFillSymbol to JSON
        /// </summary>
        /// <returns>
        /// A JSON string representation of the ImageFillSymbol.
        /// </returns>
        public string ToJson()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            double size    = Size;
            double xoffset = 0 - ((size * OriginX) - size / 2);
            double yoffset = (size * OriginY) - size / 2;

            sb.Append("{\"type\" : \"esriPMS\",");
            if (!string.IsNullOrEmpty(ImageData))
            {
                sb.AppendFormat("\"imageData\" : \"{0}\",", ImageData);
            }
            else if (!string.IsNullOrEmpty(Source))
            {
                sb.AppendFormat("\"url\" : \"{0}\",", ImageUrlResolver.ResolveUrl(Source));
            }
            sb.AppendFormat("\"width\" : {0}, \"height\" : {0}, \"xoffset\" : {1}, \"yoffset\" : {2}, \"contentType\" : \"{3}\"", size, xoffset, yoffset, contentType);
            sb.Append(" }");
            return(sb.ToString());
        }
Example #7
0
 public Uri ResolveUrl(string urlToBeResolved)
 {
     return(ImageUrlResolver.ResolveUrl(urlToBeResolved));
 }