예제 #1
1
파일: Util.cs 프로젝트: The-Mad-Pirate/Mist
 public static void ShowSteamProfile(SteamBot.Bot bot, ulong steamId)
 {
     var form = new MetroForm();
     form.Text = "Steam Community";
     form.Width = 800;
     form.Height = 600;
     form.Style = Friends.GlobalStyleManager.Style;
     form.Theme = Friends.GlobalStyleManager.Theme;
     form.Icon = MistClient.Properties.Resources.Icon;
     form.ShadowType = MetroFormShadowType.DropShadow;
     var webControl = new Awesomium.Windows.Forms.WebControl();
     webControl.Dock = System.Windows.Forms.DockStyle.Fill;
     string cookies = string.Format("steamLogin={0}; sessionid={1}", bot.token, bot.sessionId);
     webControl.WebSession = Awesomium.Core.WebCore.CreateWebSession(new Awesomium.Core.WebPreferences());
     webControl.WebSession.SetCookie(new Uri("http://steamcommunity.com"), cookies, true, true);
     webControl.Source = new Uri((string.Format("http://steamcommunity.com/profiles/{0}/", steamId)));
     webControl.DocumentReady += webControl_DocumentReady;
     webControl.TitleChanged += (s, e) => webControl_TitleChanged(s, e, form);
     form.Controls.Add(webControl);
     form.Show();
 }
예제 #2
0
        //Room detection algorithm
        public int roomDetect(Awesomium.Windows.Forms.WebControl wb, int bw)
        {
            int room = 0;
            //Take screenshot of region, store to temporary bitmap
            Bitmap   bmpScreenShot = new Bitmap(17, 36);
            Graphics gfx           = Graphics.FromImage((Image)bmpScreenShot);
            Point    ctrlp         = wb.PointToScreen(Point.Empty);

            try { gfx.CopyFromScreen(ctrlp.X, ctrlp.Y, 0, 0, new Size(17, 36)); }
            catch { return(-1); }

            bmpScreenShot.Save(temp);

            //load jungle cruise bitmap
            Bitmap fw = MyVMK_Pal.Properties.Resources.jungle_cruise_rc;

            //Check to see if is equal
            if (IsEqual())
            {
                room = 2;
            }
            //Delete temporary file
            if (File.Exists(temp))
            {
                File.Delete(temp);
            }
            //Return room id
            return(room);
        }
예제 #3
0
 private void InitializeComponent()
 {
     this.webControl = new Awesomium.Windows.Forms.WebControl();
     this.SuspendLayout();
     //
     // webControl1
     //
     this.webControl.Dock           = System.Windows.Forms.DockStyle.Fill;
     this.webControl.Location       = new System.Drawing.Point(0, 0);
     this.webControl.Size           = new System.Drawing.Size(784, 562);
     this.webControl.Source         = new System.Uri("http://support.microsoft.com/kb/322091", System.UriKind.Absolute);
     this.webControl.TabIndex       = 0;
     this.webControl.PrintRequest  += WebControl_PrintRequest;
     this.webControl.PrintComplete += WebControl_PrintComplete;
     this.webControl.PrintFailed   += WebControl_PrintFailed;
     //
     // PrinterDemo
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(784, 562);
     this.Controls.Add(this.webControl);
     this.Name = "PrinterDemo";
     this.Text = "PrinterDemo";
     this.ResumeLayout(false);
 }
 private void InitializeComponent()
 {
     this.SuspendLayout();
     this.web      = new Awesomium.Windows.Forms.WebControl();
     this.web.Dock = System.Windows.Forms.DockStyle.Fill;
     this.Controls.Add(this.web);
     this.ClientSize = new System.Drawing.Size(800, 600);
     this.Name       = "DemoForm";
     this.Text       = "DemoForm";
     this.ResumeLayout(false);
 }
 public Form1()
 {
     InitializeComponent();
     browser = new Awesomium.Windows.Forms.WebControl();
     //delay until control is ready
     browser.Paint += browser_Paint;
     Controls.Add(browser);
     browser.Location = new System.Drawing.Point(1, 12);
     browser.Name     = "webControl1";
     browser.Size     = new System.Drawing.Size(624, 442);
     browser.Source   = new System.Uri("http://www.google.it", System.UriKind.Absolute);
     browser.TabIndex = 0;
 }
