Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------------- // // 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
- TypeResolver.cs
- diagnosticsswitches.cs
- Ref.cs
- HttpRequest.cs
- AutomationIdentifierGuids.cs
- Line.cs
- metadatamappinghashervisitor.cs
- RecommendedAsConfigurableAttribute.cs
- TemplateAction.cs
- TreeNode.cs
- Accessors.cs
- QilName.cs
- Odbc32.cs
- Attributes.cs
- XmlProcessingInstruction.cs
- WebPartZoneBase.cs
- InteropBitmapSource.cs
- RandomNumberGenerator.cs
- ResourceExpressionBuilder.cs
- TransactionFlowElement.cs
- ExpressionEvaluator.cs
- RijndaelManaged.cs
- TypefaceMap.cs
- Function.cs
- log.cs
- UnsafeNativeMethods.cs
- DesignTimeType.cs
- ReflectionUtil.cs
- DocumentOrderQuery.cs
- URLString.cs
- XmlILStorageConverter.cs
- UIHelper.cs
- Activator.cs
- FastEncoder.cs
- DBConnectionString.cs
- SequenceRangeCollection.cs
- Wildcard.cs
- ImageField.cs
- SerializationInfoEnumerator.cs
- FixedSOMPage.cs
- ConsoleKeyInfo.cs
- DataService.cs
- ProfileEventArgs.cs
- DataError.cs
- ConfigurationValues.cs
- MessageRpc.cs
- XhtmlConformanceSection.cs
- QuotedPrintableStream.cs
- ColorBlend.cs
- ObjectPersistData.cs
- IEnumerable.cs
- MailBnfHelper.cs
- XmlAttributeAttribute.cs
- EntityContainerEmitter.cs
- RadioButton.cs
- __FastResourceComparer.cs
- WebPartDesigner.cs
- TypedTableHandler.cs
- InternalsVisibleToAttribute.cs
- WebPartConnectionsDisconnectVerb.cs
- XsltArgumentList.cs
- DataGridViewCellMouseEventArgs.cs
- LongMinMaxAggregationOperator.cs
- BamlResourceSerializer.cs
- ChannelManager.cs
- LinqDataSourceValidationException.cs
- UnmanagedMemoryStream.cs
- AnimatedTypeHelpers.cs
- FrameworkContentElement.cs
- HttpVersion.cs
- SecurityCapabilities.cs
- CompilationLock.cs
- ForeignConstraint.cs
- ToolboxItemAttribute.cs
- StrongNameSignatureInformation.cs
- ClusterSafeNativeMethods.cs
- RoutedEvent.cs
- XPathArrayIterator.cs
- XmlNodeComparer.cs
- ChannelManager.cs
- FunctionCommandText.cs
- CommonXSendMessage.cs
- CompilationSection.cs
- NavigateUrlConverter.cs
- BindingGroup.cs
- PersianCalendar.cs
- TransformedBitmap.cs
- AdornerHitTestResult.cs
- ReadOnlyDictionary.cs
- ImageDesigner.cs
- Exceptions.cs
- ConnectionString.cs
- FileNotFoundException.cs
- EnvironmentPermission.cs
- IsolatedStorage.cs
- WithStatement.cs
- X509PeerCertificateElement.cs
- EventLogPermissionEntryCollection.cs
- Point4D.cs
- ListBox.cs