private void Page_Loaded(object sender, RoutedEventArgs e) { Cards.Children.Clear(); int num = 0; StackPanel nowStakp = new StackPanel(); UI.Tools tools = new UI.Tools(); foreach (UI.Tools.ToolVer info in tools.List) { Application app = Application.Current; if ((string)Application.Current.FindResource("tool_title_" + info.name) != null) { info.cardInfo[0] = (string)app.Resources["tool_title_" + info.name]; info.cardInfo[1] = (string)app.Resources["tool_sub_" + info.name]; } if (info.type == "OtherTools") { if (num % 3 == 0) { nowStakp = new StackPanel(); nowStakp.Orientation = Orientation.Horizontal; Cards.Children.Add(nowStakp); } SortCard card = new SortCard(info.cardInfo, info.page, MainWindow.main) { Margin = new Thickness(0, 0, 17, 15) }; nowStakp.Children.Add(card); num++; } } }
private void Page_Loaded(object sender, RoutedEventArgs e) { pageName.Text = MainWindow.main.MainTitle.Text; // 随机抽取三个工具 Random rd = new Random(); int[] nums = new int[] { -1, -1, -1 }; UI.Tools tools = new UI.Tools(); int isSInt = rd.Next(0, 10); bool isShowHidden = isSInt == 0; Log.AddLog("None", "隐藏常数:" + isSInt); for (int i = 0; i < 3; i++) { nums[i] = rd.Next(0, tools.List.Count); for (int j = 0; j < 3; j++) { if ((nums[j] == nums[i] && i != j) || tools.List[nums[i]].page == null || (tools.List[nums[i]].type == "Hidden" && !isShowHidden)) { if (tools.List[nums[i]].type == "Hidden" && !isShowHidden) { Log.AddLog("None", "抽到了一个隐藏工具哦,但是很可惜没有抽到允许显示 XD"); } i--; break; } } } for (int i = 0; i < 3; i++) { Application app = Application.Current; List <string> info = tools.List[nums[i]].cardInfo; info[0] = (string)app.Resources["tool_title_" + tools.List[nums[i]].name]; info[1] = (string)app.Resources["tool_sub_" + tools.List[nums[i]].name]; SortCard card = new SortCard(info, tools.List[nums[i]].page, MainWindow.main) { Margin = new Thickness(0, 0, 17, 15) }; CardSt.Children.Add(card); } }