Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / MS / Internal / Ink / InkSerializedFormat / MultiByteCodec.cs / 1 / MultiByteCodec.cs
using MS.Utility; using System; using System.Runtime.InteropServices; using System.Security; using System.Globalization; using System.Windows; using System.Windows.Input; using System.Windows.Ink; using System.Collections.Generic; using MS.Internal.Ink.InkSerializedFormat; using System.Diagnostics; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; namespace MS.Internal.Ink.InkSerializedFormat { ////// MultiByteCodec /// internal class MultiByteCodec { ////// MultiByteCodec /// internal MultiByteCodec() { } ////// Encode /// /// /// internal void Encode(uint data, Listoutput) { if (output == null) { throw new ArgumentNullException("output"); } while (data > 0x7f) { byte byteToAdd = (byte)(0x80 | (byte)data & 0x7f); output.Add(byteToAdd); data >>= 7; } byte finalByteToAdd = (byte)(data & 0x7f); output.Add(finalByteToAdd); } /// /// SignEncode /// /// /// internal void SignEncode(int data, Listoutput) { uint xfData = 0; if (data < 0) { xfData = (uint)( (-data << 1) | 0x01 ); } else { xfData = (uint)data << 1; } Encode(xfData, output); } /// /// Decode /// /// /// /// ///internal uint Decode(byte[] input, int inputIndex, ref uint data) { Debug.Assert(input != null); Debug.Assert(inputIndex < input.Length); // We care about first 5 bytes uint cb = (input.Length - inputIndex > 5) ? 5 : (uint)(input.Length - inputIndex); uint index = 0; data = 0; while ((index < cb) && (input[index] > 0x7f)) { int leftShift = (int)(index * 7); data |= (uint)((input[index] & 0x7f) << leftShift); ++index; } if (index < cb) { int leftShift = (int)(index * 7); data |= (uint)((input[index] & 0x7f) << leftShift); } else { throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("invalid input in MultiByteCodec.Decode")); } return (index + 1); } /// /// SignDecode /// /// /// /// ///internal uint SignDecode(byte[] input, int inputIndex, ref int data) { Debug.Assert(input != null); //already validated at the AlgoModule level if (inputIndex >= input.Length) { throw new ArgumentOutOfRangeException("inputIndex"); } uint xfData = 0; uint cb = Decode(input, inputIndex, ref xfData); data = (0 != (0x01 & xfData)) ? -(int)(xfData >> 1) : (int)(xfData >> 1); return cb; } } } // 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
- ArrayListCollectionBase.cs
- GroupDescription.cs
- EditorPartCollection.cs
- DesignerCommandAdapter.cs
- QilParameter.cs
- MessageEnumerator.cs
- StrongNameIdentityPermission.cs
- DesignSurfaceManager.cs
- BitmapEffectInput.cs
- ImageCreator.cs
- DecoderNLS.cs
- ScriptHandlerFactory.cs
- PersistenceContextEnlistment.cs
- UserNameServiceElement.cs
- LinkButton.cs
- XamlClipboardData.cs
- MemoryMappedFileSecurity.cs
- ArgumentDesigner.xaml.cs
- FilteredReadOnlyMetadataCollection.cs
- SingleAnimationUsingKeyFrames.cs
- OdbcConnectionHandle.cs
- DefaultValueMapping.cs
- DataShape.cs
- ObjectStorage.cs
- SchemaNames.cs
- ScriptControlManager.cs
- KoreanLunisolarCalendar.cs
- XmlFormatWriterGenerator.cs
- DataTableTypeConverter.cs
- PageAdapter.cs
- ObjectQueryProvider.cs
- PageBreakRecord.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- WinCategoryAttribute.cs
- EventLogger.cs
- CopyNamespacesAction.cs
- CompiledIdentityConstraint.cs
- DLinqAssociationProvider.cs
- ExpressionBuilderCollection.cs
- Stopwatch.cs
- XXXInfos.cs
- ProfileInfo.cs
- DataGridAutoFormat.cs
- _SSPIWrapper.cs
- TrimSurroundingWhitespaceAttribute.cs
- UITypeEditors.cs
- SmtpLoginAuthenticationModule.cs
- ByeOperation11AsyncResult.cs
- SmtpNegotiateAuthenticationModule.cs
- FontUnitConverter.cs
- DuplexChannel.cs
- LinearQuaternionKeyFrame.cs
- EventMappingSettingsCollection.cs
- PathStreamGeometryContext.cs
- EmptyStringExpandableObjectConverter.cs
- SerialReceived.cs
- RuntimeResourceSet.cs
- ParameterElementCollection.cs
- PanelStyle.cs
- DesignerActionItem.cs
- Knowncolors.cs
- CachedFontFamily.cs
- Single.cs
- OneOf.cs
- BrushValueSerializer.cs
- DefaultAsyncDataDispatcher.cs
- Enumerable.cs
- CopyAttributesAction.cs
- WebEventTraceProvider.cs
- KeyboardEventArgs.cs
- WebControlsSection.cs
- RSAPKCS1SignatureFormatter.cs
- EmptyStringExpandableObjectConverter.cs
- SqlUDTStorage.cs
- cookiecollection.cs
- TraceLevelStore.cs
- DrawingDrawingContext.cs
- BaseAsyncResult.cs
- FileDialog_Vista.cs
- PLINQETWProvider.cs
- AutoResizedEvent.cs
- ColumnPropertiesGroup.cs
- InlinedAggregationOperator.cs
- SiteMapHierarchicalDataSourceView.cs
- AuthenticationService.cs
- WeakReferenceKey.cs
- CustomAttribute.cs
- UnsafeMethods.cs
- NamespaceList.cs
- GenericPrincipal.cs
- HtmlEmptyTagControlBuilder.cs
- EventMappingSettingsCollection.cs
- MarkupCompilePass2.cs
- FloaterBaseParagraph.cs
- ObjectCloneHelper.cs
- HttpWebResponse.cs
- StateFinalizationDesigner.cs
- RealizationDrawingContextWalker.cs
- HttpPostServerProtocol.cs
- WebPartVerbsEventArgs.cs