Exemplo n.º 1
0
        public BrowserInterop(TasClient tas, Config conf)
        {
            login    = conf.LobbyPlayerName;
            password = conf.LobbyPlayerPassword;
            WindowsApi.InternetSetCookiePub(Config.BaseUrl, GlobalConst.LoginCookieName, login);
            WindowsApi.InternetSetCookiePub(Config.BaseUrl, GlobalConst.PasswordHashCookieName, PlasmaShared.Utils.HashLobbyPassword(password));
            WindowsApi.InternetSetCookiePub(Config.BaseUrl, GlobalConst.LobbyAccessCookieName, "1");


            tas.LoginAccepted += delegate
            {
                login    = tas.UserName;
                password = tas.UserPassword;
                var wc  = new WebClient();
                var uri =
                    new Uri(string.Format("http://zero-k.info/Home/Logon?login={0}&password={1}",
                                          Uri.EscapeDataString(login),
                                          Uri.EscapeDataString(password)));

                WindowsApi.InternetSetCookiePub(Config.BaseUrl, GlobalConst.LoginCookieName, login);
                WindowsApi.InternetSetCookiePub(Config.BaseUrl, GlobalConst.PasswordHashCookieName, PlasmaShared.Utils.HashLobbyPassword(password));

                if (conf.IsFirstRun)
                {
                    wc.DownloadString(uri);
                }
                else
                {
                    wc.DownloadStringAsync(uri);
                }
            };
        }
Exemplo n.º 2
0
        public BrowserInterop(TasClient tas, Config conf)
        {
            login    = conf.LobbyPlayerName;
            password = conf.LobbyPlayerPassword;
            var baseUrl = GlobalConst.BaseSiteUrl;

            WindowsApi.InternetSetCookiePub(baseUrl, GlobalConst.LobbyAccessCookieName, "1");


            tas.LoginAccepted += delegate
            {
                login        = tas.UserName;
                password     = tas.UserPassword;
                sessionToken = tas.SessionToken;
                var wc  = new WebClient();
                var uri =
                    new Uri(string.Format("{2}/Home/Logon?login={0}&password={1}",
                                          Uri.EscapeDataString(login),
                                          Uri.EscapeDataString(password),
                                          GlobalConst.BaseSiteUrl));

                WindowsApi.InternetSetCookiePub(baseUrl, GlobalConst.SessionTokenVariable, sessionToken);

                if (conf.IsFirstRun)
                {
                    wc.DownloadString(uri);
                }
                else
                {
                    wc.DownloadStringAsync(uri);
                }
            };
        }
Exemplo n.º 3
0
 /// <summary>
 /// Flashes window if its not foreground - until it is foreground
 /// </summary>
 protected void FlashWindow()
 {
     if (!Focused || !Visible || WindowState == FormWindowState.Minimized)
     {
         Visible = true;
         var info = new WindowsApi.FLASHWINFO();
         info.hwnd    = Program.FormMain.Handle;
         info.dwFlags = 0x0000000C | 0x00000003;                 // flash all until foreground
         info.cbSize  = Convert.ToUInt32(Marshal.SizeOf(info));
         WindowsApi.FlashWindowEx(ref info);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Flashes window if its not foreground - until it is foreground
 /// </summary>
 protected void FlashWindow()
 {
     if (!Focused || !Visible || WindowState == FormWindowState.Minimized)
     {
         Visible = true;
         if (Environment.OSVersion.Platform != PlatformID.Unix)
         {
             // todo implement for linux with #define NET_WM_STATE_DEMANDS_ATTENTION=42
             var info = new WindowsApi.FLASHWINFO();
             info.hwnd    = Handle;
             info.dwFlags = 0x0000000C | 0x00000003; // flash all until foreground
             info.cbSize  = Convert.ToUInt32(Marshal.SizeOf(info));
             WindowsApi.FlashWindowEx(ref info);
         }
     }
 }
Exemplo n.º 5
0
        public void NotifyUser(string message, bool useSound = false, bool useFlashing = false)
        {
            bool isHidden = WindowState == FormWindowState.Minimized || Visible == false || WindowsApi.GetForegroundWindow() != (int)Handle;

            // todo use this when its easy to determine what is user looking at (flash when message not seen)
            if (!string.IsNullOrEmpty(message))
            {
                systrayIcon.ShowBalloonTip(5000, "Zero-K", message, ToolTipIcon.Info);
            }
            if (isHidden && useFlashing)
            {
                FlashWindow();
            }
            if (useSound)
            {
                SystemSounds.Exclamation.Play();
            }
        }