private void UnsubscribeToDpiChanged() { if (_dpiChangedWeakEventListener != null) { var dpiChangedListener = _dpiChangedWeakEventListener; _dpiChangedWeakEventListener = null; CompatUtility.ExecuteOnUIThread(dpiChangedListener.Detach, Dispatcher); } }
override void OnApplyTemplate() { base.OnApplyTemplate(); // Get a reference to the templated parts _image = GetTemplateChild("Image") as Image; if (_image == null) { throw new Exception("Missing 'Image' Template part."); } // Initialize default swatch dpi with the view dpi _swatchDpi = CompatUtility.IsDesignMode ? 96.0 : CompatUtility.LogicalDpi(this); }
/// <summary> /// Stop listening for the dependency property changed. /// </summary> public void Detach() { if (_relayObject != null) { CompatUtility.ExecuteOnUIThread(() => { if (_relayObject != null) { _relayObject.Dispose(); _relayObject = null; } }, _relayObject.Dispatcher); } }
/// <summary> /// Challenge for getting the credential allowing to access to the specified ArcGIS resource. /// </summary> /// <param name="credentialRequestInfo">Information about the ArcGIS resource that needs a credential for getting access to.</param> /// <returns>a Task object with <see cref="Credential"/> upon successful completion. /// Otherwise, the Task.Exception is set.</returns> public virtual Task <Credential> CreateCredentialAsync(CredentialRequestInfo credentialRequestInfo) { if (credentialRequestInfo == null) { throw new ArgumentNullException("credentialRequestInfo"); } var serverInfo = IdentityManager.Current.FindServerInfo(credentialRequestInfo.ServiceUri); if (credentialRequestInfo.AuthenticationType == AuthenticationType.Certificate) { // Challenge for a certificate return(CompatUtility.ExecuteOnUIThread(() => CreateCertificateCredentialAsync(credentialRequestInfo))); } // Check if we need to use OAuth for login. // In this case we don't have to display the SignInDialog by ourself but we have to go through the OAuth authorization page bool isOauth = false; if (serverInfo != null && credentialRequestInfo.AuthenticationType == AuthenticationType.Token) { if (serverInfo.TokenAuthenticationType != TokenAuthenticationType.ArcGISToken) { isOauth = true; // portal secured by OAuth } else if (!string.IsNullOrEmpty(serverInfo.OwningSystemUri)) { // server federated to OAuth portal? // Check if the portal uses OAuth isOauth = IdentityManager.Current.ServerInfos.Any(s => SameOwningSystem(s, serverInfo) && s.TokenAuthenticationType != TokenAuthenticationType.ArcGISToken); } } if (isOauth) { // OAuth case --> call GenerateCredentialAsync (that will throw an exception if the OAuthAuthorize component is not set) return(CreateOAuthCredentialAsync(credentialRequestInfo)); } // Display the sign in dialog and create a credential return(SignInDialogCreateCredentialAsync(credentialRequestInfo)); }
/// <summary> /// Challenge handler leaveraging the SignInDialog in a child window dialog. /// </summary> public Task <Credential> CreateCredentialAsync(CredentialRequestInfo credentialRequestInfo) { return(CompatUtility.ExecuteOnUIThread(() => DoSignInInUIThread(credentialRequestInfo))); }
private void OnSwatchDpiChanged(double newValue) { _swatchDpi = newValue > 0.0 ? newValue : CompatUtility.LogicalDpi(this); SetDirty(); }