示例#1
0
 public static void PostLoginInit()
 {
     Faculty.UpdateFacultyList();
     Mensa.UpdateMensaList();
     Mensa.LoadPrices();
     MSettings.LoadSettings();
 }
示例#2
0
 public static void Shutdown()
 {
     LogoutUser();
     MSettings.SaveSettings();
     Application.Exit();
 }
示例#3
0
        public void Initialize()
        {
            try
            {
                MSettingsFileContent = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "Data", MSettingsFileName));
                Settings             = JsonConvert.DeserializeObject <MSettings>(MSettingsFileContent);
                SettingsJSON         = JObject.Parse(MSettingsFileContent);

                Settings.MCoreFilePath = Path.Combine(Environment.CurrentDirectory, "Data", Settings.MCoreFileName);
                MCoreFileContent       = File.ReadAllText(Settings.MCoreFilePath);
                Core      = JsonConvert.DeserializeObject <MCore>(MCoreFileContent);
                MCoreJSON = JObject.Parse(MCoreFileContent);

                Settings.SongFilePath = Path.Combine(Environment.CurrentDirectory, "Data", Settings.SongFileName);
                SongFileContent       = File.ReadAllText(Settings.SongFilePath);

                Settings.CommandCollectionFilePath = Path.Combine(Environment.CurrentDirectory, "Data", Settings.CommandCollectionFileName);
                CommandCollectionFileContent       = File.ReadAllText(Settings.CommandCollectionFilePath);
                CommandCollection     = JsonConvert.DeserializeObject <Dictionary <string, MCommand> >(CommandCollectionFileContent);
                CommandCollectionJSON = JObject.Parse(CommandCollectionFileContent);

                txtBoxBotUsername.Text              = MCoreJSON["Bot"]["UserName"].ToString();
                txtBoxBotPassword.Text              = MCoreJSON["Bot"]["OAuthToken"].ToString();
                nudCommandsFrequency.Value          = decimal.Parse(CommandCollectionJSON["!commands"]["Frequency"].ToString());
                nudSongFrequency.Value              = decimal.Parse(CommandCollectionJSON["!song"]["Frequency"].ToString());
                nudRankDota2Frequency.Value         = decimal.Parse(CommandCollectionJSON["!rank dota2"]["Frequency"].ToString());
                nudRankCSGOFrequency.Value          = decimal.Parse(CommandCollectionJSON["!rank csgo"]["Frequency"].ToString());
                nudLevelDota2Frequency.Value        = decimal.Parse(CommandCollectionJSON["!level dota2"]["Frequency"].ToString());
                nudLevelCSGOFrequency.Value         = decimal.Parse(CommandCollectionJSON["!level csgo"]["Frequency"].ToString());
                nudStreamerRankDota2.Value          = decimal.Parse(MCoreJSON["Streamer"]["Dota2Rank"].ToString());
                nudStreamerRankCSGO.Value           = decimal.Parse(MCoreJSON["Streamer"]["CSGORank"].ToString());
                nudStreamerLevelDota2.Value         = decimal.Parse(MCoreJSON["Streamer"]["Dota2Level"].ToString());
                nudStreamerLevelCSGO.Value          = decimal.Parse(MCoreJSON["Streamer"]["CSGOLevel"].ToString());
                txtBoxSettingsChannelName.Text      = MCoreJSON["Channel"]["Name"].ToString();
                txtBoxSettingsOwnerDisplayName.Text = MCoreJSON["Channel"]["OwnerNickname"].ToString();
                txtBoxAutoMessageMessage.Text       = MCoreJSON["MessageOfTheDay"]["Message"].ToString();
                nudAutoMessageFrequency.Value       = decimal.Parse(MCoreJSON["MessageOfTheDay"]["Frequency"].ToString());
                chkBoxAutoMessageEnabled.Enabled    = ((bool)MCoreJSON["MessageOfTheDay"]["Enabled"] == true);
                chkBoxAutoMessageEnabled.Checked    = chkBoxAutoMessageEnabled.Enabled;
            }
            catch (FileNotFoundException)
            {
                string Message = string.Empty;
                if (string.IsNullOrWhiteSpace(MSettingsFileContent))
                {
                    Message += string.Format("Settings file \"{0}\" was not found in the current directory.\r\n", MSettingsFileName);
                    Console.Write(Message);
                    Console.ReadKey();
                    Environment.Exit(0);
                }
                if (string.IsNullOrWhiteSpace(MCoreFileContent))
                {
                    Message += string.Format("MCore file \"{0}\" was not found.\r\n", Settings.MCoreFileName);
                }
                if (string.IsNullOrWhiteSpace(SongFileContent))
                {
                    Message += string.Format("Song file \"{0}\" was not found.\r\n", Settings.SongFileName);
                }
                if (string.IsNullOrWhiteSpace(CommandCollectionFileContent))
                {
                    Message += string.Format("Commands file \"{0}\" was not found.\r\n", Settings.CommandCollectionFileName);
                }
                Console.Write(Message);
                Console.ReadKey();
                Environment.Exit(0);
            }
        }