Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Documents / InputScopeAttribute.cs / 1 / InputScopeAttribute.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: InputScopeAttribute is an image object that links IOleDataObject.
//
// History:
// 10/02/2003 : yutakas
//
//---------------------------------------------------------------------------
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using System.Diagnostics;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Documents;
using System.Windows.Controls;
using MS.Win32;
namespace System.Windows.Documents
{
//
// InputScopeAttribute is Image object that links IOleDataObject, which
// is insterted by ITextStoreACP::InsertEmbedded().
//
internal class InputScopeAttribute : UnsafeNativeMethods.ITfInputScope
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
// Creates a new InputScopeAttribute instance.
internal InputScopeAttribute(InputScope inputscope)
{
_inputScope= inputscope;
}
#endregion Constructors
//------------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
#region Internal Methods
// A method of ITfInputScope.
// This returns InputScopes in the array that is allocated by CoTaskMemAlloc.
///
/// Critical - it satisfies Marshal.* LinkDemands for unmanaged code permissions. handles out a valid pointer to unmanaged memory.
///
[SecurityCritical]
public void GetInputScopes(out IntPtr ppinputscopes, out int count)
{
if (_inputScope != null)
{
int offset = 0;
count = _inputScope.Names.Count;
try
{
ppinputscopes = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Int32)) * count);
}
catch (OutOfMemoryException)
{
throw new COMException(SR.Get(SRID.InputScopeAttribute_E_OUTOFMEMORY), NativeMethods.E_OUTOFMEMORY);
}
for (int i = 0; i < count; i++)
{
Marshal.WriteInt32(ppinputscopes, offset, (Int32)((InputScopeName)_inputScope.Names[i]).NameValue);
offset += Marshal.SizeOf(typeof(Int32));
}
}
else
{
ppinputscopes = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Int32)) * 1);
Marshal.WriteInt32(ppinputscopes, (Int32)InputScopeNameValue.Default);
count = 1;
}
}
// A method of ITfInputScope.
// This returns BSTRs in the array that is allocated by CoTaskMemAlloc.
///
/// Critical - it satisfies Marshal.AllocCoTaskMem() LinkDemand for unmanaged code permissions. handles out a valid pointer to unmanaged memory.
///
[SecurityCritical]
public int GetPhrase(out IntPtr ppbstrPhrases, out int count)
{
count = _inputScope == null ? 0 : _inputScope.PhraseList.Count;
try
{
ppbstrPhrases = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr))*count);
}
catch (OutOfMemoryException)
{
throw new COMException(SR.Get(SRID.InputScopeAttribute_E_OUTOFMEMORY), NativeMethods.E_OUTOFMEMORY);
}
int offset = 0;
for(int i=0; i 0 ? NativeMethods.S_OK : NativeMethods.S_FALSE;
}
// A method of ITfInputScope.
public int GetRegularExpression(out string desc)
{
desc = null;
if (_inputScope != null)
{
desc = _inputScope.RegularExpression;
}
return desc != null ? NativeMethods.S_OK : NativeMethods.S_FALSE;
}
// A method of ITfInputScope.
public int GetSRGC(out string desc)
{
desc = null;
if (_inputScope != null)
{
desc = _inputScope.SrgsMarkup;
}
return desc != null ? NativeMethods.S_OK : NativeMethods.S_FALSE;
}
// A method of ITfInputScope.
public int GetXML(out string desc)
{
desc = null;
return NativeMethods.S_FALSE;
}
#endregion Internal Methods
//------------------------------------------------------
//
// Internal Properties
//
//------------------------------------------------------
#region Internal Properties
#endregion Internal Properties
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
// InputScope value for this instance for ITfInputScope.
private InputScope _inputScope;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: InputScopeAttribute is an image object that links IOleDataObject.
//
// History:
// 10/02/2003 : yutakas
//
//---------------------------------------------------------------------------
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using System.Diagnostics;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Documents;
using System.Windows.Controls;
using MS.Win32;
namespace System.Windows.Documents
{
//
// InputScopeAttribute is Image object that links IOleDataObject, which
// is insterted by ITextStoreACP::InsertEmbedded().
//
internal class InputScopeAttribute : UnsafeNativeMethods.ITfInputScope
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
// Creates a new InputScopeAttribute instance.
internal InputScopeAttribute(InputScope inputscope)
{
_inputScope= inputscope;
}
#endregion Constructors
//------------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
#region Internal Methods
// A method of ITfInputScope.
// This returns InputScopes in the array that is allocated by CoTaskMemAlloc.
///
/// Critical - it satisfies Marshal.* LinkDemands for unmanaged code permissions. handles out a valid pointer to unmanaged memory.
///
[SecurityCritical]
public void GetInputScopes(out IntPtr ppinputscopes, out int count)
{
if (_inputScope != null)
{
int offset = 0;
count = _inputScope.Names.Count;
try
{
ppinputscopes = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Int32)) * count);
}
catch (OutOfMemoryException)
{
throw new COMException(SR.Get(SRID.InputScopeAttribute_E_OUTOFMEMORY), NativeMethods.E_OUTOFMEMORY);
}
for (int i = 0; i < count; i++)
{
Marshal.WriteInt32(ppinputscopes, offset, (Int32)((InputScopeName)_inputScope.Names[i]).NameValue);
offset += Marshal.SizeOf(typeof(Int32));
}
}
else
{
ppinputscopes = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Int32)) * 1);
Marshal.WriteInt32(ppinputscopes, (Int32)InputScopeNameValue.Default);
count = 1;
}
}
// A method of ITfInputScope.
// This returns BSTRs in the array that is allocated by CoTaskMemAlloc.
///
/// Critical - it satisfies Marshal.AllocCoTaskMem() LinkDemand for unmanaged code permissions. handles out a valid pointer to unmanaged memory.
///
[SecurityCritical]
public int GetPhrase(out IntPtr ppbstrPhrases, out int count)
{
count = _inputScope == null ? 0 : _inputScope.PhraseList.Count;
try
{
ppbstrPhrases = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr))*count);
}
catch (OutOfMemoryException)
{
throw new COMException(SR.Get(SRID.InputScopeAttribute_E_OUTOFMEMORY), NativeMethods.E_OUTOFMEMORY);
}
int offset = 0;
for(int i=0; i 0 ? NativeMethods.S_OK : NativeMethods.S_FALSE;
}
// A method of ITfInputScope.
public int GetRegularExpression(out string desc)
{
desc = null;
if (_inputScope != null)
{
desc = _inputScope.RegularExpression;
}
return desc != null ? NativeMethods.S_OK : NativeMethods.S_FALSE;
}
// A method of ITfInputScope.
public int GetSRGC(out string desc)
{
desc = null;
if (_inputScope != null)
{
desc = _inputScope.SrgsMarkup;
}
return desc != null ? NativeMethods.S_OK : NativeMethods.S_FALSE;
}
// A method of ITfInputScope.
public int GetXML(out string desc)
{
desc = null;
return NativeMethods.S_FALSE;
}
#endregion Internal Methods
//------------------------------------------------------
//
// Internal Properties
//
//------------------------------------------------------
#region Internal Properties
#endregion Internal Properties
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
// InputScope value for this instance for ITfInputScope.
private InputScope _inputScope;
#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
- RoutedEventArgs.cs
- BaseParagraph.cs
- ClientBuildManagerCallback.cs
- CallSiteHelpers.cs
- Utility.cs
- FormDocumentDesigner.cs
- EntityStoreSchemaGenerator.cs
- ClientSettingsProvider.cs
- ResourceWriter.cs
- KeyValueInternalCollection.cs
- SafeHandles.cs
- TrackingServices.cs
- CompiledRegexRunnerFactory.cs
- HtmlInputHidden.cs
- HatchBrush.cs
- TransportSecurityProtocolFactory.cs
- storepermission.cs
- SecureStringHasher.cs
- Parser.cs
- Pen.cs
- InvokeProviderWrapper.cs
- DirectoryInfo.cs
- SapiRecoInterop.cs
- Animatable.cs
- TextDecorationCollection.cs
- SerTrace.cs
- GeneralTransform3DTo2D.cs
- MdImport.cs
- FixUp.cs
- ToolStripDropDownClosedEventArgs.cs
- HtmlInputButton.cs
- SplineKeyFrames.cs
- PersonalizationDictionary.cs
- ComponentResourceKey.cs
- HttpConfigurationSystem.cs
- Identity.cs
- Debugger.cs
- StreamMarshaler.cs
- TextEditor.cs
- MdImport.cs
- HtmlInputPassword.cs
- PolicyException.cs
- UnknownBitmapEncoder.cs
- AnnotationMap.cs
- FixedElement.cs
- DataGridItemCollection.cs
- SizeKeyFrameCollection.cs
- InstanceNameConverter.cs
- Root.cs
- EditBehavior.cs
- ExtensibleClassFactory.cs
- FolderBrowserDialogDesigner.cs
- BufferedGraphicsContext.cs
- TextBoxBaseDesigner.cs
- HttpListenerElement.cs
- XmlSchemaAnnotated.cs
- HtmlControlPersistable.cs
- PartitionerQueryOperator.cs
- MatcherBuilder.cs
- Drawing.cs
- InvokeGenerator.cs
- PreviewKeyDownEventArgs.cs
- CardSpacePolicyElement.cs
- EncodedStreamFactory.cs
- DataGridPagerStyle.cs
- EventLogPermissionAttribute.cs
- AssemblySettingAttributes.cs
- UnauthorizedWebPart.cs
- TransformerConfigurationWizardBase.cs
- IssuerInformation.cs
- FunctionCommandText.cs
- VerticalAlignConverter.cs
- DetailsViewInsertedEventArgs.cs
- TabControlAutomationPeer.cs
- DataGridAutomationPeer.cs
- Track.cs
- MarginsConverter.cs
- XmlQueryCardinality.cs
- XNodeSchemaApplier.cs
- DataGridViewCellStateChangedEventArgs.cs
- MediaSystem.cs
- SvcMapFileLoader.cs
- StylusPointPropertyInfo.cs
- Accessible.cs
- ImageInfo.cs
- DeploymentExceptionMapper.cs
- LookupBindingPropertiesAttribute.cs
- PropertyIdentifier.cs
- Pair.cs
- FlowLayoutPanel.cs
- CodeCommentStatementCollection.cs
- NamedElement.cs
- ExtensionsSection.cs
- WindowsAuthenticationEventArgs.cs
- Html32TextWriter.cs
- AutomationTextAttribute.cs
- ValueExpressions.cs
- TCPListener.cs
- DateTimeFormatInfo.cs
- Debug.cs