停更编译器项目

This commit is contained in:
muqing 2024-08-13 19:30:40 +08:00
parent 871e195315
commit 0c3fa3e424
4 changed files with 26 additions and 31 deletions

View File

@ -52,6 +52,7 @@ public class EditorLoad
} }
} }
public ObservableCollection<ExplorerItem> GetData(string dir) public ObservableCollection<ExplorerItem> GetData(string dir)
{ {
var list = new ObservableCollection<ExplorerItem>(); var list = new ObservableCollection<ExplorerItem>();

View File

@ -8,6 +8,7 @@ using Windows.Storage;
using RustTools.Helpers; using RustTools.Helpers;
using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media;
using Windows.Foundation; using Windows.Foundation;
using System.Diagnostics;
namespace RustTools.Editor; namespace RustTools.Editor;
@ -17,33 +18,35 @@ public class EditorTreeView: TreeView
{ {
//CanDragItems = false; //CanDragItems = false;
//CanReorderItems =false; //CanReorderItems =false;
DragEnter += EditorTreeView_DragEnter; //DragEnter += EditorTreeView_DragEnter;
DragItemsStarting += TreeView_DragItemsStarting; DragItemsStarting += TreeView_DragItemsStarting;
DragItemsCompleted += EditorTreeView_DragItemsCompleted; DragItemsCompleted += EditorTreeView_DragItemsCompleted;
DragOver += TreeView_DragOver; //DragOver += TreeView_DragOver;
Drop += TreeView_Drop; //Drop += TreeView_Drop;
// 在构造函数中注册事件处理程序 // 在构造函数中注册事件处理程序
} }
private void EditorTreeView_DragEnter(object sender, DragEventArgs e){
gj.sc("EditorTreeView_DragEnter "+e);
}
private void TreeView_DragItemsStarting(TreeView sender, TreeViewDragItemsStartingEventArgs e) private void TreeView_DragItemsStarting(TreeView sender, TreeViewDragItemsStartingEventArgs e)
{ {
//gj.sc("TreeView_DragItemsStarting"+e); //gj.sc("TreeView_DragItemsStarting"+e);
var items = e.Items.Cast<ExplorerItem>(); var items = e.Items.Cast<ExplorerItem>().ToList();
var firstItem = items.FirstOrDefault(); var firstItem = items.First();
gj.sc(firstItem.Dir); gj.sc(firstItem.Dir);
e.Data.SetData("path", firstItem.Dir); e.Data.SetData("path", firstItem.Dir);
e.Data.RequestedOperation = DataPackageOperation.Move; // Use Copy to avoid moving items e.Data.RequestedOperation = DataPackageOperation.Move; // Use Copy to avoid moving items
} }
private void EditorTreeView_DragItemsCompleted(TreeView sender, TreeViewDragItemsCompletedEventArgs e) { private void EditorTreeView_DragItemsCompleted(TreeView sender, TreeViewDragItemsCompletedEventArgs e) {
var items = e.Items.Cast<ExplorerItem>();
var firstItem = items.FirstOrDefault();
gj.sc("放下了 " + firstItem.Dir); // 获取拖拽的项
var items = e.Items.Cast<ExplorerItem>().ToList();
// 检查是否有至少一个项被放下
if (items.Any())
{
var firstItem = items.First(); // 获取第一个放下的项
// 输出放下项的信息
Debug.WriteLine($"放下了 {firstItem.Dir}");
}
} }
/// <summary> /// <summary>

View File

@ -29,7 +29,7 @@
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="FileTemplate"> <DataTemplate x:Key="FileTemplate">
<TreeViewItem AutomationProperties.Name="{Binding Name}"> <TreeViewItem AutomationProperties.Name="{Binding Name}" IsExpanded="False">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE8A5;" /> <FontIcon Glyph="&#xE8A5;" />
<TextBlock Margin="0,0,10,0" /> <TextBlock Margin="0,0,10,0" />

View File

@ -30,7 +30,7 @@ public class ExplorerItem : INotifyPropertyChanged
{ {
public enum ExplorerItemType { Folder, File }; public enum ExplorerItemType { Folder, File };
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public string Name public string? Name
{ {
get; set; get; set;
} }
@ -38,40 +38,31 @@ public class ExplorerItem : INotifyPropertyChanged
{ {
get; set; get; set;
} }
public string Dir public string? Dir
{ {
get;set; get;set;
} }
private ObservableCollection<ExplorerItem> m_children; private ObservableCollection<ExplorerItem>? m_children;
public ObservableCollection<ExplorerItem> Children public ObservableCollection<ExplorerItem> Children
{ {
get get
{ {
if (m_children == null) m_children ??= new ObservableCollection<ExplorerItem>();
{
m_children = new ObservableCollection<ExplorerItem>();
}
return m_children; return m_children;
} }
set set => m_children = value;
{
m_children = value;
}
} }
private bool m_isExpanded; private bool m_isExpanded;
public bool IsExpanded public bool IsExpanded
{ {
get get => m_isExpanded;
{
return m_isExpanded;
}
set set
{ {
if (m_isExpanded != value) if (m_isExpanded != value)
{ {
m_isExpanded = value; m_isExpanded = value;
NotifyPropertyChanged("IsExpanded"); NotifyPropertyChanged(nameof(IsExpanded));
} }
} }
} }