Esempio n. 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));
        }
Esempio n. 2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            #region Set IdentityManager Referer
            // Get URL
            string appUrl = HtmlPage.Document.DocumentUri.ToString();

            // Remove query string
            Uri appUri = new Uri(appUrl);
            if (!string.IsNullOrEmpty(appUri.Query))
            {
                appUrl = appUrl.Replace(appUri.Query, "");
            }

            if (appUrl.ToLower().Contains("index.htm"))
            {
                appUrl = appUrl.Substring(0, appUrl.Length - 9);
            }

            // Set referer
            IdentityManager.Current.TokenGenerationReferer = Uri.EscapeUriString(appUrl);
            #endregion

            var result = WebRequest.RegisterPrefix("http://", ArcGISTokenWebRequestProvider.Instance);
            result = WebRequest.RegisterPrefix("https://", ArcGISTokenWebRequestProvider.Instance);

            // Check if Language Culture is supported
            string cultureName = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
            ESRI.ArcGIS.Mapping.Core.SatelliteResources.Xap resourceXap = new ESRI.ArcGIS.Mapping.Core.SatelliteResources.Xap();
            if (!resourceXap.IsSupportedLanguage(cultureName))
            {
                cultureName = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
                if (!resourceXap.IsSupportedLanguage(cultureName)) // Region only lang.
                {
                    StartupAfterGettingResources(sender, e);       //Not supported, so call StartupAfterGettingResources
                    return;
                }
            }
            // Load satellite resource file if it exist.
            string resourceUri = string.Format("/Culture/Xaps/{0}{1}", cultureName, Application.Current.Host.Source.AbsolutePath);// insert language path
            int    indexXap    = Application.Current.Host.Source.AbsolutePath.LastIndexOf('/');
            if (indexXap > 0)
            { // resources is a sub-folder of site.
                string sitePath = Application.Current.Host.Source.AbsolutePath.Substring(0, indexXap);
                string resXap   = Application.Current.Host.Source.AbsolutePath.Substring(indexXap + 1);
                resourceUri = string.Format("{0}/Culture/Xaps/{1}/{2}", sitePath, cultureName, resXap);
            }
            resourceUri = resourceUri.Replace(".xap", ".resources.xap");//update filename
            if (resourceUri.Contains("?"))
            {
                resourceUri = resourceUri.Substring(0, resourceUri.IndexOf("?", StringComparison.Ordinal));                            //remove parameters.
            }
            resourceXap.Load(resourceUri, delegate { StartupAfterGettingResources(sender, e); });
            // update the RTLHelper instance
            RTLHelper helper = Application.Current.Resources["RTLHelper"] as RTLHelper;
            Debug.Assert(helper != null);
            if (helper != null)
            {
                helper.UpdateFlowDirection();
            }
        }
Esempio n. 3
0
        private void ShowWindow(bool isModal)
        {
            if (this.IsOpen)
            {
                return;
            }

            _modal = isModal;
            if (this._overlay != null)
            {
                this._overlay.Visibility = isModal ? Visibility.Visible : Visibility.Collapsed;
            }

            this.SubscribeToEvents();
            this.SubscribeToTemplatePartEvents();
            this.SubscribeToStoryBoardEvents();

            // Set the FloatingWindow FlowDirection since it is not inherited
            RTLHelper helper = new RTLHelper();

            this.FlowDirection = helper.FlowDirection;

            if (this.ChildWindowPopup == null)
            {
                this.ChildWindowPopup       = new Popup();
                this.ChildWindowPopup.Child = this;
            }

            // Margin, MaxHeight and MinHeight properties should not be overwritten:
            this.Margin    = new Thickness(0);
            this.MaxHeight = double.PositiveInfinity;
            this.MaxWidth  = double.PositiveInfinity;

            if (this.ChildWindowPopup != null && System.Windows.Application.Current.RootVisual != null)
            {
                this.ChildWindowPopup.IsOpen = true;

                // while the ChildWindow is open, the DialogResult is always NULL:
                this._dialogresult = null;
            }

            // if the template is already loaded, display loading visuals animation
            if (this.ContentRoot != null)
            {
                this._isOpening = true;
                try
                {
                    this.ChangeVisualState();
                }
                finally
                {
                    this._isOpening = false;
                }
            }
        }
Esempio n. 4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(double))
            {
                return(value);
            }

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

            if (helper != null)
            {
                bool isRtl = helper.FlowDirection == FlowDirection.RightToLeft;
                return((isRtl) ? 180 : 0);
            }
            return(0);
        }
