Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / TrustUi / MS / Internal / documents / Application / StatusInfoItem.cs / 1 / StatusInfoItem.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Used to control an (RM or DigSig) InfoBar and ToolBar item in MongooseUI // // History: // 06/22/2005 - [....] created // //--------------------------------------------------------------------------- using MS.Internal.Documents; using System; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Shapes; using System.Windows.TrustUI; namespace MS.Internal.Documents.Application { ////// The type of StatusInfoItem (DigSig, RM) /// internal enum StatusInfoItemType { Unknown, DigSig, RM, } ////// Class used to control an item of the InfoBar, and the relevant ToolBar Button. /// internal class StatusInfoItem { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- ////// Constructs a new StatusInfoItem /// /// Type of Item /// InfoBar button to update /// ToolBar button to update public StatusInfoItem(StatusInfoItemType type, Button infoBarButton, Control toolBarControl) { // Set Type _type = type; // If InfoBar button is not null, set references to the Icon and Text. if (infoBarButton != null) { _infoBarButton = infoBarButton; _infoBarIcon = infoBarButton.Template.FindName("PUIInfoBarIcon", infoBarButton) as Rectangle; _infoBarText = infoBarButton.Template.FindName("PUIInfoBarText", infoBarButton) as TextBlock; } // Set ToolBar button reference. if (toolBarControl != null) { _toolBarControl = toolBarControl; } } //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- ////// Controls the visibility of the InfoBar button. /// public Visibility Visibility { get { return _infoBarButton.Visibility; } set { _infoBarButton.Visibility = value; // When the Visibility is set, notify the DocumentViewer to check the visibility // of the entire InfoBar if (InfoBarVisibilityChanged != null) { InfoBarVisibilityChanged(this, new EventArgs()); } } } //------------------------------------------------------ // // Public Events // //------------------------------------------------------ ////// Fired whenever the visibility has been set on the StatusInfoItem, useful for determining /// if the InfoBar should be hidden. /// public event EventHandler InfoBarVisibilityChanged; //----------------------------------------------------- // // Public Methods // //------------------------------------------------------ ////// Used to be notified of possible DigSig status changes. /// /// /// public void OnStatusChange(object sender, DocumentSignatureManager.SignatureStatusEventArgs args) { if ((args != null) && (_type == StatusInfoItemType.DigSig)) { UpdateUI(args.StatusResources); // If the Document is not signed, collapse the infobar button. if (args.SignatureStatus != SignatureStatus.NotSigned) { this.Visibility = Visibility.Visible; } else { this.Visibility = Visibility.Collapsed; } } } ////// Used to be notified of possible RM status changes. /// /// /// public void OnStatusChange(object sender, DocumentRightsManagementManager.RightsManagementStatusEventArgs args) { if ((args != null) && (_type == StatusInfoItemType.RM)) { UpdateUI(args.StatusResources); // If the Document is not RM protected, collapse the infobar button. if (args.RMStatus == RightsManagementStatus.Protected) { this.Visibility = Visibility.Visible; } else { this.Visibility = Visibility.Collapsed; } } } //----------------------------------------------------- // // Private Methods // //----------------------------------------------------- ////// Used to change the Icons and Text of the InfoBarItems and ToolBarButton. /// /// ////// This function directly updates the UI with information that may be /// used for trust decisions by the user. Since the UI is displayed in /// Avalon controls, however, untrusted callers can directly modify the /// information displayed. As a result making this method critical does /// not add any protection. /// private void UpdateUI(DocumentStatusResources resources) { if (_infoBarIcon != null) { // Set the InfoBar Image _infoBarIcon.Fill = resources.Image; } if (_infoBarText != null) { // Set the InfoBar Text _infoBarText.Text = resources.Text; } if (_infoBarButton != null) { // Set the InfoBar ToolTip _infoBarButton.ToolTip = resources.ToolTip; } if (_toolBarControl != null) { // Set the ToolBarButton Image and ToolTip _toolBarControl.Background = resources.Image; _toolBarControl.ToolTip = resources.ToolTip; } } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ private StatusInfoItemType _type; private Rectangle _infoBarIcon; private TextBlock _infoBarText; private Button _infoBarButton; private Control _toolBarControl; } } // 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
- SystemException.cs
- DocumentGridContextMenu.cs
- SystemResources.cs
- ScrollableControl.cs
- XmlExpressionDumper.cs
- UInt64Storage.cs
- Int32CAMarshaler.cs
- HWStack.cs
- UiaCoreTypesApi.cs
- WSIdentityFaultException.cs
- Assembly.cs
- ClientRuntimeConfig.cs
- PartialList.cs
- XmlSerializationReader.cs
- PageContentCollection.cs
- HyperLinkColumn.cs
- ScriptDescriptor.cs
- XsltException.cs
- ExpressionVisitor.cs
- ToolStripInSituService.cs
- HttpVersion.cs
- ExpressionNode.cs
- HtmlForm.cs
- DataGridItem.cs
- ToolboxItem.cs
- _SecureChannel.cs
- ButtonFlatAdapter.cs
- DeadCharTextComposition.cs
- SourceItem.cs
- OutputCacheProfile.cs
- ProviderException.cs
- UrlParameterReader.cs
- XmlDownloadManager.cs
- Section.cs
- WorkflowApplicationEventArgs.cs
- SQLDoubleStorage.cs
- LoginUtil.cs
- SynchronizedInputPattern.cs
- ToolStripRenderer.cs
- ControllableStoryboardAction.cs
- DbConnectionPoolOptions.cs
- TakeQueryOptionExpression.cs
- MiniCustomAttributeInfo.cs
- DesigntimeLicenseContext.cs
- PackWebRequest.cs
- XmlConvert.cs
- DecimalFormatter.cs
- StringFunctions.cs
- UserControl.cs
- ComplusEndpointConfigContainer.cs
- Rfc2898DeriveBytes.cs
- CacheDependency.cs
- SqlRowUpdatingEvent.cs
- XmlSerializerVersionAttribute.cs
- ProfileService.cs
- TextViewSelectionProcessor.cs
- UnsafeNativeMethods.cs
- ContainerParaClient.cs
- XmlTypeMapping.cs
- DeleteMemberBinder.cs
- NamespaceList.cs
- TypeListConverter.cs
- SmiEventSink.cs
- Error.cs
- ConnectionsZone.cs
- Int16.cs
- NetSectionGroup.cs
- CodeRegionDirective.cs
- CurrentChangingEventManager.cs
- StartUpEventArgs.cs
- SmtpMail.cs
- TargetParameterCountException.cs
- DateTimeSerializationSection.cs
- webeventbuffer.cs
- ReadOnlyDictionary.cs
- ConfigurationCollectionAttribute.cs
- SqlNodeAnnotations.cs
- LassoSelectionBehavior.cs
- CorePropertiesFilter.cs
- ProxyWebPart.cs
- EventProviderWriter.cs
- EncoderExceptionFallback.cs
- ContainsRowNumberChecker.cs
- DtdParser.cs
- Pipe.cs
- ShutDownListener.cs
- ProxyGenerator.cs
- OneOfConst.cs
- ArithmeticException.cs
- XmlEncodedRawTextWriter.cs
- ControlBindingsCollection.cs
- SocketAddress.cs
- CurrentChangingEventArgs.cs
- SR.cs
- DataObjectAttribute.cs
- SystemThemeKey.cs
- IPAddress.cs
- EventLog.cs
- NativeMethodsCLR.cs
- SqlTransaction.cs