Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 private void ToolStripMenuItem11Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         Pinvoke.Setup(openFileDialog1.FileName);
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 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");
 }
Exemplo n.º 6
0
 /// <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
                    )
                ));
 }
Exemplo n.º 7
0
        public void Dispose()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("Object already has been disposed");
            }

            Pinvoke.wkhtmltopdf_deinit();
            _disposed = true;
        }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
 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);
         }
     }
 }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
        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());
        }
Exemplo n.º 15
0
        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);
                }
            });
        }
Exemplo n.º 16
0
    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());
    }
Exemplo n.º 17
0
 public string GetPhaseDescription(IntPtr converter, int phase)
 {
     return(Marshal.PtrToStringAnsi(Pinvoke.wkhtmltopdf_phase_description(converter, phase)));
 }
Exemplo n.º 18
0
 public void AddObject(IntPtr converter, IntPtr objectSettings, byte[] data)
 {
     Pinvoke.wkhtmltopdf_add_object(converter, objectSettings, data);
 }
Exemplo n.º 19
0
 public IntPtr CreateConverter(IntPtr globalSettings)
 {
     return(Pinvoke.wkhtmltopdf_create_converter(globalSettings));
 }
Exemplo n.º 20
0
 public void DestroyObjectSetting(IntPtr settings)
 {
     Pinvoke.wkhtmltopdf_destroy_object_settings(settings);
 }
Exemplo n.º 21
0
 public int SetObjectSetting(IntPtr settings, string name, string value)
 {
     return(Pinvoke.wkhtmltopdf_set_object_setting(settings, name, value));
 }
Exemplo n.º 22
0
 public void DestroyGlobalSetting(IntPtr settings)
 {
     Pinvoke.wkhtmltopdf_destroy_global_settings(settings);
 }
Exemplo n.º 23
0
 public IntPtr CreateObjectSettings()
 {
     return(Pinvoke.wkhtmltopdf_create_object_settings());
 }
Exemplo n.º 24
0
 public IntPtr CreateGlobalSettings()
 {
     return(Pinvoke.wkhtmltopdf_create_global_settings());
 }
Exemplo n.º 25
0
 public int SetGlobalSetting(IntPtr settings, string name, string value)
 {
     return(Pinvoke.wkhtmltopdf_set_global_setting(settings, name, value));
 }
Exemplo n.º 26
0
 public string GetLibraryVersion()
 {
     return(Marshal.PtrToStringAnsi(Pinvoke.wkhtmltopdf_version()));
 }
Exemplo n.º 27
0
 public bool ExtendedQt()
 {
     return(Pinvoke.wkhtmltopdf_extended_qt() == 1);
 }
Exemplo n.º 28
0
 public int GetPhaseCount(IntPtr converter)
 {
     return(Pinvoke.wkhtmltopdf_phase_count(converter));
 }
Exemplo n.º 29
0
 public string GetProgressString(IntPtr converter)
 {
     return(Marshal.PtrToStringAnsi(Pinvoke.wkhtmltopdf_progress_string(converter)));
 }
Exemplo n.º 30
0
 public int GetCurrentPhase(IntPtr converter)
 {
     return(Pinvoke.wkhtmltopdf_current_phase(converter));
 }