Esempio n. 5
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this.Content == null)
            {
                initializeViewerApplication(false);
            }

            // Tooltips in RTL require the main page to be LTR, and ViewerApplicationControl to be RTL
            RTLHelper helper = Application.Current.Resources["RTLHelper"] as RTLHelper;

            if (helper != null)
            {
                FlowDirection = helper.FlowDirection;
            }
        }
        private ButtonBase CreateLayerConfigurationToolbarButton(string desc, string icon, string label, ICommand cmd, object parameter = null)
        {
            RTLHelper helper = Application.Current.Resources["RTLHelper"] as RTLHelper;

            Debug.Assert(helper != null);
            FlowDirection flowDirection = FlowDirection.LeftToRight;

            if (helper != null)
            {
                flowDirection = helper.FlowDirection;
            }

            ButtonBase btnBase = new Button()
            {
                DataContext = new ButtonDisplayInfo()
                {
                    Description = desc, Icon = icon, Label = label
                },
                Command       = cmd,
                FlowDirection = flowDirection,
            };

            return(btnBase);
        }
Esempio n. 7
0
        void AssociatedObject_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            MapContents cont = ControlTreeHelper.FindAncestorOfType <MapContents>(AssociatedObject);

            if (cont == null)
            {
                return;
            }

            MapContentsConfiguration conf = cont.DataContext as MapContentsConfiguration;

            if (conf == null)
            {
                return;
            }

            if (ToolPanels.Current != null && !string.IsNullOrWhiteSpace(conf.ContextMenuToolPanelName))
            {
                _toolPanel = ToolPanels.Current[conf.ContextMenuToolPanelName];
            }

            if (_toolPanel == null)
            {
                return;
            }

            _contextMenu = new ContextMenu();
            if (ContextMenuStyle != null)
            {
                _contextMenu.Style = ContextMenuStyle;
            }

            // Bind background and foreground properties to context menu
            Binding b = new Binding("ContextMenuBackground")
            {
                Source = this
            };

            _contextMenu.SetBinding(ContextMenu.BackgroundProperty, b);

            b = new Binding("ContextMenuForeground")
            {
                Source = this
            };
            _contextMenu.SetBinding(ContextMenu.ForegroundProperty, b);

            // set the control to the current culture settings (LTR/RTL)
            RTLHelper helper = System.Windows.Application.Current.Resources["RTLHelper"] as RTLHelper;

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

            foreach (FrameworkElement button in _toolPanel.ToolPanelItems)
            {
                System.Windows.Controls.Primitives.ButtonBase btnBase = button as System.Windows.Controls.Primitives.ButtonBase;
                if (btnBase != null)
                {
                    MenuItem          item = new MenuItem();
                    ButtonDisplayInfo info = btnBase.DataContext as ButtonDisplayInfo;
                    if (info != null)
                    {
                        item.Header = info.Label;
                        if (!string.IsNullOrEmpty(info.Icon))
                        {
                            Image   image   = new Image();
                            Binding binding = new Binding("Icon")
                            {
                                Converter = _urlResolver
                            };
                            image.SetBinding(Image.SourceProperty, binding);
                            image.DataContext = info;
                            item.Icon         = image;
                        }
                        item.Command = btnBase.Command;
                        _contextMenu.Items.Add(item);
                    }
                }
                else
                {
                    _contextMenu.Items.Add(new Separator());
                }
            }

            Point point = e.GetPosition(null);

            if (point != null)
            {
                _contextMenu.HorizontalOffset = point.X;
                _contextMenu.VerticalOffset   = point.Y;
            }

            LayerItemViewModel layerViewModel = AssociatedObject.DataContext as LayerItemViewModel;

            if (layerViewModel != null && layerViewModel.Layer != null)
            {
                if (!CoreExtensions.GetIsSelected(layerViewModel.Layer))
                {
                    SetSelectedLayer(layerViewModel.Layer);
                }
            }
            if (_contextMenu.Items.Count > 0)
            {
                _contextMenu.IsOpen = true;

                if (_contextMenu.FlowDirection == FlowDirection.RightToLeft)
                {
                    // Now that the popup is open, we can update the layout measurements so that
                    // the ActualWidth is available.
                    _contextMenu.UpdateLayout();
                    _contextMenu.HorizontalOffset -= _contextMenu.ActualWidth;
                }
            }
        }