Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / MS / Internal / Ink / TextClipboardData.cs / 1 / TextClipboardData.cs
//----------------------------------------------------------------------------
//
// File: TextClipboardData.cs
//
// Description:
// A base class which can copy a unicode text to the IDataObject.
// It also can get the unicode text from the IDataObject and create a corresponding textbox.
//
// Features:
//
// History:
// 11/17/2004 waynezen: Created
//
// Copyright (C) 2001 by Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Text;
namespace MS.Internal.Ink
{
internal class TextClipboardData : ElementsClipboardData
{
//-------------------------------------------------------------------------------
//
// Constructors
//
//-------------------------------------------------------------------------------
#region Constructors
// The default constructor
internal TextClipboardData() : this(null) {}
// The constructor with a string as argument
internal TextClipboardData(string text)
{
_text = text;
}
#endregion Constructors
// Checks if the data can be pasted.
internal override bool CanPaste(IDataObject dataObject)
{
return ( dataObject.GetDataPresent(DataFormats.UnicodeText, false)
|| dataObject.GetDataPresent(DataFormats.Text, false)
|| dataObject.GetDataPresent(DataFormats.OemText, false) );
}
//--------------------------------------------------------------------------------
//
// Protected Methods
//
//-------------------------------------------------------------------------------
#region Protected Methods
// Checks if the data can be copied.
protected override bool CanCopy()
{
return !string.IsNullOrEmpty(_text);
}
// Copy the text to the IDataObject
protected override void DoCopy(IDataObject dataObject)
{
// Put the text to the clipboard
dataObject.SetData(DataFormats.UnicodeText, _text, true);
}
// Retrieves the text from the IDataObject instance.
// Then create a textbox with the text data.
protected override void DoPaste(IDataObject dataObject)
{
ElementList = new List();
// Get the string from the data object.
string text = dataObject.GetData(DataFormats.UnicodeText, true) as string;
if ( String.IsNullOrEmpty(text) )
{
// OemText can be retrieved as CF_TEXT.
text = dataObject.GetData(DataFormats.Text, true) as string;
}
if ( !String.IsNullOrEmpty(text) )
{
// Now, create a text box and set the text to it.
TextBox textBox = new TextBox();
textBox.Text = text;
textBox.TextWrapping = TextWrapping.Wrap;
// Add the textbox to the internal array list.
ElementList.Add(textBox);
}
}
#endregion Protected Methods
//--------------------------------------------------------------------------------
//
// Private Fields
//
//--------------------------------------------------------------------------------
#region Private Fields
private string _text;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// File: TextClipboardData.cs
//
// Description:
// A base class which can copy a unicode text to the IDataObject.
// It also can get the unicode text from the IDataObject and create a corresponding textbox.
//
// Features:
//
// History:
// 11/17/2004 waynezen: Created
//
// Copyright (C) 2001 by Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Text;
namespace MS.Internal.Ink
{
internal class TextClipboardData : ElementsClipboardData
{
//-------------------------------------------------------------------------------
//
// Constructors
//
//-------------------------------------------------------------------------------
#region Constructors
// The default constructor
internal TextClipboardData() : this(null) {}
// The constructor with a string as argument
internal TextClipboardData(string text)
{
_text = text;
}
#endregion Constructors
// Checks if the data can be pasted.
internal override bool CanPaste(IDataObject dataObject)
{
return ( dataObject.GetDataPresent(DataFormats.UnicodeText, false)
|| dataObject.GetDataPresent(DataFormats.Text, false)
|| dataObject.GetDataPresent(DataFormats.OemText, false) );
}
//--------------------------------------------------------------------------------
//
// Protected Methods
//
//-------------------------------------------------------------------------------
#region Protected Methods
// Checks if the data can be copied.
protected override bool CanCopy()
{
return !string.IsNullOrEmpty(_text);
}
// Copy the text to the IDataObject
protected override void DoCopy(IDataObject dataObject)
{
// Put the text to the clipboard
dataObject.SetData(DataFormats.UnicodeText, _text, true);
}
// Retrieves the text from the IDataObject instance.
// Then create a textbox with the text data.
protected override void DoPaste(IDataObject dataObject)
{
ElementList = new List();
// Get the string from the data object.
string text = dataObject.GetData(DataFormats.UnicodeText, true) as string;
if ( String.IsNullOrEmpty(text) )
{
// OemText can be retrieved as CF_TEXT.
text = dataObject.GetData(DataFormats.Text, true) as string;
}
if ( !String.IsNullOrEmpty(text) )
{
// Now, create a text box and set the text to it.
TextBox textBox = new TextBox();
textBox.Text = text;
textBox.TextWrapping = TextWrapping.Wrap;
// Add the textbox to the internal array list.
ElementList.Add(textBox);
}
}
#endregion Protected Methods
//--------------------------------------------------------------------------------
//
// Private Fields
//
//--------------------------------------------------------------------------------
#region Private Fields
private string _text;
#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
- WSDualHttpBindingElement.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- ThreadAbortException.cs
- COM2ExtendedTypeConverter.cs
- DbProviderFactoriesConfigurationHandler.cs
- XmlArrayAttribute.cs
- XdrBuilder.cs
- EncryptedType.cs
- StorageConditionPropertyMapping.cs
- WebScriptMetadataMessageEncoderFactory.cs
- _ContextAwareResult.cs
- APCustomTypeDescriptor.cs
- BamlTreeNode.cs
- PeerResolverSettings.cs
- AnimationClock.cs
- RayMeshGeometry3DHitTestResult.cs
- AddInControllerImpl.cs
- PermissionRequestEvidence.cs
- CharacterBuffer.cs
- SoapHeaders.cs
- WebHttpEndpointElement.cs
- TextViewSelectionProcessor.cs
- ProviderBase.cs
- FormsAuthenticationTicket.cs
- AssemblyLoader.cs
- CssStyleCollection.cs
- CngUIPolicy.cs
- GacUtil.cs
- TextServicesCompartmentContext.cs
- Point4D.cs
- PenLineJoinValidation.cs
- WebBrowsableAttribute.cs
- ByteStorage.cs
- TextMessageEncodingElement.cs
- WebServiceParameterData.cs
- SimpleWebHandlerParser.cs
- ItemsControl.cs
- AutoScrollHelper.cs
- Pts.cs
- ContentFileHelper.cs
- ToolStripItemCollection.cs
- VectorKeyFrameCollection.cs
- KeyGestureValueSerializer.cs
- LazyLoadBehavior.cs
- CompilationUtil.cs
- DateTimeConverter2.cs
- HideDisabledControlAdapter.cs
- CaseInsensitiveComparer.cs
- RoleManagerEventArgs.cs
- ChannelManager.cs
- ReceiveMessageContent.cs
- DataGridCellInfo.cs
- PathTooLongException.cs
- SqlCrossApplyToCrossJoin.cs
- ToolStripComboBox.cs
- KeySpline.cs
- SwitchLevelAttribute.cs
- ConfigurationFileMap.cs
- AvTraceFormat.cs
- AppSecurityManager.cs
- BitmapCodecInfoInternal.cs
- BreakRecordTable.cs
- InstanceHandleConflictException.cs
- XmlNodeChangedEventManager.cs
- RuleInfoComparer.cs
- DataGridTablesFactory.cs
- DllNotFoundException.cs
- DependencyPropertyKey.cs
- AssociationEndMember.cs
- TextParagraphCache.cs
- HttpResponseHeader.cs
- XmlByteStreamReader.cs
- TableParaClient.cs
- InterleavedZipPartStream.cs
- HeaderElement.cs
- GridViewCellAutomationPeer.cs
- DataTableReader.cs
- ColumnResult.cs
- PlatformNotSupportedException.cs
- GraphicsPath.cs
- SerialPinChanges.cs
- ModuleConfigurationInfo.cs
- DispatcherTimer.cs
- JoinTreeSlot.cs
- ColumnClickEvent.cs
- DataGridCellAutomationPeer.cs
- ResXBuildProvider.cs
- ReflectionServiceProvider.cs
- ViewManagerAttribute.cs
- CustomWebEventKey.cs
- ReaderOutput.cs
- CharAnimationUsingKeyFrames.cs
- BuildResult.cs
- X509Utils.cs
- LiteralLink.cs
- XPathPatternParser.cs
- XmlUtf8RawTextWriter.cs
- RegexWorker.cs
- GeneralTransform3DTo2DTo3D.cs
- GlyphRunDrawing.cs