Ejemplo n.º 1
0
 int IndexOfEntry(LinkEntry le)
 {
     for (int x = 0; x < linkView.Items.Count; x++)
     {
         if (((LinkViewItem)linkView.Items[x]).Link.SteamID == le.SteamID)
         {
             return(x);
         }
     }
     return(-1);
 }
Ejemplo n.º 2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(steamIdBox.Text) || string.IsNullOrEmpty(displayBox.Text))
            {
                return;
            }

            ulong commId = 0;

            if (steamIdBox.Text.StartsWith("STEAM_"))
            {
                // parse steam id
                string[] parts = steamIdBox.Text.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length < 3)
                {
                    Util.ShowError(this, "Invalid SteamID.");
                    return;
                }

                int y, z;

                if (!int.TryParse(parts[1], out y))
                {
                    Util.ShowError(this, "Invalid SteamID.");
                    return;
                }

                if (!int.TryParse(parts[2], out z))
                {
                    Util.ShowError(this, "Invalid SteamID.");
                    return;
                }

                commId = (ulong)((z * 2) + 76561197960265728L + y);
            }

            if (commId == 0)
            {
                if (!ulong.TryParse(steamIdBox.Text, out commId))
                {
                    Util.ShowError(this, "Invalid SteamID or Community ID.");
                    return;
                }
            }

            LinkEntry le = new LinkEntry();

            le.SteamID = commId;
            le.Name    = displayBox.Text;

            if (IndexOfEntry(le) != -1)
            {
                Util.ShowError(this, "LinkID already present.");
                return;
            }

            LinkViewItem lvi = new LinkViewItem(le);

            linkView.Items.Add(lvi);
        }
Ejemplo n.º 3
0
        private void addButton_Click( object sender, EventArgs e )
        {
            if ( string.IsNullOrEmpty( steamIdBox.Text ) || string.IsNullOrEmpty( displayBox.Text ) )
                return;

            ulong commId = 0;

            if ( steamIdBox.Text.StartsWith( "STEAM_" ) )
            {
                // parse steam id
                string[] parts = steamIdBox.Text.Split( ":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries );

                if ( parts.Length < 3 )
                {
                    Util.ShowError( this, "Invalid SteamID." );
                    return;
                }

                int y, z;

                if ( !int.TryParse( parts[ 1 ], out y ) )
                {
                    Util.ShowError( this, "Invalid SteamID." );
                    return;
                }

                if ( !int.TryParse( parts[ 2 ], out z ) )
                {
                    Util.ShowError( this, "Invalid SteamID." );
                    return;
                }

                commId = (ulong)( ( z * 2 ) + 76561197960265728L + y );

            }

            if ( commId == 0 )
            {
                if ( !ulong.TryParse( steamIdBox.Text, out commId ) )
                {
                    Util.ShowError( this, "Invalid SteamID or Community ID." );
                    return;
                }
            }

            LinkEntry le = new LinkEntry();

            le.SteamID = commId;
            le.Name = displayBox.Text;

            if ( IndexOfEntry( le ) != -1 )
            {
                Util.ShowError( this, "LinkID already present." );
                return;
            }

            LinkViewItem lvi = new LinkViewItem( le );

            linkView.Items.Add( lvi );

        }
Ejemplo n.º 4
0
 int IndexOfEntry( LinkEntry le )
 {
     for (int x = 0; x < linkView.Items.Count; x++ )
     {
         if ( ( (LinkViewItem)linkView.Items[ x ] ).Link.SteamID == le.SteamID )
             return x;
     }
     return -1;
 }
Ejemplo n.º 5
0
        public LinkViewItem( LinkEntry entry )
        {
            Link = entry;

            Text = Link.SteamID.ToString();
            SubItems.Add( Link.Name );
        }