Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / TextEditorTables.cs / 1305600 / 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)
{
var onTableCommand = new ExecutedRoutedEventHandler(OnTableCommand);
var onQueryStatusNYI = new CanExecuteRoutedEventHandler(OnQueryStatusNYI);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertTable , onTableCommand, onQueryStatusNYI, SRID.KeyInsertTable, SRID.KeyInsertTableDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertRows , onTableCommand, onQueryStatusNYI, SRID.KeyInsertRows, SRID.KeyInsertRowsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertColumns , onTableCommand, onQueryStatusNYI, SRID.KeyInsertColumns, SRID.KeyInsertColumnsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.DeleteRows , onTableCommand, onQueryStatusNYI, SRID.KeyDeleteRows, SRID.KeyDeleteRowsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.DeleteColumns , onTableCommand, onQueryStatusNYI, SRID.KeyDeleteColumns, SRID.KeyDeleteColumnsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.MergeCells , onTableCommand, onQueryStatusNYI, SRID.KeyMergeCells, SRID.KeyMergeCellsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.SplitCell , onTableCommand, onQueryStatusNYI, SRID.KeySplitCell, 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.
//----------------------------------------------------------------------------
//
// 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)
{
var onTableCommand = new ExecutedRoutedEventHandler(OnTableCommand);
var onQueryStatusNYI = new CanExecuteRoutedEventHandler(OnQueryStatusNYI);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertTable , onTableCommand, onQueryStatusNYI, SRID.KeyInsertTable, SRID.KeyInsertTableDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertRows , onTableCommand, onQueryStatusNYI, SRID.KeyInsertRows, SRID.KeyInsertRowsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.InsertColumns , onTableCommand, onQueryStatusNYI, SRID.KeyInsertColumns, SRID.KeyInsertColumnsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.DeleteRows , onTableCommand, onQueryStatusNYI, SRID.KeyDeleteRows, SRID.KeyDeleteRowsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.DeleteColumns , onTableCommand, onQueryStatusNYI, SRID.KeyDeleteColumns, SRID.KeyDeleteColumnsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.MergeCells , onTableCommand, onQueryStatusNYI, SRID.KeyMergeCells, SRID.KeyMergeCellsDisplayString);
CommandHelpers.RegisterCommandHandler(controlType, EditingCommands.SplitCell , onTableCommand, onQueryStatusNYI, SRID.KeySplitCell, 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
- WebBrowserNavigatingEventHandler.cs
- TextBoxRenderer.cs
- DataGridViewDataConnection.cs
- MbpInfo.cs
- SchemaElementDecl.cs
- GlobalizationSection.cs
- LoginDesigner.cs
- NativeMethodsCLR.cs
- UniqueConstraint.cs
- FileDialog_Vista.cs
- InvokeBase.cs
- PersonalizationState.cs
- TextBoxBase.cs
- ScriptReferenceEventArgs.cs
- ReferencedCollectionType.cs
- ColumnPropertiesGroup.cs
- BuildProviderUtils.cs
- BuildProviderAppliesToAttribute.cs
- KeyedQueue.cs
- ResourcePermissionBase.cs
- MouseButtonEventArgs.cs
- Token.cs
- AsymmetricAlgorithm.cs
- LazyInitializer.cs
- SerializableAttribute.cs
- EventRouteFactory.cs
- XmlSchemaCollection.cs
- ExtentCqlBlock.cs
- CssClassPropertyAttribute.cs
- ExpressionsCollectionConverter.cs
- UpdateProgress.cs
- BooleanExpr.cs
- WorkflowService.cs
- MissingFieldException.cs
- PersonalizationEntry.cs
- AppDomainProtocolHandler.cs
- WpfWebRequestHelper.cs
- EntityWithKeyStrategy.cs
- SpanIndex.cs
- TimeBoundedCache.cs
- InfoCardXmlSerializer.cs
- SqlCharStream.cs
- TriggerCollection.cs
- SymbolPair.cs
- SqlEnums.cs
- RenderData.cs
- FamilyMap.cs
- SubMenuStyleCollection.cs
- WebRequestModuleElementCollection.cs
- SourceSwitch.cs
- StrongName.cs
- Base64Stream.cs
- ValidationErrorCollection.cs
- MSAAEventDispatcher.cs
- KeyProperty.cs
- SqlRemoveConstantOrderBy.cs
- PassportAuthenticationModule.cs
- BitmapSourceSafeMILHandle.cs
- UTF32Encoding.cs
- BaseInfoTable.cs
- FontStyles.cs
- CommandPlan.cs
- MetadataPropertyCollection.cs
- FlowDocumentFormatter.cs
- Slider.cs
- XmlSerializerNamespaces.cs
- ColorEditor.cs
- Matrix3D.cs
- Function.cs
- IdentitySection.cs
- ProxySimple.cs
- WebHttpBinding.cs
- MergeFilterQuery.cs
- WorkflowPrinting.cs
- SizeF.cs
- XmlConvert.cs
- HeaderUtility.cs
- Operand.cs
- WebBrowsableAttribute.cs
- BitmapData.cs
- ClientRuntimeConfig.cs
- DropShadowEffect.cs
- NTAccount.cs
- ChtmlPageAdapter.cs
- MexTcpBindingElement.cs
- MailAddress.cs
- DataGridViewRowsRemovedEventArgs.cs
- StylusTip.cs
- FlowLayoutSettings.cs
- GenericWebPart.cs
- SqlInternalConnectionTds.cs
- HtmlControlPersistable.cs
- ServiceModelReg.cs
- TableRowCollection.cs
- XamlBrushSerializer.cs
- TemplateNameScope.cs
- SiteMapDataSourceView.cs
- IndexedString.cs
- MailMessage.cs
- RevocationPoint.cs