private void btnlounge_Click(object sender, EventArgs e) { API.CreateInfoboxSession("Appscape Developer Lounge", "Please enter your Developer Key to enter the Lounge.", infobox.InfoboxMode.TextEntry); API.InfoboxSession.FormClosing += (object s, FormClosingEventArgs a) => { var res = API.GetInfoboxResult(); bool cont = true; if (res != "fail") { try { var dev = GetModderByDevID(res); MyDevProfile = dev.Key; LoungeClient = dev.Value; SetupLounge(); } catch { cont = false; } } if (cont != true) { API.CreateInfoboxSession("Appscape Developer Lounge", "That Developer Key was not found in the database.", infobox.InfoboxMode.Info); } }; }
/// <summary> /// Gets developer info using the specified key. /// /// Bugs: If two servers contain the same key, the first key the method sees will be returned. /// </summary> /// <param name="DevID">The key to search for.</param> /// <returns>A pair containing the developer info as well as the client that contained the key.</returns> public KeyValuePair <AppscapeModder, AppscapeClient> GetModderByDevID(string DevID) { AppscapeModder dev = null; AppscapeClient clt = null; foreach (var client in clients) { if (client.DevList.ContainsKey(DevID)) { if (dev == null) { dev = client.DevList[DevID]; clt = client; } } } return(new KeyValuePair <AppscapeModder, AppscapeClient>(dev, clt)); }
/// <summary> /// Adds a new developer key to the specified client's listing. /// </summary> /// <param name="client">The client to add to.</param> public void GenerateNewDevKey(AppscapeClient client) { var rnd = new Random(); int key = rnd.Next(1, 99999999); var dev = new AppscapeModder(); dev.DevKey = key.ToString(); dev.Name = "Modder"; bool done = false; if (!client.DevList.ContainsKey(key.ToString())) { if (done != true) { client.DevList.Add(dev.DevKey, dev); client.UploadDevList(client.DevList); done = true; API.CreateInfoboxSession("Success.", $"Your new developer key is {dev.DevKey}. As long as you are connected to the {client.IP} repository, you can use this key to enter the Appscape Lounge, make a name for yourself, and start uploading.", infobox.InfoboxMode.Info); } } }
private void Form1_Load(object sender, EventArgs e) { clients = new List <AppscapeClient>(); foreach (var ip in Package_Grabber.clients.Keys) { if (Package_Grabber.clients[ip].IsConnected) { var client = new AppscapeClient(ip); client.OnSuccessfulDownload += (object s, EventArgs a) => { this.Invoke(new Action(() => { if (AddressToSendTo != null) { var w = new BitnoteWallet(); while (w.Clients == null) { } if (API.BitnoteAddress.Bitnotes >= CurrentItemCost) { if (w.AddBitnotesToAddress(AddressToSendTo, CurrentItemCost)) { API.CreateInfoboxSession("Package downloaded.", "The package has been successfully downloaded to your system.", infobox.InfoboxMode.Info); API.BitnoteAddress.Bitnotes -= CurrentItemCost; } else { API.CreateInfoboxSession("Server-side Bitnote Error", "We couldn't complete the transaction, but the package was still downloaded. No Bitnotes have been taken from your account.", infobox.InfoboxMode.Info); } } else { File.Delete((string)s); API.CreateInfoboxSession("Insufficient funds.", "You do not have enough Bitnotes to complete the transaction.", infobox.InfoboxMode.Info); } } })); }; client.OnPackagesReceived += (object s, EventArgs a) => { this.Invoke(new Action(() => { lvmypackages.Items.Clear(); })); foreach (AppscapePackage package in client.Packages) { ListViewItem lvitem = new ListViewItem(); lvitem.Text = package.Name; package.Server = client.IP; lvitem.Tag = package; this.Invoke(new Action(() => { lvmypackages.Columns[0].Width = lvmypackages.Width; if (MyDevProfile != null && LoungeClient != null) { if (package.DevKey == MyDevProfile.DevKey) { var lvmy = new ListViewItem(); lvmy.Text = package.Name; lvmy.Tag = package; lvmypackages.Items.Add(lvmy); lvmy.SubItems.Add(package.Cost.ToString()); } } lvpackages.Items.Add(lvitem); if (package.DevKey != null) { client.GetDevList(); try { var obj = client.DevList[package.DevKey]; if (obj != null) { lvitem.SubItems.Add(obj.Name); } else { lvitem.SubItems.Add("Unknown"); } } catch { lvitem.SubItems.Add("Unknown"); } } else { lvitem.SubItems.Add("Unknown"); } lvitem.SubItems.Add(package.Cost.ToString()); })); } }; client.OnSkinDataReceived += (object s, EventArgs a) => { foreach (SkinData skin in client.Skins) { var item = new ListViewItem(); item.Text = skin.Name; skin.Server = client.IP; item.Tag = skin; this.Invoke(new Action(() => { lvpackages.Items.Add(item); item.SubItems.Add("<NYI>"); item.SubItems.Add(skin.Cost.ToString()); })); } }; client.OnDevListSync += (object s, EventArgs a) => { API.CurrentSession.Invoke(new Action(() => { foreach (ListViewItem itm in lvpackages.Items) { if (DataType == "apps") { var pkg = (AppscapePackage)itm.Tag; foreach (ListViewItem.ListViewSubItem subItem in itm.SubItems) { if (subItem.Text == "Unknown") { /********************************************************************************************************************************************************************************/ if (client.DevList != null && pkg.DevKey != null) { if (client.DevList.ContainsKey(pkg.DevKey)) { var dev = client.DevList[pkg.DevKey]; subItem.Text = dev.Name; } } } } } } })); }; client.GetDevList(); clients.Add(client); } } SetupList(); pnllist.BringToFront(); }
/// <summary> /// Front-end to handle uploading of an Appscape package. /// </summary> /// <param name="modder">The developer of the new package.</param> /// <param name="repo">The client representing the repository to upload to.</param> public AppscapeUploader(AppscapeModder modder, AppscapeClient repo) { InitializeComponent(); MyProfile = modder; Repo = repo; }