Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / DragEventArgs.cs / 1 / DragEventArgs.cs
//----------------------------------------------------------------------------
//
// File: DragEventArgs.cs
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// Description: DragEventArgs for drag-and-drop operation.
//
//
// History:
// 08/19/2004 : sangilj Created
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows.Media;
using System.Windows.Input;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows
{
///
/// The DragEventArgs class represents a type of RoutedEventArgs that
/// are relevant to all drag events(DragEnter/DragOver/DragLeave/DragDrop).
///
public sealed class DragEventArgs : RoutedEventArgs
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructs a DragEventArgs instance.
///
///
/// The data object used in this drag drop operation.
///
///
/// The current state of the mouse button and modifier keys.
///
///
/// Allowed effects of a drag-and-drop operation.
///
///
/// The target of the event.
///
///
/// The current mouse position of the target.
///
internal DragEventArgs(IDataObject data, DragDropKeyStates dragDropKeyStates, DragDropEffects allowedEffects, DependencyObject target, Point point)
{
if (!DragDrop.IsValidDragDropKeyStates(dragDropKeyStates))
{
Debug.Assert(false, "Invalid dragDropKeyStates");
}
if (!DragDrop.IsValidDragDropEffects(allowedEffects))
{
Debug.Assert(false, "Invalid allowedEffects");
}
if (target == null)
{
Debug.Assert(false, "Invalid target");
}
this._data = data;
this._dragDropKeyStates = dragDropKeyStates;
this._allowedEffects = allowedEffects;
this._target = target;
this._dropPoint = point;
this._effects = allowedEffects;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// The point of drop operation that based on relativeTo.
///
public Point GetPosition(IInputElement relativeTo)
{
Point dropPoint;
if (relativeTo == null)
{
throw new ArgumentNullException("relativeTo");
}
dropPoint = new Point(0, 0);
if (_target != null)
{
// Translate the drop point from the drop target to the relative element.
dropPoint = InputElement.TranslatePoint(_dropPoint, _target, (DependencyObject)relativeTo);
}
return dropPoint;
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
///
/// The data object of drop operation
///
public IDataObject Data
{
get { return _data; }
}
///
/// The DragDropKeyStates that indicates the current states for
/// physical keyboard keys and mouse buttons.
///
public DragDropKeyStates KeyStates
{
get { return _dragDropKeyStates; }
}
///
/// The allowed effects of drag and drop operation
///
public DragDropEffects AllowedEffects
{
get
{
return _allowedEffects;
}
}
///
/// The effects of drag and drop operation
///
public DragDropEffects Effects
{
get
{
return _effects;
}
set
{
if (!DragDrop.IsValidDragDropEffects(value))
{
throw new ArgumentException(SR.Get(SRID.DragDrop_DragDropEffectsInvalid, "value"));
}
_effects = value;
}
}
#endregion Public Properties
#region Protected Methods
//-----------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
///
/// The mechanism used to call the type-specific handler on the target.
///
///
/// The generic handler to call in a type-specific way.
///
///
/// The target to call the handler on.
///
protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget)
{
DragEventHandler handler = (DragEventHandler)genericHandler;
handler(genericTarget, this);
}
#endregion Protected Methods
//-----------------------------------------------------
//
// Private Fields
//
//-----------------------------------------------------
#region Private Fields
private IDataObject _data;
private DragDropKeyStates _dragDropKeyStates;
private DragDropEffects _allowedEffects;
private DragDropEffects _effects;
private DependencyObject _target;
private Point _dropPoint;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// File: DragEventArgs.cs
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// Description: DragEventArgs for drag-and-drop operation.
//
//
// History:
// 08/19/2004 : sangilj Created
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows.Media;
using System.Windows.Input;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows
{
///
/// The DragEventArgs class represents a type of RoutedEventArgs that
/// are relevant to all drag events(DragEnter/DragOver/DragLeave/DragDrop).
///
public sealed class DragEventArgs : RoutedEventArgs
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructs a DragEventArgs instance.
///
///
/// The data object used in this drag drop operation.
///
///
/// The current state of the mouse button and modifier keys.
///
///
/// Allowed effects of a drag-and-drop operation.
///
///
/// The target of the event.
///
///
/// The current mouse position of the target.
///
internal DragEventArgs(IDataObject data, DragDropKeyStates dragDropKeyStates, DragDropEffects allowedEffects, DependencyObject target, Point point)
{
if (!DragDrop.IsValidDragDropKeyStates(dragDropKeyStates))
{
Debug.Assert(false, "Invalid dragDropKeyStates");
}
if (!DragDrop.IsValidDragDropEffects(allowedEffects))
{
Debug.Assert(false, "Invalid allowedEffects");
}
if (target == null)
{
Debug.Assert(false, "Invalid target");
}
this._data = data;
this._dragDropKeyStates = dragDropKeyStates;
this._allowedEffects = allowedEffects;
this._target = target;
this._dropPoint = point;
this._effects = allowedEffects;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// The point of drop operation that based on relativeTo.
///
public Point GetPosition(IInputElement relativeTo)
{
Point dropPoint;
if (relativeTo == null)
{
throw new ArgumentNullException("relativeTo");
}
dropPoint = new Point(0, 0);
if (_target != null)
{
// Translate the drop point from the drop target to the relative element.
dropPoint = InputElement.TranslatePoint(_dropPoint, _target, (DependencyObject)relativeTo);
}
return dropPoint;
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
///
/// The data object of drop operation
///
public IDataObject Data
{
get { return _data; }
}
///
/// The DragDropKeyStates that indicates the current states for
/// physical keyboard keys and mouse buttons.
///
public DragDropKeyStates KeyStates
{
get { return _dragDropKeyStates; }
}
///
/// The allowed effects of drag and drop operation
///
public DragDropEffects AllowedEffects
{
get
{
return _allowedEffects;
}
}
///
/// The effects of drag and drop operation
///
public DragDropEffects Effects
{
get
{
return _effects;
}
set
{
if (!DragDrop.IsValidDragDropEffects(value))
{
throw new ArgumentException(SR.Get(SRID.DragDrop_DragDropEffectsInvalid, "value"));
}
_effects = value;
}
}
#endregion Public Properties
#region Protected Methods
//-----------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
///
/// The mechanism used to call the type-specific handler on the target.
///
///
/// The generic handler to call in a type-specific way.
///
///
/// The target to call the handler on.
///
protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget)
{
DragEventHandler handler = (DragEventHandler)genericHandler;
handler(genericTarget, this);
}
#endregion Protected Methods
//-----------------------------------------------------
//
// Private Fields
//
//-----------------------------------------------------
#region Private Fields
private IDataObject _data;
private DragDropKeyStates _dragDropKeyStates;
private DragDropEffects _allowedEffects;
private DragDropEffects _effects;
private DependencyObject _target;
private Point _dropPoint;
#endregion Private Fields
}
}
// 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
- UniformGrid.cs
- OleDbParameterCollection.cs
- MailWriter.cs
- CharacterBufferReference.cs
- PropertyToken.cs
- DocumentManager.cs
- MenuAdapter.cs
- HtmlInputControl.cs
- FileUtil.cs
- EpmSyndicationContentSerializer.cs
- HtmlFormParameterWriter.cs
- XamlFilter.cs
- SqlRowUpdatedEvent.cs
- NavigationWindowAutomationPeer.cs
- XmlTypeMapping.cs
- TypeDescriptorContext.cs
- ClientRolePrincipal.cs
- FileUtil.cs
- KeyValuePair.cs
- DispatcherExceptionEventArgs.cs
- remotingproxy.cs
- ProfileBuildProvider.cs
- TrackBarRenderer.cs
- UpDownBase.cs
- JumpList.cs
- Size.cs
- TdsValueSetter.cs
- ColorConvertedBitmap.cs
- VerificationAttribute.cs
- CustomTrackingRecord.cs
- TiffBitmapDecoder.cs
- Nodes.cs
- ChangeDirector.cs
- DataGridViewRowCancelEventArgs.cs
- ViewGenResults.cs
- MarshalByRefObject.cs
- SystemNetworkInterface.cs
- EncryptedPackageFilter.cs
- StorageEntityTypeMapping.cs
- ListViewUpdatedEventArgs.cs
- SrgsElementFactoryCompiler.cs
- IdentityVerifier.cs
- SQLCharsStorage.cs
- UnitySerializationHolder.cs
- SqlAggregateChecker.cs
- NavigateUrlConverter.cs
- Matrix3DValueSerializer.cs
- ServiceOperation.cs
- DecoderFallback.cs
- RequestQueue.cs
- BuildProviderAppliesToAttribute.cs
- Attributes.cs
- TagNameToTypeMapper.cs
- httpstaticobjectscollection.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- WebPartEditorApplyVerb.cs
- NestPullup.cs
- SoapAttributes.cs
- IndentedTextWriter.cs
- CrossAppDomainChannel.cs
- DirtyTextRange.cs
- ValidationHelper.cs
- ExpressionsCollectionEditor.cs
- ProvidePropertyAttribute.cs
- SqlGatherConsumedAliases.cs
- X509ScopedServiceCertificateElement.cs
- XmlLanguage.cs
- PointAnimationBase.cs
- PersistenceContextEnlistment.cs
- ListSurrogate.cs
- RectangleHotSpot.cs
- TimeSpanStorage.cs
- HtmlWindow.cs
- ContractsBCL.cs
- MatchSingleFxEngineOpcode.cs
- Pts.cs
- DataSetViewSchema.cs
- StrongNameMembershipCondition.cs
- PriorityBindingExpression.cs
- CqlErrorHelper.cs
- CompoundFileDeflateTransform.cs
- AmbientValueAttribute.cs
- SharedPerformanceCounter.cs
- DebugHandleTracker.cs
- future.cs
- UIServiceHelper.cs
- SqlRetyper.cs
- CapabilitiesUse.cs
- DbConnectionPoolCounters.cs
- CompilerState.cs
- WebRequestModuleElement.cs
- XhtmlBasicTextBoxAdapter.cs
- QueryOperatorEnumerator.cs
- PropertyNames.cs
- infer.cs
- PagedControl.cs
- StrongNameIdentityPermission.cs
- HGlobalSafeHandle.cs
- RequestCache.cs
- TraceContext.cs