Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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 [....]: 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
- SqlNode.cs
- CaseDesigner.xaml.cs
- CompModSwitches.cs
- SchemaElementLookUpTable.cs
- InteropEnvironment.cs
- XmlSchemaType.cs
- TextContainerChangeEventArgs.cs
- XmlCountingReader.cs
- BitmapCodecInfo.cs
- SessionPageStateSection.cs
- NamedElement.cs
- WebPartCancelEventArgs.cs
- ValidatorCompatibilityHelper.cs
- TabPanel.cs
- AssemblyAttributes.cs
- XmlSchemaProviderAttribute.cs
- NetworkCredential.cs
- Enum.cs
- ConfigXmlComment.cs
- DataGridPagerStyle.cs
- ParameterCollection.cs
- OleDbConnectionInternal.cs
- SortKey.cs
- ValidationErrorCollection.cs
- OleDbConnectionInternal.cs
- BindToObject.cs
- CoreSwitches.cs
- SqlCacheDependency.cs
- NavigationCommands.cs
- OperationParameterInfo.cs
- SmiContext.cs
- PrintControllerWithStatusDialog.cs
- DateTimeConstantAttribute.cs
- DateTimeStorage.cs
- WindowsStreamSecurityBindingElement.cs
- IconBitmapDecoder.cs
- IntegerValidator.cs
- ConfigXmlComment.cs
- Process.cs
- CollectionBase.cs
- ElementUtil.cs
- Exceptions.cs
- DocumentXmlWriter.cs
- RealizationDrawingContextWalker.cs
- WriterOutput.cs
- CryptoApi.cs
- DSASignatureDeformatter.cs
- XPathEmptyIterator.cs
- PrintSchema.cs
- sitestring.cs
- CoTaskMemUnicodeSafeHandle.cs
- TypeUnloadedException.cs
- SqlMethodCallConverter.cs
- EUCJPEncoding.cs
- TransformerConfigurationWizardBase.cs
- COM2PictureConverter.cs
- EntityViewGenerator.cs
- GC.cs
- ValidationRuleCollection.cs
- UInt64Storage.cs
- SendSecurityHeaderElement.cs
- MemberHolder.cs
- RoleManagerSection.cs
- TagPrefixAttribute.cs
- SlipBehavior.cs
- StringValueConverter.cs
- TimeZone.cs
- ReservationNotFoundException.cs
- PointCollectionValueSerializer.cs
- WsatServiceAddress.cs
- TypeBuilder.cs
- URLIdentityPermission.cs
- NewArrayExpression.cs
- Expander.cs
- StylusPointPropertyUnit.cs
- TextEditorSelection.cs
- HttpCapabilitiesEvaluator.cs
- NetNamedPipeBinding.cs
- WebConfigurationHost.cs
- EventDriven.cs
- RuntimeUtils.cs
- AlignmentXValidation.cs
- GridViewHeaderRowPresenter.cs
- NeedSkipTokenVisitor.cs
- EncryptedData.cs
- ResourceBinder.cs
- PageCodeDomTreeGenerator.cs
- MachineKeySection.cs
- SafeLibraryHandle.cs
- XmlDataImplementation.cs
- ListInitExpression.cs
- ScriptManager.cs
- connectionpool.cs
- TabletDevice.cs
- ToolStripSystemRenderer.cs
- MaskInputRejectedEventArgs.cs
- XmlConvert.cs
- EntityConnectionStringBuilderItem.cs
- AccessibilityHelperForVista.cs
- IPCCacheManager.cs