public (int, Fase, string) GetBid(BiddingState biddingState, string handsString) { var description = new StringBuilder(128); var bidFromRule = Pinvoke.GetBidFromRuleEx(biddingState.fase, handsString, biddingState.nextBidIdForRule, out var nextfase, description); return(bidFromRule, nextfase, description.ToString()); }
public void TestAuctionsQueens(string testName, string northHand, string southHand, string expectedBidsNorth, string expectedBidsSouth) { // This test can fail because it relies on the sampling and dds. if (testName is null) { throw new ArgumentNullException(nameof(testName)); } logger.Info($"Executing testcase {testName}"); _ = Pinvoke.Setup("Tosr.db3"); var bidManager = new BidManager(new BidGenerator(), fasesWithOffset, reverseDictionaries, true, false); var auction = bidManager.GetAuction(northHand, southHand); var actualBidsSouth = auction.GetBidsAsString(Player.South); Assert.Equal(expectedBidsSouth, actualBidsSouth); var actualBidsNorth = auction.GetBidsAsString(Player.North); Assert.Equal(expectedBidsNorth, actualBidsNorth); var constructedSouthHand = bidManager.biddingInformation.ConstructSouthHand(northHand); Assert.Equal(Util.HandWithx(southHand), constructedSouthHand.First()); var queens = bidManager.biddingInformation.GetQueensFromAuction(auction, reverseDictionaries); Assert.True(BiddingInformation.CheckQueens(queens, southHand)); }
private void ToolStripMenuItem11Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { Pinvoke.Setup(openFileDialog1.FileName); } }
public byte[] GetConversionResult(IntPtr converter) { var length = Pinvoke.wkhtmltopdf_get_output(converter, out var data); var result = new byte[length]; Marshal.Copy(data, result, 0, length); return(result); }
public static void setupTest(string testName, Logger logger) { if (testName is null) { throw new ArgumentNullException(nameof(testName)); } logger.Info($"Executing test-case {testName}"); Pinvoke.Setup("Tosr.db3"); }
/// <summary> /// Creates a new ColorProfileViewModel from a given name, but only /// if the color profile's color space is known by the view model. /// Directory and file extension will be appended automatically. /// Note that the lcms2.dll must have been loaded prior to calling /// this method! /// </summary> /// <param name="fileName">Full file name of the ICS color profile.</param> /// <returns>Instance of ColorProfileViewModel, or null if the color /// profile has an unknown color space.</returns> public static ColorProfileViewModel CreateFromName(string name) { return(CreateFromFile( System.IO.Path.Combine( Pinvoke.GetColorDirectory(), name + Lcms.Constants.COLOR_PROFILE_EXTENSION ) )); }
public void Dispose() { if (_disposed) { throw new ObjectDisposedException("Object already has been disposed"); } Pinvoke.wkhtmltopdf_deinit(); _disposed = true; }
public WorkingClipboard() { try { Pinvoke.OpenClipboard((IntPtr)Excel.ViewModels.Instance.Default.Application.Hwnd); } catch (System.ComponentModel.Win32Exception e) { throw new WorkingClipboardException("Unable to obtain access to Windows clipboard", e); } }
public unsafe string GetObjectSetting(IntPtr settings, string name) { //default const char * size is 2048 bytes var buffer = new byte[2048]; fixed(byte *tempBuffer = buffer) { Pinvoke.wkhtmltopdf_get_object_setting(settings, name, tempBuffer, buffer.Length); } return(GetString(buffer)); }
void Dispose(bool calledFromDispose) { if (!_disposed) { _disposed = true; // Free unmanaged resources (Pinvoke class has static methods) Pinvoke.CloseClipboard(); if (_emfHandle != IntPtr.Zero) { Pinvoke.DeleteEnhMetaFile(_emfHandle); } } }
public void Initialize() { if (_initialized) { throw new InvalidOperationException("WkHtmlToPdf alreay has been initialized"); } if (Pinvoke.wkhtmltopdf_init(0) != 1) { throw new InvalidOperationException("Failed to initialize wkhtmltopdf"); } _initialized = true; }
public static void ExecuteTest() { var fasesWithOffset = JsonConvert.DeserializeObject <Dictionary <Fase, bool> >(File.ReadAllText("FasesWithOffset.json")); var bidGenerator = new BidGenerator(); var expectedSouthBids = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText("expectedSouthBidsPerHand.json")); Pinvoke.Setup("Tosr.db3"); foreach (var(hand, expectedBids) in expectedSouthBids) { var generatedAuction = BidManager.GetAuction(hand, bidGenerator, fasesWithOffset); var generatedSouthBids = generatedAuction.GetBidsAsString(Player.South); Assert.Equal(expectedBids, generatedSouthBids); } }
public static void Resume(this Process process) { foreach (ProcessThread thread in process.Threads) { var handle = Pinvoke.OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id); if (handle == IntPtr.Zero) { break; } Pinvoke.ResumeThread(handle); Pinvoke.CloseHandle(handle); } }
public Form1() { InitializeComponent(); ShowBiddingBox(); ShowAuction(); // Need to set in code because of a .net core bug numericUpDown1.Maximum = 100_000; numericUpDown1.Value = 1000; Shuffle(); BidTillSouth(auctionControl.auction, biddingState); Pinvoke.Setup("Tosr.db3"); openFileDialog1.InitialDirectory = Environment.CurrentDirectory; auctionsShape = LoadAuctions <string>("AuctionsByShape.txt", () => new BatchBidding().GenerateAuctionsForShape()); auctionsControls = LoadAuctions <List <string> >("AuctionsByControls.txt", () => new BatchBidding().GenerateAuctionsForControls()); }
public BasicInject(string Login, string Password) { var task = Task.Run(() => { try { string GamePath = Logic.ini.Sections["GameSettings"].Keys["Path"].Value; ProcessStartInfo processInfo = new ProcessStartInfo(); processInfo.FileName = GamePath; processInfo.Arguments = $"-{Login} -{Password}"; processInfo.ErrorDialog = true; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = true; processInfo.RedirectStandardError = true; processInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(GamePath); Process proc = Process.Start(processInfo); while (proc.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(150); } Injector injector = new Injector(proc); var dll = Directory.GetCurrentDirectory() + "\\libs\\PW_Classic.dll"; var result = injector.Inject(dll); Pinvoke.RECT rct; Pinvoke.GetWindowRect(new HandleRef(this, proc.MainWindowHandle), out rct); int width = rct.Right - rct.Left + 1; int height = rct.Bottom - rct.Top + 1; Pinvoke.MoveWindow(proc.MainWindowHandle, 0, 0, width, height, true); //File.AppendAllText("Autologin.log", $"Путь до dll {dll} + result = {result}" + Environment.NewLine); } catch (Exception ex) { //File.AppendAllText("Autologin.log", ex.Message + Environment.NewLine); } }); }
static string GenPinvokeDecl(Pinvoke pinvoke) { var sb = new StringBuilder(); var method = pinvoke.Method; sb.Append(WasmTuner.MapType(method.ReturnType)); sb.Append($" {pinvoke.EntryPoint} ("); int pindex = 0; foreach (var p in method.Parameters) { if (pindex > 0) { sb.Append(","); } sb.Append(WasmTuner.MapType(method.Parameters [pindex].ParameterType)); pindex++; } sb.Append(");"); return(sb.ToString()); }
public string GetPhaseDescription(IntPtr converter, int phase) { return(Marshal.PtrToStringAnsi(Pinvoke.wkhtmltopdf_phase_description(converter, phase))); }
public void AddObject(IntPtr converter, IntPtr objectSettings, byte[] data) { Pinvoke.wkhtmltopdf_add_object(converter, objectSettings, data); }
public IntPtr CreateConverter(IntPtr globalSettings) { return(Pinvoke.wkhtmltopdf_create_converter(globalSettings)); }
public void DestroyObjectSetting(IntPtr settings) { Pinvoke.wkhtmltopdf_destroy_object_settings(settings); }
public int SetObjectSetting(IntPtr settings, string name, string value) { return(Pinvoke.wkhtmltopdf_set_object_setting(settings, name, value)); }
public void DestroyGlobalSetting(IntPtr settings) { Pinvoke.wkhtmltopdf_destroy_global_settings(settings); }
public IntPtr CreateObjectSettings() { return(Pinvoke.wkhtmltopdf_create_object_settings()); }
public IntPtr CreateGlobalSettings() { return(Pinvoke.wkhtmltopdf_create_global_settings()); }
public int SetGlobalSetting(IntPtr settings, string name, string value) { return(Pinvoke.wkhtmltopdf_set_global_setting(settings, name, value)); }
public string GetLibraryVersion() { return(Marshal.PtrToStringAnsi(Pinvoke.wkhtmltopdf_version())); }
public bool ExtendedQt() { return(Pinvoke.wkhtmltopdf_extended_qt() == 1); }
public int GetPhaseCount(IntPtr converter) { return(Pinvoke.wkhtmltopdf_phase_count(converter)); }
public string GetProgressString(IntPtr converter) { return(Marshal.PtrToStringAnsi(Pinvoke.wkhtmltopdf_progress_string(converter))); }
public int GetCurrentPhase(IntPtr converter) { return(Pinvoke.wkhtmltopdf_current_phase(converter)); }