Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / TrustUi / MS / Internal / documents / RightsManagementResourceHelper.cs / 1 / RightsManagementResourceHelper.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: // RMResourceHelper is a helper class used to get resources. // // History: // 06/21/05 - [....] created // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Drawing; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.TrustUI; using System.Globalization; // For localization of string conversion using System.Security.Cryptography.X509Certificates; using System.Security.RightsManagement; using System.Security; namespace MS.Internal.Documents { internal sealed class RightsManagementResourceHelper { #region Constructors //----------------------------------------------------- // Constructors //----------------------------------------------------- ////// The constructor /// private RightsManagementResourceHelper() { } #endregion Constructors #region Internal Methods //------------------------------------------------------ // Internal Methods //----------------------------------------------------- ////// GetDocumentLevelResources. /// internal static DocumentStatusResources GetDocumentLevelResources(RightsManagementStatus status) { DocumentStatusResources docStatusResources = new DocumentStatusResources(); // Set appropriate Text and ToolTip values. switch (status) { case (RightsManagementStatus.Protected): docStatusResources.Text = SR.Get(SRID.RMProtected); docStatusResources.ToolTip = SR.Get(SRID.RMAppliedToolTip); break; default: // RightsManagementStatus.Unknown or RightsManagementStatus.Unprotected docStatusResources.Text = String.Empty; docStatusResources.ToolTip = SR.Get(SRID.RMDefaultToolTip); break; } docStatusResources.Image = GetDrawingBrushFromStatus(status); return docStatusResources; } ////// GetCredentialManagementResources. /// /// The user object from which to get resources ////// Critical /// 1) Returns critical information from a user object /// [SecurityCritical] internal static string GetCredentialManagementResources(RightsManagementUser user) { string accountName = null; if (user == null) { throw new ArgumentNullException("user"); } switch (user.AuthenticationType) { case (AuthenticationType.Windows): accountName = String.Format( CultureInfo.CurrentCulture, SR.Get(SRID.RMCredManagementWindowsAccount), user.Name); break; case (AuthenticationType.Passport): accountName = String.Format( CultureInfo.CurrentCulture, SR.Get(SRID.RMCredManagementPassportAccount), user.Name); break; default: accountName = String.Format( CultureInfo.CurrentCulture, SR.Get(SRID.RMCredManagementUnknownAccount), user.Name); break; } return accountName; } #endregion Internal Methods #region Private Methods //-------------------------------------------------------------------------- // Private Methods //-------------------------------------------------------------------------- ////// Get the DrawingBrush icon for the status. /// /// Requested status ///A DrawingBrush on success (valid status, DrawingBrush found), null otherwise. private static DrawingBrush GetDrawingBrushFromStatus(RightsManagementStatus status) { if (_brushResources == null) { // Get the entire list of RightsManagementStatus values. Array statusList = Enum.GetValues(typeof(RightsManagementStatus)); // Construct the array to hold brush references. _brushResources = new DrawingBrush[statusList.Length]; // To find the DrawingBrushes in the theme resources we need a FrameworkElement. // TextBlock was used as it appears to have a very small footprint, and won't // take long to construct. The actual FrameworkElement doesn't matter as long // as we have an instance to one _frameworkElement = new TextBlock(); } if ((_brushResources != null) && (_frameworkElement != null)) { int index = (int)status; // If there is no cached value of the requested DrawingBrush, then find // it in the Resources. if (_brushResources[index] == null) { // Determine resource name. string resourceName = "PUIRMStatus" + Enum.GetName(typeof(RightsManagementStatus), status) + "BrushKey"; // Acquire reference to the brush. object resource = _frameworkElement.FindResource( new ComponentResourceKey(typeof(PresentationUIStyleResources), resourceName)); // Set cache value for the brush. _brushResources[index] = resource as DrawingBrush; } return _brushResources[index]; } return null; } #endregion Private Methods private static DrawingBrush[] _brushResources; // To cache DrawingBrushes. private static FrameworkElement _frameworkElement; // Used to search resources. } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContentDefinition.cs
- SaveFileDialog.cs
- SurrogateEncoder.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- WindowsSpinner.cs
- XamlPoint3DCollectionSerializer.cs
- BindingExpressionUncommonField.cs
- XmlDataSourceNodeDescriptor.cs
- Simplifier.cs
- DataGridViewSortCompareEventArgs.cs
- ListBindableAttribute.cs
- SecurityContextCookieSerializer.cs
- OleDbCommand.cs
- RadioButtonList.cs
- CheckedListBox.cs
- ToolStripDropDownClosingEventArgs.cs
- CodeThrowExceptionStatement.cs
- MessageVersion.cs
- FormParameter.cs
- DbConnectionStringCommon.cs
- RangeValuePatternIdentifiers.cs
- IntSecurity.cs
- ADConnectionHelper.cs
- EtwTrace.cs
- FontWeightConverter.cs
- WebPartZoneCollection.cs
- ListItemParagraph.cs
- KeyFrames.cs
- LinkButton.cs
- Focus.cs
- ProcessHostFactoryHelper.cs
- MonitoringDescriptionAttribute.cs
- ScriptingProfileServiceSection.cs
- ResourceManagerWrapper.cs
- SymmetricAlgorithm.cs
- RequiredArgumentAttribute.cs
- IsolatedStorageException.cs
- CustomExpression.cs
- PolicyManager.cs
- OAVariantLib.cs
- KeyGestureValueSerializer.cs
- DefaultValueConverter.cs
- SpellerError.cs
- ConfigsHelper.cs
- FullTextLine.cs
- EventSinkHelperWriter.cs
- UnsafeCollabNativeMethods.cs
- AuthorizationSection.cs
- OutputCacheModule.cs
- SafeThemeHandle.cs
- ShapingEngine.cs
- LinqToSqlWrapper.cs
- BaseComponentEditor.cs
- Misc.cs
- Vector3DConverter.cs
- OracleCommand.cs
- HashHelper.cs
- ToolStripLocationCancelEventArgs.cs
- TrackingServices.cs
- StateDesignerConnector.cs
- CfgParser.cs
- DbProviderServices.cs
- TimeSpanSecondsConverter.cs
- MatrixConverter.cs
- MailMessageEventArgs.cs
- NavigateUrlConverter.cs
- ScriptManagerProxy.cs
- ToolStripArrowRenderEventArgs.cs
- CanonicalFontFamilyReference.cs
- SafeArrayTypeMismatchException.cs
- CompilerLocalReference.cs
- SequentialUshortCollection.cs
- EditorAttribute.cs
- ToolStripArrowRenderEventArgs.cs
- SerialReceived.cs
- cryptoapiTransform.cs
- RemotingConfigParser.cs
- DbProviderFactory.cs
- SelectionEditingBehavior.cs
- FtpWebResponse.cs
- Rijndael.cs
- SetterBase.cs
- DataGridViewColumnCollection.cs
- ManagementNamedValueCollection.cs
- SqlMethodTransformer.cs
- _StreamFramer.cs
- ResourceManager.cs
- NegatedCellConstant.cs
- AppDomainShutdownMonitor.cs
- WebServiceFaultDesigner.cs
- UserMapPath.cs
- PowerStatus.cs
- FragmentQuery.cs
- CreateUserErrorEventArgs.cs
- FileEnumerator.cs
- MsmqIntegrationBinding.cs
- SQLDecimal.cs
- TemplateBuilder.cs
- DataRelationCollection.cs
- HttpWebResponse.cs