有没有办法让我的不和谐嵌入名称和值在同一行上?我浏览了 the discord.py docs 却一无所获。任何答案都会有所帮助。
答案 0 :(得分:1)
据我所知,使用public partial class MainWindow : Window
{
MenuItem root = new MenuItem();
string path = "";
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.FolderBrowserDialog folderDlg = new System.Windows.Forms.FolderBrowserDialog();
folderDlg.ShowNewFolderButton = true; // Show the FolderBrowserDialog.
System.Windows.Forms.DialogResult result = folderDlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
path = folderDlg.SelectedPath;
// st = System.IO.Path.GetFileName(path);
}
updateroot(path);
string[] subdirectoryEntries = Directory.GetDirectories(path);
// Loop through them to see if they have any other subdirectories
foreach (string subdirectory in subdirectoryEntries)
{
MenuItem child = new MenuItem();
child.Title = subdirectory;
root.Items.Add(child);
}
task1(root);
trvMenu.Items.Add(root);
}
public void updateroot(string str)
{
root.Title = str;
}
public void task1(MenuItem subtree)
{
for (int index = 0; index < subtree.Items.Count; index++)
{
operateTree(subtree.Items[index]);
if(subtree.Items[index].Items.Count > 0)
{
task1(subtree.Items[index]);
}
}
}
public void operateTree(MenuItem rootitems )
{
string str = rootitems.Title;
string[] subdirectoryEntries1 = Directory.GetDirectories(str);
// Loop through them to see if they have any other subdirectories
foreach (string subdirectory in subdirectoryEntries1)
{
MenuItem child = new MenuItem();
child.Title = subdirectory;
rootitems.Items.Add(child);
}
}
private void TextBlock_Selected(object sender, RoutedEventArgs e)
{
}
private void trvMenu_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
}
private void trvMenu_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
}
}
public class MenuItem
{
public MenuItem()
{
this.Items = new ObservableCollection<MenuItem>();
}
public string Title { get; set; }
public ObservableCollection<MenuItem> Items { get; set; }
}
,其discord的API规则,一行最多可以有3个字段
您不能在一行中创建多个字段。