diff --git a/XplorePlane/ViewModels/MainViewModel.cs b/XplorePlane/ViewModels/MainViewModel.cs index 49ffc96..d0632a4 100644 --- a/XplorePlane/ViewModels/MainViewModel.cs +++ b/XplorePlane/ViewModels/MainViewModel.cs @@ -1,312 +1,33 @@ -// MainViewModel.cs -using System; +using Prism.Commands; +using Prism.Mvvm; using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using System.Windows.Input; -using XplorePlane.Models; namespace XplorePlane.ViewModels { - /// - /// Root ViewModel for the MainWindow. - /// Implements INotifyPropertyChanged for two-way data binding. - /// - public class MainViewModel : INotifyPropertyChanged + public class MainViewModel : BindableBase { - // ── INotifyPropertyChanged ──────────────────────────────────── - public event PropertyChangedEventHandler PropertyChanged; - protected void OnPropertyChanged([CallerMemberName] string name = null) - => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + private string _licenseInfo = "ǰʱ"; + + + public ObservableCollection NavigationTree { get; set; } + + public DelegateCommand NavigateHomeCommand { get; set; } + public DelegateCommand NavigateInspectCommand { get; set; } + public DelegateCommand OpenFileCommand { get; set; } + public DelegateCommand ExportCommand { get; set; } + public DelegateCommand ClearCommand { get; set; } + public DelegateCommand EditPropertiesCommand { get; set; } - // ── Constructor ─────────────────────────────────────────────── public MainViewModel() { - // Seed navigation tree - NavigationTree = new ObservableCollection - { - new NavGroupNode("参考模型") - { - Children = new ObservableCollection - { - new NavGroupNode("007模型.stp") - { - Children = new ObservableCollection - { - new NavLeafNode("圆柱 2 -ref", IconColor: "#00AAFF"), - new NavLeafNode("圆柱 1 -ref", IconColor: "#00AAFF"), - new NavLeafNode("球 1 -ref", IconColor: "#FFAA00"), - new NavLeafNode("圆 1 -ref", IconColor: "#888888"), - new NavLeafNode("圆 2 -ref", IconColor: "#888888"), - new NavLeafNode("圆 3 -ref", IconColor: "#888888"), - new NavLeafNode("圆 4 -ref", IconColor: "#888888"), - } - } - } - }, - new NavGroupNode("目标模型") - { - Children = new ObservableCollection - { - new NavGroupNode("007数据.sti") - { - Children = new ObservableCollection - { - new NavLeafNode("圆柱 2 -tgt", IconColor: "#00AAFF"), - new NavLeafNode("圆柱 1 -tgt", IconColor: "#00AAFF", IsSelected: true), - new NavLeafNode("球 1 -tgt", IconColor: "#FFAA00"), - new NavLeafNode("圆 1 -tgt", IconColor: "#888888"), - new NavLeafNode("圆 2 -tgt", IconColor: "#888888"), - new NavLeafNode("圆 3 -tgt", IconColor: "#888888"), - new NavLeafNode("圆 4 -tgt", IconColor: "#888888"), - } - } - } - }, - new NavGroupNode("特征分类") - { - Children = new ObservableCollection - { - new NavLeafNode("默认特征分页", IconColor: "#888888") - } - } - }; - - // Seed inspection callouts - InspectionCallouts = new ObservableCollection - { - new InspectionCalloutVM("圆柱 1 -ref", 310, 270, - new[] - { - new CalloutRowVM("X", "20.0001", "19.7591", "±0.1000", "-0.2410", false), - new CalloutRowVM("Y", "79.9998", "79.2057", "±0.1000", "-0.7941", false), - new CalloutRowVM("Z", "12.0000", "12.6008", "±0.1000", "0.6008", false), - new CalloutRowVM("半径","5.0000", "4.9933", "±0.1000", "-0.0067", true), - new CalloutRowVM("圆3","300", "9.9866", "±0.1000", "-0.0134", true), - new CalloutRowVM("高度","15.0001","15.0028", "±0.1000", "0.0027", true), - }), - new InspectionCalloutVM("圆柱 2 -ref", 665, 270, - new[] - { - new CalloutRowVM("X", "180.0000","179.8487","±0.1000","-0.1513", false), - new CalloutRowVM("Y", "79.9999", "81.0710", "±0.1000", "1.0711", false), - new CalloutRowVM("Z", "35.0000", "27.3757", "±0.1000","-7.6243", false), - new CalloutRowVM("半径","5.0000", "4.9656", "±0.1000","-0.0344", true), - new CalloutRowVM("直径","10.0000","9.9311", "±0.1000","-0.0689", true), - new CalloutRowVM("高度","15.0001","15.0014", "±0.1000", "0.0013", true), - }), - new InspectionCalloutVM("球 1 -ref", 455, 415, - new[] - { - new CalloutRowVM("X", "60.0000","60.0000","±0.1000", "0.0000", true), - new CalloutRowVM("Y", "20.0000","20.0000","±0.1000","-0.0000",true), - new CalloutRowVM("Z", "20.0000","20.0000","±0.1000", "0.0000", true), - new CalloutRowVM("半径","12.0000","11.8959","±0.1000","-0.1041",false), - }), - }; - - // Selected feature (matches 圆柱 1) - SelectedFeature = new FeatureProperties - { - Name = "圆柱 1", - DatumLabel = "空", - X = 19.7591, - Y = 79.2067, - Z = 12.6008, - NrX = 0.0163, - NrY = 0.1049, - NrZ = 0.9943, - Height = 15.0028, - Radius = 4.9933, - Diameter = 9.9866, - }; - - // Status bar defaults - LicenseInfo = "软件购买类型: 通用;截止日期: 2025/6/30"; - ConnectionStatus = "Polyworks未连接"; - FpsInfo = "Fps = 0"; - TempInfo = "TempS = 0 ℃"; - CurrentTime = "AM 38%"; - ZoomLevel = 38; + NavigationTree = new ObservableCollection(); + + NavigateHomeCommand = new DelegateCommand(() => { }); + NavigateInspectCommand = new DelegateCommand(() => { }); + OpenFileCommand = new DelegateCommand(() => { }); + ExportCommand = new DelegateCommand(() => { }); + ClearCommand = new DelegateCommand(() => { }); + EditPropertiesCommand = new DelegateCommand(() => { }); } - - // ── Navigation Tree ─────────────────────────────────────────── - public ObservableCollection NavigationTree { get; } - - // ── Inspection Callouts ─────────────────────────────────────── - public ObservableCollection InspectionCallouts { get; } - - // ── Selected Feature Properties ─────────────────────────────── - private FeatureProperties _selectedFeature = new(); - public FeatureProperties SelectedFeature - { - get => _selectedFeature; - set { _selectedFeature = value; OnPropertyChanged(); } - } - - // ── Status Bar ──────────────────────────────────────────────── - private string _licenseInfo = string.Empty; - public string LicenseInfo - { - get => _licenseInfo; - set { _licenseInfo = value; OnPropertyChanged(); } - } - - private string _connectionStatus = string.Empty; - public string ConnectionStatus - { - get => _connectionStatus; - set { _connectionStatus = value; OnPropertyChanged(); } - } - - private string _fpsInfo = string.Empty; - public string FpsInfo - { - get => _fpsInfo; - set { _fpsInfo = value; OnPropertyChanged(); } - } - - private string _tempInfo = string.Empty; - public string TempInfo - { - get => _tempInfo; - set { _tempInfo = value; OnPropertyChanged(); } - } - - private string _currentTime = string.Empty; - public string CurrentTime - { - get => _currentTime; - set { _currentTime = value; OnPropertyChanged(); } - } - - private int _zoomLevel = 100; - public int ZoomLevel - { - get => _zoomLevel; - set { _zoomLevel = value; OnPropertyChanged(); } - } - - // ── Geometry Selection Flags ────────────────────────────────── - private bool _isPointSelected; - public bool IsPointSelected - { - get => _isPointSelected; - set { _isPointSelected = value; OnPropertyChanged(); } - } - - private bool _isPlaneSelected; - public bool IsPlaneSelected - { - get => _isPlaneSelected; - set { _isPlaneSelected = value; OnPropertyChanged(); } - } - - private bool _isCylinderSelected; - public bool IsCylinderSelected - { - get => _isCylinderSelected; - set { _isCylinderSelected = value; OnPropertyChanged(); } - } - - private bool _isSurfacePointSelected; - public bool IsSurfacePointSelected - { - get => _isSurfacePointSelected; - set { _isSurfacePointSelected = value; OnPropertyChanged(); } - } - - private bool _isCircleSelected; - public bool IsCircleSelected - { - get => _isCircleSelected; - set { _isCircleSelected = value; OnPropertyChanged(); } - } - - private bool _isSphereSelected; - public bool IsSphereSelected - { - get => _isSphereSelected; - set { _isSphereSelected = value; OnPropertyChanged(); } - } - - private bool _isLineSelected; - public bool IsLineSelected - { - get => _isLineSelected; - set { _isLineSelected = value; OnPropertyChanged(); } - } - - private bool _isSlotSelected; - public bool IsSlotSelected - { - get => _isSlotSelected; - set { _isSlotSelected = value; OnPropertyChanged(); } - } - - private bool _isFaceSelected; - public bool IsFaceSelected - { - get => _isFaceSelected; - set { _isFaceSelected = value; OnPropertyChanged(); } - } - - // ── Commands ────────────────────────────────────────────────── - public ICommand OpenFileCommand => new RelayCommand(_ => OpenFile()); - public ICommand ExportCommand => new RelayCommand(_ => Export()); - public ICommand ClearCommand => new RelayCommand(_ => Clear()); - public ICommand OpenTemplateCommand => new RelayCommand(_ => OpenTemplate()); - public ICommand SaveTemplateCommand => new RelayCommand(_ => SaveTemplate()); - public ICommand TemplateInspectCommand => new RelayCommand(_ => TemplateInspect()); - public ICommand GdtInspectCommand => new RelayCommand(_ => GdtInspect()); - public ICommand AutoAlignCommand => new RelayCommand(_ => AutoAlign()); - public ICommand NPointAlignCommand => new RelayCommand(_ => NPointAlign()); - public ICommand FeatureAlignCommand => new RelayCommand(_ => FeatureAlign()); - public ICommand RpsAlignCommand => new RelayCommand(_ => RpsAlign()); - public ICommand AxisAlignCommand => new RelayCommand(_ => AxisAlign()); - public ICommand ImportMatrixCommand => new RelayCommand(_ => ImportMatrix()); - public ICommand CalcColorDiffCommand => new RelayCommand(_ => CalcColorDiff()); - public ICommand AnnotateCommand => new RelayCommand(_ => Annotate()); - public ICommand ReportInfoCommand => new RelayCommand(_ => ReportInfo()); - public ICommand SavePdfCommand => new RelayCommand(_ => SavePdf()); - public ICommand SaveCsvCommand => new RelayCommand(_ => SaveCsv()); - public ICommand NavigateHomeCommand => new RelayCommand(_ => NavigateHome()); - public ICommand NavigateInspectCommand => new RelayCommand(_ => NavigateInspect()); - public ICommand ToggleFullScreenCommand=> new RelayCommand(_ => ToggleFullScreen()); - public ICommand OpenOptionsCommand => new RelayCommand(_ => OpenOptions()); - public ICommand CollapseNavCommand => new RelayCommand(_ => CollapseNav()); - public ICommand EditPropertiesCommand => new RelayCommand(_ => EditProperties()); - public ICommand ClosePropertiesCommand => new RelayCommand(_ => CloseProperties()); - public ICommand ClearAnnotationsCommand=> new RelayCommand(_ => ClearAnnotations()); - public ICommand DeleteSelectionCommand => new RelayCommand(_ => DeleteSelection()); - - // ── Command Handlers (stub — wire up your services here) ────── - private void OpenFile() { /* Open file dialog */ } - private void Export() { /* Export dialog */ } - private void Clear() { /* Clear scene */ } - private void OpenTemplate() { /* Load template project */ } - private void SaveTemplate() { /* Save template project */ } - private void TemplateInspect() { /* Run template inspection */ } - private void GdtInspect() { /* GD&T inspection dialog */ } - private void AutoAlign() { /* Auto alignment */ } - private void NPointAlign() { /* N-point alignment dialog */ } - private void FeatureAlign() { /* Feature alignment */ } - private void RpsAlign() { /* RPS alignment */ } - private void AxisAlign() { /* Axis alignment */ } - private void ImportMatrix() { /* Import alignment matrix */ } - private void CalcColorDiff() { /* Calculate color difference */ } - private void Annotate() { /* Add annotation */ } - private void ReportInfo() { /* Report info dialog */ } - private void SavePdf() { /* Save PDF report */ } - private void SaveCsv() { /* Save CSV report */ } - private void NavigateHome() { /* Switch to Home tab */ } - private void NavigateInspect() { /* Switch to Inspect tab */ } - private void ToggleFullScreen(){ /* Toggle fullscreen */ } - private void OpenOptions() { /* Open options dialog */ } - private void CollapseNav() { /* Collapse navigation panel */ } - private void EditProperties() { /* Edit selected feature props */ } - private void CloseProperties() { /* Close properties panel */ } - private void ClearAnnotations(){ /* Clear all viewport annotations */ } - private void DeleteSelection() { /* Delete selected item */ } } -} \ No newline at end of file +} diff --git a/XplorePlane/Views/MainWindow.xaml b/XplorePlane/Views/MainWindow.xaml index 39a8690..ee7cf48 100644 --- a/XplorePlane/Views/MainWindow.xaml +++ b/XplorePlane/Views/MainWindow.xaml @@ -4,9 +4,10 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:XplorePlane.ViewModels" + xmlns:fluent="urn:fluent-ribbon" mc:Ignorable="d" - Title="检测系统" - Height="768" Width="1136" + Title="XplorePlane" + Height="768" Width="1080" Background="#F5F5F5" WindowStartupLocation="CenterScreen"> @@ -15,46 +16,42 @@ + + + - - + - - + + + + + + + + + + + + + + + + + + + + + + + - - - - -