예제 #6
0
        public static void StyleWebcontrolScrollbars(ref Awesomium.Windows.Forms.WebControl webcontrol)
        {
            var script = @" var css = ""::-webkit-scrollbar { width: 12px; } ::-webkit-scrollbar-track { background-color: #111111;	} ::-webkit-scrollbar-thumb { background-color: #444444; } ::-webkit-scrollbar-thumb:hover { background-color: #5e5e5e;	}"";
                            var style = document.createElement('style');
                            if (style.styleSheet)
                            {
                                style.styleSheet.cssText = css;
                            }
                            else 
                            {
                                style.appendChild(document.createTextNode(css));
                            }
                            document.getElementsByTagName('head')[0].appendChild(style);
                            ";

            webcontrol.ExecuteJavascript(script);
        }
예제 #7
0
 protected void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OgreForm));
     webView   = new Awesomium.Windows.Forms.WebControl(this.components);
     SelectBar = new Awesomium.Windows.Forms.WebControl(this.components);
     Hud       = new Awesomium.Windows.Forms.WebControl(this.components);
     this.SuspendLayout();
     //
     // webView
     //
     webView.Dock     = System.Windows.Forms.DockStyle.Fill;
     webView.Location = new System.Drawing.Point(0, 0);
     webView.Size     = new System.Drawing.Size(884, 353);
     webView.TabIndex = 0;
     //
     // SelectBar
     //
     SelectBar.Location = new System.Drawing.Point(118, 37);
     SelectBar.Margin   = new System.Windows.Forms.Padding(2);
     SelectBar.Size     = new System.Drawing.Size(56, 19);
     SelectBar.TabIndex = 1;
     //
     // Hud
     //
     Hud.Location = new System.Drawing.Point(0, 0);
     Hud.Size     = new System.Drawing.Size(800, 29);
     Hud.TabIndex = 2;
     //
     // OgreForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(884, 353);
     this.Controls.Add(Hud);
     this.Controls.Add(SelectBar);
     this.Controls.Add(webView);
     this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name = "SkyLands";
     this.Text = "SkyLands";
     this.ResumeLayout(false);
 }
예제 #8
0
        public static void ShowSteamProfile(SteamBot.Bot bot, ulong steamId)
        {
            var form = new MetroForm();

            form.Text       = "Steam Community";
            form.Width      = 800;
            form.Height     = 600;
            form.Style      = Friends.GlobalStyleManager.Style;
            form.Theme      = Friends.GlobalStyleManager.Theme;
            form.Icon       = MistClient.Properties.Resources.Icon;
            form.ShadowType = MetroFormShadowType.DropShadow;
            var webControl = new Awesomium.Windows.Forms.WebControl();

            webControl.Dock = System.Windows.Forms.DockStyle.Fill;
            string cookies = string.Format("steamLogin={0}; sessionid={1}", bot.token, bot.sessionId);

            webControl.WebSession = Awesomium.Core.WebCore.CreateWebSession(new Awesomium.Core.WebPreferences());
            webControl.WebSession.SetCookie(new Uri("http://steamcommunity.com"), cookies, true, true);
            webControl.Source         = new Uri((string.Format("http://steamcommunity.com/profiles/{0}/", steamId)));
            webControl.DocumentReady += webControl_DocumentReady;
            webControl.TitleChanged  += (s, e) => webControl_TitleChanged(s, e, form);
            form.Controls.Add(webControl);
            form.Show();
        }
예제 #9
0
파일: HotKeys.cs 프로젝트: eolsen4/myVMKPal
 public HotKeys(Form1 form, Awesomium.Windows.Forms.WebControl client)
 {
     this.form   = form;
     this.client = client;
 }
