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
- CollectionViewGroupRoot.cs
- WorkflowQueue.cs
- BooleanExpr.cs
- ArgIterator.cs
- TextRangeBase.cs
- AnnouncementEndpoint.cs
- DiscoveryMessageProperty.cs
- TreeNodeConverter.cs
- Int32AnimationUsingKeyFrames.cs
- StorageMappingItemCollection.cs
- SymLanguageVendor.cs
- HostedBindingBehavior.cs
- RegexMatchCollection.cs
- PackageDigitalSignature.cs
- ScaleTransform.cs
- SettingsBindableAttribute.cs
- _ListenerRequestStream.cs
- _UriTypeConverter.cs
- Control.cs
- EventQueueState.cs
- DataObject.cs
- ScriptControlManager.cs
- StateChangeEvent.cs
- TypeLibraryHelper.cs
- ItemCheckedEvent.cs
- TextReader.cs
- BaseCodeDomTreeGenerator.cs
- PinnedBufferMemoryStream.cs
- Imaging.cs
- AsymmetricSecurityProtocolFactory.cs
- UrlMappingsSection.cs
- DrawingBrush.cs
- JavaScriptSerializer.cs
- OverlappedAsyncResult.cs
- ScriptingRoleServiceSection.cs
- StrongNameMembershipCondition.cs
- TreeView.cs
- DuplicateContext.cs
- ReadOnlyNameValueCollection.cs
- UnicastIPAddressInformationCollection.cs
- thaishape.cs
- OdbcRowUpdatingEvent.cs
- PositiveTimeSpanValidatorAttribute.cs
- ListItemCollection.cs
- XmlAttribute.cs
- DBDataPermission.cs
- DockProviderWrapper.cs
- ActiveXHost.cs
- clipboard.cs
- RefreshPropertiesAttribute.cs
- PenThread.cs
- SchemaSetCompiler.cs
- RuntimeConfig.cs
- Camera.cs
- SAPIEngineTypes.cs
- InputLanguageProfileNotifySink.cs
- ExternalCalls.cs
- DelegatedStream.cs
- DataControlButton.cs
- VariableBinder.cs
- VisualBrush.cs
- ToolTip.cs
- QualificationDataAttribute.cs
- EntityConnection.cs
- RijndaelManaged.cs
- RIPEMD160.cs
- ThousandthOfEmRealDoubles.cs
- InlineCollection.cs
- SiteMapDataSource.cs
- XXXOnTypeBuilderInstantiation.cs
- DoubleMinMaxAggregationOperator.cs
- SmiMetaDataProperty.cs
- TextEndOfParagraph.cs
- DispatchChannelSink.cs
- SafeEventLogWriteHandle.cs
- MapPathBasedVirtualPathProvider.cs
- KeyFrames.cs
- NamespaceImport.cs
- PackUriHelper.cs
- ListSortDescription.cs
- OrderedDictionary.cs
- LineBreakRecord.cs
- CodeCompileUnit.cs
- AdapterUtil.cs
- DropTarget.cs
- DtdParser.cs
- MediaTimeline.cs
- TreeNodeBindingCollection.cs
- DataColumnSelectionConverter.cs
- Rect3DConverter.cs
- OleDragDropHandler.cs
- DiagnosticTraceRecords.cs
- ArcSegment.cs
- DocumentPaginator.cs
- BindingList.cs
- TextPointer.cs
- CustomBindingCollectionElement.cs
- ConfigurationValidatorBase.cs
- xsdvalidator.cs
- FunctionImportElement.cs