Files
Ramitta-lib/template/MainWindow.xaml.cs

167 lines
6.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Newtonsoft.Json.Linq;
using Ramitta;
using System.Data.Common;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Xml.Linq;
using static Ramitta.lib.Basic;
using static Ramitta.winDataGrid;
namespace template
{
public partial class MainWindow : Window
{
static string? filePath;
private JToken? _currentJsonData = null;
private string? _currentFilePath = null;
#region MainWindow
public MainWindow(StartupEventArgs e)
{
Startupe = ParseCommandLineArgs(e.Args);
InitializeComponent();
if (Startupe.TryGetValue("getfile", out string filePath))
{
MainWindow.filePath = filePath;
DebugBar(Debugtag, $"操作目标:{filePath}", 绿);
}
else
{
DebugBar(Debugtag, $"未指定操作目标", );
}
xDataGrid.AddColumn("标题", ColumnType.Label);
xDataGrid.AddColumn("判断", ColumnType.CheckBox);
xDataGrid.AddColumn("康波", ColumnType.ComboBox);
xDataGrid.Rows.Add(
new Dictionary<string, Dictionary<string, object>?> {
{
"标题", new Dictionary<string, object> {
{ "Content", "你妈妈" }
}
},
{
"判断", new Dictionary<string, object> {
{ "IsChecked", true }
}
},
{
"康波", new Dictionary<string, object> {
{ "ItemsSource", new List<string>{"你妈","日你"} },
{ "SelectedValue","日你"}
}
}
});
xDataGrid.AddRow()["标题"]["Content"] = "2";
xDataGrid.AddRow()["标题"]["Content"] = "3";
// 修改按钮文本
// 查找Content为"删除"的第一行
/*
var targetRow = xDataGrid.Rows.FirstOrDefault(row =>
row.ContainsKey("Content") && row["Content"]?.ToString() == "他妈");
if (targetRow != null)
{
targetRow["IsChecked"] = true;
targetRow["SelectedValue"] = "新值";
}
*/
}
#endregion
private void (object sender, RoutedEventArgs e)
{
// 添加顶层节点
TreeList.AddCheckboxNode("A");
TreeList.AddCheckboxNode("B");
// 添加标签节点 "GroupC",并嵌套子节点 "D" 和 "E"
var groupC = TreeList.AddLabelNode("GroupC");
TreeList.AddCheckboxNode("D", parent: groupC); // GroupC 下的 "D"
TreeList.AddCheckboxNode("E", parent: groupC); // GroupC 下的 "E"
// 添加标签节点 "GroupF",并嵌套子节点 "G" 和 "H"
var groupF = TreeList.AddLabelNode("GroupF");
TreeList.AddCheckboxNode("G", parent: groupF); // GroupF 下的 "G"
var groupH = TreeList.AddCheckboxNode("H", parent: groupF); // GroupF 下的 "H"
// 在 "H" 下添加节点 "I" 和 "J"
TreeList.AddCheckboxNode("I", parent: groupH); // "H" 下的 "I"
TreeList.AddCheckboxNode("J", parent: groupH); // "H" 下的 "J"
// 添加多个类型为 "K" 的节点(分别加入不同层级)
TreeList.AddCheckboxNode("K", "1"); // 顶层 "K" 节点
TreeList.AddLabelNode("K", parent: groupH); // "H" 下的 "K" 节点
TreeList.AddCheckboxNode("K", "3", parent: groupF); // "GroupF" 下的 "K" 节点
TreeList.AddCheckboxNode("K", "4", parent: groupC); // "GroupC" 下的 "K" 节点
// 添加更多重复节点
TreeList.AddCheckboxNode("A"); // 顶层重复 "A" 节点
TreeList.AddCheckboxNode("B"); // 顶层重复 "B" 节点
// 再次在 GroupC 下添加重复节点 "D" 和 "E"
TreeList.AddCheckboxNode("D", parent: groupC); // GroupC 下重复 "D"
TreeList.AddCheckboxNode("E", parent: groupC); // GroupC 下重复 "E"
// 再次在 GroupF 下添加重复节点 "G"
TreeList.AddCheckboxNode("G", parent: groupF); // GroupF 下重复 "G"
// 在 "H" 下添加重复节点 "I" 和 "J"
TreeList.AddCheckboxNode("I", parent: groupH); // "H" 下重复 "I"
TreeList.AddCheckboxNode("J", parent: groupH); // "H" 下重复 "J"
// 为了形成至少5层的嵌套再加一个新的标签节点 "GroupG",并添加节点
var groupG = TreeList.AddLabelNode("GroupG");
TreeList.AddCheckboxNode("L", parent: groupG); // GroupG 下的 "L"
TreeList.AddCheckboxNode("M", parent: groupG); // GroupG 下的 "M"
// 继续在 GroupG 下添加节点 "N"
TreeList.AddCheckboxNode("N", parent: groupG); // GroupG 下的 "N"
// 再添加 GroupG 下的 "O" 和 "P"
TreeList.AddCheckboxNode("O", parent: groupG); // GroupG 下的 "O"
TreeList.AddCheckboxNode("P", parent: groupG); // GroupG 下的 "P"
}
private void (object sender, RoutedEventArgs e)
{
}
private void (object sender, RoutedEventArgs e)
{
}
private void (object sender, RoutedEventArgs e)
{
var sukablayt = TreeList.FindArgvNode(null, ["GroupF"]);
foreach (var arg in sukablayt.Children) {
var suka = arg as CheckboxTreeNode;
Debug.WriteLine($"{arg.Text}:{suka.IsChecked}");
}
if (sukablayt == null)DebugBar(Debugtag, $"没找到", );
}
}
}