예제 #10
0
 void ShowMiniProfile(object sender, JavascriptMethodEventArgs e)
 {
     try
     {
         SteamID profileId = new SteamID(Convert.ToUInt64(e.Arguments[0].ToString()));
         var miniHtml = SteamTrade.SteamWeb.Fetch("http://steamcommunity.com/miniprofile/" + profileId.AccountID);
         var file = File.ReadAllText(Application.StartupPath + "/Resources/MiniProfile.html");
         file = file.Substring(0, file.IndexOf("<body>"));
         file += "<body>" + miniHtml + "</body></html>";
         File.WriteAllText(Application.StartupPath + "/Resources/MiniProfile.html", file);
         MiniProfile.Close();
         MiniProfile = new Form();
         MiniProfile.Width = 300;
         MiniProfile.Height = 144;
         MiniProfile.ShowInTaskbar = false;
         MiniProfile.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
         MiniProfile.ControlBox = false;
         var webControlMini = new Awesomium.Windows.Forms.WebControl();
         webControlMini.DocumentReady += (sen, ev) => webControlMini_DocumentReady(sen, ev, MiniProfile);
         webControlMini.Enabled = false;
         webControlMini.Dock = DockStyle.Fill;
         webControlMini.Source = (Application.StartupPath + "/Resources/MiniProfile.html").ToUri();
         MiniProfile.Controls.Add(webControlMini);
         MiniProfile.StartPosition = FormStartPosition.Manual;
         MiniProfile.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y + 10);
         MiniProfile.TopMost = true;
         MiniProfile.Show();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
예제 #11
0
 private void sendTradeOfferToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var sid = new SteamID(contextMenuSteamId);
     var url = "http://steamcommunity.com/tradeoffer/new/?partner=" + sid.AccountID;
     var tradeOffersForm = new MetroForm();
     tradeOffersForm.Icon = MistClient.Properties.Resources.Icon;
     tradeOffersForm.Width = 720;
     tradeOffersForm.Height = 730;
     tradeOffersForm.Text = "Trade Offer with " + bot.SteamFriends.GetFriendPersonaName(sid);
     tradeOffersForm.Style = this.Style;
     tradeOffersForm.Theme = this.Theme;
     tradeOffersForm.ShadowType = MetroFormShadowType.DropShadow;
     var tradeOffersWeb = new Awesomium.Windows.Forms.WebControl();
     tradeOffersWeb.Dock = DockStyle.Fill;
     string cookies = string.Format("steamLogin={0}; sessionid={1}", bot.token, bot.sessionId);
     tradeOffersWeb.WebSession = WebCore.CreateWebSession(new WebPreferences());
     tradeOffersWeb.WebSession.SetCookie("http://steamcommunity.com".ToUri(), cookies, true, true);
     tradeOffersWeb.Source = url.ToUri();
     tradeOffersWeb.DocumentReady += tradeOffersWeb_DocumentReady;
     tradeOffersForm.Controls.Add(tradeOffersWeb);
     tradeOffersForm.Show();
     tradeOffersForm.Focus();
 }
예제 #12
0
 private void tradeOffersToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var tradeOffersForm = new MetroForm();
     tradeOffersForm.Icon = MistClient.Properties.Resources.Icon;
     tradeOffersForm.Width = 1012;
     tradeOffersForm.Height = 500;
     tradeOffersForm.Text = "Trade Offers";
     tradeOffersForm.Style = this.Style;
     tradeOffersForm.Theme = this.Theme;
     tradeOffersForm.ShadowType = MetroFormShadowType.DropShadow;
     var tradeOffersWeb = new Awesomium.Windows.Forms.WebControl();
     tradeOffersWeb.Dock = DockStyle.Fill;
     string cookies = string.Format("steamLogin={0}; sessionid={1}", bot.token, bot.sessionId);
     tradeOffersWeb.WebSession = WebCore.CreateWebSession(new WebPreferences());
     tradeOffersWeb.WebSession.SetCookie("http://steamcommunity.com".ToUri(), cookies, true, true);
     tradeOffersWeb.Source = ("http://steamcommunity.com/profiles/" + bot.SteamUser.SteamID.ConvertToUInt64() + "/tradeoffers/").ToUri();
     tradeOffersWeb.DocumentReady += tradeOffersWeb_DocumentReady;
     tradeOffersForm.Controls.Add(tradeOffersWeb);
     tradeOffersForm.Show();
     tradeOffersForm.Focus();
 }
