private void onClose(object sender, EventArgs e) { //save RPreset RPreset preset = new RPreset(); preset.ActivityName = textBox1.Text; preset.Description = textBox2.Text; preset.InLobby = checkBox1.Checked; preset.LobbyCount = (int)numericUpDown1.Value; preset.LobbyMax = (int)numericUpDown2.Value; preset.Thumbnails = checkBox2.Checked; preset.LargeImageKeyword = textBox3.Text; preset.LargeImageText = textBox4.Text; preset.SmallImageKeyword = textBox5.Text; preset.SmallImageText = textBox6.Text; preset.TimeElapsedCheckbox = checkBox3.Checked; preset.TimeRemainingCheckbox = checkBox4.Checked; preset.TimeElapsed = dateTimePicker1.Value; preset.TimeRemaining = dateTimePicker2.Value; File.WriteAllText(Form2.LUPpath, JsonConvert.SerializeObject(preset)); System.Windows.Forms.Application.Exit(); }
public Form1() { InitializeComponent(); bool UserFound = false; bool TimeRanOut = false; string filePath = "test.html"; originalPreview = File.ReadAllText(filePath); string clientID = Form2.cID; //////////////////////// // Enter Loading Mode // //////////////////////// discord = new Discord.Discord(Int64.Parse(clientID), (UInt64)Discord.CreateFlags.Default); // Managers activityManager = discord.GetActivityManager(); userManager = discord.GetUserManager(); applicationManager = discord.GetApplicationManager(); // Logger discord.SetLogHook(Discord.LogLevel.Debug, (level, message) => { Console.WriteLine("Log[{0}] {1}", level, message); }); // Get Current User userManager.OnCurrentUserUpdate += () => { currentUser = userManager.GetCurrentUser(); Console.WriteLine("User {0} is {1}", currentUser.Id, currentUser.Username); Console.WriteLine("Test: {0}", currentUser.Avatar); UserFound = true; }; // Run callbacks until all criteria met System.Timers.Timer aTimer = new System.Timers.Timer(5000); aTimer.Elapsed += (s, e) => { TimeRanOut = true; }; while (!UserFound && !TimeRanOut) { discord.RunCallbacks(); } aTimer.Stop(); aTimer.Dispose(); Console.WriteLine("Loaded..."); //////////////// // Form Setup // //////////////// // Activity setup textBox1.ForeColor = Color.Gray; textBox1.Text = ActivitiesFiller; // Details setup textBox2.ForeColor = Color.Gray; textBox2.Text = DetailsFiller; // Preview Setup (put into seperate function later) String file = originalPreview; file = file.Replace("CRP_PROFILE_IMAGE_PLACEHOLDER", "https://cdn.discordapp.com/avatars/" + currentUser.Id + "/" + currentUser.Avatar + ".png"); //profile img file = file.Replace("CRP_USERNAME_PLACEHOLDER", currentUser.Username); //username file = file.Replace("CRP_DISCRIM_PLACEHOLDER", "#" + currentUser.Discriminator); //discriminator file = file.Replace("CRP_ACTIVITYNAME_PLACEHOLDER", ""); //activity name file = file.Replace("CRP_DESCRIPTION_PLACEHOLDER", ""); //description file = file.Replace("CRP_LOBBY_PLACEHOLDER", " "); //lobby file = file.Replace("CRP_IMAGE_MARGIN_PLACEHOLDER", ""); // < v thumbnails file = file.Replace("CRP_IMAGE_PLACEHOLDER", ""); file = file.Replace("CRP_TIME_PLACEHOLDER", ""); webView1.NavigateToString(file); //load in last used preset (if available) if (Form2.LUPexists) { RPreset preset = JsonConvert.DeserializeObject <RPreset>(File.ReadAllText(Form2.LUPpath)); textBox1.Text = preset.ActivityName; textBox2.Text = preset.Description; checkBox1.Checked = preset.InLobby; numericUpDown1.Value = preset.LobbyCount; numericUpDown2.Value = preset.LobbyMax; checkBox2.Checked = preset.Thumbnails; textBox3.Text = preset.LargeImageKeyword; textBox4.Text = preset.LargeImageText; textBox5.Text = preset.SmallImageKeyword; textBox6.Text = preset.SmallImageText; checkBox3.Checked = preset.TimeElapsedCheckbox; checkBox4.Checked = preset.TimeRemainingCheckbox; dateTimePicker1.Value = preset.TimeElapsed; dateTimePicker2.Value = preset.TimeRemaining; textBox1.ForeColor = Color.Black; textBox2.ForeColor = Color.Black; updatePreview(); } }