コード例 #1
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            Logging.InitFormLogger();

            BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;

            await Task.Run(async() => {
                ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

                if (!Directory.Exists(SharedInfo.ConfigDirectory))
                {
                    ASF.ArchiLogger.LogGenericError("Config directory could not be found!");
                    Environment.Exit(1);
                }

                await ASF.CheckForUpdate().ConfigureAwait(false);

                // Before attempting to connect, initialize our list of CMs
                Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider);
            });

            foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension))
            {
                switch (botName)
                {
                case SharedInfo.ASF:
                case "example":
                case "minimal":
                    continue;
                }

                Bot bot = new Bot(botName);

                BotStatusForm botStatusForm = new BotStatusForm(bot);

                BotIndexes[botName] = AvatarImageList.Images.Count;

                AvatarImageList.Images.Add(botName, botStatusForm.AvatarPictureBox.Image);

                botStatusForm.TopLevel = false;
                BotStatusPanel.Controls.Add(botStatusForm);

                ListViewItem botListViewItem = new ListViewItem {
                    ImageIndex = BotIndexes[botName],
                    Text       = botName
                };

                BotListView.Items.Add(botListViewItem);
            }

            if (BotListView.Items.Count > 0)
            {
                BotListView.Items[0].Selected = true;
                BotListView.Select();
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: JustArchi/ArchiSteamFarm
		private async void MainForm_Load(object sender, EventArgs e) {
			Logging.InitFormLogger();

			BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;

			await Task.Run(async () => {
				ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

				if (!Directory.Exists(SharedInfo.ConfigDirectory)) {
					ASF.ArchiLogger.LogGenericError("Config directory could not be found!");
					Environment.Exit(1);
				}

				await ASF.CheckForUpdate().ConfigureAwait(false);

				// Before attempting to connect, initialize our list of CMs
				Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider);
			});

			foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
				switch (botName) {
					case SharedInfo.ASF:
					case "example":
					case "minimal":
						continue;
				}

				Bot bot = new Bot(botName);

				BotStatusForm botStatusForm = new BotStatusForm(bot);

				BotIndexes[botName] = AvatarImageList.Images.Count;

				AvatarImageList.Images.Add(botName, botStatusForm.AvatarPictureBox.Image);

				botStatusForm.TopLevel = false;
				BotStatusPanel.Controls.Add(botStatusForm);

				ListViewItem botListViewItem = new ListViewItem {
					ImageIndex = BotIndexes[botName],
					Text = botName
				};

				BotListView.Items.Add(botListViewItem);
			}

			if (BotListView.Items.Count > 0) {
				BotListView.Items[0].Selected = true;
				BotListView.Select();
			}
		}