Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / Documents / TextEditorTables.cs / 1 / TextEditorTables.cs
//---------------------------------------------------------------------------- // // File: TextEditorTables.cs // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: A Component of TextEditor supporting Table editing commands // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using MS.Internal; using System.Globalization; using System.Threading; using System.ComponentModel; using System.Text; using System.Collections; // ArrayList using System.Runtime.InteropServices; using System.Windows.Threading; using System.Windows.Input; using System.Windows.Controls; // ScrollChangedEventArgs using System.Windows.Controls.Primitives; // CharacterCasing, TextBoxBase using System.Windows.Media; using System.Windows.Markup; using MS.Utility; using MS.Win32; using MS.Internal.Documents; using MS.Internal.Commands; // CommandHelpers ////// Text editing service for controls. /// internal static class TextEditorTables { //----------------------------------------------------- // // Class Internal Methods // //----------------------------------------------------- #region Class Internal Methods // Registers all text editing command handlers for a given control type internal static void _RegisterClassHandlers(Type controlType, bool registerEventListeners) { CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertTable , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeyInsertTable), SR.Get(SRID.KeyInsertTableDisplayString)) ); CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertRows , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeyInsertRows), SR.Get(SRID.KeyInsertRowsDisplayString)) ); CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertColumns , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeyInsertColumns), SR.Get(SRID.KeyInsertColumnsDisplayString)) ); CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.DeleteRows , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeyDeleteRows), SR.Get(SRID.KeyDeleteRowsDisplayString)) ); CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.DeleteColumns , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeyDeleteColumns), SR.Get(SRID.KeyDeleteColumnsDisplayString)) ); CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.MergeCells , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeyMergeCells), SR.Get(SRID.KeyMergeCellsDisplayString)) ); CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.SplitCell , new ExecutedRoutedEventHandler(OnTableCommand) , new CanExecuteRoutedEventHandler(OnQueryStatusNYI), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.KeySplitCell), SR.Get(SRID.KeySplitCellDisplayString)) ); } #endregion Class Internal Methods //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- #region Private Methods private static void OnTableCommand(object target, ExecutedRoutedEventArgs args) { TextEditor This = TextEditor._GetTextEditor(target); if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection)) { return; } TextEditorTyping._FlushPendingInputItems(This); // Forget previously suggested horizontal position TextEditorSelection._ClearSuggestedX(This); // Execute the command if (args.Command == EditingCommands.InsertTable) { ((TextSelection)This.Selection).InsertTable(/*rowCount:*/4, /*columnCount:*/4); } else if (args.Command == EditingCommands.InsertRows) { ((TextSelection)This.Selection).InsertRows(+1); } else if (args.Command == EditingCommands.InsertColumns) { ((TextSelection)This.Selection).InsertColumns(+1); } else if (args.Command == EditingCommands.DeleteRows) { ((TextSelection)This.Selection).DeleteRows(); } else if (args.Command == EditingCommands.DeleteColumns) { ((TextSelection)This.Selection).DeleteColumns(); } else if (args.Command == EditingCommands.MergeCells) { ((TextSelection)This.Selection).MergeCells(); } else if (args.Command == EditingCommands.SplitCell) { ((TextSelection)This.Selection).SplitCell(1000, 1000); // Split all ways to possible maximum } } // ---------------------------------------------------------- // // Misceleneous Commands // // ---------------------------------------------------------- #region Misceleneous Commands ////// StartInputCorrection command QueryStatus handler /// private static void OnQueryStatusNYI(object target, CanExecuteRoutedEventArgs args) { TextEditor This = TextEditor._GetTextEditor(target); if (This == null) { return; } args.CanExecute = true; } #endregion Misceleneous Commands #endregion Private methods } } // 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
- TemplateControlCodeDomTreeGenerator.cs
- GridViewUpdatedEventArgs.cs
- PersonalizationStateInfoCollection.cs
- EventDriven.cs
- RichTextBox.cs
- WebPartZone.cs
- wgx_render.cs
- SecondaryViewProvider.cs
- InvalidateEvent.cs
- CodeGotoStatement.cs
- XDeferredAxisSource.cs
- WebColorConverter.cs
- CodeBlockBuilder.cs
- UserNamePasswordValidator.cs
- MediaPlayerState.cs
- BeginStoryboard.cs
- ModifierKeysValueSerializer.cs
- SystemDropShadowChrome.cs
- ProtocolsSection.cs
- WindowPatternIdentifiers.cs
- OdbcConnectionHandle.cs
- ResourceExpressionEditor.cs
- AutomationTextAttribute.cs
- SiteMap.cs
- ProgressPage.cs
- StrokeNodeOperations.cs
- CreateUserWizardStep.cs
- StrongNamePublicKeyBlob.cs
- HttpsTransportBindingElement.cs
- Types.cs
- Typography.cs
- DataGridAddNewRow.cs
- XmlComment.cs
- BooleanToVisibilityConverter.cs
- CatalogPartChrome.cs
- IntAverageAggregationOperator.cs
- BaseTemplateCodeDomTreeGenerator.cs
- BufferModesCollection.cs
- ContextMenu.cs
- ReflectionHelper.cs
- CryptoStream.cs
- CompareValidator.cs
- MLangCodePageEncoding.cs
- RtfToXamlLexer.cs
- BuilderPropertyEntry.cs
- TextElement.cs
- ObfuscationAttribute.cs
- StorageComplexTypeMapping.cs
- HyperLinkStyle.cs
- ToggleButton.cs
- SystemWebSectionGroup.cs
- JournalEntryListConverter.cs
- RunWorkerCompletedEventArgs.cs
- LocalFileSettingsProvider.cs
- SoapIgnoreAttribute.cs
- UnicodeEncoding.cs
- DbTransaction.cs
- SwitchElementsCollection.cs
- MimeTypeMapper.cs
- SerialStream.cs
- ProxyWebPartConnectionCollection.cs
- SafeFileHandle.cs
- ClassImporter.cs
- ListControl.cs
- SpoolingTask.cs
- SmtpDigestAuthenticationModule.cs
- CheckedListBox.cs
- BindMarkupExtensionSerializer.cs
- Material.cs
- FormsAuthenticationUserCollection.cs
- AlternateView.cs
- HashMembershipCondition.cs
- CallInfo.cs
- documentsequencetextpointer.cs
- Block.cs
- PropertyChangedEventManager.cs
- DispatcherOperation.cs
- SerializationStore.cs
- ToggleProviderWrapper.cs
- SerTrace.cs
- WebBrowserProgressChangedEventHandler.cs
- TransformerConfigurationWizardBase.cs
- PrintPreviewGraphics.cs
- GridProviderWrapper.cs
- UrlAuthFailureHandler.cs
- UriParserTemplates.cs
- BlurEffect.cs
- ThicknessAnimationBase.cs
- TextElementAutomationPeer.cs
- Win32.cs
- DocumentReferenceCollection.cs
- DocumentViewerBaseAutomationPeer.cs
- UnsafeNativeMethods.cs
- DefaultValueAttribute.cs
- TriState.cs
- RuntimeConfigurationRecord.cs
- CodeMemberProperty.cs
- UnauthorizedAccessException.cs
- BindingManagerDataErrorEventArgs.cs
- CanonicalizationDriver.cs