添加 MX-PD-盘古 项目文件

将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
Shi.Ji
2026-05-18 11:43:09 +08:00
parent 03632a379d
commit e31d3560bb
739 changed files with 99783 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Controls.Primitives;
using MainShell.Common;
using MainShell.Models;
using MainShell.Recipe.Models;
using MainShell.Recipe.ViewModel;
namespace MainShell.Recipe.View
{
/// <summary>
/// RecipeView.xaml 的交互逻辑
/// </summary>
public partial class RecipeView : UserControl
{
public RecipeView()
{
InitializeComponent();
}
private void SideMenu_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var viewModel = DataContext as RecipeViewModel;
if (viewModel == null)
return;
FocusedEditorCommitHelper.CommitFocusedEditorChanges();
var targetMenuItem = FindMenuItemWrap(e.OriginalSource as DependencyObject);
if (targetMenuItem == null)
return;
e.Handled = true;
viewModel.TrySelectMenuItem(targetMenuItem);
}
private void RecipeList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var viewModel = DataContext as RecipeViewModel;
if (viewModel == null)
return;
FocusedEditorCommitHelper.CommitFocusedEditorChanges();
var targetRecipeWrap = FindDataContext<RecipeWrap>(e.OriginalSource as DependencyObject);
if (targetRecipeWrap == null)
return;
e.Handled = true;
viewModel.TrySelectRecipeWrap(targetRecipeWrap);
}
private static MenuItemWrap FindMenuItemWrap(DependencyObject dependencyObject)
{
return FindDataContext<MenuItemWrap>(dependencyObject);
}
private static T FindDataContext<T>(DependencyObject dependencyObject) where T : class
{
var current = dependencyObject;
while (current != null)
{
if (current is FrameworkElement frameworkElement && frameworkElement.DataContext is T dataContext)
{
return dataContext;
}
if (current is FrameworkContentElement frameworkContentElement && frameworkContentElement.DataContext is T contentDataContext)
{
return contentDataContext;
}
current = GetParent(current);
}
return null;
}
private static DependencyObject GetParent(DependencyObject dependencyObject)
{
if (dependencyObject is FrameworkElement frameworkElement)
{
return frameworkElement.Parent ?? VisualTreeHelper.GetParent(frameworkElement);
}
if (dependencyObject is FrameworkContentElement frameworkContentElement)
{
return frameworkContentElement.Parent;
}
return null;
}
}
}