Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / Effects / BitmapEffect.cs / 1407647 / BitmapEffect.cs
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2005
//
// File: BitmapEffect.cs
//-----------------------------------------------------------------------------
using MS.Internal;
using System;
using System.IO;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Threading;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Markup;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Media.Imaging;
using System.Security;
using MS.Internal.PresentationCore;
using System.Security.Permissions;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.Effects
{
///
/// BitmapEffect
///
///
/// We have the Inheritance demand, because we don't want
/// third parties to be able to subclass BitmapEffect in the partial trust scenario
///
[UIPermissionAttribute(SecurityAction.InheritanceDemand, Window = UIPermissionWindow.AllWindows)]
public abstract partial class BitmapEffect
{
#region Constructors
///
/// Constructor
///
protected BitmapEffect()
{
// Even though BitmapEffects are obsolete, to preserve compat they are
// still never allowed in partial trust scenarios. The previous BitmapEffects
// would create a native COM object in the constructor, which would demand.
// So, demand UIWindow permission immediately in the ctor.
SecurityHelper.DemandUIWindowPermission();
// STA Requirement
//
// Avalon doesn't necessarily require STA, but many components do. Examples
// include Cicero, OLE, COM, etc. So we throw an exception here if the
// thread is not STA.
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
throw new InvalidOperationException(SR.Get(SRID.RequiresSTA));
}
}
#endregion
#region Protected Methods
///
/// This method is called before calling GetOutput on an effect.
/// It gives a chance for the managed effect to update the properties
/// of the unmanaged object.
///
///
/// Critical - receives a security critical type SafeHandle.
///
[SecurityCritical]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
abstract protected void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect);
///
/// Returns a safe handle to an unmanaged effect clone
///
///
/// Critical - returns a security critical type SafeHandle.
///
[SecurityCritical]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe abstract protected SafeHandle CreateUnmanagedEffect();
///
/// SetValue
///
/// SafeHandle to the unmanaged effect object
/// Name of the unmanaged property to be set
/// Object value to set unmanaged property to
///
///
/// Critical - calls native code
/// TreatAsSafe - as there is a demand
///
[SecurityCritical, SecurityTreatAsSafe]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe static protected void SetValue(SafeHandle effect, string propertyName, object value)
{
SecurityHelper.DemandUIWindowPermission();
}
///
/// Creates an IMILBitmapEffect object
///
/// IMILBitmapEffect object
///
/// Critical - calls native code
/// TreatAsSafe - as there is a demand
///
[SecurityCritical, SecurityTreatAsSafe]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe static protected SafeHandle /* IMILBitmapEffect */ CreateBitmapEffectOuter()
{
SecurityHelper.DemandUIWindowPermission();
return null;
}
///
/// Initializes the IMILBitmapEffect object with the IMILBitmapEffectPrimitive object
///
/// The IMILBitmapEffect object
/// The IMILBitmapEffectPrimitive object
///
/// Critical - calls native code
/// TreatAsSafe - as there is a demand
///
[SecurityCritical, SecurityTreatAsSafe]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe static protected void InitializeBitmapEffect(SafeHandle /*IMILBitmapEffect */ outerObject,
SafeHandle/* IMILBitmapEffectPrimitive */ innerObject)
{
SecurityHelper.DemandUIWindowPermission();
}
#endregion
#region Public Methods
///
/// This returns the output at index 0
///
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
public BitmapSource GetOutput(BitmapEffectInput input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
// if we don't have the input set, we should not be calling the output property
if (input.Input == null)
{
throw new ArgumentException(SR.Get(SRID.Effect_No_InputSource), "input");
}
if (input.Input == BitmapEffectInput.ContextInputSource)
{
throw new InvalidOperationException(SR.Get(SRID.Effect_No_ContextInputSource, null));
}
return input.Input.Clone();
}
#endregion
#region Internal Methods
///
/// True if the effect can be emulated by the Effect pipeline. Derived classes
/// can override this method to indicate that they can be emulated using the ImageEffect
/// pipeline. If a derived class returns true it needs to also implement the GetEmulatingImageEffect
/// property to provide an emulating ImageEffect.
///
internal virtual bool CanBeEmulatedUsingEffectPipeline()
{
return false;
}
///
/// Derived classes need to return an emulating image effect if they return true from CanBeEmulatedUsingImageEffectPipeline.
///
internal virtual Effect GetEmulatingEffect()
{
throw new NotImplementedException();
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2005
//
// File: BitmapEffect.cs
//-----------------------------------------------------------------------------
using MS.Internal;
using System;
using System.IO;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Threading;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Markup;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Media.Imaging;
using System.Security;
using MS.Internal.PresentationCore;
using System.Security.Permissions;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.Effects
{
///
/// BitmapEffect
///
///
/// We have the Inheritance demand, because we don't want
/// third parties to be able to subclass BitmapEffect in the partial trust scenario
///
[UIPermissionAttribute(SecurityAction.InheritanceDemand, Window = UIPermissionWindow.AllWindows)]
public abstract partial class BitmapEffect
{
#region Constructors
///
/// Constructor
///
protected BitmapEffect()
{
// Even though BitmapEffects are obsolete, to preserve compat they are
// still never allowed in partial trust scenarios. The previous BitmapEffects
// would create a native COM object in the constructor, which would demand.
// So, demand UIWindow permission immediately in the ctor.
SecurityHelper.DemandUIWindowPermission();
// STA Requirement
//
// Avalon doesn't necessarily require STA, but many components do. Examples
// include Cicero, OLE, COM, etc. So we throw an exception here if the
// thread is not STA.
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
throw new InvalidOperationException(SR.Get(SRID.RequiresSTA));
}
}
#endregion
#region Protected Methods
///
/// This method is called before calling GetOutput on an effect.
/// It gives a chance for the managed effect to update the properties
/// of the unmanaged object.
///
///
/// Critical - receives a security critical type SafeHandle.
///
[SecurityCritical]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
abstract protected void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect);
///
/// Returns a safe handle to an unmanaged effect clone
///
///
/// Critical - returns a security critical type SafeHandle.
///
[SecurityCritical]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe abstract protected SafeHandle CreateUnmanagedEffect();
///
/// SetValue
///
/// SafeHandle to the unmanaged effect object
/// Name of the unmanaged property to be set
/// Object value to set unmanaged property to
///
///
/// Critical - calls native code
/// TreatAsSafe - as there is a demand
///
[SecurityCritical, SecurityTreatAsSafe]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe static protected void SetValue(SafeHandle effect, string propertyName, object value)
{
SecurityHelper.DemandUIWindowPermission();
}
///
/// Creates an IMILBitmapEffect object
///
/// IMILBitmapEffect object
///
/// Critical - calls native code
/// TreatAsSafe - as there is a demand
///
[SecurityCritical, SecurityTreatAsSafe]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe static protected SafeHandle /* IMILBitmapEffect */ CreateBitmapEffectOuter()
{
SecurityHelper.DemandUIWindowPermission();
return null;
}
///
/// Initializes the IMILBitmapEffect object with the IMILBitmapEffectPrimitive object
///
/// The IMILBitmapEffect object
/// The IMILBitmapEffectPrimitive object
///
/// Critical - calls native code
/// TreatAsSafe - as there is a demand
///
[SecurityCritical, SecurityTreatAsSafe]
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
unsafe static protected void InitializeBitmapEffect(SafeHandle /*IMILBitmapEffect */ outerObject,
SafeHandle/* IMILBitmapEffectPrimitive */ innerObject)
{
SecurityHelper.DemandUIWindowPermission();
}
#endregion
#region Public Methods
///
/// This returns the output at index 0
///
[Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
public BitmapSource GetOutput(BitmapEffectInput input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
// if we don't have the input set, we should not be calling the output property
if (input.Input == null)
{
throw new ArgumentException(SR.Get(SRID.Effect_No_InputSource), "input");
}
if (input.Input == BitmapEffectInput.ContextInputSource)
{
throw new InvalidOperationException(SR.Get(SRID.Effect_No_ContextInputSource, null));
}
return input.Input.Clone();
}
#endregion
#region Internal Methods
///
/// True if the effect can be emulated by the Effect pipeline. Derived classes
/// can override this method to indicate that they can be emulated using the ImageEffect
/// pipeline. If a derived class returns true it needs to also implement the GetEmulatingImageEffect
/// property to provide an emulating ImageEffect.
///
internal virtual bool CanBeEmulatedUsingEffectPipeline()
{
return false;
}
///
/// Derived classes need to return an emulating image effect if they return true from CanBeEmulatedUsingImageEffectPipeline.
///
internal virtual Effect GetEmulatingEffect()
{
throw new NotImplementedException();
}
#endregion
}
}
// 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
- Win32.cs
- BridgeDataRecord.cs
- Path.cs
- NamedObject.cs
- MetadataItem_Static.cs
- CursorEditor.cs
- CellParaClient.cs
- _DigestClient.cs
- ActiveXContainer.cs
- TdsParserSessionPool.cs
- TextSelectionHighlightLayer.cs
- AnnotationService.cs
- DelegateSerializationHolder.cs
- TypefaceMetricsCache.cs
- ObjectReaderCompiler.cs
- ComponentEditorPage.cs
- HttpHandlerActionCollection.cs
- ReferenceService.cs
- DiagnosticsConfigurationHandler.cs
- HttpWebResponse.cs
- MbpInfo.cs
- HtmlTable.cs
- StaticTextPointer.cs
- ColorEditor.cs
- TimeoutValidationAttribute.cs
- SelectorAutomationPeer.cs
- FixedSOMElement.cs
- ProtocolsSection.cs
- XmlTextReader.cs
- DependencyObjectValidator.cs
- CallbackWrapper.cs
- BuildProvider.cs
- Pair.cs
- PublisherMembershipCondition.cs
- DataComponentNameHandler.cs
- HtmlInputPassword.cs
- HttpModule.cs
- RegistryPermission.cs
- WebBrowserPermission.cs
- CommonRemoteMemoryBlock.cs
- SelectionRange.cs
- Model3DGroup.cs
- ExpressionEditorAttribute.cs
- Expressions.cs
- ParameterReplacerVisitor.cs
- CreateUserWizardStep.cs
- DependencyPropertyAttribute.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- TreeViewImageKeyConverter.cs
- CompiledQueryCacheEntry.cs
- Zone.cs
- Win32MouseDevice.cs
- SimpleWorkerRequest.cs
- SQLRoleProvider.cs
- TabControlCancelEvent.cs
- JavaScriptObjectDeserializer.cs
- XmlLinkedNode.cs
- MetadataArtifactLoaderComposite.cs
- MediaPlayer.cs
- RegistrySecurity.cs
- PriorityBindingExpression.cs
- SecurityHelper.cs
- UpdateException.cs
- TextEditorThreadLocalStore.cs
- WebPartMinimizeVerb.cs
- Activator.cs
- ChangeProcessor.cs
- ApplicationHost.cs
- UnmanagedMemoryAccessor.cs
- Size3DConverter.cs
- TextBoxBaseDesigner.cs
- DetailsViewRowCollection.cs
- OleDbConnectionFactory.cs
- DetailsViewDeleteEventArgs.cs
- EnvelopedPkcs7.cs
- ConfigurationSectionCollection.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- TabControlDesigner.cs
- TextEncodedRawTextWriter.cs
- SByte.cs
- ResXResourceWriter.cs
- AppliesToBehaviorDecisionTable.cs
- LabelTarget.cs
- NativeRecognizer.cs
- Size3D.cs
- DesignerAttributeInfo.cs
- Repeater.cs
- IntSecurity.cs
- TagMapInfo.cs
- EntityClientCacheKey.cs
- HttpResponseInternalBase.cs
- Pair.cs
- ConnectionsZone.cs
- DefaultPropertyAttribute.cs
- GeneralTransform3DTo2D.cs
- PiiTraceSource.cs
- ClientEventManager.cs
- ChildTable.cs
- QilLoop.cs
- ControlAdapter.cs