using System;
using System.Windows.Forms;
using VkNet;
using VkNet.Model.RequestParams;
using VkNet.Enums.Filters;
using VkNet.Exception;
namespace vkmessenger
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Auth auth = Auth.GetAuth();
FrndList FrndList = new FrndList();
FrndList.Owner = this;
FrndList.Show();
Hide();
}
}
}
using System;
using System.Windows.Forms;
using VkNet;
using VkNet.Enums.Filters;
using VkNet.Model.RequestParams;
using VkNet.Exception;
namespace vkmessenger
{
public class Auth
{
private static Auth AuthManager;
private Auth()
{
}
VkApi vk = new VkApi();
Settings scope = Settings.All;
public static Auth GetAuth()
{
if(AuthManager == null)
{
lock(typeof (Auth))
{
if (AuthManager == null)
AuthManager = new Auth();
}
}
return AuthManager;
}
public void GetAuth(string login, string pass)
{
try
{
vk.Authorize(new ApiAuthParams
{
ApplicationId = 6049500,
Login = login,
Password = pass,
Settings = scope
});
}
catch (Exception ex)
{
MessageBox.Show("" + ex);
}
}
public void GetFriendList(ListBox lb)
{
var friends = vk.Friends.Get(vk.UserId.Value, ProfileFields.FirstName | ProfileFields.LastName);
foreach (var friend in friends)
{
lb.Items.Add(friend.FirstName + " " + friend.LastName);
}
}
}
}
Auth auth = Auth.GetAuth();