Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ScrollItemPatternIdentifiers.cs
- Region.cs
- LocalizableResourceBuilder.cs
- AdPostCacheSubstitution.cs
- CellTreeNode.cs
- DataTablePropertyDescriptor.cs
- NTAccount.cs
- dataobject.cs
- VarInfo.cs
- XmlResolver.cs
- FileDialogCustomPlacesCollection.cs
- InkCanvas.cs
- MetadataException.cs
- SqlDataSourceCache.cs
- DocumentPaginator.cs
- WebPartsPersonalizationAuthorization.cs
- CodeDomLocalizationProvider.cs
- ProfileGroupSettings.cs
- ColumnReorderedEventArgs.cs
- QuaternionKeyFrameCollection.cs
- TextStore.cs
- TryExpression.cs
- EventListenerClientSide.cs
- EditingCoordinator.cs
- PropertyChangedEventArgs.cs
- SubclassTypeValidatorAttribute.cs
- ContainsRowNumberChecker.cs
- TabItemWrapperAutomationPeer.cs
- ResXDataNode.cs
- DoubleStorage.cs
- ModelTypeConverter.cs
- HelpInfo.cs
- MsmqProcessProtocolHandler.cs
- XamlFigureLengthSerializer.cs
- Helpers.cs
- CompModSwitches.cs
- ClickablePoint.cs
- SmiMetaData.cs
- CodeExporter.cs
- SQLMembershipProvider.cs
- CatalogPartChrome.cs
- SqlDataSourceSelectingEventArgs.cs
- AccessibleObject.cs
- TypeExtension.cs
- ListBoxItem.cs
- KeyInstance.cs
- Clipboard.cs
- RtfToken.cs
- UrlMappingsSection.cs
- ContainerAction.cs
- TokenBasedSetEnumerator.cs
- ButtonField.cs
- FloaterBaseParaClient.cs
- Statements.cs
- HijriCalendar.cs
- ManagedWndProcTracker.cs
- Comparer.cs
- DrawTreeNodeEventArgs.cs
- DockPanel.cs
- TemplateComponentConnector.cs
- Error.cs
- OperationSelectorBehavior.cs
- XmlSchemaCollection.cs
- Debugger.cs
- EntityViewGenerationConstants.cs
- _LocalDataStoreMgr.cs
- Literal.cs
- DocumentPaginator.cs
- SqlProvider.cs
- UIElementCollection.cs
- MenuItemCollection.cs
- TypeGeneratedEventArgs.cs
- DBCommandBuilder.cs
- XmlSchemaSimpleTypeUnion.cs
- Drawing.cs
- UserUseLicenseDictionaryLoader.cs
- Quaternion.cs
- SchemaElement.cs
- MenuItemStyleCollection.cs
- ProxyElement.cs
- MimeMultiPart.cs
- Receive.cs
- CustomLineCap.cs
- RectangleGeometry.cs
- GridViewRowCollection.cs
- NodeInfo.cs
- BitmapSource.cs
- HandlerMappingMemo.cs
- MetadataCache.cs
- RedirectionProxy.cs
- HostProtectionPermission.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs
- XmlDeclaration.cs
- BaseServiceProvider.cs
- RootProjectionNode.cs
- SplitterCancelEvent.cs
- RegexWriter.cs
- RouteItem.cs
- CompressionTransform.cs
- CurrencyWrapper.cs