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
- ISO2022Encoding.cs
- LayoutManager.cs
- ConfigurationPropertyAttribute.cs
- InstanceKeyCollisionException.cs
- FixedSOMSemanticBox.cs
- Subtree.cs
- RenderingEventArgs.cs
- PrinterSettings.cs
- PageCatalogPart.cs
- BamlStream.cs
- SingleSelectRootGridEntry.cs
- DSACryptoServiceProvider.cs
- WindowsFormsHelpers.cs
- Int64KeyFrameCollection.cs
- HTMLTagNameToTypeMapper.cs
- TextLineBreak.cs
- LinkUtilities.cs
- OrthographicCamera.cs
- XPathBuilder.cs
- Qualifier.cs
- XmlAttributeCache.cs
- DataGridRow.cs
- PolyLineSegmentFigureLogic.cs
- ListViewContainer.cs
- Token.cs
- ApplicationCommands.cs
- CachedRequestParams.cs
- _BufferOffsetSize.cs
- MDIControlStrip.cs
- ActivityBuilderHelper.cs
- RadioButtonStandardAdapter.cs
- InternalControlCollection.cs
- ReferenceSchema.cs
- DataTemplateSelector.cs
- ComboBoxRenderer.cs
- MarkupExtensionParser.cs
- WindowsFormsHostPropertyMap.cs
- ProfileProvider.cs
- ParserContext.cs
- TreeViewHitTestInfo.cs
- ImageCodecInfo.cs
- ActionMessageFilter.cs
- Size.cs
- QueryExpr.cs
- ResXBuildProvider.cs
- DataGridViewAutoSizeModeEventArgs.cs
- QueryableFilterRepeater.cs
- TrustManagerMoreInformation.cs
- JoinElimination.cs
- SQLByteStorage.cs
- StackSpiller.Temps.cs
- ColumnClickEvent.cs
- FragmentQueryKB.cs
- CategoryGridEntry.cs
- XmlObjectSerializerReadContextComplex.cs
- StorageAssociationSetMapping.cs
- UrlMappingCollection.cs
- ResourceProviderFactory.cs
- StateWorkerRequest.cs
- IntMinMaxAggregationOperator.cs
- Cursor.cs
- DesignTimeParseData.cs
- DependentList.cs
- IdnMapping.cs
- TextCollapsingProperties.cs
- ColorAnimation.cs
- DataGridViewImageColumn.cs
- DeliveryStrategy.cs
- NullReferenceException.cs
- StagingAreaInputItem.cs
- SocketAddress.cs
- GlyphCache.cs
- AutomationElement.cs
- SoapSchemaMember.cs
- UpdateRecord.cs
- RegexBoyerMoore.cs
- BindingListCollectionView.cs
- ResourceContainer.cs
- SpellerInterop.cs
- figurelengthconverter.cs
- EtwTrace.cs
- View.cs
- DecoderBestFitFallback.cs
- Accessible.cs
- DataControlHelper.cs
- WebSysDefaultValueAttribute.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- ComplusEndpointConfigContainer.cs
- RealizationContext.cs
- SqlDataAdapter.cs
- SQLRoleProvider.cs
- CodeTypeMemberCollection.cs
- ArglessEventHandlerProxy.cs
- HtmlWindowCollection.cs
- SchemaCollectionCompiler.cs
- WindowsEditBox.cs
- FrameworkElement.cs
- SafeRightsManagementHandle.cs
- SqlGatherProducedAliases.cs
- PropertyStore.cs