Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();
            this.Enabled = false; // input is disabled until we login to steam3

            Steam3.AddHandler(this);

            selfControl.IsHighlighted  = false;
            selfControl.BorderStyle    = BorderStyle.None;
            selfControl.CanOpenProfile = true;

            selfControl.DisableDoubleClick();

            sortTimer          = new Timer();
            sortTimer.Interval = 100;
            sortTimer.Tick    += new EventHandler(sortTimer_Tick);
        }
Esempio n. 2
0
        public FriendControl()
        {
            InitializeComponent();

            btnAccept.Visible = false;
            btnDeny.Visible   = false;

            IsHighlighted = true;

            Steam3.AddHandler(this);

            this.MouseDoubleClick += FriendControl_MouseDoubleClick;
            this.MouseEnter       += FriendControl_MouseEnter;
            this.MouseLeave       += FriendControl_MouseLeave;

            foreach (Control ctrl in this.Controls)
            {
                ctrl.MouseDoubleClick += FriendControl_MouseDoubleClick;
                ctrl.MouseEnter       += FriendControl_MouseEnter;
                ctrl.MouseLeave       += FriendControl_MouseLeave;
            }
        }
Esempio n. 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            this.Enabled = false;

            try
            {
                Steam3.UserName = txtUser.Text;
                Steam3.Password = txtPass.Text;

                Steam3.Initialize(useUdp);

                Steam3.Connect();
            }
            catch (Steam3Exception ex)
            {
                Util.MsgBox(this, "Unable to login to Steam3: " + ex.Message);
                this.Enabled = true;
                return;
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 4
0
        static void Start(string[] args)
        {
            LoginDialog ld = new LoginDialog(FindArg(args, "-udp"));

            if (ld.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            CDNCache.Initialize();

            MainForm mf = new MainForm();

            mf.Show();

            while (mf.Created)
            {
                Steam3.Update();
                Application.DoEvents();

                Thread.Sleep(1);   // sue me, AzuiSleet.
            }

            Steam3.Shutdown();

            CDNCache.Shutdown();

            if (mf.Relog)
            {
                try
                {
                    Start(args);
                }
                catch (Exception ex)
                {
                    new ErrorDialog(ex).ShowDialog();
                }
            }
        }
Esempio n. 5
0
        public ChatManager()
        {
            chatMap = new Dictionary <SteamID, ChatDialog>();

            Steam3.AddHandler(this);
        }
Esempio n. 6
0
        public void HandleCallback(CallbackMsg msg)
        {
            if (msg.IsType <SteamFriends.PersonaStateCallback>())
            {
                var perState = (SteamFriends.PersonaStateCallback)msg;

                if (perState.FriendID == selfControl.Friend.SteamID)
                {
                    selfControl.UpdateFriend(selfControl.Friend);

                    suppressStateMsg            = true;
                    stateComboBox.SelectedIndex = GetIndexFromState(perState.State);
                    suppressStateMsg            = false;

                    return;
                }

                nextSort = DateTime.Now + TimeSpan.FromSeconds(0.1);
                sortTimer.Start();
            }

            if (msg.IsType <SteamUser.LoggedOffCallback>())
            {
                var callback = (SteamUser.LoggedOffCallback)msg;

                Util.MsgBox(this, string.Format("Logged off from Steam3: {0}", callback.Result));

                this.Relog = true;
                this.Close();

                return;
            }

            if (msg.IsType <SteamFriends.FriendsListCallback>())
            {
                selfControl.UpdateFriend(new Friend(Steam3.SteamUser.SteamID));
                this.UpdateFriends();
            }

            if (msg.IsType <SteamUser.LoginKeyCallback>())
            {
                Steam3.SteamFriends.SetPersonaState(EPersonaState.Online);
                this.Enabled = true;
            }

            if (msg.IsType <SteamUser.LoggedOnCallback>())
            {
                var logOnResp = (SteamUser.LoggedOnCallback)msg;

                if (logOnResp.Result == EResult.AccountLogonDenied)
                {
                    expectDisconnect = true;

                    SteamGuardDialog sgDialog = new SteamGuardDialog();

                    if (sgDialog.ShowDialog(this) != DialogResult.OK)
                    {
                        this.Relog = true;
                        this.Close();

                        return;
                    }

                    Steam3.AuthCode = sgDialog.AuthCode;

                    // if we got this logon response, we got disconnected, so lets reconnect
                    try
                    {
                        Steam3.Connect();
                    }
                    catch (Steam3Exception ex)
                    {
                        Util.MsgBox(this, string.Format("Unable to connect to Steam3: {0}", ex.Message));

                        this.Relog = true;
                        this.Close();

                        return;
                    }
                }
                else if (logOnResp.Result != EResult.OK)
                {
                    Util.MsgBox(this, string.Format("Unable to login to Steam3. Result code: {0}", logOnResp.Result));

                    this.Relog = true;
                    this.Close();

                    return;
                }
            }

            if (msg.IsType <SteamFriends.FriendAddedCallback>())
            {
                var friendAdded = (SteamFriends.FriendAddedCallback)msg;

                if (friendAdded.Result != EResult.OK)
                {
                    Util.MsgBox(this, "Unable to add friend! Result: " + friendAdded.Result);
                }
            }

            msg.Handle <SteamClient.DisconnectedCallback>((callback) =>
            {
                // if we expected this disconnection (cause of steamguard), we do nothing
                if (expectDisconnect)
                {
                    expectDisconnect = false;
                    return;
                }

                Util.MsgBox(this, "Disconnected from Steam3!");

                this.Relog = true;
                this.Close();

                return;
            });
        }
Esempio n. 7
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     Steam3.RemoveHandler(this);
     base.OnFormClosing(e);
 }