Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- MessageBox.cs
- _HTTPDateParse.cs
- BitmapSource.cs
- PerfCounterSection.cs
- Matrix.cs
- ComponentChangedEvent.cs
- SignedInfo.cs
- WhiteSpaceTrimStringConverter.cs
- SafeTokenHandle.cs
- TableLayoutSettings.cs
- ExtensibleClassFactory.cs
- InkCanvasInnerCanvas.cs
- OleDbFactory.cs
- Errors.cs
- HttpRequest.cs
- TableLayoutPanel.cs
- FolderBrowserDialog.cs
- DbTransaction.cs
- RuntimeHandles.cs
- NativeMethods.cs
- WebHttpSecurityElement.cs
- TextViewBase.cs
- DataGridViewRow.cs
- EntityContainer.cs
- WebControlsSection.cs
- FacetEnabledSchemaElement.cs
- DispatchChannelSink.cs
- KeyboardNavigation.cs
- FileDataSource.cs
- GroupQuery.cs
- TableLayoutPanel.cs
- DynamicPropertyHolder.cs
- PropertyInformation.cs
- DigitalSignature.cs
- SqlBuilder.cs
- TransactionFlowElement.cs
- ReflectionUtil.cs
- DbTransaction.cs
- SerializationFieldInfo.cs
- IndependentlyAnimatedPropertyMetadata.cs
- DocumentViewerBase.cs
- FrameworkElement.cs
- XmlReaderSettings.cs
- RepeaterItemCollection.cs
- TextRunCacheImp.cs
- EqualityArray.cs
- AffineTransform3D.cs
- XmlAttributeOverrides.cs
- File.cs
- URLAttribute.cs
- WS2007FederationHttpBindingCollectionElement.cs
- CacheDependency.cs
- Int32Rect.cs
- SendSecurityHeaderElement.cs
- UnsafeNativeMethodsCLR.cs
- MsmqDecodeHelper.cs
- AncestorChangedEventArgs.cs
- StylusPoint.cs
- BasicCommandTreeVisitor.cs
- NodeFunctions.cs
- WindowsFormsSynchronizationContext.cs
- HostProtectionPermission.cs
- TempFiles.cs
- PropertyDescriptorGridEntry.cs
- LinkedList.cs
- Visual3D.cs
- BitmapPalette.cs
- BitmapEffect.cs
- XslTransform.cs
- COM2IDispatchConverter.cs
- TaskSchedulerException.cs
- StylusLogic.cs
- SortDescriptionCollection.cs
- SqlResolver.cs
- Matrix3D.cs
- WebPartPersonalization.cs
- TrackingCondition.cs
- SqlExpressionNullability.cs
- XhtmlBasicLiteralTextAdapter.cs
- BrowserCapabilitiesFactoryBase.cs
- XamlPoint3DCollectionSerializer.cs
- NativeMethods.cs
- InvalidCastException.cs
- XmlSchemaSimpleTypeUnion.cs
- OracleCommandBuilder.cs
- LinkedList.cs
- FileDialog_Vista.cs
- DocobjHost.cs
- PrintEvent.cs
- ReachFixedPageSerializerAsync.cs
- CryptoKeySecurity.cs
- XmlElementAttribute.cs
- HtmlLink.cs
- ServerValidateEventArgs.cs
- AudioFormatConverter.cs
- Touch.cs
- KeyPressEvent.cs
- SecurityToken.cs
- WebBrowserNavigatedEventHandler.cs
- MethodMessage.cs