停更编译器项目

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)
{
var list = new ObservableCollection<ExplorerItem>();

View File

@ -8,6 +8,7 @@ using Windows.Storage;
using RustTools.Helpers;
using Microsoft.UI.Xaml.Media;
using Windows.Foundation;
using System.Diagnostics;
namespace RustTools.Editor;
@ -17,33 +18,35 @@ public class EditorTreeView: TreeView
{
//CanDragItems = false;
//CanReorderItems =false;
DragEnter += EditorTreeView_DragEnter;
//DragEnter += EditorTreeView_DragEnter;
DragItemsStarting += TreeView_DragItemsStarting;
DragItemsCompleted += EditorTreeView_DragItemsCompleted;
DragOver += TreeView_DragOver;
Drop += TreeView_Drop;
//DragOver += TreeView_DragOver;
//Drop += TreeView_Drop;
// 在构造函数中注册事件处理程序
}
private void EditorTreeView_DragEnter(object sender, DragEventArgs e){
gj.sc("EditorTreeView_DragEnter "+e);
}
private void TreeView_DragItemsStarting(TreeView sender, TreeViewDragItemsStartingEventArgs e)
{
//gj.sc("TreeView_DragItemsStarting"+e);
var items = e.Items.Cast<ExplorerItem>();
var firstItem = items.FirstOrDefault();
var items = e.Items.Cast<ExplorerItem>().ToList();
var firstItem = items.First();
gj.sc(firstItem.Dir);
e.Data.SetData("path", firstItem.Dir);
e.Data.RequestedOperation = DataPackageOperation.Move; // Use Copy to avoid moving items
}
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>

View File

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

View File

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