Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Ink / TextClipboardData.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ZipIOExtraFieldElement.cs
- SQLGuid.cs
- TableItemStyle.cs
- ConnectionStringsExpressionBuilder.cs
- OleDbErrorCollection.cs
- PathGeometry.cs
- validation.cs
- TableColumnCollection.cs
- CustomCategoryAttribute.cs
- Opcode.cs
- ColorConverter.cs
- OperandQuery.cs
- ColumnResizeAdorner.cs
- Html32TextWriter.cs
- SessionViewState.cs
- XmlAttributeAttribute.cs
- GPPOINTF.cs
- ACL.cs
- SqlDataRecord.cs
- WhiteSpaceTrimStringConverter.cs
- CodeGenerator.cs
- DoubleIndependentAnimationStorage.cs
- CLRBindingWorker.cs
- RolePrincipal.cs
- ChangeBlockUndoRecord.cs
- EdmTypeAttribute.cs
- RuntimeResourceSet.cs
- HotSpotCollection.cs
- TypefaceMetricsCache.cs
- LocatorManager.cs
- UrlUtility.cs
- CodeThrowExceptionStatement.cs
- DataView.cs
- TextStore.cs
- DesignerForm.cs
- ListDataBindEventArgs.cs
- FloaterBaseParagraph.cs
- DirectoryInfo.cs
- PersistenceTypeAttribute.cs
- EntityViewContainer.cs
- Misc.cs
- Column.cs
- RelativeSource.cs
- Encoder.cs
- InheritanceRules.cs
- Thickness.cs
- NonBatchDirectoryCompiler.cs
- ProviderMetadata.cs
- Grant.cs
- TableSectionStyle.cs
- ReflectTypeDescriptionProvider.cs
- BuildProviderAppliesToAttribute.cs
- PassportAuthenticationEventArgs.cs
- InvalidDataException.cs
- Paragraph.cs
- RoleManagerEventArgs.cs
- IConvertible.cs
- TableRowCollection.cs
- HtmlInputSubmit.cs
- InvalidateEvent.cs
- UIElement.cs
- WebPartEditorApplyVerb.cs
- PolyBezierSegment.cs
- WebColorConverter.cs
- XhtmlConformanceSection.cs
- TextRunCacheImp.cs
- WebPartMenu.cs
- EnterpriseServicesHelper.cs
- AuthenticationManager.cs
- AutoGeneratedFieldProperties.cs
- IItemContainerGenerator.cs
- TableColumn.cs
- RegionData.cs
- WsdlInspector.cs
- DataGridViewCellConverter.cs
- TimeSpanConverter.cs
- ClientScriptItem.cs
- ConnectionPoolManager.cs
- HtmlEncodedRawTextWriter.cs
- EmissiveMaterial.cs
- TagNameToTypeMapper.cs
- Run.cs
- MetadataCache.cs
- OpCellTreeNode.cs
- SevenBitStream.cs
- SafeNativeMethods.cs
- StandardCommandToolStripMenuItem.cs
- IgnoreDeviceFilterElementCollection.cs
- NamespaceExpr.cs
- _KerberosClient.cs
- WorkflowStateRollbackService.cs
- AutomationPropertyInfo.cs
- IndependentAnimationStorage.cs
- ArgIterator.cs
- RewritingValidator.cs
- SubclassTypeValidator.cs
- StatusBarDrawItemEvent.cs
- ApplicationProxyInternal.cs
- DesignerVerbToolStripMenuItem.cs
- CfgParser.cs