예제 #13
0
 private void steamCommunityMarketToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var form = new MetroForm();
     form.Text = "Steam Community Market";
     form.Width = 1025;
     form.Height = 600;
     form.Style = Friends.GlobalStyleManager.Style;
     form.Theme = Friends.GlobalStyleManager.Theme;
     form.Icon = MistClient.Properties.Resources.Icon;
     form.ShadowType = MetroFormShadowType.DropShadow;
     var webControl = new Awesomium.Windows.Forms.WebControl();
     form.Controls.Add(webControl);
     webControl.Dock = System.Windows.Forms.DockStyle.Fill;
     string cookies = string.Format("steamLogin={0}; sessionid={1}", bot.token, bot.sessionId);
     webControl.WebSession = Awesomium.Core.WebCore.CreateWebSession(new Awesomium.Core.WebPreferences());
     webControl.WebSession.SetCookie(new Uri("http://steamcommunity.com"), cookies, true, true);
     webControl.Source = new Uri("http://steamcommunity.com/market");
     webControl.DocumentReady += steamCommunityMarket_DocumentReady;
     webControl.TitleChanged += (s, ev) => webControl_TitleChanged(s, ev, form);
     form.Show();
 }
예제 #14
0
파일: Payouts.cs 프로젝트: eolsen4/myVMKPal
        public int readScore(Awesomium.Windows.Forms.WebControl clientBrowser, int gameID)
        {
            int score = 0;

            int[] size      = new int[2];
            int   fontColor = 255;

            switch (gameID)
            {
            case 1:
                //Fireworks
                break;

            case 2:
                //Jungle Cruise
                size[0]   = 94;
                size[1]   = 36;
                fontColor = 239;
                break;

            default:
                //Something went wrong
                return(0);
            }

            //Take screenshot of region, store to temporary bitmap
            Bitmap   scoreShot = new Bitmap(size[0], size[1]);
            Graphics gfx       = Graphics.FromImage((Image)scoreShot);
            Point    ctrlp     = clientBrowser.PointToScreen(Point.Empty);

            try { gfx.CopyFromScreen(ctrlp.X, ctrlp.Y, 0, 0, new Size(size[0], size[1])); }
            catch { return(-1); }

            //Replace everything except characters with black
            for (int x = 0; x < scoreShot.Width; x++)
            {
                for (int y = 0; y < scoreShot.Height; y++)
                {
                    Color gotColor = scoreShot.GetPixel(x, y);
                    if (gotColor != Color.FromArgb(fontColor, fontColor, fontColor))
                    {
                        scoreShot.SetPixel(x, y, Color.Black);
                    }
                }
            }

            //Use tessnet2 to extract score via OCR

            Ocr ocr = new Ocr();
            List <tessnet2.Word> res = new List <tessnet2.Word>();

            using (Bitmap bmp = scoreShot)
            {
                tessnet2.Tesseract tessocr = new tessnet2.Tesseract();
                tessocr.Init(null, "eng", false);
                tessocr.GetThresholdedImage(bmp, Rectangle.Empty).Save("c:\\x\\" + Guid.NewGuid().ToString() + ".bmp");
                // Tessdata directory must be in the same directory as this exe
                res = ocr.DoOCRNormal(bmp, "eng");
            }

            foreach (tessnet2.Word word in res)
            {
                bool isNumeric = int.TryParse(word.Text, out score);
                if (!isNumeric)
                {
                    score = 0;
                }
            }

            //Return the score value
            return(score);
        }